From 8574303a94698dce2fbd4ba4357d41842e1b6843 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 8 Mar 2014 16:49:57 +1100 Subject: [PATCH] Plane: treat PWM below 900 as invalid for mode switch the FrSky X8R receiver will briefly give a PWM of 874 on channel 5 when connection is lost to the transmitter. We need to ensure this doesn't cause a mode switch --- ArduPlane/control_modes.pde | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ArduPlane/control_modes.pde b/ArduPlane/control_modes.pde index 81a59eb413..317551d9bc 100644 --- a/ArduPlane/control_modes.pde +++ b/ArduPlane/control_modes.pde @@ -16,6 +16,11 @@ static void read_control_switch() return; } + if (hal.scheduler->millis() - failsafe.last_valid_rc_ms > 100) { + // only use signals that are less than 0.1s old. + return; + } + // we look for changes in the switch position. If the // RST_SWITCH_CH parameter is set, then it is a switch that can be // used to force re-reading of the control switch. This is useful @@ -57,9 +62,10 @@ static void read_control_switch() } } -static uint8_t readSwitch(void){ +static uint8_t readSwitch(void) +{ uint16_t pulsewidth = hal.rcin->read(g.flight_mode_channel - 1); - if (pulsewidth <= 800 || pulsewidth >= 2200) return 255; // This is an error condition + if (pulsewidth <= 900 || pulsewidth >= 2200) return 255; // This is an error condition if (pulsewidth > 1230 && pulsewidth <= 1360) return 1; if (pulsewidth > 1360 && pulsewidth <= 1490) return 2; if (pulsewidth > 1490 && pulsewidth <= 1620) return 3;