20#ifndef SBL_HW_COMPONENTS_INPUT_POT_HPP_
21#define SBL_HW_COMPONENTS_INPUT_POT_HPP_
47 : filter_(static_cast<uint8_t>(config.smoothing)),
48 deadband_(config.deadband) {}
56 float delta = s - stable_value_;
57 if (delta < 0.0f) delta = -delta;
58 if (delta >= deadband_) {
65 void update_dma(
const uint16_t* buffer, uint8_t channel_index) {
66 update(
static_cast<const volatile uint16_t*
>(buffer)[channel_index]);
70 float value()
const {
return stable_value_; }
79 return static_cast<float>(calibration_.
normalize(filter_.
value())) *
84 uint16_t
raw()
const {
return raw_; }
107 stable_value_ = 0.0f;
116 float stable_value_ = 0.0f;
117 bool changed_ =
false;
uint16_t update(uint16_t raw)
Feed a new sample and return the smoothed value.
uint16_t value() const
Return current smoothed value without updating.
void reset()
Reset filter state (next update will re-seed)
Exponentially Weighted Moving Average filter.
Smoothing
Smoothing presets for the raw-domain EWMA filter.
@ Medium
alpha=1/8, settles in ~24 samples (pots, knobs)
Root namespace for all Sound Byte Libs code.
Two-point ADC calibration.