rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
files_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 "card_tree.h"
22#include "files_screen.h"
23#include "fm_req.h"
24#include "fm_rules.h"
25#include "fm_tree.h"
26#include "gfx.h"
27#include "touch_types.h"
28#include "ui_layout.h"
29#include "ui_text.h"
30#include "ui_textkey.h"
31#include "ui_widgets.h"
32
33#define SCREEN_W UI_PANEL_W
36#define SCREEN_H UI_BODY_H
37#define MAX_FBS 3
38
45#define FS_FONT_LABEL (&gfx_font_10x20)
46#define FS_FONT_FINE (&gfx_font_8x16)
47#define FS_FONT_BODY (&gfx_font_12x24)
48
50#define FS_L UI_MARGIN
51#define FS_R (SCREEN_W - UI_MARGIN)
52#define FS_W (FS_R - FS_L)
53
54/* ---------------------------------------------------------------- panes */
55
66#define FS_PANE_W 500
67#define FS_PANE_GAP 8
69#define FS_PANE_X(i) (FS_L + (i) * (FS_PANE_W + FS_PANE_GAP))
70#define FS_HDR_Y 4
71#define FS_HDR_H UI_TAP_MIN
72#define FS_PG_W 88
73#define FS_UP_W 312
75#define FS_UP(i) gfx_rect_make(FS_PANE_X(i), FS_HDR_Y, FS_UP_W, FS_HDR_H)
77#define FS_PREV(i) gfx_rect_make(FS_PANE_X(i) + FS_PANE_W - 2 * FS_PG_W - 4, \
78 FS_HDR_Y, FS_PG_W, FS_HDR_H)
79
80#define FS_NEXT(i) gfx_rect_make(FS_PANE_X(i) + FS_PANE_W - FS_PG_W, \
81 FS_HDR_Y, FS_PG_W, FS_HDR_H)
82#define FS_LIST_Y 60
83#define FS_HEAD_H 30
84#define FS_ROW_H 48
85#define FS_ROWS 6
87#define FS_LIST(i) gfx_rect_make(FS_PANE_X(i), FS_LIST_Y, FS_PANE_W, \
88 FS_HEAD_H + FS_ROWS * FS_ROW_H + 4)
89#define FS_BAR_W 56
90#define FS_BAR_MIN 32
92#define FS_BAR(i) gfx_rect_make(FS_PANE_X(i) + FS_PANE_W - 8 - FS_BAR_W, \
93 FS_LIST_Y + FS_HEAD_H, FS_BAR_W, \
94 FS_ROWS * FS_ROW_H - 4)
95#define FS_ROW_IN 8
97#define FS_ROW_W (FS_PANE_W - FS_ROW_IN - 8 - FS_BAR_W - 8)
98#define FS_ICON 24
99#define FS_SIZE_W 90
100
105#define FS_MSG_Y 388
106#define FS_MSG_LH 24
107
117#define FOOT_H 52
118#define FOOT_Y (SCREEN_H - UI_ALERT_H - 4 - FOOT_H)
119#define FOOT_W 118
120#define FOOT_W_FIRST 140
121#define FOOT_GAP 6
122#define FOOT_PAD 6
123#define FOOT_N 8
126#define FS_FOOT_X(i) (FS_L + (((i) == 0) ? 0 \
127 : FOOT_W_FIRST + FOOT_GAP \
128 + ((i) - 1) * (FOOT_W + FOOT_GAP)))
129
130#define FS_FOOT(i) gfx_rect_make(FS_FOOT_X(i), FOOT_Y, \
131 ((i) == 0) ? FOOT_W_FIRST : FOOT_W, \
132 FOOT_H)
133
136typedef enum {
137 FS_RESCAN = 0,
138 FS_COPY,
139 FS_MOVE,
140 FS_RENAME,
141 FS_DELETE,
142 FS_NEW,
143 FS_INFO,
144 FS_OPEN
145} fs_foot_t;
146
147_Static_assert(FS_RESCAN == 0, "RESCAN is the first, wide button");
148_Static_assert(FS_OPEN == FOOT_N - 1, "OPEN is the last button");
149
150/* ---------------------------------------------------------------- boxes */
151
157#define FS_BOX_Y 100
158#define FS_BOX_H 280
160#define FS_BOX gfx_rect_make(162, FS_BOX_Y, 700, FS_BOX_H)
161#define FS_Q_CANCEL gfx_rect_make(186, 304, 300, 56)
162#define FS_Q_DELETE gfx_rect_make(538, 304, 300, 56)
164#define FS_JOB_CANCEL gfx_rect_make(362, 304, 300, 56)
166#define FS_JOB_BAR gfx_rect_make(186, 228, 652, 24)
167
173#define FS_INFO_Y 20
174#define FS_INFO_H 420
176#define FS_INFO_BOX gfx_rect_make(112, FS_INFO_Y, 800, FS_INFO_H)
177#define FS_INFO_LH 32
178#define FS_INFO_KEY_W 160
179#define FS_INFO_CLOSE gfx_rect_make(362, 364, 300, 56)
180
185#define FS_NEW_W 300
186#define FS_NEW_ROW_H UI_CHOICE_ROW_H
187#define FS_NEW_H (2 * FS_NEW_ROW_H + 8)
189#define FS_NEW_X (FS_FOOT_X(FS_NEW) + FOOT_W - FS_NEW_W)
190#define FS_NEW_Y (FOOT_Y - 8 - FS_NEW_H)
192#define FS_NEW_LIST gfx_rect_make(FS_NEW_X, FS_NEW_Y, FS_NEW_W, FS_NEW_H)
194#define FS_NEW_ROW(i) gfx_rect_make(FS_NEW_X + 4, \
195 FS_NEW_Y + 4 + (i) * FS_NEW_ROW_H, \
196 FS_NEW_W - 8, FS_NEW_ROW_H)
197
202#define FS_TK_AREA gfx_rect_make(FS_L, 4, FS_W, FOOT_Y + FOOT_H - 4)
203
206#define FS_JOB_BOX_S 0.25f
207
210#define DRAG_SLOP 8
211
218
234
235_Static_assert(FOOT_Y + FOOT_H + 4 <= SCREEN_H - UI_ALERT_H,
236 "the footer ends 4px above the alert band");
237_Static_assert(FOOT_H >= UI_TAP_MIN, "the footer's buttons are a finger tall");
238_Static_assert(FS_FOOT_X(FOOT_N - 1) + FOOT_W == FS_R,
239 "the footer's buttons end at the right margin");
240_Static_assert(FS_ROW_H >= UI_TAP_MIN, "a row is a finger tall");
241_Static_assert(FS_HDR_H >= UI_TAP_MIN && FS_PG_W >= UI_TAP_MIN,
242 "UP, PREV and NEXT are a finger tall and wide");
243_Static_assert(FS_UP_W + 8 <= FS_PANE_W - 2 * FS_PG_W - 4,
244 "UP ends 8px short of PREV");
245_Static_assert(FS_PANE_X(1) + FS_PANE_W == FS_R, "the right pane ends at the margin");
246_Static_assert(FS_HDR_Y + FS_HDR_H + 8 <= FS_LIST_Y,
247 "the header row ends 8px above the list");
248_Static_assert(FS_LIST_Y + FS_HEAD_H + FS_ROWS * FS_ROW_H + 4 + 6 <= FS_MSG_Y,
249 "the lists end above the message line");
250_Static_assert(FS_MSG_Y + 2 * FS_MSG_LH + 4 <= FOOT_Y,
251 "the message line's two lines end 4px above the footer");
252_Static_assert(FS_ICON + 8 + 28 * 10 + 8 + FS_SIZE_W + 8 <= FS_ROW_W,
253 "a row holds its icon, 28 cells of name and the size");
254_Static_assert((FS_ROWS * FS_ROW_H - 4) * FS_ROWS / FM_PAGE_MAX >= 32,
255 "the scroll bar's thumb is 32px or more on a full page");
256_Static_assert(FS_NEW_Y + FS_NEW_H + 8 <= FOOT_Y,
257 "NEW's choice ends 8px above the footer");
258_Static_assert(FS_NEW_ROW_H >= UI_TAP_MIN, "a choice row is a finger tall");
259_Static_assert(FS_INFO_Y + FS_INFO_H <= SCREEN_H - UI_ALERT_H - 4,
260 "INFO ends 4px above the alert band");
261_Static_assert(FS_BOX_Y + FS_BOX_H <= SCREEN_H - UI_ALERT_H - 4,
262 "the question ends 4px above the alert band");
263
265#define FS_MSG_MAX 192
266
273
275typedef struct {
277 bool have_io;
279
281 int scroll[2];
282 int active;
283 bool read[2];
286 unsigned mount;
287
288 /* The listings waiting for the card's task, one per pane. */
289 bool need[2];
294 bool keep_place[2];
295
296 /* The request under way, the card's task's until it is answered. */
298 bool busy;
300 bool req_keep;
301 float busy_s;
302 uint64_t prog_done;
303 uint64_t prog_total;
305
309
310 /* The DELETE question: the entry it names, copied, and its pane. */
313
314 /* INFO: the entry, its folder, and what the card answered. */
319
320 /* The keyboard for a name, and what it is typed for. */
323 uint32_t drawn_tk_rev;
324
325 /* The bench as the gate and the rules see it, read each frame. */
330
331 /* The message line, kept as its text's ID and names, not as words,
332 * so it is worded in the language showing when it is drawn. */
339
340 /* The contact that holds a press, where it came down, and what on. */
341 bool tap_have;
343 uint8_t tap_id;
344 int16_t tap_x0;
345 int16_t tap_y0;
346 int press;
350 bool dragged;
352
354} fs_state_t;
355
357extern fs_state_t fs_s;
358#define s fs_s
359
360/* --- files_screen.c ----------------------------------------------------- */
361
366const fm_entry_t *fs_selected(void);
367
374bool fs_foot_live(fs_foot_t b, fm_err_t *why);
375
381bool fs_paged(int i);
382
387void fs_foot(fs_foot_t b);
388
395void fs_turn(int i, fm_go_t go, bool up);
396
403void fs_row_tap(int i, int row);
404
406void fs_delete_doomed(void);
407
412void fs_new_name(bool folder);
413
418void fs_name_typed(const char *name);
419
421void fs_job_cancel(void);
422
435void fs_say(bool ok, ui_text_id_t id, const char *a, const char *b);
436
442void fs_say_err(fm_err_t err, const char *name);
443
445void fs_quiet(void);
446
453const char *fs_message(char *buf, size_t n);
454
462void fs_err_text(fm_err_t err, const char *name, char *out, size_t n);
463
470void fs_bar_thumb(int i, int *y, int *h);
471
478int fs_bar_scroll_at(int i, int top);
479
484void fs_clamp_scroll(int i);
485
486/* --- files_draw.c ------------------------------------------------------- */
487
494void fs_render(gfx_canvas_t *c, int buffer_index);
495
501const char *fs_kind_word(int kind);
502
503/* --- files_events.c ----------------------------------------------------- */
504
509void fs_event(const touch_event_t *e);
510
512void fs_cancel_press(void);
The folders of the panel's SD (Secure Digital) card, and the files in them with a fixed name.
#define CARD_DIR_MAX
Room for a folder path and its terminator: two folders of 8 characters and the "/" between them are 1...
Definition card_tree.h:113
void fs_render(gfx_canvas_t *c, int buffer_index)
FILES drawn: the panes and the footer, or a box over them, and the keyboard on top.
Definition files_draw.c:601
const char * fs_kind_word(int kind)
The words of entry kind kind.
Definition files_draw.c:29
void fs_cancel_press(void)
Drop a press under way: the touch stream lost an event.
Definition files_events.c:96
void fs_event(const touch_event_t *e)
One touch event, in the screen's coordinates.
Definition files_events.c:344
void fs_clamp_scroll(int i)
Pane i's scroll held to its rows.
Definition files_screen.c:521
#define FOOT_N
Definition files_int.h:123
void fs_quiet(void)
The message line says nothing.
Definition files_screen.c:116
#define FS_FOOT_X(i)
Footer button i's left edge: x 8 for the first, then 146px on and 124px a button after it.
Definition files_int.h:126
const char * fs_message(char *buf, size_t n)
The message line in the language showing.
Definition files_screen.c:121
fs_msg_kind_t
What the message line holds.
Definition files_int.h:268
@ FS_MSG_NONE
Definition files_int.h:269
@ FS_MSG_TEXT
Definition files_int.h:270
@ FS_MSG_ERR
Definition files_int.h:271
fs_name_for_t
What a name is typed for.
Definition files_int.h:213
@ FS_NAME_RENAME
Definition files_int.h:216
@ FS_NAME_FILE
Definition files_int.h:215
@ FS_NAME_FOLDER
Definition files_int.h:214
#define FS_ROW_H
Definition files_int.h:84
fs_hit_t
What a press came down on.
Definition files_int.h:220
@ FS_HIT_JOB_CANCEL
Definition files_int.h:232
@ FS_HIT_INFO_CLOSE
Definition files_int.h:230
@ FS_HIT_BAR
Definition files_int.h:227
@ FS_HIT_NEXT
Definition files_int.h:225
@ FS_HIT_NEW_ROW
Definition files_int.h:231
@ FS_HIT_UP
Definition files_int.h:223
@ FS_HIT_PREV
Definition files_int.h:224
@ FS_HIT_Q_CANCEL
Definition files_int.h:228
@ FS_HIT_Q_DELETE
Definition files_int.h:229
@ FS_HIT_ROW
Definition files_int.h:226
#define FS_NEW_H
Definition files_int.h:187
#define SCREEN_H
The body's height, 540px: the router owns the band and hands this screen the body.
Definition files_int.h:36
#define FS_UP_W
Definition files_int.h:73
void fs_bar_thumb(int i, int *y, int *h)
The scroll bar's thumb of pane i.
Definition files_screen.c:535
const fm_entry_t * fs_selected(void)
The selected entry of the active pane.
Definition files_screen.c:509
#define FS_ROW_W
A row's width: from the inset to 8px short of the bar.
Definition files_int.h:97
void fs_say_err(fm_err_t err, const char *name)
The message line says why err, for name (fs_err_text()).
Definition files_screen.c:106
#define FS_MSG_Y
The message line under the panes: two lines of the 12 x 24 face, 84 cells each, 24px apart,...
Definition files_int.h:105
bool fs_paged(int i)
Whether a pane's folder holds more than its page.
Definition files_screen.c:514
#define FS_HDR_Y
Definition files_int.h:70
fs_state_t fs_s
The screen's state, defined in files_screen.c.
Definition files_screen.c:36
void fs_err_text(fm_err_t err, const char *name, char *out, size_t n)
The words of a refusal or a failure, for name.
Definition files_screen.c:145
#define FS_ICON
Definition files_int.h:98
#define FOOT_W
Definition files_int.h:119
#define FS_INFO_Y
The INFO box: 800 x 420px, its rows in the 10 x 20 face at a pitch of FS_INFO_LH under the heading,...
Definition files_int.h:173
void fs_foot(fs_foot_t b)
Act on footer button b: a tap on it, live or dimmed.
Definition files_screen.c:711
#define FS_HEAD_H
Definition files_int.h:83
#define FS_NEW_Y
Definition files_int.h:190
#define FS_PG_W
Definition files_int.h:72
#define FS_LIST_Y
Definition files_int.h:82
#define FS_SIZE_W
Definition files_int.h:99
void fs_delete_doomed(void)
The DELETE question's DELETE: the job that deletes it.
Definition files_screen.c:839
#define FS_MSG_LH
Definition files_int.h:106
#define FS_HDR_H
Definition files_int.h:71
#define FOOT_Y
Definition files_int.h:118
void fs_name_typed(const char *name)
The keyboard closed with name: the job that makes or renames.
Definition files_screen.c:862
bool fs_foot_live(fs_foot_t b, fm_err_t *why)
Whether footer button b takes a press now, and why not.
Definition files_screen.c:613
void fs_say(bool ok, ui_text_id_t id, const char *a, const char *b)
The message line says id, with up to two names.
Definition files_screen.c:95
#define FS_R
Definition files_int.h:51
#define FS_BOX_H
Definition files_int.h:158
#define FOOT_H
The footer, body y 440 to 492, ending 4px above the router's alert band (y 496), in LOGS' order: RESC...
Definition files_int.h:117
int fs_bar_scroll_at(int i, int top)
The scroll of pane i that puts the thumb's top nearest top.
Definition files_screen.c:553
#define FS_NEW_ROW_H
Definition files_int.h:186
#define MAX_FBS
Definition files_int.h:37
#define FS_INFO_H
Definition files_int.h:174
#define FS_ROWS
Definition files_int.h:85
void fs_row_tap(int i, int row)
A tap on row row of pane i: the pane active and the row selected; a tap on the selected row of the ac...
Definition files_screen.c:824
void fs_job_cancel(void)
CANCEL on the progress box.
Definition files_screen.c:896
#define FS_PANE_W
The two panes, 500px wide at x 8 and x 516, 8px apart.
Definition files_int.h:66
#define FS_BOX_Y
The DELETE question and the progress box, in place of the panes and the footer: 700 x 280px,...
Definition files_int.h:157
void fs_turn(int i, fm_go_t go, bool up)
Read another page of pane i, or the folder above it.
Definition files_screen.c:807
void fs_new_name(bool folder)
NEW's choice: the keyboard for the new entry's name.
Definition files_screen.c:853
fs_foot_t
The footer's buttons, left to right: each one's number is its place in the footer.
Definition files_int.h:136
#define FS_PANE_X(i)
Pane i's left edge: 8 or 516.
Definition files_int.h:69
FILES: the SD (Secure Digital) card in two panes, commander style, and the operations on its files an...
files_view_t
What the screen shows over its panes.
Definition files_screen.h:122
fm_err_t
What a call of the core or of the card came to. FM_OK is 0; every other value is a refusal or a failu...
Definition fm_io.h:51
#define FM_NAME_BUF
Room for a listed name and its terminator: FM_LIST_NAME_MAX (63) bytes, as the panel's directory walk...
Definition fm_io.h:44
#define FM_PATH_SIZE
Room for a path and its terminator.
Definition fm_name.h:54
One request of the FILES screen to the card's task, and the runner that answers it: a page of a pane,...
What the file manager may do to a name: the places the bench keeps, the files the logger writes,...
One pane of the file manager: a folder of the card, the page of its entries on show,...
#define FM_PAGE_MAX
Rows of one page, as LOGS' page (LOG_VIEWER_MAX_FILES).
Definition fm_tree.h:48
fm_go_t
Which page fm_tree_page() reads.
Definition fm_tree.h:65
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
The card's task as the screen reaches it. Every function may be called on the task that renders; none...
Definition files_screen.h:64
The bench as the rules see it, filled by the caller each time it asks. Every pointer may be NULL.
Definition fm_rules.h:101
One entry of a page.
Definition fm_tree.h:53
What INFO reads of one entry.
Definition fm_req.h:62
One request. The screen fills the fields of its kind, the runner writes the answer into the same requ...
Definition fm_req.h:74
One pane. The fields are the pane's; read them, change them through the functions.
Definition fm_tree.h:77
The screen's state.
Definition files_int.h:275
files_view_t view
Definition files_int.h:278
int press_row
Definition files_int.h:348
fm_req_t req
Definition files_int.h:297
bool dragged
Definition files_int.h:350
fm_entry_t doomed
Definition files_int.h:311
ui_text_id_t msg_id
Definition files_int.h:334
bool tap_have
Definition files_int.h:341
int bar_grab
Definition files_int.h:351
bool drawn_gate
Definition files_int.h:329
fs_msg_kind_t msg_kind
Definition files_int.h:333
int press_scroll0
Definition files_int.h:349
fm_err_t pane_err[2]
Definition files_int.h:284
uint64_t prog_total
Definition files_int.h:303
bool have_io
Definition files_int.h:277
int press
Definition files_int.h:346
fm_bench_t bench
Definition files_int.h:326
fm_go_t need_go[2]
Definition files_int.h:290
uint64_t prog_done
Definition files_int.h:302
uint8_t tap_id
Definition files_int.h:343
fm_info_t info
Definition files_int.h:317
char msg_a[FM_NAME_BUF]
Definition files_int.h:336
char select_after[2][FM_NAME_BUF]
The name a pane selects once its next page is read: a new folder, a new file, a renamed entry.
Definition files_int.h:308
ui_textkey_t tk
Definition files_int.h:321
int scroll[2]
Definition files_int.h:281
float busy_s
Definition files_int.h:301
char info_dir[FM_PATH_SIZE]
Definition files_int.h:316
int press_pane
Definition files_int.h:347
fm_tree_t pane[2]
Definition files_int.h:280
bool valid[MAX_FBS]
Definition files_int.h:353
bool busy
Definition files_int.h:298
unsigned mount
Definition files_int.h:286
char auto_dir[CARD_DIR_MAX]
Definition files_int.h:328
bool keep_place[2]
The pane's wish waiting is RESCAN's: its answer keeps the pane's place (place_keep() in files_screen....
Definition files_int.h:294
char user_dir[CARD_DIR_MAX]
Definition files_int.h:327
fm_err_t msg_err
Definition files_int.h:335
char msg_b[FM_NAME_BUF]
Definition files_int.h:337
int16_t tap_y0
Definition files_int.h:345
bool cancel_asked
Definition files_int.h:304
int doomed_pane
Definition files_int.h:312
int16_t tap_x0
Definition files_int.h:344
files_io_t io
Definition files_int.h:276
fs_name_for_t name_for
Definition files_int.h:322
bool need_look
Definition files_int.h:291
int req_pane
Definition files_int.h:299
bool read[2]
Definition files_int.h:283
fm_entry_t info_entry
Definition files_int.h:315
bool need[2]
Definition files_int.h:289
bool message_ok
Definition files_int.h:338
bool tap_moved
Definition files_int.h:342
bool req_keep
Definition files_int.h:300
uint32_t drawn_tk_rev
Definition files_int.h:323
fm_err_t info_err
Definition files_int.h:318
char enter_name[FM_NAME_BUF]
Definition files_int.h:285
int active
Definition files_int.h:282
Definition gfx.h:129
A DOWN, MOVE or UP of one contact.
Definition touch_types.h:69
A keyboard: what it was opened for, what is typed, and the press it holds.
Definition ui_textkey.h:114
Plain data types shared by the touch controller driver, the coordinate mapper and the event tracker....
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
#define UI_ALERT_H
The alert band the router draws across the bottom of the panel while an alert shows.
Definition ui_layout.h:43
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
An on-screen keyboard for a short name: capitals, digits, space and the marks a name or a file needs,...
Stateless drawing helpers shared by every screen.