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
This commit is contained in:
Randy Mackay 2013-10-22 13:13:36 +09:00
parent c98d375e49
commit fb49cd82c1
3 changed files with 21 additions and 4 deletions

View File

@ -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),

View File

@ -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)
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)
}
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;
}
}

View File

@ -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)