From b95ac72d35a4a13bf09eb4d00ee7bd999e77035c Mon Sep 17 00:00:00 2001 From: Ammarf <35584084+Ammarf@users.noreply.github.com> Date: Thu, 24 May 2018 17:13:12 +0900 Subject: [PATCH] Rover: add LOITER to ch7 options --- APMrover2/Parameters.cpp | 4 ++-- APMrover2/control_modes.cpp | 9 +++++++++ APMrover2/defines.h | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/APMrover2/Parameters.cpp b/APMrover2/Parameters.cpp index c8fc0b2542..bb50df91a5 100644 --- a/APMrover2/Parameters.cpp +++ b/APMrover2/Parameters.cpp @@ -41,7 +41,7 @@ const AP_Param::Info Rover::var_info[] = { // @Param: INITIAL_MODE // @DisplayName: Initial driving mode // @Description: This selects the mode to start in on boot. This is useful for when you want to start in AUTO mode on boot without a receiver. Usually used in combination with when AUTO_TRIGGER_PIN or AUTO_KICKSTART. - // @Values: 0:MANUAL,1:ACRO,3:STEERING,4:HOLD,10:AUTO,11:RTL,15:GUIDED + // @Values: 0:MANUAL,1:ACRO,3:STEERING,4:HOLD,5:LOITER,10:AUTO,11:RTL,15:GUIDED // @User: Advanced GSCALAR(initial_mode, "INITIAL_MODE", MANUAL), @@ -129,7 +129,7 @@ const AP_Param::Info Rover::var_info[] = { // @Param: CH7_OPTION // @DisplayName: Channel 7 option // @Description: What to do use channel 7 for - // @Values: 0:Nothing,1:SaveWaypoint,2:LearnCruiseSpeed,3:ArmDisarm,4:Manual,5:Acro,6:Steering,7:Hold,8:Auto,9:RTL,10:SmartRTL,11:Guided + // @Values: 0:Nothing,1:SaveWaypoint,2:LearnCruiseSpeed,3:ArmDisarm,4:Manual,5:Acro,6:Steering,7:Hold,8:Auto,9:RTL,10:SmartRTL,11:Guided,12:Loiter // @User: Standard GSCALAR(ch7_option, "CH7_OPTION", CH7_OPTION), diff --git a/APMrover2/control_modes.cpp b/APMrover2/control_modes.cpp index 9ed3885611..a17787a5c7 100644 --- a/APMrover2/control_modes.cpp +++ b/APMrover2/control_modes.cpp @@ -273,6 +273,15 @@ void Rover::read_aux_switch() reset_control_switch(); } break; + + // Set mode to LOITER + case CH7_LOITER: + if (aux_ch7 == AUX_SWITCH_HIGH) { + set_mode(mode_loiter, MODE_REASON_TX_COMMAND); + } else if ((aux_ch7 == AUX_SWITCH_LOW) && (control_mode == &mode_loiter)) { + reset_control_switch(); + } + break; } } diff --git a/APMrover2/defines.h b/APMrover2/defines.h index 5e3a44ad1a..61eacbb147 100644 --- a/APMrover2/defines.h +++ b/APMrover2/defines.h @@ -26,7 +26,8 @@ enum ch7_option { CH7_AUTO = 8, CH7_RTL = 9, CH7_SMART_RTL = 10, - CH7_GUIDED = 11 + CH7_GUIDED = 11, + CH7_LOITER = 12 }; // HIL enumerations