rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
picker_screen_int.h
Go to the documentation of this file.
1
16#pragma once
17
18#include <stdbool.h>
19#include <stdint.h>
20
21#include "gfx.h"
22#include "link_drawing.h"
23#include "out_bind.h"
24#include "outputs_screen.h"
25#include "picker_screen.h"
26#include "ui_cats.h"
27#include "ui_layout.h"
28#include "ui_screen.h"
29#include "ui_widgets.h"
30
31#define SCREEN_W UI_PANEL_W
32#define SCREEN_H UI_BODY_H
33#define MAX_FBS 3
34
39#define FOOT (UI_ALERT_Y - UI_BAND_H - 4)
40
51#define PK_FONT_LABEL (&gfx_font_10x20)
52#define PK_FONT_FINE (&gfx_font_8x16)
53#define PK_FONT_PIN (&gfx_font_16x28)
54#define PK_FONT_HEAD (&gfx_font_20x36)
55#define PK_CELL 10
56
65#define BOARD_W 600
66#define BOARD_MAX_H 240
67
76#define TIERS 2
77#define TGAP 6
78#define BTNW 50
79#define KEY_H UI_BTN_H_TALL
80#define GAP 6
81
82_Static_assert((FOOT - BOARD_MAX_H) / 2 >= TIERS * KEY_H + TGAP + GAP,
83 "two tiers of keys fit above and below the tallest board");
84_Static_assert(BTNW >= UI_TAP_MIN && KEY_H >= UI_TAP_MIN,
85 "a key is a finger wide and tall");
86
87/*
88 * The marks inside the board. A ground is a round marker 36px across, 40
89 * px in from its pad: a servo lead needs a ground as much as a signal, so it
90 * is as legible as a button, and grounds are five pads apart, so it has
91 * nothing to collide with. A rail is 32px across, enough for "5V0", at one
92 * of two depths that alternate along the row: rails sit on neighbouring
93 * pads, 29px apart, and a rail beside a ground goes below the ground's
94 * marker -- 78px is the ground's 40 plus both radii and both rings.
95 */
96#define GND_R 18
97#define GND_DROP 40
98#define RAIL_R 16
100#define RAIL_DROP_0 30
101#define RAIL_DROP_1 78
102#define RING 2
103
117#define HEAD_X 8
118#define HEAD_Y 8
119#define HEAD_W 350
120#define FACE_W 280
121#define FACE_H 56
122#define COUNT_Y (HEAD_Y + FACE_H + 8)
123#define REASON_Y (COUNT_Y + 24)
124#define REASON_PITCH 22
126#define HEAD_H (REASON_Y + REASON_PITCH + 20 - HEAD_Y)
127
128/*
129 * The open list covers the board, as it covers the pins on OUTPUTS: the
130 * protocols in a column of 48px rows from the face's top, the PROG PORT
131 * entries in a second column beside it. With its margins and shadow it
132 * ends at body y 404.
133 */
134#define POP_W 300
135#define POP_ROW UI_TAP_MIN
136
137_Static_assert(HEAD_Y + (int)OUTBIND_PROTOS * POP_ROW + 8 + 4 <= FOOT,
138 "the protocol list ends above the alert band");
139
151#define PINS_X 8
152#define PINS_Y (HEAD_Y + HEAD_H + 10)
153#define PINS_W 171
154#define PINS_NAME_X 34
155#define PINS_TOP (PINS_Y + 48)
156#define ROW_H 36
157
158_Static_assert(PINS_TOP + (int)LINK_OUT_SLOTS * ROW_H <= FOOT,
159 "the PINS table holds 8 pins above the alert band");
160_Static_assert(PINS_NAME_X + 7 * 16 + 4 <= PINS_W - 2 * PK_CELL,
161 "a pin name (GPIO 28) ends 4px left of a two-digit pad");
162_Static_assert(PINS_X + PINS_W + 8 <= (SCREEN_W - BOARD_W) / 2 - BTNW / 2,
163 "the PINS table ends 8px left of any key");
164
174#define USE_W 168
175#define USE_X (SCREEN_W - 8 - USE_W)
176#define USE_Y 4
177#define USE_TOP (USE_Y + 56)
178#define USE_FOOT FOOT
179#define USE_NAME_H 20
180#define USE_PIN_H 28
181#define USE_PIN_H_C 20
182#define USE_PIN_H_D 16
183
184_Static_assert(USE_X >= (SCREEN_W + BOARD_W) / 2 + BTNW / 2 + 8,
185 "the IN USE table starts 8px right of any key");
186
187/* With no interface on, every line fits at the 16px pin rows: every port,
188 * every protocol's name and every slot's pin. */
189_Static_assert(USE_TOP
190 + (1 + (int)OUTBIND_PROTOS - 1) * USE_NAME_H
191 + ((int)LINK_PG_PORTS_MAX + (int)LINK_OUT_SLOTS)
193 <= USE_FOOT,
194 "the IN USE table holds a binding beside 4 ports");
195/* And with every interface on as well, at 16px a line: 27 lines. PPM's
196 * one pin takes all 8 slots, so at most 6 protocols share them, one name
197 * fewer than PICKER_USE_MAX counts. */
198_Static_assert(USE_TOP + ((int)PICKER_USE_MAX - 1) * USE_PIN_H_D
199 <= USE_FOOT,
200 "the IN USE table holds its fullest list");
201
206#define NOART_W 640
207#define NOART_H 180
208
209#define IVORY GFX_RGB(236, 235, 228)
210#define EBONY GFX_RGB(22, 23, 28)
211#define INK GFX_RGB(10, 10, 14)
212#define HALO GFX_RGB(6, 6, 8)
213
214enum { HIT_NONE = 0, HIT_FACE, HIT_ROW, HIT_BUTTON };
215
221typedef struct {
226 /* The IOmcu's drawing, for the board drawing_board names; it
227 * agreed with that board's catalogue when it was set. */
233 uint16_t drawing_board;
235
237 int hit;
238 bool open;
239 /* The binding shown is not one a read confirmed: no button acts. */
244 bool unread;
245 /* The pin whose tap a PWM clash refused last, or -1: the reason line
246 * says why, until another pick or tick. */
252 /* Each interface's pins at the last frame. */
253 uint64_t iface[OUTPUTS_IFACE_COUNT];
254 /* The PROG PORT picked, -1 for a protocol (picker_port.c), and the
255 * ports' view drawn. */
256 int port;
257 uint32_t view_rev;
259 /* The cat (picker_cat.c): picked on the first frame of a visit from
260 * the roll entering took, and drawn while its box stays clear. */
262 uint32_t cat_roll;
265} pk_state_t;
266
267/* Defined in picker_screen.c. */
268extern pk_state_t pk_s;
270#define s pk_s
271
272/* --- picker_screen.c: the state the other two read -------------------- */
273
274void pk_touched(void);
275const outbind_shape_t *pk_shape(void);
276const link_drawing_t *pk_drawing(void);
277uint8_t pk_proto_shown(void);
278bool pk_prog_taken(uint8_t index);
279outputs_iface_t pk_iface_taken(uint8_t index);
280int8_t pk_channel_of(uint8_t index);
281
282/* --- picker_geometry.c ------------------------------------------------- */
283
292void pk_board_box(int *x, int *y, int *w, int *h);
301bool pk_pad_xy(uint8_t pad, int *px, int *py);
307bool pk_pad_is_top(uint8_t pad);
316bool pk_button_at(int i, gfx_rect_t *out, int *tier_out);
325bool pk_marker_at(uint8_t e, int *mx, int *my, int *r);
331int pk_pop_rows(void);
338
339/* --- picker_draw.c ------------------------------------------------------ */
340
346void pk_render(gfx_canvas_t *c, int buffer_index);
347
348/* --- picker_cat.c ------------------------------------------------------- */
349
351void pk_cat_enter(void);
353void pk_cat_reset(void);
#define ROW_H
Definition analyser_screen.c:117
#define SCREEN_W
Definition files_int.h:33
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
Binding a protocol to pins: what the operator chooses, and the OUTPUTS page that comes out of it.
#define OUTBIND_PROTOS
Entries in the protocol table, OFF included.
Definition out_bind.h:408
#define POP_ROW
Definition outputs_screen.c:108
The outputs screen: choose a protocol, then tick the pins it drives.
outputs_iface_t
Definition outputs_screen.h:284
void pk_cat_render(gfx_canvas_t *c)
Pick the cat on a visit's first frame and draw it while its box is clear; called last in a frame that...
Definition picker_cat.c:179
void pk_cat_reset(void)
Forget the cat: none until the next visit.
Definition picker_cat.c:165
void pk_cat_enter(void)
A visit begins: roll for the cat, picked on its first frame.
Definition picker_cat.c:172
void pk_render(gfx_canvas_t *c, int buffer_index)
Draws the screen into frame buffer buffer_index.
Definition picker_draw.c:507
bool pk_pad_is_top(uint8_t pad)
Returns which of the two pad rows a pad is in.
Definition picker_geometry.c:113
bool pk_pad_xy(uint8_t pad, int *px, int *py)
Gives where a pad sits on screen, from the drawing's pad record or else the shape's grid.
Definition picker_geometry.c:84
bool pk_marker_at(uint8_t e, int *mx, int *my, int *r)
Gives the centre and radius of the marker of pad-list entry e.
Definition picker_geometry.c:209
int pk_pop_rows(void)
Returns the rows of the protocol list: the protocols, then one PROG PORT entry per port.
Definition picker_geometry.c:284
bool pk_button_at(int i, gfx_rect_t *out, int *tier_out)
Gives the button of catalogue entry i and its tier; only a pin an output may have gets one.
Definition picker_geometry.c:129
gfx_rect_t pk_pop_rect(void)
Returns the protocol list's rectangle: one column of POP_W px, two with PROG PORT entries.
Definition picker_geometry.c:290
void pk_board_box(int *x, int *y, int *w, int *h)
Gives the box the board occupies: the drawing's outline or else the shape's, centred across the scree...
Definition picker_geometry.c:60
const link_drawing_t * pk_drawing(void)
The drawing, while it is the one for the board the binding names.
Definition picker_screen.c:183
const outbind_shape_t * pk_shape(void)
The shape page of the board the binding names.
Definition picker_screen.c:173
outputs_iface_t pk_iface_taken(uint8_t index)
What SETUP > INTERFACES holds pin index for: no protocol and no port holds it, and the IOmcu does not...
Definition picker_screen.c:239
bool pk_prog_taken(uint8_t index)
Whether the programming port has pin index: it is the port's and no protocol holds it....
Definition picker_screen.c:216
pk_state_t pk_s
The screen's state; picker_screen_int.h names it s.
Definition picker_screen.c:25
void pk_touched(void)
Count a change: every framebuffer's picture is stale.
Definition picker_screen.c:51
uint8_t pk_proto_shown(void)
The protocol shown: the binding's, OFF for one out of range.
Definition picker_screen.c:201
int8_t pk_channel_of(uint8_t index)
The channel the OUTPUTS page gives catalogue entry index. Channels are allocated in pin order across ...
Definition picker_screen.c:337
The pin picker: the board itself, with a button on every pin an output may have.
void(*) picker_apply_fn(const outbind_t *b)
Definition picker_screen.h:272
#define PICKER_USE_MAX
Definition picker_screen.h:226
void(*) picker_drawing_fn(uint16_t board)
Definition picker_screen.h:294
void(*) picker_select_fn(uint8_t proto)
Definition picker_screen.h:87
#define PK_CELL
Definition picker_screen_int.h:55
#define PINS_TOP
Definition picker_screen_int.h:155
#define USE_PIN_H_D
Definition picker_screen_int.h:182
#define TGAP
Definition picker_screen_int.h:77
#define GAP
Definition picker_screen_int.h:80
#define PINS_NAME_X
Definition picker_screen_int.h:154
#define BTNW
Definition picker_screen_int.h:78
#define USE_FOOT
Definition picker_screen_int.h:178
#define BOARD_W
The board's box: 600px wide and as tall as its outline makes it, up to 240px, centred between the bod...
Definition picker_screen_int.h:65
#define TIERS
Two staggered tiers of keys above the board and two below.
Definition picker_screen_int.h:76
#define USE_TOP
Definition picker_screen_int.h:177
#define FOOT
The lowest row the screen draws or takes a press on, in the screen's coordinates: 4px above the alert...
Definition picker_screen_int.h:39
#define BOARD_MAX_H
Definition picker_screen_int.h:66
#define PINS_X
The PINS table, left of the board: 171px, "CH7" in the label face (30px), "GPIO 28" in PK_FONT_PIN fr...
Definition picker_screen_int.h:151
#define MAX_FBS
Definition picker_screen_int.h:33
#define KEY_H
Definition picker_screen_int.h:79
#define PINS_W
Definition picker_screen_int.h:153
#define USE_X
Definition picker_screen_int.h:175
#define USE_NAME_H
Definition picker_screen_int.h:179
Definition gfx.h:129
Definition gfx.h:81
Where a board's pads are: two rows on one pitch, which is every 0.1-inch header board.
Definition out_bind.h:89
The selection: which board, the protocol being edited, and each protocol's pins.
Definition out_bind.h:423
PICK A PIN's state: the binding shown, the callbacks that apply and select, the IOmcu's drawing of th...
Definition picker_screen_int.h:221
uint32_t cat_roll
Definition picker_screen_int.h:262
bool chrome_valid[MAX_FBS]
Definition picker_screen_int.h:258
bool open
Definition picker_screen_int.h:238
picker_select_fn select
Definition picker_screen_int.h:224
uint32_t view_rev
Definition picker_screen_int.h:257
int hit_kind
Definition picker_screen_int.h:236
uint16_t drawing_board
Definition picker_screen_int.h:233
int port
Definition picker_screen_int.h:256
bool unread
Whether the binding shown is not one a read confirmed: no button acts.
Definition picker_screen_int.h:244
int hit
Definition picker_screen_int.h:237
bool cat_pending
Definition picker_screen_int.h:261
bool has_drawing
Definition picker_screen_int.h:234
link_drawing_t drawing
The IOmcu's drawing, for the board drawing_board names; it agreed with that board's catalogue when it...
Definition picker_screen_int.h:232
ui_cat_pick_t cat
Definition picker_screen_int.h:263
picker_drawing_fn source
Definition picker_screen_int.h:225
gfx_rect_t cat_drawn
Definition picker_screen_int.h:264
picker_apply_fn apply
Definition picker_screen_int.h:223
int refused
Pin whose tap a PWM clash refused last, -1 for none; the reason line says why.
Definition picker_screen_int.h:251
outbind_t bind
Definition picker_screen_int.h:222
uint64_t iface[OUTPUTS_IFACE_COUNT]
Definition picker_screen_int.h:253
A pick: a pose and the index of its spot in the screen's list, or both UI_CAT_NONE.
Definition ui_cats.h:76
Cat drawings on the screens: the poses, the spots a screen offers them, the random pick of one and th...
The panel's geometry, in one place.
#define UI_TAP_MIN
The smallest touch target for a control, in pixels: 48px, 7.2mm.
Definition ui_layout.h:71
Screen router.
Stateless drawing helpers shared by every screen.