|
Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
Potentiometer with EWMA smoothing, deadband, and change detection. More...
#include <pot.hpp>
Public Member Functions | |
| Pot (const PotConfig &config={}) | |
| void | update (uint16_t raw) |
| Feed a new raw ADC sample through EWMA → deadband check. | |
| uint16_t | value () const |
| Current stable (deadbanded) value (0-65535) | |
| uint16_t | raw () const |
| Last raw (unfiltered) ADC value. | |
| int32_t | scaled (int32_t min, int32_t max) const |
| Map stable value to an output range (linear) | |
| int32_t | scaled_curved (int32_t min, int32_t max, uint16_t curve=sbl::dsp::curve::Log) const |
| Map stable value with curve shaping. | |
| bool | changed () |
| True if value moved past deadband since last check. | |
| void | set_pickup (uint16_t target) |
| Arm pickup mode — freeze output until knob crosses target. | |
| bool | picked_up () const |
| True if knob has caught up (or pickup was never armed) | |
| void | clear_pickup () |
| Cancel pickup, resume normal tracking immediately. | |
| void | reset () |
| Reset all state (filter, stable value, changed flag, pickup) | |
Potentiometer with EWMA smoothing, deadband, and change detection.
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
Last raw (unfiltered) ADC value.
Definition at line 100 of file pot.hpp.
References sbl::components::cv::CvInput::raw().
Referenced by update().
|
inline |
Reset all state (filter, stable value, changed flag, pickup)
Definition at line 180 of file pot.hpp.
References sbl::components::cv::CvInput::reset().
|
inline |
Map stable value to an output range (linear)
Linear interpolation from [0, 65535] -> [min, max]. Uses int64_t intermediate to avoid overflow. For non-linear mapping (frequency, filter cutoff), see scaled_curved().
|
inline |
Map stable value with curve shaping.
Applies ExpCurveWarp::warp() before scaling, useful for knob-friendly non-linear mapping (frequency, filter cutoff, gain).
| min | Output minimum (inclusive) |
| max | Output maximum (inclusive) |
| curve | Shape preset or arbitrary value (see sbl::dsp::curve) |
Definition at line 125 of file pot.hpp.
References sbl::dsp::ExpCurveWarp::warp().
|
inline |
Arm pickup mode — freeze output until knob crosses target.
The physical knob must cross target (a raw 0-65535 position) before stable_value_ resumes tracking. Until then, value(), scaled(), and scaled_curved() all return values based on target.
Use on mode switch: save the current knob position per-mode, then set_pickup(saved_position) when re-entering that mode.
| target | The knob position (0-65535) that must be crossed |
Definition at line 155 of file pot.hpp.
References sbl::components::cv::CvInput::value().
|
inline |
Feed a new raw ADC sample through EWMA → deadband check.
The EWMA filter smooths the raw value first. Then, if the smoothed value has moved more than deadband from the last stable value, we update the stable value and set the changed flag.
When pickup is armed, the EWMA filter tracks the physical position but stable_value_ stays frozen until the knob crosses the target.
Definition at line 66 of file pot.hpp.
References raw(), sbl::components::cv::CvInput::update(), and sbl::components::cv::CvInput::value().
Referenced by sbl::pot::read(), and sbl::pot::read_dma().
|
inline |
Current stable (deadbanded) value (0-65535)
Definition at line 97 of file pot.hpp.
Referenced by sbl::pot::read(), and sbl::pot::read_dma().