|
| bool | sweep_cfg_valid (const sweep_cfg_t *cfg) |
| | Whether cfg is one a sweep can run: a curve, a speed and an amplitude in range, and a dwell no longer than SWEEP_DWELL_MAX_MS.
|
| bool | sweep_start (sweep_t *w, const sweep_cfg_t *cfg, uint32_t now_ms) |
| | Start cfg at now_ms. False, and stopped, for a configuration sweep_cfg_valid() refuses.
|
| void | sweep_stop (sweep_t *w) |
| | Stop, and forget any paused phase.
|
| void | sweep_pause (sweep_t *w, uint32_t now_ms) |
| | Stop a running sweep at now_ms and keep how far into it it was, so sweep_resume() carries on from there: the same point of the curve, the same dwell, the movements reached so far. Nothing for a sweep that is not running, finished included.
|
| bool | sweep_resume (sweep_t *w, uint32_t now_ms) |
| | Carry a paused sweep on at now_ms from where it was paused. False, and nothing changes, when nothing is paused: never paused, stopped or started since.
|
| static cycle_t | cycle_of (const sweep_cfg_t *c) |
| | Derive the cycle lengths of a sweep.
|
| static uint64_t | elapsed_us (const sweep_t *w, uint32_t now_ms) |
| | Microseconds since the sweep started.
|
| static uint64_t | ends_by (const cycle_t *y, uint64_t t) |
| | Ends reached by t microseconds into the sweep, with no limit.
|
| static uint64_t | done_at (const cycle_t *y, uint32_t n) |
| | When the dwell at the n-th end is over, n at least 1.
|
| uint32_t | sweep_moves (const sweep_t *w, uint32_t now_ms) |
| | How many ends the sweep has reached by now_ms, the moves limit included once reached.
|
| bool | sweep_slew_limited (const sweep_cfg_t *cfg, uint16_t slew_per_s) |
| | Whether a slew of slew_per_s command units a second is slower than the fastest change cfg's curve asks for, so the slew and not the curve decides how the output moves. The fastest change, at amplitude A and f = mhz / 1000 cycles a second, is 2 pi f A for a sine (at the centre) and 4 f A for a triangle (throughout). A square jumps, so any slew limits it. The dwell does not enter: it adds time at the ends, not to the motion.
|
| static float | shape (sweep_kind_t kind, float x) |
| | The curve's position, -1..1, a fraction x of the way through its motion.
|
| bool | sweep_step (sweep_t *w, uint32_t now_ms, uint16_t *command) |
| | The command at now_ms into command. True while the sweep runs; false once it has stopped or made its movements, with command at the centre. The clock may wrap.
|
The sweep. See servo_sweep.h.
SPDX-License-Identifier: MIT
| bool sweep_slew_limited |
( |
const sweep_cfg_t * | cfg, |
|
|
uint16_t | slew_per_s ) |
Whether a slew of slew_per_s command units a second is slower than the fastest change cfg's curve asks for, so the slew and not the curve decides how the output moves. The fastest change, at amplitude A and f = mhz / 1000 cycles a second, is 2 pi f A for a sine (at the centre) and 4 f A for a triangle (throughout). A square jumps, so any slew limits it. The dwell does not enter: it adds time at the ends, not to the motion.
A slew of 0 is no limit, as on an output channel, and limits nothing. False for a configuration sweep_cfg_valid() refuses and for an amplitude of 0, which asks for no change.
- Parameters
-
| cfg | Configuration of the curve. |
| slew_per_s | Slew limit, command units a second. 0 is no limit. |
- Returns
- true when the slew limits the curve; false for an invalid cfg, a slew of 0 or an amplitude of 0.