rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
servo_workbench_int.h
Go to the documentation of this file.
1
11#pragma once
12
13/* --- which task and which panel hold the left column --------------------- */
14
15/* Whether a panel covers the left column: the keypad, the keyboard, the
16 * list, a warning or the question. */
17static inline bool modal_open(void)
18{
19 return s.kp.open || s.tk.open || s.ch.open || s.warn.open || s.ask.open;
20}
21
22static inline ui_wb_task_t wb_task(void) { return ui_wb_strip_task(&s.wb); }
23
24/*
25 * PROGRAM's sessions, the registry's SERVO rows (prog_registry.h), as the
26 * screen drives them: each distinct page set once. A session is shown
27 * over the left column, the strip with it, one level down from PROGRAM's
28 * list; while it holds its port it stays shown.
29 */
30/* A page set's hooks are called through prog_ps_*() (prog_registry.h). */
31/* The session shown, or NULL. */
32const prog_page_set_t *prog_shown_set(void);
33static inline bool prog_shown(void) { return prog_shown_set() != NULL; }
34/* A session holds its port: ARM, the TARGET row and PORT PWM lock. */
35bool prog_holds(void);
36/* Every session laid out over the left column; the screen entered; left;
37 * touch events lost; the bench armed or asked to arm; a frame. */
38void prog_init(void);
39void prog_entry(void);
40void prog_leave(void);
41void prog_cancel(void);
42void prog_armed(bool armed);
43void prog_tick(float dt_s);
44/* A session holding its port and not shown shows again, on PROGRAM. */
45void prog_follow_hold(void);
46/* PROGRAM's rows changed what they show (a capability, a pin, a port
47 * taken): the page repaints. */
48void prog_page_follow(void);
49
50/* The page of rows shown, PG_*, or -1: SETTINGS' page, or on TEST a run's
51 * settings. */
52static inline int rows_page(void)
53{
54 switch (wb_task()) {
55 case UI_WB_SETTINGS: return s.tabs.selected;
56 case UI_WB_TEST:
57 return (s.run_list == RL_AUTO) ? PG_AUTO
58 : (s.run_list == RL_LIMIT) ? PG_LIMRUN : -1;
59 default: return -1;
60 }
61}
62
63/* Whether a page of rows or a panel holds the left column: what took the
64 * settings' presses and owned the knob as the settings overlay did. */
65static inline bool ov_shown(void)
66{
67 return modal_open() || rows_page() >= 0;
68}
69
70/* Whether LIVE's dial is in sight and takes presses: LIVE, no panel, no
71 * session. */
72static inline bool live_shown(void)
73{
74 return wb_task() == UI_WB_LIVE && !modal_open() && !prog_shown();
75}
76
77/* --- servo_settings_panel.c's side, which the workbench calls ----------- */
78
79/* Whether the TARGET row and PORT PWM are locked: ARMED, a sweep, a run,
80 * the programmer holding the port (servo_settings_panel.c). @p id is
81 * SET_SERVO_TARGET or SET_SERVO_PORT_PWM. */
82bool target_locked_for(setting_id_t id);
83/* The pages of rows, their presses (ov_down()) included. */
85
86/* --- servo_workbench.c's side, which the screen calls -------------------- */
87
88/* The strip, the TARGET row and PROGRAM's list laid out (reset); a tile's
89 * entry (LIVE); leaving (the run's settings close); touch events lost. */
90void wb_init(void);
91void wb_enter(void);
92void wb_leave(void);
93void wb_cancel(void);
94/* The home tag: a panel closes; in a session, the session's back()
95 * (an editor closes, the session closes to PROGRAM's list, or a port in
96 * programming asks for LEAVE); a run's settings close to TEST. Whether
97 * it did one; false lets the screen go. */
98bool wb_back(void);
99/* A DOWN on the strip or the TARGET row, and the rest of a press on
100 * either: whether it was theirs. */
101bool wb_down(const touch_event_t *evt);
102bool wb_rest(const touch_event_t *evt);
103/* A DOWN on TEST's page, its run cards; on PROGRAM's list. */
104void test_page_down(const touch_event_t *evt);
105void prog_page_down(const touch_event_t *evt);
106/* The search typed on the keyboard opened from PROGRAM's list. */
107void prog_search_done(const char *text);
108/* The strip; TEST's page; the TARGET row on the right card; SUPPLY's caps,
109 * read-only, at (@p x, @p y). */
110void draw_strip(gfx_canvas_t *c);
112void draw_prog_page(gfx_canvas_t *c);
113void draw_target(gfx_canvas_t *c);
114void draw_caps_line(gfx_canvas_t *c, int x, int y);
115/* The strip's row, and START LIMIT RUN on its card. */
116gfx_rect_t strip_area(void);
118
119/* --- the page area and TEST's run cards --------------------------------- */
120
121/* The page area: the left card under the strip. */
122static inline gfx_rect_t page_area(void)
123{
124 return (gfx_rect_t){ PAD, CARD_Y, LCARD_W, CARD_H };
125}
126
127/*
128 * TEST's two run cards, AUTOMATIC TEST over LIMIT RUN, across the page
129 * area: each its name and a summary line, its START hold with SETTINGS
130 * beside it, and the lines under them. The caps line follows the second
131 * card.
132 */
133#define RUN_CARD_X (PAD + 10)
134#define RUN_CARD_W (LCARD_W - 20)
135#define RUN_CARD_H 200
136#define RUN_CARD_GAP 4
138#define RUN_CARD_Y(k) (CARD_Y + RUN_CARD_GAP + (k) * (RUN_CARD_H + RUN_CARD_GAP))
139#define RUN_NAME_DY 8
140#define RUN_SUM_DY 32
141#define RUN_BTN_DY 60
142#define RUN_BTN_W 300
143#define RUN_BTN_H 56
144#define RUN_LINE_DY 120
145#define RUN_LINE_P 22
146#define RUN_SET_W 160
148#define RUN_CAPS_Y (RUN_CARD_Y(1) + RUN_CARD_H + RUN_CARD_GAP)
149_Static_assert(RUN_CAPS_Y + 20 <= STOP_FLOOR,
150 "the caps line ends above the alert band");
151_Static_assert(RUN_LINE_DY + 2 * RUN_LINE_P + 20 <= RUN_CARD_H,
152 "a card's three lines under START end inside it");
153
159static inline gfx_rect_t run_card_rect(int k)
160{
161 return (gfx_rect_t){ RUN_CARD_X, (int16_t)RUN_CARD_Y(k), RUN_CARD_W,
162 RUN_CARD_H };
163}
164
172static inline gfx_rect_t run_set_rect(int k)
173{
174 return (gfx_rect_t){ (int16_t)(RUN_CARD_X + RUN_CARD_W - 10 - RUN_SET_W),
175 (int16_t)(RUN_CARD_Y(k) + RUN_BTN_DY
176 + (RUN_BTN_H - UI_TAP_MIN) / 2),
178}
179
185static inline gfx_rect_t run_close_rect(void)
186{
187 return (gfx_rect_t){ (int16_t)(RUN_CARD_X + RUN_CARD_W - 140),
188 (int16_t)(CARD_Y + 4), 140, UI_TAP_MIN };
189}
190
192#define RUN_PAGE_NAME_DY 4
194#define RUN_PAGE_SAVE_DY 28
195
204static inline gfx_rect_t save_line_rect(void)
205{
206 if (rows_page() >= PG_COUNT) {
207 const int x = OV_X + 10;
208 return (gfx_rect_t){ (int16_t)x, (int16_t)(CARD_Y + RUN_PAGE_SAVE_DY),
209 (int16_t)(run_close_rect().x - 10 - x), 20 };
210 }
211 return (gfx_rect_t){ (int16_t)(OV_X + 10), OV_SAVE_Y,
212 (int16_t)(OV_W - 20), 20 };
213}
214_Static_assert(CARD_Y + RUN_PAGE_SAVE_DY + 20 <= RL_ROW0 - 4,
215 "a run's save line ends over its first row");
216
218static inline gfx_rect_t test_start_rect(void)
219{
220 return (gfx_rect_t){ (int16_t)(RUN_CARD_X + 10),
221 (int16_t)(RUN_CARD_Y(0) + RUN_BTN_DY), RUN_BTN_W,
222 RUN_BTN_H };
223}
#define PAD
Definition analyser_screen.c:26
#define LCARD_W
Definition analyser_screen.c:52
#define CARD_H
Definition balance_screen.c:56
#define CARD_Y
Definition balance_screen.c:44
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
#define k
Short name for kst_panel_k inside the overlay's seven files.
Definition kst_panel_int.h:238
#define STOP_FLOOR
The lowest row a control that stops what the bench drives, or a line of text, may reach: 4px above th...
Definition motor_screen_int.h:75
#define OV_X
Definition servo_screen_int.h:191
#define OV_W
Definition servo_screen_int.h:193
#define OV_SAVE_Y
The save line under SETTINGS' rows and notes, 20px tall, ending 4px above the alert band.
Definition servo_screen_int.h:224
#define RL_ROW0
Definition servo_screen_int.h:214
void draw_rows_page(gfx_canvas_t *c)
A page of rows in the page area: SETTINGS' page under its tabs, or a run's settings under the run's n...
Definition servo_settings_draw.c:264
void draw_caps_line(gfx_canvas_t *c, int x, int y)
SUPPLY's caps in force, which a run's steps and a set point stay inside, read-only here: their home i...
Definition servo_workbench.c:544
gfx_rect_t lim_start_rect(void)
START LIMIT RUN, on the LIMIT RUN card: START TEST's place on its own card.
Definition servo_workbench.c:385
void draw_test_page(gfx_canvas_t *c)
TEST: the two run cards, then the caps.
Definition servo_workbench.c:557
void wb_init(void)
The strip, the TARGET row and PROGRAM's list laid out; LIVE.
Definition servo_workbench.c:305
static gfx_rect_t run_card_rect(int k)
Run card k.
Definition servo_workbench_int.h:159
static gfx_rect_t run_set_rect(int k)
A card's SETTINGS, right of its START: its run's settings, one level down. Clear of CLOSE on the run'...
Definition servo_workbench_int.h:172
#define RUN_CAPS_Y
The caps line under the two cards.
Definition servo_workbench_int.h:148
#define RUN_CARD_X
Definition servo_workbench_int.h:133
#define RUN_CARD_W
Definition servo_workbench_int.h:134
#define RUN_PAGE_SAVE_DY
The save line on a run's settings, under the name.
Definition servo_workbench_int.h:194
#define RUN_LINE_DY
Definition servo_workbench_int.h:144
#define RUN_BTN_H
Definition servo_workbench_int.h:143
#define RUN_BTN_DY
Definition servo_workbench_int.h:141
static gfx_rect_t run_close_rect(void)
CLOSE on a run's settings, top right in the line of the run's name: back to TEST, as the home tag goe...
Definition servo_workbench_int.h:185
#define RUN_LINE_P
Definition servo_workbench_int.h:145
#define RUN_BTN_W
Definition servo_workbench_int.h:142
#define RUN_CARD_H
Definition servo_workbench_int.h:135
static gfx_rect_t save_line_rect(void)
The save line of a page of rows, 20px tall. On SETTINGS' pages along the bottom, under the notes; on ...
Definition servo_workbench_int.h:204
#define RUN_CARD_Y(k)
Run card k's top (0 AUTOMATIC TEST, 1 LIMIT RUN).
Definition servo_workbench_int.h:138
#define RUN_SET_W
Definition servo_workbench_int.h:146
static gfx_rect_t test_start_rect(void)
START TEST, on the AUTOMATIC TEST card.
Definition servo_workbench_int.h:218
setting_id_t
Every setting's id, in schema order.
Definition settings.h:67
Definition gfx.h:129
Definition gfx.h:81
Definition prog_registry.h:129
A DOWN, MOVE or UP of one contact.
Definition touch_types.h:69
#define UI_TAP_MIN
The smallest touch target for a control, in pixels: 48px, 7.2mm.
Definition ui_layout.h:71
ui_wb_task_t ui_wb_strip_task(const ui_wb_strip_t *w)
Definition ui_workbench.c:38
ui_wb_task_t
Definition ui_workbench.h:39