// 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 } } }
// 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; } } }