Hysteresis Filter

template<typename T, T LowThreshold, T HighThreshold>
struct Hysteresis

Filter with hysteresis (dead zone) to prevent oscillation.

This filter implements a hysteresis window with upper and lower thresholds, propagating only when crossing these thresholds and ignoring changes within the dead zone to prevent rapid toggling.

Since

v0.1.0

// Example: Hysteresis for button debouncing (10-90 range)
Signal<int, 10, Hysteresis<int, 10, 90>> button(0);

Note

Propagates when crossing thresholds, suppresses changes within dead zone.

Warning

  • Only accepts arithmetic types (integral and floating-point).

  • LowThreshold must be less than HighThreshold.

Template Parameters:
typename T

Arithmetic type.

T LowThreshold

Lower threshold.

T HighThreshold

Upper threshold.

Public Functions

inline bool operator()(const T &old_value, const T &new_value) const

See Also