6#include <AH/STL/limits>
7#include <AH/STL/type_traits>
57 class input_t = uint_fast16_t,
58 class state_t =
typename std::make_unsigned<input_t>::type>
96 max_state = std::numeric_limits<state_t>::max(),
97 half_state = max_state / 2 + 1,
98 zero = std::is_unsigned<input_t>::value ?
state_t{0} : half_state,
101 static_assert(std::is_unsigned<state_t>::value,
102 "state type should be unsigned");
104 static_assert(max_state >= std::numeric_limits<input_t>::max(),
105 "state type cannot be narrower than input type");
123 using sstate_t =
typename std::make_signed<state_t>::type;
125 min >= std::numeric_limits<input_t>::min() &&
127 (std::is_unsigned<input_t>::value
129 : min >= -
static_cast<sstate_t>(max_state >> (
K + 1)) - 1 &&
175 filtered += (value - filtered) * alpha;
#define BEGIN_AH_NAMESPACE
A class for single-pole infinite impulse response filters or exponential moving average filters.
float operator()(float value)
Filter the input: Given , calculate .
float filter(float value)
Filter the input: Given , calculate .
EMA_f(float pole)
Create an exponential moving average filter with a pole at the given location.
Exponential moving average filter.
void reset(input_t value=input_t(0))
Reset the filter to the given value.
static constexpr bool supports_range(T min, T max)
Verify the input range to make sure it's compatible with the shift factor and the width of the state ...
input_t filter(input_t input)
Filter the input: Given , calculate .
EMA(input_t initial=input_t{0})
Constructor: initialize filter to zero or optional given value.
input_t operator()(input_t input)
Filter the input: Given , calculate .
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...