Skip to content

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:

  • cf Instance.
  • dead_band Minimum absolute change to report. Use 0.0f to report any change.
  • min_interval_ms Minimum milliseconds between reports. Use 0 to disable rate limiting.

function syn_change_filter_last

Get the last reported value.

static inline float syn_change_filter_last (
    const SYN_ChangeFilter * cf
) 

Parameters:

  • cf Filter instance.

Returns:

Last value that passed the filter.


function syn_change_filter_reset

Force the filter to report on next update.

static inline void syn_change_filter_reset (
    SYN_ChangeFilter * cf
) 

Resets the initialized flag so the next call to update() returns true regardless of dead-band or interval.

Parameters:

  • cf Filter 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:

  • cf Filter instance.
  • dead_band New dead-band threshold.
  • min_interval_ms New minimum reporting interval (ms).

function syn_change_filter_update

Feed a new value and check if it should be reported.

static inline bool syn_change_filter_update (
    SYN_ChangeFilter * cf,
    float value,
    uint32_t now_ms
) 

The first call always returns true (initial value).

Parameters:

  • cf Instance.
  • value New value to test.
  • now_ms Current 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