File syn_ramp.c¶
FileList > src > syntropic > util > syn_ramp.c
Go to the source code of this file
Ramp / motion profile generator implementation.
#include "../util/syn_assert.h"#include "syn_ramp.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_ramp_init (SYN_Ramp * ramp, int32_t initial) Initialize ramp generator. |
| void | syn_ramp_jump (SYN_Ramp * ramp, int32_t value) Jump immediately to a value (no ramp). |
| void | syn_ramp_set_target (SYN_Ramp * ramp, int32_t target, int32_t rate) Set new target with linear ramp. |
| void | syn_ramp_set_target_trapezoid (SYN_Ramp * ramp, int32_t target, int32_t max_rate, int32_t accel) Set new target with trapezoidal ramp (acceleration/deceleration). |
| void | syn_ramp_set_target_trapezoid_fp (SYN_Ramp * ramp, int32_t target, int32_t max_rate, int32_t accel, uint8_t frac_bits) Set new target with fixed-point trapezoidal ramp. |
| int32_t | syn_ramp_update (SYN_Ramp * ramp) Update the ramp — call once per tick. |
Public Static Functions¶
| Type | Name |
|---|---|
| int32_t | update_linear (SYN_Ramp * ramp) Linear ramp step toward target. |
| int32_t | update_trapezoid (SYN_Ramp * ramp) Trapezoid ramp step toward target. |
Public Functions Documentation¶
function syn_ramp_init¶
Initialize ramp generator.
Parameters:
rampRamp instance.initialStarting value.
function syn_ramp_jump¶
Jump immediately to a value (no ramp).
Parameters:
rampRamp instance.valueValue to jump to.
function syn_ramp_set_target¶
Set new target with linear ramp.
Parameters:
rampRamp instance.targetDesired final value.rateMax change per update call (always positive).
function syn_ramp_set_target_trapezoid¶
Set new target with trapezoidal ramp (acceleration/deceleration).
void syn_ramp_set_target_trapezoid (
SYN_Ramp * ramp,
int32_t target,
int32_t max_rate,
int32_t accel
)
Parameters:
rampRamp instance.targetDesired final value.max_rateMax velocity (units/tick).accelAcceleration (units/tick²). Controls smoothness.
function syn_ramp_set_target_trapezoid_fp¶
Set new target with fixed-point trapezoidal ramp.
void syn_ramp_set_target_trapezoid_fp (
SYN_Ramp * ramp,
int32_t target,
int32_t max_rate,
int32_t accel,
uint8_t frac_bits
)
Like syn_ramp_set_target_trapezoid(), but velocity and acceleration are in Qfrac_bits fixed-point. This allows sub-unit-per-tick resolution for smooth motion at high update rates.
Parameters:
rampRamp instance.targetDesired final value (integer, not fixed-point).max_rateMax velocity in Qfrac_bits(e.g., Q8).accelAcceleration in Qfrac_bits.frac_bitsNumber of fractional bits (e.g., 8 for Q8).
function syn_ramp_update¶
Update the ramp — call once per tick.
Parameters:
rampRamp instance.
Returns:
Current output value.
Public Static Functions Documentation¶
function update_linear¶
Linear ramp step toward target.
Parameters:
rampRamp instance.
Returns:
Current ramp value.
function update_trapezoid¶
Trapezoid ramp step toward target.
Supports fixed-point velocity/accel when frac_bits > 0. Velocity and accel are in Qfrac_bits format. Position is integer; a fractional accumulator carries sub-unit remainder.
Parameters:
rampRamp instance.
Returns:
Current ramp value (integer position).
The documentation for this class was generated from the following file src/syntropic/util/syn_ramp.c