Browse Source

Copter: add LAND to aux switch

Fix aux switch AUTO and RTL so they resets flight mode if still in those
modes when switch brought low
master
Randy Mackay 11 years ago
parent
commit
fb49cd82c1
  1. 4
      ArduCopter/Parameters.pde
  2. 20
      ArduCopter/control_modes.pde
  3. 1
      ArduCopter/defines.h

4
ArduCopter/Parameters.pde

@ -389,14 +389,14 @@ const AP_Param::Info var_info[] PROGMEM = { @@ -389,14 +389,14 @@ const AP_Param::Info var_info[] PROGMEM = {
// @Param: CH7_OPT
// @DisplayName: Channel 7 option
// @Description: Select which function if performed when CH7 is above 1800 pwm
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune, 18:Land
// @User: Standard
GSCALAR(ch7_option, "CH7_OPT", CH7_OPTION),
// @Param: CH8_OPT
// @DisplayName: Channel 8 option
// @Description: Select which function if performed when CH8 is above 1800 pwm
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune, 18:Land
// @User: Standard
GSCALAR(ch8_option, "CH8_OPT", CH8_OPTION),

20
ArduCopter/control_modes.pde

@ -164,8 +164,8 @@ static void do_aux_switch_function(int8_t ch_function, uint8_t ch_flag) @@ -164,8 +164,8 @@ static void do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
// engage RTL (if not possible we remain in current flight mode)
set_mode(RTL);
}else{
// disengage RTL to previous flight mode if we are currently in RTL or loiter
if (control_mode == RTL || control_mode == LOITER) {
// return to flight mode switch's flight mode if we are currently in RTL
if (control_mode == RTL) {
reset_control_switch();
}
}
@ -289,6 +289,11 @@ static void do_aux_switch_function(int8_t ch_function, uint8_t ch_flag) @@ -289,6 +289,11 @@ static void do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
case AUX_SWITCH_AUTO:
if (ch_flag == AUX_SWITCH_HIGH) {
set_mode(AUTO);
}else{
// return to flight mode switch's flight mode if we are currently in AUTO
if (control_mode == AUTO) {
reset_control_switch();
}
}
break;
@ -311,6 +316,17 @@ static void do_aux_switch_function(int8_t ch_function, uint8_t ch_flag) @@ -311,6 +316,17 @@ static void do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
}
break;
#endif
case AUX_SWITCH_LAND:
if (ch_flag == AUX_SWITCH_HIGH) {
set_mode(LAND);
}else{
// return to flight mode switch's flight mode if we are currently in LAND
if (control_mode == LAND) {
reset_control_switch();
}
}
break;
}
}

1
ArduCopter/defines.h

@ -70,6 +70,7 @@ @@ -70,6 +70,7 @@
#define AUX_SWITCH_SPRAYER 15 // enable/disable the crop sprayer
#define AUX_SWITCH_AUTO 16 // change to auto flight mode
#define AUX_SWITCH_AUTOTUNE 17 // auto tune
#define AUX_SWITCH_LAND 18 // change to LAND flight mode
// values used by the ap.ch7_opt and ap.ch8_opt flags
#define AUX_SWITCH_LOW 0 // indicates auxiliar switch is in the low position (pwm <1200)

Loading…
Cancel
Save