timeout Helper¶
-
template<size_t MaxDeps = 8, size_t HistorySize = 0, typename Source>
TimeoutSignal<Source, MaxDeps, HistorySize> RxESP32::Helpers::Temporal::timeout(Source &source, const uint32_t timeout_ms, const decltype(source.get()) &fallback_value, const typename Effect<1>::Options &options = {})¶ Create a timeout-monitored signal that falls back to a default value.
Wraps a source Signal with timeout monitoring using FreeRTOS timers. If the source doesn’t update within the specified timeout period, the Signal automatically switches to the fallback value. The timer resets whenever the source updates.
- Since
v0.1.0
Signal<float> temperature; auto monitored = timeout(temperature, 10000, -999.0f); // 10s timeout temperature.set(22.5); // monitored.signal().get() == 22.5 delay(11000); // Timeout! // monitored.signal().get() == -999.0 temperature.set(23.0); // monitored.signal().get() == 23.0 (recovered)Note
Uses a FreeRTOS one-shot timer that resets on each source update.
The internal Effect occupies 1 dependency slot on the source.
See Also¶
Temporal Helpers - Overview