rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
esc_profile.h
Go to the documentation of this file.
1
29
30#ifndef RCBENCH_ESC_PROFILE_H
31#define RCBENCH_ESC_PROFILE_H
32
33#include <stdbool.h>
34#include <stddef.h>
35#include <stdint.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
44#define ESC_PROFILE_SCHEMA 1u
45
51#define ESC_PROFILE_MAX_BYTES 65536u
52
56#define ESC_PROFILE_MAX_OVERRIDES 32u
57
64#define ESC_MAKER_MODELS_MAX 512u
65
77
81typedef enum {
82 ESC_ENC_COUNT = 0,
83 ESC_ENC_SHORT_LONG,
84 ESC_ENC_MELODY,
85 ESC_ENC_YES_NO,
87
97
99typedef enum {
100 ESC_THR_MIN = 0,
101 ESC_THR_MID,
102 ESC_THR_MAX,
105
109typedef enum {
110 ESC_ANNOUNCE_ITEM = 0,
111 ESC_ANNOUNCE_VALUE,
112 ESC_ANNOUNCE_ITEM_THEN_VALUE,
114
116typedef struct {
117 const char *name;
118 uint8_t cells_min;
119 uint8_t cells_max;
120 bool nimh;
121 uint32_t v_max_mv;
122 uint16_t current_a;
123 uint32_t v_min_mv;
125
129#define ESC_AFTER_MAX 4u
130
132typedef struct {
133 const char *name;
134 uint8_t number;
151 uint8_t after_count;
154
156typedef struct {
157 const char *name;
158 const char *key;
159 uint8_t number;
160 uint8_t value_count;
166 const char *const *applies_to;
172 const char *applies_when;
173} esc_item_t;
174
189
193#define ESC_MANUAL_ACTION_MAX 120u
197#define ESC_MANUAL_MAX 4u
198
206typedef struct {
208 const char *action;
209 uint32_t hold_ms;
215 const char *action_de;
229 bool locks;
231
286
287/* ------------------------------------------------------------ built in */
288
293extern const size_t esc_profiles_builtin_count;
294
295/* ------------------------------------------------------------ the card */
296
313bool esc_profile_parse(const char *json, size_t len, esc_profile_t *out,
314 void **block, char *err, size_t err_size);
315
329bool esc_profile_file_is(const char *file_name, const char *id);
330
331/* -------------------------------------------------------- the registry */
332
343bool esc_profiles_override(const esc_profile_t *p, void *block);
344
359bool esc_profiles_override_why(const esc_profile_t *p, void *block,
360 const char **why);
361
371bool esc_brand_same(const char *a, const char *b);
372
377
383size_t esc_profiles_override_count(void);
384
391size_t esc_profiles_count(void);
398const esc_profile_t *esc_profiles_at(size_t i);
399
407const esc_profile_t *esc_profiles_find(const char *id);
408
416
417/* ------------------------------------------------------------- search */
418
432bool esc_text_matches(const char *text, const char *pattern);
433
445bool esc_profile_matches(const esc_profile_t *p, const char *pattern);
446
458bool esc_model_matches(const esc_profile_t *p, unsigned model,
459 const char *pattern);
460
473bool esc_item_applies(const esc_profile_t *p, unsigned item, int model);
474
483 esc_manual_when_t when);
484
485#ifdef __cplusplus
486}
487#endif
488
489#endif /* RCBENCH_ESC_PROFILE_H */
bool esc_profile_parse(const char *json, size_t len, esc_profile_t *out, void **block, char *err, size_t err_size)
Parse one profile file.
Definition esc_json.c:1080
const esc_profile_t esc_profiles_builtin[]
The profiles compiled in, sorted by id.
esc_encoding_t
How one number is sounded.
Definition esc_profile.h:81
esc_auto_t
Who can run the sequence.
Definition esc_profile.h:91
@ ESC_AUTO_FULL
Definition esc_profile.h:92
@ ESC_AUTO_ASSISTED
Definition esc_profile.h:93
@ ESC_AUTO_NONE
Definition esc_profile.h:95
esc_announce_t
What the ESC announces before a selection.
Definition esc_profile.h:109
esc_manual_when_t
When an operator's step at the ESC is due, in the order of a run.
Definition esc_profile.h:178
@ ESC_MANUAL_BEFORE_MENU
Definition esc_profile.h:181
@ ESC_MANUAL_AT_POWER_UP
Definition esc_profile.h:180
@ ESC_MANUAL_BEFORE_POWER_OFF
Definition esc_profile.h:184
@ ESC_MANUAL_AFTER_PROGRAMMING
Definition esc_profile.h:187
@ ESC_MANUAL_DURING_MENU
Definition esc_profile.h:183
@ ESC_MANUAL_BEFORE_POWER
Definition esc_profile.h:179
esc_scheme_t
How the menu as a whole is driven.
Definition esc_profile.h:69
@ ESC_SCHEME_MELODY_GROUPS
Definition esc_profile.h:72
@ ESC_SCHEME_SHORT_LONG
Definition esc_profile.h:71
@ ESC_SCHEME_YES_NO
Definition esc_profile.h:73
@ ESC_SCHEME_STICK_POSITION
Definition esc_profile.h:74
@ ESC_SCHEME_COUNT
Definition esc_profile.h:70
#define ESC_AFTER_MAX
The most stick moves a value asks for after its selection.
Definition esc_profile.h:129
esc_throttle_t
Throttle stick position that a step uses.
Definition esc_profile.h:99
@ ESC_THR_NONE
Definition esc_profile.h:103
size_t esc_profiles_count(void)
Every profile the bench offers: the built-in ones with card files in their place, then card profiles ...
Definition esc_registry.c:169
const esc_profile_t * esc_profiles_at(size_t i)
The profile at index i of the list the bench offers.
Definition esc_registry.c:178
const esc_profile_t * esc_profiles_find(const char *id)
NULL when no profile has this id.
Definition esc_registry.c:196
void esc_profiles_clear_overrides(void)
Drop every card profile; the built-in ones remain.
Definition esc_registry.c:155
bool esc_profiles_override_why(const esc_profile_t *p, void *block, const char **why)
esc_profiles_override(), with why it refused in why (a static string; may be NULL): "no profile",...
Definition esc_registry.c:130
bool esc_profile_file_is(const char *file_name, const char *id)
Whether file_name is the name the profile id belongs in: the id with ".json" after it,...
Definition esc_registry.c:215
size_t esc_profiles_override_count(void)
Card profiles held, for a status line.
Definition esc_registry.c:164
bool esc_profiles_override(const esc_profile_t *p, void *block)
Add a parsed profile from the card.
Definition esc_registry.c:125
bool esc_model_matches(const esc_profile_t *p, unsigned model, const char *pattern)
Whether pattern finds model model of p: in the maker and the family read as one text,...
Definition esc_registry.c:363
bool esc_profiles_is_override(const esc_profile_t *p)
Whether the profile at p came from the card.
Definition esc_registry.c:205
bool esc_brand_same(const char *a, const char *b)
Whether a and b name one maker: the letters A to Z folded, every other byte itself,...
Definition esc_registry.c:68
unsigned esc_profile_manual_count(const esc_profile_t *p, esc_manual_when_t when)
How many of the profile's manual steps are due at when.
Definition esc_registry.c:375
bool esc_text_matches(const char *text, const char *pattern)
Whether pattern is found in text.
Definition esc_registry.c:318
bool esc_item_applies(const esc_profile_t *p, unsigned item, int model)
Whether item item of p is on model model: an item without applies_to is on every model; one with it o...
Definition esc_registry.c:341
bool esc_profile_matches(const esc_profile_t *p, const char *pattern)
Whether pattern (as esc_text_matches()) is found in the profile's manufacturer and name read as one t...
Definition esc_registry.c:323
One menu item: its name, sounded number and values.
Definition esc_profile.h:156
uint8_t number
Definition esc_profile.h:159
const esc_value_t * values
Definition esc_profile.h:161
uint8_t applies_count
Model names this item exists on; 0 entries: every model.
Definition esc_profile.h:165
const char * applies_when
A condition in words, e.g. "model type heli"; "" when none.
Definition esc_profile.h:172
const char * key
Definition esc_profile.h:158
uint8_t value_count
Definition esc_profile.h:160
A step a person does at the ESC besides the throttle and the power: fit or pull a jumper,...
Definition esc_profile.h:206
bool locks
The ESC locks itself when its supply goes off before the step is done (a Kontronik KOBY,...
Definition esc_profile.h:229
bool starts_menu
The step starts the menu: the ESC answers it and sounds its series at once (a Kontronik jumper pulled...
Definition esc_profile.h:222
const char * action_de
The same step in German, shown when the interface is; "" or NULL where the profile gives none,...
Definition esc_profile.h:215
uint32_t hold_ms
Definition esc_profile.h:209
One model the profile lists, with its battery and input limits.
Definition esc_profile.h:116
uint32_t v_max_mv
Definition esc_profile.h:121
uint32_t v_min_mv
Definition esc_profile.h:123
uint8_t cells_min
Definition esc_profile.h:118
uint8_t cells_max
Definition esc_profile.h:119
bool nimh
Definition esc_profile.h:120
uint16_t current_a
Definition esc_profile.h:122
One ESC programming profile: its family, menu and steps.
Definition esc_profile.h:233
const esc_model_t * models
Definition esc_profile.h:276
int16_t repeat
Definition esc_profile.h:269
bool entry_after_power
Definition esc_profile.h:243
const char * automatable_note
Definition esc_profile.h:241
esc_throttle_t select_throttle
Definition esc_profile.h:245
esc_announce_t announce
Definition esc_profile.h:239
uint32_t gap_ms
Definition esc_profile.h:267
const char * brand
Definition esc_profile.h:235
uint8_t item_count
Definition esc_profile.h:277
const esc_item_t * items
Definition esc_profile.h:278
uint32_t select_within_ms
Definition esc_profile.h:246
uint32_t value_select_within_ms
Definition esc_profile.h:253
uint8_t manual_count
The operator's steps at the ESC, in the order they are due; 0 entries on every profile that is not as...
Definition esc_profile.h:283
uint32_t beep_ms
Definition esc_profile.h:266
const char * id
Definition esc_profile.h:234
esc_auto_t automatable
Definition esc_profile.h:240
esc_scheme_t scheme
Definition esc_profile.h:237
uint32_t group_gap_ms
Definition esc_profile.h:268
uint16_t model_count
Definition esc_profile.h:275
const char *const * steps
Definition esc_profile.h:274
uint8_t long_equals_short
Definition esc_profile.h:265
const char * family
Definition esc_profile.h:236
esc_throttle_t skip_throttle
Definition esc_profile.h:254
bool one_change_per_entry
Definition esc_profile.h:271
esc_throttle_t value_select_throttle
In a two-stage menu, the move that stores the value sounded, after select_throttle picked the item; E...
Definition esc_profile.h:252
esc_throttle_t store_throttle
The move that stores a selection once the ESC has answered it; ESC_THR_NONE where the selection itsel...
Definition esc_profile.h:264
uint8_t step_count
Definition esc_profile.h:273
esc_throttle_t entry_throttle
Definition esc_profile.h:242
esc_encoding_t encoding
Definition esc_profile.h:238
uint32_t entry_hold_ms
Definition esc_profile.h:244
esc_throttle_t listen_throttle
Where the stick rests while the menu sounds; ESC_THR_NONE where the entry left it.
Definition esc_profile.h:259
bool verified
Definition esc_profile.h:272
One value an item can take, with the moves that program it.
Definition esc_profile.h:132
bool is_default
Definition esc_profile.h:135
uint8_t number
Definition esc_profile.h:134
uint8_t after_count
The moves this value asks for after its select move, in order, each once the ESC has answered the one...
Definition esc_profile.h:151
esc_throttle_t entry_throttle
The stick position the manual programs this value from, where it differs by value; ESC_THR_NONE: the ...
Definition esc_profile.h:140
uint32_t entry_hold_ms
Power-on to the menu when this value is programmed, where the manual gives one other than the entry's...
Definition esc_profile.h:145