From aab787b08bee8ebd4800242994b5a7228d986e3b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 6 Jun 2019 09:39:14 +1000 Subject: [PATCH] RC_Channel: move mission reset in from Copter --- libraries/RC_Channel/RC_Channel.cpp | 16 ++++++++++++++++ libraries/RC_Channel/RC_Channel.h | 1 + 2 files changed, 17 insertions(+) diff --git a/libraries/RC_Channel/RC_Channel.cpp b/libraries/RC_Channel/RC_Channel.cpp index 2b860c6106..0b4356834a 100644 --- a/libraries/RC_Channel/RC_Channel.cpp +++ b/libraries/RC_Channel/RC_Channel.cpp @@ -446,6 +446,7 @@ void RC_Channel::init_aux_function(const aux_func_t ch_option, const aux_switch_ switch(ch_option) { case AUX_FUNC::RC_OVERRIDE_ENABLE: case AUX_FUNC::AVOID_PROXIMITY: + case AUX_FUNC::MISSION_RESET: do_aux_function(ch_option, ch_flag); break; // the following functions do not need to be initialised: @@ -633,6 +634,18 @@ void RC_Channel::do_aux_function_rc_override_enable(const aux_switch_pos_t ch_fl } } +void RC_Channel::do_aux_function_mission_reset(const aux_switch_pos_t ch_flag) +{ + if (ch_flag != HIGH) { + return; + } + AP_Mission *mission = AP::mission(); + if (mission == nullptr) { + return; + } + mission->reset(); +} + void RC_Channel::do_aux_function(const aux_func_t ch_option, const aux_switch_pos_t ch_flag) { switch(ch_option) { @@ -674,6 +687,9 @@ void RC_Channel::do_aux_function(const aux_func_t ch_option, const aux_switch_po case AUX_FUNC::CLEAR_WP: do_aux_function_clear_wp(ch_flag); break; + case AUX_FUNC::MISSION_RESET: + do_aux_function_mission_reset(ch_flag); + break; case AUX_FUNC::SPRAYER: do_aux_function_sprayer(ch_flag); diff --git a/libraries/RC_Channel/RC_Channel.h b/libraries/RC_Channel/RC_Channel.h index 6dd3a6d2d5..5026e7a256 100644 --- a/libraries/RC_Channel/RC_Channel.h +++ b/libraries/RC_Channel/RC_Channel.h @@ -195,6 +195,7 @@ protected: void do_aux_function_clear_wp(const aux_switch_pos_t ch_flag); void do_aux_function_gripper(const aux_switch_pos_t ch_flag); void do_aux_function_lost_vehicle_sound(const aux_switch_pos_t ch_flag); + void do_aux_function_mission_reset(const aux_switch_pos_t ch_flag); void do_aux_function_rc_override_enable(const aux_switch_pos_t ch_flag); void do_aux_function_relay(uint8_t relay, bool val); void do_aux_function_sprayer(const aux_switch_pos_t ch_flag);