rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
servo_sweep.h
Go to the documentation of this file.
1
27
28#pragma once
29
30#include <stdbool.h>
31#include <stdint.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37typedef enum {
38 SWEEP_OFF = 0,
39 SWEEP_SQUARE,
40 SWEEP_SINE,
41 SWEEP_TRIANGLE,
42 SWEEP_KIND_COUNT
43} sweep_kind_t;
44
46#define SWEEP_MHZ_MIN 50u
47#define SWEEP_MHZ_MAX 5000u
49#define SWEEP_AMPLITUDE_MAX 500u
51#define SWEEP_DWELL_MAX_MS 5000u
53#define SWEEP_CENTRE 500u
54
55typedef struct {
56 sweep_kind_t kind;
57 uint16_t mhz;
58 uint16_t amplitude;
59 uint16_t dwell_ms;
60 uint16_t moves;
62
63typedef struct {
64 sweep_cfg_t cfg;
65 uint32_t start_ms;
66 bool running;
67 bool paused;
68 uint32_t paused_ms;
69} sweep_t;
70
80bool sweep_cfg_valid(const sweep_cfg_t *cfg);
81
91bool sweep_start(sweep_t *w, const sweep_cfg_t *cfg, uint32_t now_ms);
92
98void sweep_stop(sweep_t *w);
99
109void sweep_pause(sweep_t *w, uint32_t now_ms);
110
121bool sweep_resume(sweep_t *w, uint32_t now_ms);
122
134bool sweep_step(sweep_t *w, uint32_t now_ms, uint16_t *command);
135
145uint32_t sweep_moves(const sweep_t *w, uint32_t now_ms);
146
165bool sweep_slew_limited(const sweep_cfg_t *cfg, uint16_t slew_per_s);
166
167#ifdef __cplusplus
168}
169#endif
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 ...
Definition servo_sweep.c:207
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 ask...
Definition servo_sweep.c:155
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,...
Definition servo_sweep.c:62
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.
Definition servo_sweep.c:142
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...
Definition servo_sweep.c:13
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.
Definition servo_sweep.c:22
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 the...
Definition servo_sweep.c:52
void sweep_stop(sweep_t *w)
Stop, and forget any paused phase.
Definition servo_sweep.c:38
Definition servo_sweep.h:55
uint16_t dwell_ms
Definition servo_sweep.h:59
uint16_t amplitude
Definition servo_sweep.h:58
uint16_t moves
Definition servo_sweep.h:60
uint16_t mhz
Definition servo_sweep.h:57
Definition servo_sweep.h:63
uint32_t paused_ms
Definition servo_sweep.h:68
bool paused
Definition servo_sweep.h:67