Rev 1910 | Rev 2099 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1910 | - | 1 | #include <stdlib.h> |
2 | #include "commands.h" |
||
3 | #include "controlMixer.h" |
||
4 | #include "flight.h" |
||
5 | #include "eeprom.h" |
||
6 | #include "attitude.h" |
||
7 | #include "output.h" |
||
8 | |||
9 | void commands_handleCommands(void) { |
||
10 | /* |
||
11 | * Get the current command (start/stop motors, calibrate), if any. |
||
12 | */ |
||
13 | uint8_t command = controlMixer_getCommand(); |
||
14 | uint8_t repeated = controlMixer_isCommandRepeated(); |
||
15 | |||
16 | if (!(MKFlags & MKFLAG_MOTOR_RUN)) { |
||
17 | if (command == COMMAND_GYROCAL && !repeated) { |
||
18 | // Run gyro calibration but do not repeat it. |
||
19 | GRN_OFF; |
||
20 | |||
21 | // TODO: out of here. Anyway, MKFLAG_MOTOR_RUN is cleared. Not enough? |
||
22 | // isFlying = 0; |
||
23 | // check roll/pitch stick position |
||
24 | // if pitch stick is top or roll stick is left or right --> change parameter setting |
||
25 | // according to roll/pitch stick position |
||
26 | |||
1927 | - | 27 | ParamSet_ReadFromEEProm(); |
1910 | - | 28 | attitude_setNeutral(); |
29 | flight_setNeutral(); |
||
30 | controlMixer_setNeutral(); |
||
1927 | - | 31 | beepNumber(1); |
1910 | - | 32 | } |
33 | |||
34 | // save the ACC neutral setting to eeprom |
||
1927 | - | 35 | else if (command == COMMAND_ACCCAL && !repeated) { |
1910 | - | 36 | // Run gyro and acc. meter calibration but do not repeat it. |
37 | GRN_OFF; |
||
38 | analog_calibrateAcc(); |
||
39 | attitude_setNeutral(); |
||
40 | flight_setNeutral(); |
||
41 | controlMixer_setNeutral(); |
||
1927 | - | 42 | beepNumber(1); |
1910 | - | 43 | } |
44 | } // end !MOTOR_RUN condition. |
||
45 | if (command == COMMAND_START) { |
||
46 | isFlying = 1; // TODO: Really???? |
||
47 | // if (!controlMixer_isCommandRepeated()) { |
||
48 | // attitude_startDynamicCalibration(); // Try sense the effect of the motors on sensors. |
||
49 | MKFlags |= (MKFLAG_MOTOR_RUN | MKFLAG_START); // set flag RUN and START. TODO: Is that START flag used at all??? |
||
50 | // } else { // Pilot is holding stick, ever after motor start. Continue to sense the effect of the motors on sensors. |
||
51 | // attitude_continueDynamicCalibration(); |
||
52 | // setPointYaw = 0; |
||
53 | // IPartPitch = 0; |
||
54 | // IPartRoll = 0; |
||
55 | // } |
||
56 | } else if (command == COMMAND_STOP) { |
||
57 | isFlying = 0; |
||
58 | MKFlags &= ~(MKFLAG_MOTOR_RUN); |
||
59 | } |
||
60 | } |