Subversion Repositories FlightCtrl

Rev

Rev 1927 | Rev 2102 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1927 Rev 2099
Line 3... Line 3...
3
#include "controlMixer.h"
3
#include "controlMixer.h"
4
#include "flight.h"
4
#include "flight.h"
5
#include "eeprom.h"
5
#include "eeprom.h"
6
#include "attitude.h"
6
#include "attitude.h"
7
#include "output.h"
7
#include "output.h"
-
 
8
#include "rc.h"
Line 8... Line 9...
8
 
9
 
9
void commands_handleCommands(void) {
-
 
10
        /*
-
 
11
         * Get the current command (start/stop motors, calibrate), if any.
-
 
12
         */
10
#ifdef USE_MK3MAG
13
        uint8_t command = controlMixer_getCommand();
11
// TODO: Kick that all outa here!
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.
12
uint8_t compassCalState = 0;
Line -... Line 13...
-
 
13
#endif
-
 
14
 
19
                        GRN_OFF;
15
void commands_handleCommands(void) {
20
 
16
  /*
21
                        // TODO: out of here. Anyway, MKFLAG_MOTOR_RUN is cleared. Not enough?
17
   * Get the current command (start/stop motors, calibrate), if any.
22
                        // isFlying = 0;
18
   */
23
                        // check roll/pitch stick position
19
  uint8_t command = controlMixer_getCommand();
Line -... Line 20...
-
 
20
  uint8_t repeated = controlMixer_isCommandRepeated();
-
 
21
  uint8_t argument = controlMixer_getArgument();
-
 
22
 
24
                        // if pitch stick is top or roll stick is left or right --> change parameter setting
23
  if (!(MKFlags & MKFLAG_MOTOR_RUN)) {
25
                        // according to roll/pitch stick position
24
    if (command == COMMAND_GYROCAL && !repeated) {
26
 
25
      // Gyro calinbration, with or without selecting a new parameter-set.
27
                                ParamSet_ReadFromEEProm();
26
      paramSet_readFromEEProm(1);
28
                                attitude_setNeutral();
27
      analog_calibrateGyros();
29
                                flight_setNeutral();
28
      attitude_setNeutral();
Line 30... Line 29...
30
                                controlMixer_setNeutral();
29
      controlMixer_setNeutral();
-
 
30
      beepNumber(1);
-
 
31
    }
31
                                beepNumber(1);
32
 
32
                }
33
    // save the ACC neutral setting to eeprom
33
 
-
 
34
                // save the ACC neutral setting to eeprom
34
    /*
35
                else if (command == COMMAND_ACCCAL && !repeated) {
35
     else {
36
                                // Run gyro and acc. meter calibration but do not repeat it.
-
 
37
                                GRN_OFF;
36
     if (command == COMMAND_ACCCAL && !repeated) {
38
                                analog_calibrateAcc();
37
     // Run gyro and acc. meter calibration but do not repeat it.
39
                                attitude_setNeutral();
38
     analog_calibrateAcc();
40
                                flight_setNeutral();
-
 
41
                                controlMixer_setNeutral();
-
 
42
                                beepNumber(1);
-
 
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();
39
     attitude_setNeutral();
52
                // setPointYaw = 0;
-
 
53
                // IPartPitch = 0;
40
     controlMixer_setNeutral();
54
                // IPartRoll = 0;
41
     beepNumber(getActiveParamSet());
55
                // }
-
 
56
        } else if (command == COMMAND_STOP) {
42
     }