Browse Source

Plane: remove duplicate last mode reason

apm_2208
Iampete1 3 years ago committed by Andrew Tridgell
parent
commit
90f2bf3ba2
  1. 1
      ArduPlane/Plane.h
  2. 2
      ArduPlane/events.cpp
  3. 5
      ArduPlane/system.cpp

1
ArduPlane/Plane.h

@ -1057,7 +1057,6 @@ private: @@ -1057,7 +1057,6 @@ private:
bool set_mode(Mode& new_mode, const ModeReason reason);
bool set_mode(const uint8_t mode, const ModeReason reason) override;
bool set_mode_by_number(const Mode::Number new_mode_number, const ModeReason reason);
ModeReason _last_reason;
void check_long_failsafe();
void check_short_failsafe();
void startup_INS_ground(void);

2
ArduPlane/events.cpp

@ -201,7 +201,7 @@ void Plane::failsafe_short_off_event(ModeReason reason) @@ -201,7 +201,7 @@ void Plane::failsafe_short_off_event(ModeReason reason)
gcs().send_text(MAV_SEVERITY_WARNING, "Short Failsafe Cleared");
failsafe.state = FAILSAFE_NONE;
// restore entry mode if desired but check that our current mode is still due to failsafe
if ( _last_reason == ModeReason::RADIO_FAILSAFE) {
if (control_mode_reason == ModeReason::RADIO_FAILSAFE) {
set_mode_by_number(failsafe.saved_mode_number, ModeReason::RADIO_FAILSAFE_RECOVERY);
gcs().send_text(MAV_SEVERITY_INFO,"Flight mode %s restored",control_mode->name());
}

5
ArduPlane/system.cpp

@ -204,14 +204,11 @@ void Plane::startup_ground(void) @@ -204,14 +204,11 @@ void Plane::startup_ground(void)
bool Plane::set_mode(Mode &new_mode, const ModeReason reason)
{
// update last reason
const ModeReason last_reason = _last_reason;
_last_reason = reason;
if (control_mode == &new_mode) {
// don't switch modes if we are already in the correct mode.
// only make happy noise if using a difent method to switch, this stops beeping for repeated change mode requests from GCS
if ((reason != last_reason) && (reason != ModeReason::INITIALISED)) {
if ((reason != control_mode_reason) && (reason != ModeReason::INITIALISED)) {
AP_Notify::events.user_mode_change = 1;
}
return true;

Loading…
Cancel
Save