pot_ui.h
Generated from the header
This page is rodeo-sdk/common/pot_ui.h — its comments and declarations.
To change it, change the header.
Same deal as adc_convert.h: the parts of the panel behaviour that are just math and state live here, dependency-free, so they can be unit-tested on the HOST with no libDaisy in the build — and the firmware calls THESE functions, so the tests guard the real path (see common/tests/README.md).
Time is passed in as a millisecond argument rather than read from System::GetNow(), which is what keeps this header host-safe and the tests deterministic.
StepWithHysteresis
inline int StepWithHysteresis(float norm, int steps, int current, float hyst = 0.03f);Quantize a 0..1 pot reading into steps equal zones, with hysteresis so a
knob parked on a boundary can’t flicker between two settings.
current is the zone in effect right now (pass a value outside 0..steps-1 to
seed from the reading alone). A different zone only wins once the reading has
cleared the current zone’s edge by hyst.
KnobWatch
struct KnobWatchTracks which pot the user is currently touching, so a display can pop up that parameter and then fall back to its idle view.
Motion is measured against anchor — the value at which motion was LAST
declared — not against the previous sample. That matters: a slow deliberate
sweep moves less than the deadband per sample, so a previous-sample
comparison would filter it out entirely, while an anchor comparison lets the
movement accumulate until it trips.
Members
static constexpr int kMaxPots = 24— pots one KnobWatch can trackfloat anchor[kMaxPots] = {0.0f}int active = -1— most recently moved pot, -1 = noneuint32_t t_move_ms = 0— when that pot last moved
KnobWatch::Reset
void Reset(const float *norms, int n);Seed the anchors from the current readings without declaring motion. Call once after the ADC scan has populated every channel, otherwise the boot-time zeros read as a full-scale move on every pot.
KnobWatch::Update
bool Update(const float *norms, int n, uint32_t now_ms, float deadband = 0.012f, uint32_t hold_ms = 800);Feed the current raw readings. Returns true while the popup should show;
active names which pot it is for.