7 memset(
self, 0,
sizeof(*
self));
13 self->_duration = duration;
19 self->_tick_end =
self->_tick_start +
self->_duration;
28 self->_active =
false;
36 return _twr_ramp_interpolate(
twr_tick_get(), self->_tick_start, self->_tick_end, self->_start, self->_stop);
41 if (x < x_min) { x = x_min; }
42 if (x > x_max) { x = x_max; }
44 return (
float) (x - x_min) * (y_max - y_min) / (float) (x_max - x_min) + y_min;
float twr_ramp_get(twr_ramp_t *self)
Get current ramp value.
void twr_ramp_init(twr_ramp_t *self, float start, float stop, twr_tick_t duration)
Initialize ramp instance.
void twr_ramp_start(twr_ramp_t *self)
Start ramp sequence.
twr_tick_t twr_tick_get(void)
Get absolute timestamp since start of program.
uint64_t twr_tick_t
Timestamp data type.