throttle Helper¶
-
template<typename Source>
Effect<1> RxESP32::Helpers::Temporal::throttle(Source &source, Source &target, uint32_t interval_ms, const typename Effect<1>::Options &options = {})¶ Throttle source changes to limit update rate.
Creates an Effect that limits how often the target is updated from the source. First change passes immediately, subsequent changes are throttled to at most one update per interval. Uses FreeRTOS timer (non-blocking).
- Since
v0.1.0
Signal<float> sensor_reading(0.0); Signal<float> throttled_reading(0.0); // Update display at most once per second auto throttler = throttle(sensor_reading, throttled_reading, 1000); sensor_reading.set(10.5); // Passes immediately sensor_reading.set(11.2); // Queued, waits for timer sensor_reading.set(12.8); // Replaces queued value // After 1000ms, throttled_reading = 12.8 (latest value)Note
Non-blocking - uses FreeRTOS timer callback.
First change passes through immediately.
Warning
Source and target must have the same type.
Minimum interval is
1ms(FreeRTOS limitation).
See Also¶
Temporal Helpers - Overview