49 if (__builtin_popcount(v) == 1) {
return __builtin_ctz(v) - 1; }
51 uint8_t next_pow_of_2{ 0 };
59 return --next_pow_of_2;
76template< u
int8_t A = 10 >
Exponentially Weighted Moving Average.
void addValue(int32_t input)
Add a new value and actualize the EMA, DEMA and TEMA.
auto getAverageD() const
Get the DEMA.
auto getAverageT() const
Get the TEMA.
auto getAverageS() const
Get the EMA.
constexpr uint8_t round_up_to_power_of_2(uint16_t v)
Helper compile-time function to retrieve the previous power of 2 of the given number (120 => 64 => 6)
Some useful but missing stl functions templates.