rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
esc_stick_panel_int.h
Go to the documentation of this file.
1
18#pragma once
19
20#include <stdbool.h>
21#include <stdint.h>
22
23#include "esc_profile.h"
24#include "esc_stick.h"
25#include "settings.h"
26#include "ui_keypad.h"
27#include "ui_textkey.h"
28
29#include "esc_stick_int.h"
30
31/* ------------------------------------------------------- the stick class */
32
39#define SP_MAX (128)
40#define SP_ROWS 7
41#define SP_ROW_Y0 CARD_Y
42#define SP_ROW_H UI_TAP_MIN
43#define SP_ROW_P 56
44#define SP_ROW_X (PAD + 12)
45#define SP_ROW_TY ((SP_ROW_H - 20) / 2)
46#define SP_QUEUE 8
47#define SP_NOTE 160
48
56#define SP_NAME_CELLS 30
57#define SP_AMPS_X 320
58#define SP_VOLTS_X 384
59#define SP_FAMILY_X 460
61#define SP_WHY_CELLS ((W - 2 * PAD - 24 - 12 - SP_FAMILY_X) / SP_CELL)
63#define SP_MAKER_RIGHT_W 370
64
70#define SP_FIND_MAX 16
71#define SP_KEY_W 56
72#define SP_LIST_DN_X (W - PAD - 12 - SP_KEY_W)
73#define SP_LIST_UP_X (SP_LIST_DN_X - 8 - SP_KEY_W)
74#define SP_FIND_W 260
75#define SP_FIND_X (SP_LIST_UP_X - 8 - SP_FIND_W)
76#define SP_CLR_W UI_TAP_MIN
77#define SP_DOCK_X 352
79#define SP_TRAIL_CELLS ((SP_FIND_X - 8 - (PAD + 12 + BACK_W + 16)) \
80 / SP_CRUMB_CELL)
81
83#define SP_FOOT_Y (SP_ROW_Y0 + (SP_ROWS - 1) * SP_ROW_P + SP_ROW_H + 4)
84#define SP_COUNT_W 360
85_Static_assert(SP_FOOT_Y + 20 <= SP_FOOT, "the list's footer ends above "
86 "the alert band");
87/* The most models one maker's list holds: as many as the registry lets a
88 * maker have, so the count and the rows always agree. */
93#define SP_MODELS ((int)ESC_MAKER_MODELS_MAX)
94
95/* The stack light at the right of the run's card: a cap, the red and the
96 * green lens, each with a collar under it, and the base, px. */
97#define SP_TOWER_W 44
98#define SP_TOWER_X (W - PAD - 16 - SP_TOWER_W)
99#define SP_TOWER_Y (RUN_Y + 14)
100#define SP_TOWER_CAP 8
101#define SP_TOWER_LENS 58
102#define SP_TOWER_RING 3
103#define SP_TOWER_BASE 26
106#define SP_LINE_CELLS ((SP_TOWER_X - 12 - (PAD + 12)) / SP_CELL)
109#define SP_WIDE_CELLS ((W - 2 * PAD - 24) / SP_CELL)
110_Static_assert(SP_TOWER_Y + SP_TOWER_CAP + 2 * (SP_TOWER_LENS + SP_TOWER_RING)
111 + SP_TOWER_BASE + 4 <= RUN_L0 + 6 * LINE_P,
112 "a result's lines from its seventh pass under the stack "
113 "light");
114
117#define SP_SETTINGS 14
123
130typedef struct {
131 const char *name;
132 uint16_t models,
135 bool manual;
136} sp_maker_t;
137
142typedef struct {
143 uint16_t prof,
145} sp_row_t;
146
152typedef struct {
153 /* The list in two levels. Level 0 the makers, alphabetical; level 1
154 * the models of one maker, by current, voltage and name. count,
155 * runnable and scroll are the level's showing; bscroll is the makers'
156 * kept while a maker is open. */
157 int level;
163 const char *maker;
164 int count,
168 int model;
169
170 /* The profile picked, and what is to change: per item, -1 to keep it,
171 * else the index of the value to store. */
176 int pick[256];
179 char note[SP_NOTE];
180 bool could;
181
182 /* The warning, and its hold. */
183 bool warn,
185 uint8_t warn_id;
187
188 bool timing;
191 /* TIMING's keypad, the row of sp_settings_list it types, and its
192 * revision as the page last followed it. */
194 int kp_idx;
195 uint32_t kp_rev;
197
198 /* The run, and whether its result is still on screen. */
200 bool shown;
201 uint32_t runs;
203 uint32_t sig;
204 uint32_t built_key;
205 uint32_t builds;
206
207 /* The bench, as the application last said. */
208 uint32_t now_ms,
211 bool armed,
213 /* The output binding, as the application last said: whether one is
214 * read, and the channels it binds as a throttle (one bit each). */
217
218 /* The search: the pattern the list shows, what it was when the
219 * keyboard opened (CANCEL goes back to it), and the keyboard. */
220 char find[SP_FIND_MAX + 1];
224 uint32_t tk_rev;
227
228 /* The stack light's green, as the last tick had it. */
230 bool green;
231
232 /* What the run has asked for, and what is still to be taken. */
238 int qn;
239 bool sent_arm,
241 float sent_pct;
242
243 /* The manual steps' pop-up and the profile it shows: the page's, or a
244 * row's that does not run. It opens by itself the first time a
245 * profile with manual steps is opened, one bit a profile by its index
246 * in the registry. */
250 int hand_model; /* the model it was opened for, or
251 -1: the family's lowest */
254
255 /* The supply as its newest reading had it, run or no run: whether its
256 * output is live, and since when it has read off. */
257 bool sup_have,
263 uint32_t sup_at,
266 uint8_t hand_seen[SP_MAX / 8];
267
280} stick_t;
281
283typedef struct {
285
286 /* The phase tap, as the control task last read it. */
288} sp_state_t;
289
295#define s esc_stick_s
296
297/* --- the functions one file calls of another ---------------------------- */
298
299/* esc_stick_panel.c */
300
307size_t sp_changes(esc_stick_change_t *ch, size_t *picked);
318void sp_supply(uint32_t *mv, uint32_t *ma);
323bool sp_supply_reads_off(void);
328bool sp_warn_gated(void);
334bool sp_warn_steps_fit(const esc_profile_t *p);
340unsigned sp_later_steps(const esc_profile_t *p);
345bool sp_hold_blocked(void);
350bool sp_can_run(void);
353void sp_follow(void);
355void sp_end_hold(void);
361
362/* esc_stick_list.c */
363
373void sp_text(gfx_canvas_t *c, int x, int y, const char *text, int max_chars,
374 gfx_color_t ink);
380const char *sp_action(const esc_manual_t *m);
386const char *sp_when_text(const esc_manual_t *m);
392const char *sp_why_text(const char *why);
406const char *sp_rating_why(const esc_profile_t *p, int model, uint32_t mv,
407 uint32_t ma, bool by_hand, bool longer, char *buf,
408 size_t n);
420const char *sp_rating_warn(const esc_profile_t *p, int model, uint32_t mv,
421 bool by_hand, bool longer, char *buf, size_t n);
430const char *sp_model_warn(const esc_profile_t *p, int model, char *buf,
431 size_t n);
440const char *sp_model_why(const esc_profile_t *p, int model, char *buf,
441 size_t n);
446uint32_t sp_list_key(void);
453bool sp_model_runs(const esc_profile_t *p, int model);
458void sp_build_list(bool keep_scroll);
463void sp_pick_profile(const esc_profile_t *p);
468int sp_items(void);
474int sp_item_at(int at);
476void sp_pick_shown(void);
477
478/* esc_stick_touch.c */
479
486int sp_rows_shown(int total, int scroll);
492gfx_rect_t sp_row(int i);
494void sp_find_close(void);
496void sp_kp_close(void);
497
498/* esc_stick_draw.c */
499
504uint32_t sp_entry_shown(void);
505
506/* esc_stick_draw_run.c */
507
512bool sp_red(void);
519void sp_result_head(const esc_stick_t *e, char *buf, size_t n);
527void sp_result_more(const esc_stick_t *e, unsigned shown, char *buf,
528 size_t n);
534const char *sp_left_text(const esc_stick_t *e);
ESC (electronic speed controller) programming profiles: how to enter an ESC's throttle-stick programm...
Stick programming: an ESC (electronic speed controller) programmed through its throttle-stick menu,...
esc_stick_reason_t
Reason a run ended.
Definition esc_stick.h:479
uint32_t sp_entry_shown(void)
The entry time the page shows, ms.
Definition esc_stick_draw.c:353
DRAWER void sp_draw_hand(gfx_canvas_t *c)
A profile's manual steps drawn.
Definition esc_stick_draw_run.c:811
const char * sp_left_text(const esc_stick_t *e)
What a run waiting for a manual step asks of the operator.
Definition esc_stick_draw_run.c:862
DRAWER void sp_draw_result(gfx_canvas_t *c)
A run's result drawn.
Definition esc_stick_draw_run.c:544
void sp_result_head(const esc_stick_t *e, char *buf, size_t n)
Into buf: the result's count of the selections made for certain.
Definition esc_stick_draw_run.c:520
DRAWER void sp_draw_warning(gfx_canvas_t *c)
The RUN warning drawn.
Definition esc_stick_draw_run.c:746
DRAWER void sp_draw_progress(gfx_canvas_t *c)
A run under way drawn.
Definition esc_stick_draw_run.c:345
DRAWER void sp_draw_prompt(gfx_canvas_t *c)
A run's prompt for a manual step drawn.
Definition esc_stick_draw_run.c:871
void sp_result_more(const esc_stick_t *e, unsigned shown, char *buf, size_t n)
Into buf: the changes past the first shown, as the result's last line says them.
Definition esc_stick_draw_run.c:528
bool sp_red(void)
The red light: a result on screen, until OK, of a run that ended on something not as expected.
Definition esc_stick_draw_run.c:511
bool sp_model_runs(const esc_profile_t *p, int model)
Whether model model of p runs on this bench.
Definition esc_stick_list.c:308
const char * sp_rating_warn(const esc_profile_t *p, int model, uint32_t mv, bool by_hand, bool longer, char *buf, size_t n)
The warning for a voltage the data cannot vouch for, into buf, or NULL; the run goes ahead.
Definition esc_stick_list.c:219
void sp_build_list(bool keep_scroll)
The level showing built again, from the top or, with keep_scroll, where it was.
Definition esc_stick_list.c:435
const char * sp_model_why(const esc_profile_t *p, int model, char *buf, size_t n)
Why model model cannot run, into buf, or NULL when it can.
Definition esc_stick_list.c:255
void sp_pick_shown(void)
The picked item kept among those shown; the first otherwise.
Definition esc_stick_list.c:519
const char * sp_action(const esc_manual_t *m)
What a manual step asks, in the language showing.
Definition esc_stick_list.c:66
int sp_items(void)
The items the page offers.
Definition esc_stick_list.c:494
void sp_text(gfx_canvas_t *c, int x, int y, const char *text, int max_chars, gfx_color_t ink)
text at (x, y) cut to max_chars, with ".." in place of what did not fit.
Definition esc_stick_list.c:38
const char * sp_rating_why(const esc_profile_t *p, int model, uint32_t mv, uint32_t ma, bool by_hand, bool longer, char *buf, size_t n)
What the supply's set points break of a model's ratings, into buf, or NULL: the short form for a row,...
Definition esc_stick_list.c:179
void sp_pick_profile(const esc_profile_t *p)
Profile p picked: its picks cleared, and its manual steps shown the first time it is opened.
Definition esc_stick_list.c:449
const char * sp_why_text(const char *why)
The engine's reason why in the language showing.
Definition esc_stick_list.c:169
const char * sp_when_text(const esc_manual_t *m)
When a manual step is due, in the language showing.
Definition esc_stick_list.c:72
uint32_t sp_list_key(void)
VOLTAGE and the SUPPLY cap, mV: what decides from outside a profile whether it runs.
Definition esc_stick_list.c:283
const char * sp_model_warn(const esc_profile_t *p, int model, char *buf, size_t n)
sp_rating_warn() for model model with the settings now.
Definition esc_stick_list.c:239
int sp_item_at(int at)
The profile's index of the at-th item offered, or -1.
Definition esc_stick_list.c:506
void sp_end_run(esc_stick_reason_t why)
The run ends now as why; nothing it queued survives.
Definition esc_stick_panel.c:644
void sp_follow(void)
What the run asks for, onto the paths an operator's own presses take.
Definition esc_stick_panel.c:411
bool sp_hold_blocked(void)
Whether HOLD TO RUN may not count.
Definition esc_stick_panel.c:379
bool sp_supply_reads_off(void)
Whether the supply reads off now, by the rule a run holds the supply to.
Definition esc_stick_panel.c:314
void sp_timing(esc_stick_timing_t *t)
The timing as the settings hold it, the profile's own entry where it states one.
Definition esc_stick_panel.c:156
sp_state_t esc_stick_s
The state, esc_stick_s, in esc_stick_panel.c, so its .bss stays where psram_bss.lf puts esc_stick_pan...
Definition esc_stick_panel.c:75
unsigned sp_later_steps(const esc_profile_t *p)
The steps of p the run stops for after the warning's.
Definition esc_stick_panel.c:370
bool sp_warn_steps_fit(const esc_profile_t *p)
Whether the warning shows every before-power step of p whole.
Definition esc_stick_panel.c:345
void sp_supply(uint32_t *mv, uint32_t *ma)
The supply's set points for a run, mV and mA: VOLTAGE, or the profile's cell count when it is 0.
Definition esc_stick_panel.c:177
void sp_end_hold(void)
The warning's hold dropped, with nothing started.
Definition esc_stick_panel.c:471
bool sp_warn_gated(void)
Whether the warning asks a step at an unpowered ESC of the operator and may not, as the supply does n...
Definition esc_stick_panel.c:328
bool sp_can_run(void)
Whether a run can start now.
Definition esc_stick_panel.c:385
const setting_id_t sp_settings_list[]
The TIMING page's settings, SP_SETTINGS of them, in the order the page lists them.
Definition esc_stick_panel.c:62
size_t sp_changes(esc_stick_change_t *ch, size_t *picked)
The picks as changes, in item order.
Definition esc_stick_panel.c:135
#define SP_TOWER_CAP
Definition esc_stick_panel_int.h:100
#define SP_ROWS
Definition esc_stick_panel_int.h:40
gfx_rect_t sp_row(int i)
Profile row i, narrowed to the left of the keyboard while it is open.
Definition esc_stick_touch.c:78
#define SP_TOWER_LENS
Definition esc_stick_panel_int.h:101
#define SP_SETTINGS
The settings the TIMING page shows, in esc_stick_panel.c, and their count.
Definition esc_stick_panel_int.h:117
#define SP_FIND_MAX
The search field in the crumb row, X at its right end, and the page keys right of it; the keyboard do...
Definition esc_stick_panel_int.h:70
int sp_rows_shown(int total, int scroll)
The rows a page of ROWS_MAX shows of total from scroll.
Definition esc_stick_touch.c:64
#define SP_TOWER_BASE
Definition esc_stick_panel_int.h:103
#define SP_MODELS
Most models one maker holds: ESC_MAKER_MODELS_MAX, so the count and the rows agree.
Definition esc_stick_panel_int.h:93
#define SP_TOWER_RING
Definition esc_stick_panel_int.h:102
#define SP_MAX
The profile list: SP_ROWS rows to a page, UI_TAP_MIN tall at an SP_ROW_P pitch from SP_ROW_Y0,...
Definition esc_stick_panel_int.h:39
#define SP_FOOT_Y
The footer under the rows: the count at its right, or at its left beside the docked keyboard.
Definition esc_stick_panel_int.h:83
#define SP_NOTE
Definition esc_stick_panel_int.h:47
#define SP_QUEUE
Definition esc_stick_panel_int.h:46
void sp_find_close(void)
The keyboard closes; the search stays as typed.
Definition esc_stick_touch.c:88
void sp_kp_close(void)
TIMING's keypad closes, with nothing typed taken.
Definition esc_stick_touch.c:160
#define SP_TOWER_Y
Definition esc_stick_panel_int.h:99
Device settings: a typed schema, a value per entry, and a persistence seam.
setting_id_t
Every setting's id, in schema order.
Definition settings.h:67
A step a person does at the ESC besides the throttle and the power: fit or pull a jumper,...
Definition esc_profile.h:206
One ESC programming profile: its family, menu and steps.
Definition esc_profile.h:233
One selection: the profile's item and value, as indices.
Definition esc_stick.h:317
The green light: on while the detector holds a pulse, from the reading that rose above the threshold ...
Definition esc_stick.h:935
State of one stick programming run.
Definition esc_stick.h:587
How the beeps are timed and told apart from the ESC's idle current.
Definition esc_stick.h:108
Definition gfx.h:129
Definition gfx.h:81
Definition motor_screen.h:44
A maker on the list's first level.
Definition esc_stick_panel_int.h:130
uint16_t found
Definition esc_stick_panel_int.h:133
bool manual
Definition esc_stick_panel_int.h:135
const char * name
Definition esc_stick_panel_int.h:131
uint16_t models
Definition esc_stick_panel_int.h:132
uint16_t runs
Definition esc_stick_panel_int.h:134
A model on the list's second level: its profile's index in the registry and its own index in that pro...
Definition esc_stick_panel_int.h:142
uint16_t prof
Definition esc_stick_panel_int.h:143
uint16_t model
Definition esc_stick_panel_int.h:144
The panel's state: the stick class's, and the phase tap's.
Definition esc_stick_panel_int.h:283
tone_readout_t tone
Definition esc_stick_panel_int.h:287
stick_t st
Definition esc_stick_panel_int.h:284
The stick class's state: the profile list, the picked profile, the run, the warning,...
Definition esc_stick_panel_int.h:152
bool bind_read
Definition esc_stick_panel_int.h:215
uint8_t warn_id
Definition esc_stick_panel_int.h:185
bool green
Definition esc_stick_panel_int.h:230
int bscroll
Definition esc_stick_panel_int.h:167
int tpicked
Definition esc_stick_panel_int.h:190
gfx_rect_t find_box
Definition esc_stick_panel_int.h:225
bool sup_off_known
Definition esc_stick_panel_int.h:259
int level
Definition esc_stick_panel_int.h:157
uint32_t built_key
Definition esc_stick_panel_int.h:204
bool sup_live
Definition esc_stick_panel_int.h:258
const char * maker
Definition esc_stick_panel_int.h:163
motor_cmd_t q[SP_QUEUE]
Commands the run asked for and the application has not taken, SP_QUEUE at most.
Definition esc_stick_panel_int.h:237
bool armed
Definition esc_stick_panel_int.h:211
bool warn_read
Definition esc_stick_panel_int.h:253
gfx_rect_t hand_btn
Definition esc_stick_panel_int.h:273
uint32_t stops
Definition esc_stick_panel_int.h:209
bool shown
Definition esc_stick_panel_int.h:200
int model
Definition esc_stick_panel_int.h:168
gfx_rect_t timing_btn
Definition esc_stick_panel_int.h:275
ui_hold_t hold
Definition esc_stick_panel_int.h:186
gfx_rect_t list_up
Definition esc_stick_panel_int.h:269
uint32_t now_ms
Definition esc_stick_panel_int.h:208
bool sent_arm
Definition esc_stick_panel_int.h:239
bool timing
Definition esc_stick_panel_int.h:188
int picked
Definition esc_stick_panel_int.h:178
gfx_rect_t steps_btn
Definition esc_stick_panel_int.h:274
int runnable
Definition esc_stick_panel_int.h:165
char note[SP_NOTE]
Definition esc_stick_panel_int.h:179
int hand_model
Model the pop-up was opened for.
Definition esc_stick_panel_int.h:250
uint32_t builds
Definition esc_stick_panel_int.h:205
bool was_running
Definition esc_stick_panel_int.h:252
sp_row_t rows_m[SP_MODELS]
Models of the open maker on level 1, by current, voltage and name.
Definition esc_stick_panel_int.h:162
int scroll
Definition esc_stick_panel_int.h:166
uint32_t sup_off_since
Definition esc_stick_panel_int.h:264
const esc_profile_t * hand_p
Definition esc_stick_panel_int.h:248
uint32_t sup_at
Definition esc_stick_panel_int.h:263
bool hand_open
Definition esc_stick_panel_int.h:247
uint32_t runs
Definition esc_stick_panel_int.h:201
char find[SP_FIND_MAX+1]
Definition esc_stick_panel_int.h:220
bool sup_have
Definition esc_stick_panel_int.h:257
gfx_rect_t hold_btn
Definition esc_stick_panel_int.h:271
esc_stick_light_t light
Definition esc_stick_panel_int.h:229
int kp_idx
Definition esc_stick_panel_int.h:194
uint32_t sig
What the progress showed last, to redraw on a change.
Definition esc_stick_panel_int.h:203
uint8_t hand_seen[SP_MAX/8]
Per profile, one bit: its manual steps were shown.
Definition esc_stick_panel_int.h:266
uint32_t tk_rev
Definition esc_stick_panel_int.h:224
bool warn_down
Definition esc_stick_panel_int.h:184
char find_was[SP_FIND_MAX+1]
The pattern when the keyboard opened; CANCEL restores it.
Definition esc_stick_panel_int.h:222
uint8_t throttle_mask
Definition esc_stick_panel_int.h:216
ui_keypad_t kp
Definition esc_stick_panel_int.h:193
uint32_t pressed
Definition esc_stick_panel_int.h:210
bool sent_supply
Definition esc_stick_panel_int.h:240
uint32_t kp_rev
Definition esc_stick_panel_int.h:195
bool link_up
Definition esc_stick_panel_int.h:212
gfx_rect_t find_clr
Definition esc_stick_panel_int.h:226
int count
Definition esc_stick_panel_int.h:164
int iscroll
Definition esc_stick_panel_int.h:177
int pick[256]
Per item: -1 keeps the item, else the index of the value to store.
Definition esc_stick_panel_int.h:176
ui_textkey_t tk
Definition esc_stick_panel_int.h:223
const esc_profile_t * p
Definition esc_stick_panel_int.h:172
esc_stick_t run
Definition esc_stick_panel_int.h:199
int qn
Definition esc_stick_panel_int.h:238
int tscroll
Definition esc_stick_panel_int.h:189
bool sup_gate
Definition esc_stick_panel_int.h:260
gfx_rect_t cancel_btn
Definition esc_stick_panel_int.h:272
gfx_rect_t list_dn
Definition esc_stick_panel_int.h:270
bool warn
Definition esc_stick_panel_int.h:183
sp_maker_t makers[SP_MAX]
Definition esc_stick_panel_int.h:158
bool sup_off_drawn
What a result last showed of the supply's off state.
Definition esc_stick_panel_int.h:262
gfx_rect_t hand_res
MANUAL INTERVENTION REQUIRED on a run's result: in the foot row, left of OK; hand_btn is its place on...
Definition esc_stick_panel_int.h:279
float sent_pct
Definition esc_stick_panel_int.h:241
gfx_rect_t rows[SP_ROWS]
Definition esc_stick_panel_int.h:268
bool could
Definition esc_stick_panel_int.h:180
The screen's copy: a plain value the control task fills and the renderer reads.
Definition tone_link.h:217
Definition ui_widgets.h:415
A numeric keypad: what it was opened with, what is typed, and the press it holds.
Definition ui_keypad.h:61
A keyboard: what it was opened for, what is typed, and the press it holds.
Definition ui_textkey.h:114
ESC STICK's private seam between esc_stick_pages.c, the page set MOTOR & ESC opens from PROGRAM's lis...
#define RUN_L0
Definition esc_stick_int.h:122
#define SP_FOOT
Definition esc_stick_int.h:66
#define LINE_P
Definition esc_stick_int.h:52
A numeric keypad over part of a screen, for a value a slider is too coarse to place.
An on-screen keyboard for a short name: capitals, digits, space and the marks a name or a file needs,...