Debounce Filter

template<typename T, uint32_t DebounceMs>
struct Debounce

Filter that debounces changes with a time delay.

This stateful filter waits for a value to remain stable for the specified duration (in milliseconds) before propagating, preventing rapid oscillations.

Since

v0.1.0

// Example: Debounce with 50ms stability requirement
Signal<bool, 10, Debounce<bool, 50>> switch_signal(false);

Note

Stateful filter. Uses millis() for timing.

Warning

  • DebounceMs must be greater than 0.

  • Type T must support operator==.

Template Parameters:
typename T

Any type.

uint32_t DebounceMs

Stability time required in milliseconds.

Public Functions

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

Public Members

mutable bool initialized = false
mutable T pending_value = T()
mutable uint32_t last_change_time = 0

See Also