rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
prog_registry.h
Go to the documentation of this file.
1
55#pragma once
56
57#include <stdbool.h>
58#include <stddef.h>
59#include <stdint.h>
60
61#include "gfx.h"
62#include "touch_types.h"
63#include "ui_text.h"
64#include "ui_workbench.h"
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
71typedef enum {
72 PROG_DEV_SERVO = 0,
73 PROG_DEV_MOTOR,
74 PROG_DEVICES
76
78#define PROG_REG_NO_PORT 0xFFu
80#define PROG_REG_NO_PIN 0xFFu
83#define PROG_REG_PORTS 4u
86#define PROG_REG_TESTER_PORT 0xFEu
87
88/*
89 * A function that calls one hook of a page set and nothing else through a
90 * pointer: tools/stack_check.py follows the call by the function's name
91 * (PROG_CALLS), so the compiler may neither inline it nor clone it under
92 * another name.
93 */
94#if defined(__GNUC__) && !defined(__clang__)
95#define PROG_ONE_CALL __attribute__((noinline, noclone))
96#else
97#define PROG_ONE_CALL __attribute__((noinline))
98#endif
99
107#define PROG_FULL_STRIP_X 12
108#define PROG_FULL_STRIP_Y 4
109#define PROG_FULL_STRIP_H 20
110#define PROG_FULL_Y 28
111#define PROG_FULL_STRIP_FONT (&gfx_font_10x20)
114#define PROG_FULL_STRIP_CELLS 100
115
117#define PROG_LIST_SEARCH_OVER 9
118#define PROG_LIST_HEADINGS_OVER 8
119#define PROG_LIST_MAX 48
121#define PROG_LIST_QUERY_MAX 16
122
129typedef struct {
131 void (*init)(gfx_rect_t area);
133 void (*entry)(void);
134 void (*open)(void);
135 bool (*is_open)(void);
141 void (*back)(void);
144 bool (*holds_port)(void);
146 void (*armed)(bool armed);
147 void (*tick)(float dt_s);
148 bool (*has_press)(uint8_t id);
149 void (*event)(const touch_event_t *evt);
150 void (*render)(gfx_canvas_t *c);
152 uint32_t (*revision)(void);
154 uint32_t (*hold_revision)(void);
155 gfx_rect_t (*hold_rect)(void);
157 void (*leave)(void);
159 void (*cancel)(void);
161 uint8_t (*pin)(void);
165 bool (*safe_at)(int x, int y);
167
168typedef struct {
169 uint8_t device;
170 uint8_t task;
171 ui_text_id_t name;
172 ui_text_id_t group;
173 ui_text_id_t transport;
174 uint8_t port;
176 const prog_page_set_t *page_set;
181
183const prog_reg_row_t *prog_registry(size_t *count);
184
187void prog_registry_use(const prog_reg_row_t *rows, size_t count);
188
196void prog_registry_set_ports(uint8_t tester_port, uint8_t held);
197
200uint8_t prog_reg_port(const prog_reg_row_t *r);
201
209bool prog_reg_servo_holds(void);
210
211/* ------------------------------------------------------------ the checks */
212
228
236 size_t *at);
237
238/* ------------------------------------------------- a device's sessions */
239
244int prog_reg_sets(uint8_t device, const prog_page_set_t *out[PROG_LIST_MAX]);
245
248
249/*
250 * A page set's hooks, each called from one function of its own, so
251 * tools/stack_check.py follows the call by name (PROG_CALLS there). The
252 * hosts call a session through these and through nothing else.
253 */
254void prog_ps_init(const prog_page_set_t *ps, gfx_rect_t area);
255void prog_ps_entry(const prog_page_set_t *ps);
256void prog_ps_open(const prog_page_set_t *ps);
257bool prog_ps_is_open(const prog_page_set_t *ps);
258void prog_ps_back(const prog_page_set_t *ps);
259bool prog_ps_holds(const prog_page_set_t *ps);
260void prog_ps_armed(const prog_page_set_t *ps, bool armed);
261void prog_ps_tick(const prog_page_set_t *ps, float dt_s);
262bool prog_ps_has_press(const prog_page_set_t *ps, uint8_t id);
263void prog_ps_event(const prog_page_set_t *ps, const touch_event_t *evt);
264void prog_ps_render(const prog_page_set_t *ps, gfx_canvas_t *c);
265uint32_t prog_ps_revision(const prog_page_set_t *ps);
266uint32_t prog_ps_hold_revision(const prog_page_set_t *ps);
267gfx_rect_t prog_ps_hold_rect(const prog_page_set_t *ps);
268void prog_ps_leave(const prog_page_set_t *ps);
269void prog_ps_cancel(const prog_page_set_t *ps);
270uint8_t prog_ps_pin(const prog_page_set_t *ps);
271bool prog_ps_safe_at(const prog_page_set_t *ps, int x, int y);
272
273/* ------------------------------------------------------- a row's state */
274
280
283 size_t i, uint16_t caps);
284
286uint16_t prog_reg_missing(const prog_reg_row_t *row, uint16_t caps);
287
290const char *prog_reg_cap_name(uint16_t bit);
291
307bool prog_reg_detail(const prog_reg_row_t *rows, size_t n, size_t i,
308 uint16_t caps, char *out, size_t size);
309
310/* -------------------------------------------------------- the list model */
311
313typedef struct {
314 uint8_t row;
315 bool heading;
317
318typedef struct {
319 uint8_t total;
320 uint8_t rows;
321 uint8_t count;
322 bool search;
323 bool headings;
324 prog_list_entry_t e[2 * PROG_LIST_MAX];
326
335void prog_list_build(prog_list_t *l, const prog_reg_row_t *rows, size_t n,
336 uint8_t device, uint8_t task, const char *query);
337
338/* --------------------------------------------------------------- the view */
339
350#define PROG_VIEW_PAD 10
351#define PROG_VIEW_BAR_H 48
352#define PROG_VIEW_ROW_H 48
353#define PROG_VIEW_ROW_P 56
354#define PROG_VIEW_HEAD_H 28
355#define PROG_VIEW_HEAD_P 32
356#define PROG_VIEW_SEARCH_W 260
357#define PROG_VIEW_KEY_W 56
358#define PROG_VIEW_FONT (&gfx_font_10x20)
359
361enum { PROG_VIEW_P_NONE = -1, PROG_VIEW_P_SEARCH = -2, PROG_VIEW_P_UP = -3,
362 PROG_VIEW_P_DOWN = -4 };
363
364typedef struct {
365 gfx_rect_t area;
366 int top;
368 uint8_t id;
372
379
380void prog_view_init(prog_view_t *v, gfx_rect_t area);
381
384
386bool prog_view_has_bar(const prog_view_t *v, const prog_list_t *l);
387
389int prog_view_shown(const prog_view_t *v, const prog_list_t *l);
390
393 int k);
394
416
423 const touch_event_t *evt, uint8_t *row);
424
427
441void prog_view_render(const prog_view_t *v, const prog_list_t *l,
442 const prog_reg_row_t *rows, size_t n, uint16_t caps,
443 const char *query, gfx_canvas_t *c);
444
445#ifdef __cplusplus
446}
447#endif
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
#define k
Short name for kst_panel_k inside the overlay's seven files.
Definition kst_panel_int.h:238
const prog_reg_row_t * prog_registry(size_t *count)
Definition prog_registry.c:87
void prog_view_top(prog_view_t *v)
Definition prog_registry.c:478
gfx_rect_t prog_view_up_rect(const prog_view_t *v, const prog_list_t *l)
"^" on the bar, PROG_VIEW_KEY_W wide, 8px left of "v".
Definition prog_registry.c:593
#define PROG_LIST_QUERY_MAX
Definition prog_registry.h:121
bool prog_reg_servo_holds(void)
Whether a servo programmer holds a port: the KST programmer's session, or the Hitec programmer's,...
Definition prog_registry.c:82
bool prog_view_has_bar(const prog_view_t *v, const prog_list_t *l)
Definition prog_registry.c:514
prog_device_t
Definition prog_registry.h:71
void prog_list_build(prog_list_t *l, const prog_reg_row_t *rows, size_t n, uint8_t device, uint8_t task, const char *query)
Definition prog_registry.c:418
const char * prog_reg_cap_name(uint16_t bit)
Definition prog_registry.c:362
int prog_view_shown(const prog_view_t *v, const prog_list_t *l)
Definition prog_registry.c:544
gfx_rect_t prog_view_down_rect(const prog_view_t *v, const prog_list_t *l)
"v" on the bar, PROG_VIEW_KEY_W wide at the right.
Definition prog_registry.c:604
void prog_registry_use(const prog_reg_row_t *rows, size_t count)
Definition prog_registry.c:95
prog_view_ev_t
Definition prog_registry.h:373
@ PROG_VIEW_NONE
Definition prog_registry.h:374
@ PROG_VIEW_SEARCH
Definition prog_registry.h:377
@ PROG_VIEW_ROW
Definition prog_registry.h:376
@ PROG_VIEW_TAKEN
Definition prog_registry.h:375
int prog_reg_sets(uint8_t device, const prog_page_set_t *out[PROG_LIST_MAX])
Definition prog_registry.c:182
gfx_rect_t prog_view_entry_rect(const prog_view_t *v, const prog_list_t *l, int k)
Definition prog_registry.c:558
prog_row_state_t
Definition prog_registry.h:275
@ PROG_ROW_NO_CAP
Definition prog_registry.h:277
@ PROG_ROW_LIVE
Definition prog_registry.h:276
@ PROG_ROW_PORT_BUSY
Definition prog_registry.h:278
uint16_t prog_reg_missing(const prog_reg_row_t *row, uint16_t caps)
Definition prog_registry.c:312
void prog_view_render(const prog_view_t *v, const prog_list_t *l, const prog_reg_row_t *rows, size_t n, uint16_t caps, const char *query, gfx_canvas_t *c)
Draws the list in PROG_VIEW_FONT: query in the SEARCH box ("SEARCH" while empty), each row's name and...
Definition prog_registry.c:711
prog_reg_fault_t prog_reg_check(const prog_reg_row_t *rows, size_t n, size_t *at)
Definition prog_registry.c:129
prog_view_ev_t prog_view_event(prog_view_t *v, const prog_list_t *l, const touch_event_t *evt, uint8_t *row)
Definition prog_registry.c:649
void prog_registry_set_ports(uint8_t tester_port, uint8_t held)
Definition prog_registry.c:64
bool prog_reg_full_width(const prog_page_set_t *ps)
Definition prog_registry.c:202
prog_reg_fault_t
Definition prog_registry.h:213
@ PROG_REG_NO_GROUP
Definition prog_registry.h:218
@ PROG_REG_BAD_DEVICE
Definition prog_registry.h:215
@ PROG_REG_NO_NAME
Definition prog_registry.h:217
@ PROG_REG_BAD_PORT
Definition prog_registry.h:220
@ PROG_REG_NO_TRANSPORT
Definition prog_registry.h:219
@ PROG_REG_NO_PAGE_SET
Definition prog_registry.h:221
@ PROG_REG_BAD_WIDTH
Definition prog_registry.h:226
@ PROG_REG_TOO_MANY
Definition prog_registry.h:223
@ PROG_REG_SAME_NAME
Definition prog_registry.h:222
@ PROG_REG_BAD_TASK
Definition prog_registry.h:216
gfx_rect_t prog_view_search_rect(const prog_view_t *v, const prog_list_t *l)
SEARCH on the bar, PROG_VIEW_SEARCH_W wide from the left.
Definition prog_registry.c:578
void prog_view_cancel(prog_view_t *v)
Definition prog_registry.c:704
prog_row_state_t prog_reg_state(const prog_reg_row_t *rows, size_t n, size_t i, uint16_t caps)
Definition prog_registry.c:321
uint8_t prog_reg_port(const prog_reg_row_t *r)
Definition prog_registry.c:71
bool prog_reg_detail(const prog_reg_row_t *rows, size_t n, size_t i, uint16_t caps, char *out, size_t size)
The text right of row i's name: for a live row on a port its number and the session's pin ("PROG PORT...
Definition prog_registry.c:373
Definition gfx.h:129
Definition gfx.h:81
Definition prog_registry.h:313
uint8_t row
Definition prog_registry.h:314
Definition prog_registry.h:318
bool search
Definition prog_registry.h:322
bool headings
Definition prog_registry.h:323
uint8_t rows
Definition prog_registry.h:320
uint8_t total
Definition prog_registry.h:319
uint8_t count
Definition prog_registry.h:321
Definition prog_registry.h:129
void(*) init(gfx_rect_t area)
Definition prog_registry.h:131
bool(*) holds_port(void)
Definition prog_registry.h:144
bool(*) safe_at(int x, int y)
Definition prog_registry.h:165
void(*) leave(void)
Definition prog_registry.h:157
uint32_t(*) hold_revision(void)
Definition prog_registry.h:154
uint32_t(*) revision(void)
Definition prog_registry.h:152
void(*) back(void)
Definition prog_registry.h:141
void(*) armed(bool armed)
Definition prog_registry.h:146
void(*) entry(void)
Definition prog_registry.h:133
void(*) cancel(void)
Definition prog_registry.h:159
uint8_t(*) pin(void)
Definition prog_registry.h:161
Definition prog_registry.h:168
bool full_width
Definition prog_registry.h:179
uint8_t port
Definition prog_registry.h:174
uint16_t needs_capability
Definition prog_registry.h:175
uint8_t task
Definition prog_registry.h:170
uint8_t device
Definition prog_registry.h:169
Definition prog_registry.h:364
int pressed
Definition prog_registry.h:367
uint8_t id
Definition prog_registry.h:368
char query[PROG_LIST_QUERY_MAX+1]
Definition prog_registry.h:370
int top
Definition prog_registry.h:366
A DOWN, MOVE or UP of one contact.
Definition touch_types.h:69
Plain data types shared by the touch controller driver, the coordinate mapper and the event tracker....
The interface's words, one table per language.
ui_text_id_t
The screens' strings, TX_<ID> for each UI_TEXT() of ui_text.def.
Definition ui_text.h:43
A workbench's task strip: one device, its tasks as tabs under the band.