Plane: use has_valid_input in place of checking throttle counter

This commit is contained in:
Peter Barker 2020-07-26 10:52:15 +10:00 committed by Andrew Tridgell
parent c8bc0b7e0d
commit 9981a08791
3 changed files with 7 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();
}