diff --git a/src/modules/rc_update/rc_update.cpp b/src/modules/rc_update/rc_update.cpp index b357a9039b..9a43288d05 100644 --- a/src/modules/rc_update/rc_update.cpp +++ b/src/modules/rc_update/rc_update.cpp @@ -542,6 +542,12 @@ void RCUpdate::Run() } _last_timestamp_signal = input_rc.timestamp_last_signal; + + } else { + // RC input unstable or lost, clear any previous manual_switches + if (_manual_switches_last_publish.timestamp_sample != 0) { + _manual_switches_last_publish = {}; + } } memcpy(_rc_values_previous, input_rc.values, sizeof(input_rc.values[0]) * channel_count_limited); @@ -643,8 +649,10 @@ void RCUpdate::UpdateManualSwitches(const hrt_abstime ×tamp_sample) switches.video_switch = get_rc_sw2pos_position(rc_channels_s::FUNCTION_AUX_4, 0.5f); #endif - // last 2 switch updates identical (simple protection from bad RC data) - if (switches == _manual_switches_previous) { + // last 2 switch updates identical within 1 second (simple protection from bad RC data) + if ((switches == _manual_switches_previous) + && (switches.timestamp_sample < _manual_switches_previous.timestamp_sample + 1_s)) { + const bool switches_changed = (switches != _manual_switches_last_publish); // publish immediately on change or at ~1 Hz