Subversion Repositories FlightCtrl

Rev

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

Rev 2102 Rev 2103
Line 152... Line 152...
152
#define COMMAND_CHANNEL_VERTICAL CH_THROTTLE
152
#define COMMAND_CHANNEL_VERTICAL CH_THROTTLE
153
#define COMMAND_CHANNEL_HORIZONTAL CH_YAW
153
#define COMMAND_CHANNEL_HORIZONTAL CH_YAW
Line 154... Line 154...
154
 
154
 
Line 155... Line 155...
155
#define RC_SCALING 4
155
#define RC_SCALING 4
156
 
156
 
157
uint8_t getControlModeSwitch() {
157
uint8_t getControlModeSwitch(void) {
158
        int16_t channel = RCChannel(CH_MODESWITCH) + POT_OFFSET;
158
        int16_t channel = RCChannel(CH_MODESWITCH) + POT_OFFSET;
159
        uint8_t flightMode = channel < 256/3 ? FLIGHT_MODE_MANUAL :
159
        uint8_t flightMode = channel < 256/3 ? FLIGHT_MODE_MANUAL :
160
                (channel > 256*2/3 ? FLIGHT_MODE_ANGLES : FLIGHT_MODE_RATE);
160
                (channel > 256*2/3 ? FLIGHT_MODE_ANGLES : FLIGHT_MODE_RATE);
Line 173... Line 173...
173
                lastFlightMode = flightMode;
173
                lastFlightMode = flightMode;
174
                lastRCCommand = COMMAND_CHMOD;
174
                lastRCCommand = COMMAND_CHMOD;
175
                return lastRCCommand;
175
                return lastRCCommand;
176
        }
176
        }
Line 177... Line 177...
177
 
177
 
178
        int16_t channel = RCChannel(CH_MODESWITCH) + POT_OFFSET;
178
        int16_t channel = RCChannel(CH_THROTTLE);
179
        if (channel <= -32) { // <= 900 us
179
        if (channel <= -140) { // <= 900 us
180
                if (commandTimer == COMMAND_TIMER) {
180
                if (commandTimer == COMMAND_TIMER) {
181
                        lastRCCommand = COMMAND_GYROCAL;
181
                        lastRCCommand = COMMAND_GYROCAL;
182
                }
182
                }
183
                if (commandTimer <= COMMAND_TIMER) {
183
                if (commandTimer <= COMMAND_TIMER) {
184
                        commandTimer++;
184
                        commandTimer++;
-
 
185
                }
185
                }
186
        } else {
-
 
187
          commandTimer = 0;
-
 
188
          lastRCCommand = COMMAND_NONE;
186
        } else commandTimer = 0;
189
        }
187
        return lastRCCommand;
190
        return lastRCCommand;
Line 188... Line 191...
188
}
191
}
189
 
192
 
190
uint8_t RC_getArgument(void) {
193
uint8_t RC_getArgument(void) {
Line 191... Line 194...
191
        return lastFlightMode;
194
        return lastFlightMode;
192
}
195
}
193
 
196
 
194
/*
197
/*
195
 * Get Pitch, Roll, Throttle, Yaw values
198
 * Get Pitch, Roll, Throttle, Yaw values
196
 */
199
 */
197
void RC_periodicTaskAndPRTY(int16_t* PRTY) {
-
 
198
  if (RCQuality) {
-
 
199
    RCQuality--;
-
 
200
    PRTY[CONTROL_ELEVATOR]   = RCChannel(CH_ELEVATOR) * RC_SCALING;
-
 
Line 201... Line 200...
201
    PRTY[CONTROL_AILERONS]   = RCChannel(CH_AILERONS) * RC_SCALING;
200
void RC_periodicTaskAndPRYT(int16_t* PRYT) {
-
 
201
  if (RCQuality) {
-
 
202
    RCQuality--;
202
    PRTY[CONTROL_THROTTLE]   = RCChannel(CH_THROTTLE) * RC_SCALING;
203
 
-
 
204
    debugOut.analog[20] = RCChannel(CH_ELEVATOR);
-
 
205
    debugOut.analog[21] = RCChannel(CH_AILERONS);
-
 
206
    debugOut.analog[22] = RCChannel(CH_RUDDER);
-
 
207
    debugOut.analog[23] = RCChannel(CH_THROTTLE);
-
 
208
 
Line 203... Line 209...
203
    PRTY[CONTROL_RUDDER]     = RCChannel(CH_RUDDER)   * RC_SCALING;
209
    PRYT[CONTROL_ELEVATOR]   = RCChannel(CH_ELEVATOR) * RC_SCALING;
204
 
210
    PRYT[CONTROL_AILERONS]   = RCChannel(CH_AILERONS) * RC_SCALING;
205
    debugOut.analog[16] = PRTY[CONTROL_ELEVATOR];
211
    PRYT[CONTROL_RUDDER]     = RCChannel(CH_RUDDER)   * RC_SCALING;
206
    debugOut.analog[17] = PRTY[CONTROL_THROTTLE];
212
    PRYT[CONTROL_THROTTLE]   = RCChannel(CH_THROTTLE) * RC_SCALING;