From 4631392f31fad94bb0feecaa24c562c18547651f Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sun, 26 Jul 2020 10:52:15 +1000 Subject: [PATCH] Plane: use has_valid_input in place of checking throttle counter --- ArduPlane/control_modes.cpp | 5 ++--- ArduPlane/quadplane.cpp | 6 +++--- ArduPlane/servos.cpp | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ArduPlane/control_modes.cpp b/ArduPlane/control_modes.cpp index d97ce4212a..62689c78a2 100644 --- a/ArduPlane/control_modes.cpp +++ b/ArduPlane/control_modes.cpp @@ -107,9 +107,8 @@ void Plane::read_control_switch() // If we get this value we do not want to change modes. if(switchPosition == 255) return; - if (failsafe.rc_failsafe || failsafe.throttle_counter > 0) { - // when we are in rc_failsafe mode then RC input is not - // working, and we need to ignore the mode switch channel + if (!rc().has_valid_input()) { + // ignore the mode switch channel if there is no valid RC input return; } diff --git a/ArduPlane/quadplane.cpp b/ArduPlane/quadplane.cpp index e2b41272c1..3e8fd6ca54 100644 --- a/ArduPlane/quadplane.cpp +++ b/ArduPlane/quadplane.cpp @@ -1233,7 +1233,8 @@ float QuadPlane::get_desired_yaw_rate_cds(bool should_weathervane) // get pilot desired climb rate in cm/s float QuadPlane::get_pilot_desired_climb_rate_cms(void) const { - if (plane.failsafe.rc_failsafe || plane.failsafe.throttle_counter > 0) { + if (!rc().has_valid_input()) { + // no valid input means no sensible pilot desired climb rate. // descend at 0.5m/s for now return -50; } @@ -1744,8 +1745,7 @@ void QuadPlane::update(void) // disable throttle_wait when throttle rises above 10% if (throttle_wait && (plane.get_throttle_input() > 10 || - plane.failsafe.rc_failsafe || - plane.failsafe.throttle_counter>0)) { + !rc().has_valid_input())) { throttle_wait = false; } diff --git a/ArduPlane/servos.cpp b/ArduPlane/servos.cpp index 41b6f8ff45..2e52219587 100644 --- a/ArduPlane/servos.cpp +++ b/ArduPlane/servos.cpp @@ -561,7 +561,7 @@ void Plane::set_servos_controlled(void) control_mode == &mode_fbwa || control_mode == &mode_autotune) { // a manual throttle mode - if (failsafe.throttle_counter) { + if (!rc().has_valid_input()) { SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, 0.0); } else if (g.throttle_passthru_stabilize) { // manual pass through of throttle while in FBWA or @@ -615,7 +615,7 @@ void Plane::set_servos_flaps(void) int8_t manual_flap_percent = 0; // work out any manual flap input - if (channel_flap != nullptr && !failsafe.rc_failsafe && failsafe.throttle_counter == 0) { + if (channel_flap != nullptr && rc().has_valid_input()) { manual_flap_percent = channel_flap->percent_input(); }