Rev 2058 | Rev 2069 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2058 | Rev 2059 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | #include "flight.h" |
5 | #include "flight.h" |
6 | #include "output.h" |
6 | #include "output.h" |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line -... | ||
8 | uint16_t emergencyFlightTime; |
- | |
9 | - | ||
10 | void setFailsafeFlightParameters(void) { |
- | |
11 | flight_setParameters(0, 90, 120, 90, 120); |
- | |
12 | } |
- | |
13 | - | ||
14 | void setNormalFlightParameters(void) { |
- | |
15 | flight_setParameters(staticParams.IFactor, dynamicParams.gyroP, |
- | |
16 | staticParams.bitConfig & CFG_HEADING_HOLD ? 0 : dynamicParams.gyroI, |
- | |
17 | dynamicParams.gyroP, staticParams.yawIFactor); |
- | |
18 | } |
8 | uint16_t emergencyFlightTime; |
19 | 9 | ||
20 | void FC_setNeutral(void) { |
10 | void FC_setNeutral(void) { |
Line 21... | Line 11... | ||
21 | setNormalFlightParameters(); |
11 | configuration_setNormalFlightParameters(); |
- | 12 | } |
|
- | 13 | ||
- | 14 | void FC_periodicTaskAndPRTY(uint16_t* PRTY) { |
|
22 | } |
15 | |
23 | 16 | debugOut.analog[25] = emergencyFlightTime; |
|
24 | void FC_periodicTaskAndPRTY(uint16_t* PRTY) { |
17 | |
Line 25... | Line 18... | ||
25 | if (controlMixer_getSignalQuality() <= SIGNAL_BAD) { // the rc-frame signal is not reveived or noisy |
18 | if (controlMixer_getSignalQuality() <= SIGNAL_BAD) { // the rc-frame signal is not reveived or noisy |
26 | if (controlMixer_didReceiveSignal) |
19 | if (controlMixer_didReceiveSignal) |
27 | beepRCAlarm(); // Only make alarm if a control signal was received before the signal loss. |
20 | beepRCAlarm(); // Only make alarm if a control signal was received before the signal loss. |
28 | 21 | ||
29 | // There are the possibilities: We are not yet in emergency flight, we are already in emergency flight. |
22 | // There are the possibilities: We are not yet in emergency flight, we are already in emergency flight. |
30 | if (!(MKFlags & MKFLAG_EMERGENCY_FLIGHT)) { |
23 | if (!(MKFlags & MKFLAG_EMERGENCY_FLIGHT)) { |
31 | if (isFlying > 256) { |
24 | if (isFlying > 256) { |
32 | MKFlags |= MKFLAG_EMERGENCY_FLIGHT; // Set flag for emergency landing |
25 | MKFlags |= MKFLAG_EMERGENCY_FLIGHT; // Set flag for emergency landing |
33 | setFailsafeFlightParameters(); |
26 | configuration_setFailsafeFlightParameters(); |
34 | // Set the time in whole seconds. |
27 | // Set the time in whole seconds. |
35 | if (staticParams.emergencyFlightDuration > (65535 - F_MAINLOOP) / F_MAINLOOP) |
28 | if (staticParams.emergencyFlightDuration > (65535 - (uint16_t)F_MAINLOOP) / (uint16_t)F_MAINLOOP) |
36 | emergencyFlightTime = 0xffff; |
29 | emergencyFlightTime = 0xffff; |
37 | else |
30 | else |
38 | emergencyFlightTime = (uint16_t) staticParams.emergencyFlightDuration * F_MAINLOOP; |
31 | emergencyFlightTime = (uint16_t)staticParams.emergencyFlightDuration * (uint16_t)F_MAINLOOP; |
39 | } |
32 | } |
Line 51... | Line 44... | ||
51 | PRTY[CONTROL_PITCH] = PRTY[CONTROL_ROLL] = PRTY[CONTROL_YAW] = 0; |
44 | PRTY[CONTROL_PITCH] = PRTY[CONTROL_ROLL] = PRTY[CONTROL_YAW] = 0; |
52 | } else { |
45 | } else { |
53 | // Signal is OK. |
46 | // Signal is OK. |
54 | if (MKFlags & MKFLAG_EMERGENCY_FLIGHT) { |
47 | if (MKFlags & MKFLAG_EMERGENCY_FLIGHT) { |
55 | MKFlags &= ~MKFLAG_EMERGENCY_FLIGHT; // Clear flag for emergency landing |
48 | MKFlags &= ~MKFLAG_EMERGENCY_FLIGHT; // Clear flag for emergency landing |
56 | setNormalFlightParameters(); |
49 | configuration_setNormalFlightParameters(); |
57 | } |
50 | } |
58 | } |
51 | } |
Line 59... | Line 52... | ||
59 | 52 | ||
60 | /* |
53 | /* |