From 2b89ac625f43eeda326ff0569c24b78f7ddbcadf Mon Sep 17 00:00:00 2001 From: Tatsuya Yamaguchi Date: Sun, 7 Feb 2021 13:58:50 +0900 Subject: [PATCH] Copter: add allows_save_trim function to Mode class --- ArduCopter/RC_Channel.cpp | 2 +- ArduCopter/mode.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ArduCopter/RC_Channel.cpp b/ArduCopter/RC_Channel.cpp index fefe8adb89..f25406e083 100644 --- a/ArduCopter/RC_Channel.cpp +++ b/ArduCopter/RC_Channel.cpp @@ -201,7 +201,7 @@ void RC_Channel_Copter::do_aux_function(const aux_func_t ch_option, const AuxSwi case AUX_FUNC::SAVE_TRIM: if ((ch_flag == AuxSwitchPos::HIGH) && - (copter.flightmode->mode_number() <= Mode::Number::ACRO) && + (copter.flightmode->allows_save_trim()) && (copter.channel_throttle->get_control_in() == 0)) { copter.save_trim(); } diff --git a/ArduCopter/mode.h b/ArduCopter/mode.h index dfa1ea6b2e..debb32d9ea 100644 --- a/ArduCopter/mode.h +++ b/ArduCopter/mode.h @@ -60,6 +60,7 @@ public: virtual bool has_user_takeoff(bool must_navigate) const { return false; } virtual bool in_guided_mode() const { return false; } virtual bool logs_attitude() const { return false; } + virtual bool allows_save_trim() const { return false; } // return a string for this flightmode virtual const char *name() const = 0; @@ -275,6 +276,7 @@ public: void exit(); // whether an air-mode aux switch has been toggled void air_mode_aux_changed(); + bool allows_save_trim() const override { return true; } protected: @@ -1236,6 +1238,7 @@ public: bool has_manual_throttle() const override { return true; } bool allows_arming(bool from_gcs) const override { return true; }; bool is_autopilot() const override { return false; } + bool allows_save_trim() const override { return true; } protected: