Bedtime. /Parameters

Parameters

Smoothed, range-clamped values — the unit ui_menu edits and the encoder drives

A params_t holds a target and a smoothed current value. You set the target; param_update_fast() walks val toward it and returns true on the frames it changed, which is your cue to redraw. Set refresh = true or val never follows target.

Driving a param from the encoder

// in tick()
param_write_delta_coarse(&m->cutoff, os_controls_encoder_get_delta());
if (param_update_fast(&m->cutoff, m)) m->dirty = true;

// in redraw()
gfx_draw_strf(gfx, 10, 40, "cutoff %d%%", (int)(param_val_percent(&m->cutoff) * 100));

Put the same params_t in a ui_menu_node_t's param field and the menu edits it for you — the two paths are interchangeable.

Note — There is no param_init(): it hands back a slot from a firmware-owned pool. Declare params_t values in your own model and fill the fields directly.

void param_set(params_t* param, const float value)

Set the value immediately (clamped to min/max), skipping smoothing

params_t*param
const floatvalue
void param_set_rawfast(params_t* param, const float value)

Set the value with no clamp and no smoothing — fast path for audio code

params_t*param
const floatvalue
void param_set_target(params_t* param, const float value)

Set the target; `val` then eases toward it on param_update_fast()

params_t*param
const floatvalue
void param_inc(params_t* param, const float value)

Add to the target (clamped)

params_t*param
const floatvalue
void param_dec(params_t* param, const float value)

Subtract from the target (clamped)

params_t*param
const floatvalue
bool param_update_fast(params_t* param, void* ctx)

Advance `val` toward `target`; true if it moved this call (redraw cue)

params_t*param
void*ctx
bool param_update_val(params_t* param)

Advance `val` toward `target` without firing the callback

params_t*param
bool param_updated(const params_t* param)

Did the value change since the last check?

const params_t*param
void param_write_delta_coarse(params_t* param, int32_t acc)

Apply an encoder delta using the param's `coarse` step

params_t*param
int32_tacc
void param_write_delta_val(params_t* param, int32_t acc)

Apply an encoder delta using the param's `fine` step

params_t*param
int32_tacc
void param_set_callback(params_t* param, void (*callback)(params_t* self, void* context))

Called whenever the value changes; receives the param and your ctx

params_t*param
void (*callback)(params_t* self, void* context)
float param_raw(const params_t* param)

Raw current value, before range mapping

const params_t*param
float param_map(const params_t* param, const float min, const float max)

Current value rescaled from the param's range into [min, max]

const params_t*param
const floatmin
const floatmax
float param_val_percent(const params_t* param)

Current value as 0.0-1.0 across the param's own range

const params_t*param
bool param_same(const params_t* p1, const params_t* p2)

Do two params hold the same value?

const params_t*p1
const params_t*p2