Example #1
0
unsigned unifiedLength(Channels &a)
{
	unsigned len=0;

	for(unsigned c=0;c<a.size();c++)
		if(a[c].size()>len)
			len=a[c].size();

	for(unsigned c=0;c<a.size();c++)
		if(a[c].size()<len)
			a[c]=a[c].resizeTo(len);

	return len;
}
Example #2
0
unsigned unifiedSamplerate(Channels &a)
{
	unsigned samplerate=0;

	for(unsigned c=0;c<a.size();c++)
		if(a[c].samplerate()>samplerate)
			samplerate=a[c].samplerate();

	for(unsigned c=0;c<a.size();c++)
		if(a[c].samplerate()<samplerate)
			a[c]=a[c].resampleTo(samplerate);

	return samplerate;
}
Example #3
0
// Step through list of controls reading the servo channel, calculating new position 
// and setting either a surface or engine(s) to the value
void ServosToControls(void)
{
	int   iIndex = 0;
	int   iSize = ControlSurfaces.size();
	int   iServoChannel;
	intbb ServoValue;
	float ControlSetting;
	ChannelSetup* pScanSetup;

	for (iIndex = 0; iIndex < iSize; iIndex++)
	{
		pScanSetup = &ControlSurfaces[iIndex];

		iServoChannel = pScanSetup->mServoChannel;
		ServoValue._.B1 = SERVO_IN[2*iServoChannel];
		ServoValue._.B0 = SERVO_IN[(2*iServoChannel)+1];

		ControlSetting = pScanSetup->GetControlDeflection(ServoValue.BB);
		
		if (pScanSetup->mControlType == CONTROL_TYPE_SURFACE)
		{
			XPLMSetDataf(pScanSetup->mControlSurfaceRef, ControlSetting);
		}
		else if (pScanSetup->mControlType == CONTROL_TYPE_ENGINE)
		{
			unsigned int Mask = pScanSetup->mEngineMask;

			for (int Engine = 0; Engine < 8; Engine++)
			{
				if ((Mask & 0x01) != 0)
				{
					ThrottleSettings[Engine] = ControlSetting;
				}
				Mask >>= 1;
			}
			if (ControlSetting > PARKBRAKE_THROTTLE_THRESHOLD)  // if engine is throttled-up above threshold..
			{
				BrakeSetting = PARKBRAKE_OFF;   // remove parkbrake
			}
			else
			{
				BrakeSetting = PARKBRAKE_ON;    // apply parkbrake
			}
		}
	}
Example #4
0
// Step through list of controls reading the servo channel, calculating new position 
// and setting either a surface or engine(s) to the value
void ServosToControls()
{
	int		iIndex = 0;
	int		iSize = ControlSurfaces.size();
	
	int		iServoChannel;
	intbb	ServoValue;

	int		Value;

	float	ControlSetting;

	ChannelSetup* pScanSetup;

	for(iIndex = 0; iIndex < iSize; iIndex++)
	{
		pScanSetup = &ControlSurfaces[iIndex];

		iServoChannel = pScanSetup->mServoChannel;
		ServoValue._.B1 = SERVO_IN[2*iServoChannel];
		ServoValue._.B0 = SERVO_IN[(2*iServoChannel)+1];

		ControlSetting = pScanSetup->GetControlDeflection(ServoValue.BB);
		
		if(pScanSetup->mControlType == CONTROL_TYPE_SURFACE)
		{
			XPLMSetDataf(pScanSetup->mControlSurfaceRef, ControlSetting);
		}
		else if(pScanSetup->mControlType == CONTROL_TYPE_ENGINE)
		{
			unsigned int Mask = pScanSetup->mEngineMask;

			for (int Engine = 0; Engine < 8; Engine++)
			{
				if( (Mask & 0x01) != 0 )
				{
					ThrottleSettings[Engine] = ControlSetting;
				}
				Mask >>= 1;
			}
		}
	}