rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
ui_screen.h
Go to the documentation of this file.
1
16
17#pragma once
18
19#include <math.h>
20#include <stdbool.h>
21#include <stdint.h>
22
23#include "gfx.h"
24#include "touch_types.h"
25#include "ui_layout.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31typedef enum {
32 SCREEN_SPLASH = 0,
33 SCREEN_OVERVIEW,
34 SCREEN_MOTOR,
35 SCREEN_SERVO,
36 SCREEN_ANALYSER,
37 SCREEN_LOGS,
38 SCREEN_SETUP,
39 SCREEN_BATTERY,
40 SCREEN_BALANCE,
41 SCREEN_OUTPUTS,
42 SCREEN_PICKER,
43 SCREEN_SUPPLY,
44 /* Start-up only, and not reachable from the menu: the bus self-test
45 * failed and the panel says so before anything else. */
46 SCREEN_BUSFAULT,
47 /* WI-FI, from LOGS and from SETUP: the panel's Wi-Fi for card
48 * downloads and firmware uploads. */
49 SCREEN_WIFI,
50 /* While the panel writes its own firmware, and not reachable from the
51 * menu: nothing on the bench runs, so it carries no band either. */
52 SCREEN_UPDATE,
53 /* Not reachable from the menu either: the panel opens it to offer the
54 * IOmcu an update, and shows the update's progress on it. */
55 SCREEN_COPROC_UPDATE,
56 /* UPDATES, from SETUP: the check for a newer release on GitHub, the
57 * reminder's switch, and the download. */
58 SCREEN_UPDATES,
59 /* Not reachable from the menu: the panel opens it on OVERVIEW when the
60 * start-up check found a newer release. */
61 SCREEN_UPD_REMIND,
62 /* FILES, from SETUP and from LOGS: the card's folders and files in two
63 * panes. */
64 SCREEN_FILES,
65 SCREEN_COUNT
66} ui_screen_id_t;
67
68typedef struct {
69 const char *title;
74 void (*reset)(void);
75 void (*enter)(void);
76 void (*leave)(void);
77 void (*tick)(float dt_s);
79 void (*event)(const touch_event_t *evt);
89 void (*cancel)(void);
90 void (*render)(gfx_canvas_t *c, int buffer_index);
99 bool (*back)(void);
108 bool (*hold)(ui_screen_id_t to);
119 bool (*safe_at)(int x, int y);
121
122/*
123 * UI_BAND_H, the band the router owns, and UI_ALERT_H and UI_ALERT_Y, the
124 * alert band the router draws across the bottom of the panel while an alert
125 * shows, are in ui_layout.h. The alert band takes the touches under it, so a
126 * screen puts nothing that acts there -- except a control that stops what the
127 * bench drives, whose press the router hands through (ui_screen_t's safe_at).
128 */
129
139int ui_router_alert_rows(const char *text);
140
141void ui_router_init(void);
142
144void ui_router_goto(ui_screen_id_t id);
145
146ui_screen_id_t ui_router_current(void);
147
159ui_screen_id_t ui_router_parent(ui_screen_id_t id);
160
167uint32_t ui_router_navigations(void);
168
175uint32_t ui_router_dispatched(void);
176const char *ui_router_title(ui_screen_id_t id);
177
178void ui_router_tick(float dt_s);
179
196void ui_router_event(const touch_event_t *evt);
197
206void ui_router_render(gfx_canvas_t *c, int buffer_index);
207
209void ui_router_invalidate(void);
210
211/* ------------------------------------------------------------ bench state */
212
219#define UI_ARMED_MOTOR 0x01u
220#define UI_ARMED_SERVO 0x02u
221
222typedef struct {
223 bool link_up;
224 bool armed;
229 uint8_t armed_roles;
230 uint16_t faults;
231 uint32_t run_seconds;
232 const char *mode;
244
245 /*
246 * A link_cap_t bitmap from the IOmcu's identity page. Zero means
247 * nothing is fitted or nothing answered; the menu treats both the same.
248 */
249 uint16_t capabilities;
250
255 uint32_t link_errors;
256
263 uint32_t link_refused;
264
272
273void ui_router_set_status(const ui_bench_status_t *status);
274
288
298
302
304bool ui_router_stop_live(void);
305const ui_bench_status_t *ui_router_status(void);
306
316bool ui_router_take_stop(void);
317
318/* ------------------------------------------------------------------ alert */
319
321#define UI_ALERT_MAX 128
322
324#define UI_ALERT_SHOW_S 30.0f
325
341void ui_router_set_alert(const char *text);
342
349uint32_t ui_router_alert_number(void);
350
357bool ui_router_withdraw_alert(uint32_t number);
358
366void ui_router_hold_alert(const char *text);
367
369const char *ui_router_alert(void);
370
371#ifdef __cplusplus
372}
373#endif
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
Definition gfx.h:129
Definition gfx.h:81
A DOWN, MOVE or UP of one contact.
Definition touch_types.h:69
Definition ui_screen.h:222
uint32_t link_errors
Definition ui_screen.h:255
uint8_t armed_roles
Definition ui_screen.h:229
uint16_t faults
Definition ui_screen.h:230
float mcu_temp_c
Definition ui_screen.h:270
bool simulated
Definition ui_screen.h:243
uint32_t link_refused
Definition ui_screen.h:263
const char * mode
Definition ui_screen.h:232
Definition ui_screen.h:68
void(*) leave(void)
Definition ui_screen.h:76
void(*) event(const touch_event_t *evt)
Definition ui_screen.h:79
void(*) cancel(void)
Definition ui_screen.h:89
const char * title
Definition ui_screen.h:69
void(*) reset(void)
Definition ui_screen.h:74
bool(*) back(void)
Definition ui_screen.h:99
bool(*) hold(ui_screen_id_t to)
Definition ui_screen.h:108
bool(*) safe_at(int x, int y)
Definition ui_screen.h:119
Plain data types shared by the touch controller driver, the coordinate mapper and the event tracker....
The panel's geometry, in one place.
uint32_t ui_router_dispatched(void)
Definition ui_router.c:238
uint32_t ui_router_navigations(void)
Definition ui_router.c:237
int ui_router_alert_rows(const char *text)
The rows the alert band gives text.
Definition ui_router.c:801
void ui_router_invalidate(void)
Definition ui_router.c:240
ui_band_chip_t ui_router_help(void)
Definition ui_router.c:320
ui_band_chip_t
Definition ui_screen.h:279
@ UI_BAND_CHIP_LINK
Definition ui_screen.h:281
@ UI_BAND_CHIP_FAULT
Definition ui_screen.h:283
@ UI_BAND_CHIP_ARMED
Definition ui_screen.h:284
@ UI_BAND_CHIP_CLOCK
Definition ui_screen.h:285
@ UI_BAND_CHIP_MODE
Definition ui_screen.h:282
bool ui_router_take_stop(void)
Whether a press came down on STOP since the last call; clears it.
Definition ui_router.c:330
bool ui_router_stop_live(void)
Definition ui_router.c:365
ui_screen_id_t ui_router_parent(ui_screen_id_t id)
Where the home tag of screen id leads when it leaves the screen. A screen with several openers return...
Definition ui_router.c:230
bool ui_router_withdraw_alert(uint32_t number)
Definition ui_router.c:761
void ui_router_hold_alert(const char *text)
Definition ui_router.c:770
void ui_router_set_alert(const char *text)
Show text in a 34px band across the bottom of every screen, or NULL to clear it.
Definition ui_router.c:740
void ui_router_goto(ui_screen_id_t id)
Definition ui_router.c:197
void ui_router_cancel_gestures(void)
Definition ui_router.c:704
void ui_router_event(const touch_event_t *evt)
Definition ui_router.c:521
uint32_t ui_router_alert_number(void)
Definition ui_router.c:756
bool ui_router_help_rect(gfx_rect_t *out)
Definition ui_router.c:322
const char * ui_router_alert(void)
Definition ui_router.c:779