File syn_change_filter.h¶
FileList > src > syntropic > util > syn_change_filter.h
Go to the source code of this file
Dead-band + rate-limited change detector (header-only). More...
#include <stdbool.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_ChangeFilter Dead-band + rate-limited change filter. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | syn_change_filter_init (SYN_ChangeFilter * cf, float dead_band, uint32_t min_interval_ms) Initialize a change filter. |
| float | syn_change_filter_last (const SYN_ChangeFilter * cf) Get the last reported value. |
| void | syn_change_filter_reset (SYN_ChangeFilter * cf) Force the filter to report on next update. |
| void | syn_change_filter_set (SYN_ChangeFilter * cf, float dead_band, uint32_t min_interval_ms) Update dead-band and interval at runtime. |
| bool | syn_change_filter_update (SYN_ChangeFilter * cf, float value, uint32_t now_ms) Feed a new value and check if it should be reported. |
Detailed Description¶
Reports a value as "changed" only when the difference from the last reported value exceeds a dead-band AND a minimum time interval has elapsed. Useful for suppressing noise in telemetry, sensor logging, display updates, or any push-on-change pattern.
Header-only — zero code size if unused.
** **
SYN_ChangeFilter cf;
syn_change_filter_init(&cf, 0.5f, 1000); // dead_band=0.5, min_ms=1000
// In sensor loop:
float temp = read_temperature();
if (syn_change_filter_update(&cf, temp, now_ms)) {
// Value changed significantly — transmit / log / display
send_update(temp);
}
Public Static Functions Documentation¶
function syn_change_filter_init¶
Initialize a change filter.
static inline void syn_change_filter_init (
SYN_ChangeFilter * cf,
float dead_band,
uint32_t min_interval_ms
)
Parameters:
cfInstance.dead_bandMinimum absolute change to report. Use 0.0f to report any change.min_interval_msMinimum milliseconds between reports. Use 0 to disable rate limiting.
function syn_change_filter_last¶
Get the last reported value.
Parameters:
cfFilter instance.
Returns:
Last value that passed the filter.
function syn_change_filter_reset¶
Force the filter to report on next update.
Resets the initialized flag so the next call to update() returns true regardless of dead-band or interval.
Parameters:
cfFilter instance.
function syn_change_filter_set¶
Update dead-band and interval at runtime.
static inline void syn_change_filter_set (
SYN_ChangeFilter * cf,
float dead_band,
uint32_t min_interval_ms
)
Parameters:
cfFilter instance.dead_bandNew dead-band threshold.min_interval_msNew minimum reporting interval (ms).
function syn_change_filter_update¶
Feed a new value and check if it should be reported.
The first call always returns true (initial value).
Parameters:
cfInstance.valueNew value to test.now_msCurrent tick in milliseconds.
Returns:
true if the value should be reported.
The documentation for this class was generated from the following file src/syntropic/util/syn_change_filter.h