Browse Source

Copter: add allows_save_trim function to Mode class

zr-v5.1
Tatsuya Yamaguchi 4 years ago committed by Peter Barker
parent
commit
2b89ac625f
  1. 2
      ArduCopter/RC_Channel.cpp
  2. 3
      ArduCopter/mode.h

2
ArduCopter/RC_Channel.cpp

@ -201,7 +201,7 @@ void RC_Channel_Copter::do_aux_function(const aux_func_t ch_option, const AuxSwi @@ -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();
}

3
ArduCopter/mode.h

@ -60,6 +60,7 @@ public: @@ -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: @@ -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: @@ -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:

Loading…
Cancel
Save