7,21 → 7,14 |
|
uint16_t emergencyFlightTime; |
|
void setFailsafeFlightParameters(void) { |
flight_setParameters(0, 90, 120, 90, 120); |
void FC_setNeutral(void) { |
configuration_setNormalFlightParameters(); |
} |
|
void setNormalFlightParameters(void) { |
flight_setParameters(staticParams.IFactor, dynamicParams.gyroP, |
staticParams.bitConfig & CFG_HEADING_HOLD ? 0 : dynamicParams.gyroI, |
dynamicParams.gyroP, staticParams.yawIFactor); |
} |
void FC_periodicTaskAndPRTY(uint16_t* PRTY) { |
|
void FC_setNeutral(void) { |
setNormalFlightParameters(); |
} |
debugOut.analog[25] = emergencyFlightTime; |
|
void FC_periodicTaskAndPRTY(uint16_t* PRTY) { |
if (controlMixer_getSignalQuality() <= SIGNAL_BAD) { // the rc-frame signal is not reveived or noisy |
if (controlMixer_didReceiveSignal) |
beepRCAlarm(); // Only make alarm if a control signal was received before the signal loss. |
30,12 → 23,12 |
if (!(MKFlags & MKFLAG_EMERGENCY_FLIGHT)) { |
if (isFlying > 256) { |
MKFlags |= MKFLAG_EMERGENCY_FLIGHT; // Set flag for emergency landing |
setFailsafeFlightParameters(); |
configuration_setFailsafeFlightParameters(); |
// Set the time in whole seconds. |
if (staticParams.emergencyFlightDuration > (65535 - F_MAINLOOP) / F_MAINLOOP) |
if (staticParams.emergencyFlightDuration > (65535 - (uint16_t)F_MAINLOOP) / (uint16_t)F_MAINLOOP) |
emergencyFlightTime = 0xffff; |
else |
emergencyFlightTime = (uint16_t) staticParams.emergencyFlightDuration * F_MAINLOOP; |
emergencyFlightTime = (uint16_t)staticParams.emergencyFlightDuration * (uint16_t)F_MAINLOOP; |
} |
} else { |
if (emergencyFlightTime) { |
53,7 → 46,7 |
// Signal is OK. |
if (MKFlags & MKFLAG_EMERGENCY_FLIGHT) { |
MKFlags &= ~MKFLAG_EMERGENCY_FLIGHT; // Clear flag for emergency landing |
setNormalFlightParameters(); |
configuration_setNormalFlightParameters(); |
} |
} |
|