rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
kst_panel.h
Go to the documentation of this file.
1
29#pragma once
30
31#include <stdbool.h>
32#include <stddef.h>
33#include <stdint.h>
34
35#include "gfx.h"
36#include "kst_prog.h"
37#include "prog_registry.h"
38#include "touch_types.h"
39#include "ui_keypad.h"
40#include "ui_textkey.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
48#define KST_PANEL_STD_MV 6000u
52#define KST_PANEL_NAME_TYPED 16
54#define KST_PANEL_MSG_LINES 3
55#define KST_PANEL_LINE 96
56
58void kst_panel_init(gfx_rect_t area);
59
61void kst_panel_screen_entry(void);
62
67void kst_panel_open(void);
72bool kst_panel_is_open(void);
73
78void kst_panel_close(void);
79
85void kst_panel_back(void);
86
88bool kst_panel_holds_port(void);
89
92uint8_t kst_panel_pin(void);
93
96bool kst_panel_safe_at(int x, int y);
97
100
102void kst_panel_leave(void);
103
105void kst_panel_cancel(void);
106
112void kst_panel_tick(float dt_s);
113
115bool kst_panel_has_press(uint8_t id);
116
118void kst_panel_event(const touch_event_t *evt);
119
121
123uint32_t kst_panel_revision(void);
124
126uint32_t kst_panel_hold_revision(void);
127
128/* --- the control task's side ------------------------------------------------ */
129
135void kst_panel_feed(const kst_prog_feed_t *f);
141void kst_panel_set_hv(bool on);
146void kst_panel_bench_armed(bool armed);
150bool kst_panel_card_look(void);
175size_t kst_panel_file_take(char *out, size_t n);
180void kst_panel_file_done(bool ok);
187bool kst_panel_file_load(const char *text, size_t len);
192bool kst_panel_file_late(const char *text, size_t len);
193
194/* --- the limit run's sessions (servo_limrun.h) ------------------------------- */
195
196/*
197 * A limit run lowers LEFT ANGLE and RIGHT ANGLE through the model the
198 * overlay holds, a session at a time: CONNECT with its read, one write,
199 * LEAVE. Each call starts the step and kst_panel_run_poll() says how it
200 * ended. The run's start, held for 2s, is the operator's consent: no
201 * warning page is shown and the soft rules a value breaks are confirmed.
202 * The rest is the model's: the hard rules, the file the first write of a
203 * session saves (none for a later session of the run: kst_prog_run_hold()),
204 * the journal, the read back of every write.
205 */
206
213
216bool kst_panel_run_ready(void);
218void kst_panel_run_begin(void);
222kst_prog_msg_id_t kst_panel_run_connect(bool supply, uint16_t mv,
223 uint16_t ma);
226kst_prog_msg_id_t kst_panel_run_write(uint16_t left, uint16_t right);
234kst_prog_msg_id_t kst_panel_run_pulses(uint16_t lower_dus, uint16_t upper_dus);
248bool kst_panel_run_no_servo(void);
262bool kst_panel_run_servo(uint16_t angle[2], uint16_t *lo, uint16_t *hi,
263 bool *reversion, unsigned *type,
264 uint16_t pulse_dus[3]);
266const char *kst_panel_run_backup(void);
269void kst_panel_run_end(void);
270
271/* --- for the tests ------------------------------------------------------------ */
272
274
280 char out[KST_PANEL_MSG_LINES][KST_PANEL_LINE]);
281
290int kst_panel_text_rows(const char *s);
291
293const char *kst_panel_rule_text(unsigned rule);
294
295/*
296 * Where things are, for a test's taps. Rows by page, row and column. A
297 * coordinate no row has gives an empty rectangle (value, step), false (live)
298 * or NULL (button, label). Every control is UI_TAP_MIN (48px) tall or
299 * more and a control at the foot ends 4px above the alert band.
300 */
317gfx_rect_t kst_panel_value_rect(int page, int row, int col);
325gfx_rect_t kst_panel_step_rect(int page, int row, bool up);
341ui_keypad_t *kst_panel_keypad(void);
342ui_textkey_t *kst_panel_textkey(void);
343
346int kst_panel_editor(void);
347
349int kst_panel_page(void);
350
353const char *kst_panel_warning_line(int i);
356int kst_panel_warning_level(int i);
359const char *kst_panel_standing_line(int i);
361bool kst_panel_row_live(int page, int row, int col);
364const char *kst_panel_status_line(int i);
366const char *kst_panel_button(int page, int row, int col);
368const char *kst_panel_label(int page, int row, int col);
369const char *kst_panel_choice_label(int i);
371const char *kst_panel_choice_title(void);
372
390int kst_panel_pack_notes(const int *rows, const bool *standing, int count,
391 int room, int *page);
392
395int kst_panel_note_pages(void);
396
400
402int kst_panel_note_page(void);
403
405const char *kst_panel_shown_note(int i);
406
409
413
414#ifdef __cplusplus
415}
416#endif
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
const char * kst_panel_standing_line(int i)
Definition kst_panel_draw.c:155
kst_prog_t * kst_panel_model(void)
Gives the model the overlay holds.
Definition kst_panel_run.c:297
gfx_rect_t kst_panel_value_rect(int page, int row, int col)
A row's value: 150px, a wide row's 260px less its keys.
Definition kst_panel.c:416
void kst_panel_event(const touch_event_t *evt)
Definition kst_panel_touch.c:299
int kst_panel_shown_message_lines(void)
Definition kst_panel_draw.c:668
int kst_panel_text_rows(const char *s)
The rows of 10 x 20 cells a line of a message, a note or a warning page takes, wrapped at a space to ...
Definition kst_panel.c:303
bool kst_panel_take(kst_prog_cmd_t *out)
Takes the next command for the link task.
Definition kst_panel.c:703
bool kst_panel_card_take(kst_prog_card_req_t *out)
Definition kst_panel.c:721
uint32_t kst_panel_revision(void)
Definition kst_panel.c:601
int kst_panel_note_pages(void)
Definition kst_panel_draw.c:645
gfx_rect_t kst_panel_choice_cancel_rect(void)
A list's CANCEL, 150 x 48px at the foot's right.
Definition kst_panel.c:439
gfx_rect_t kst_panel_cancel_rect(void)
A warning page's CANCEL, 180 x 56px at the foot's right.
Definition kst_panel.c:452
int kst_panel_warning_level(int i)
Definition kst_panel.c:487
int kst_panel_message_lines(const kst_prog_msg_t *m, char out[KST_PANEL_MSG_LINES][KST_PANEL_LINE])
Definition kst_panel_text.c:325
const char * kst_panel_button(int page, int row, int col)
Definition kst_panel_draw.c:738
gfx_rect_t kst_panel_apply_rect(void)
A warning page's hold button, 300 x 56px at the foot's left.
Definition kst_panel.c:445
int kst_panel_editor(void)
Definition kst_panel.c:515
gfx_rect_t kst_panel_step_rect(int page, int row, bool up)
A stepped row's minus or plus key, 56 x 48px.
Definition kst_panel.c:423
void kst_panel_cancel(void)
Definition kst_panel_touch.c:314
uint8_t kst_panel_pin(void)
Definition kst_panel_touch.c:156
kst_prog_msg_id_t kst_panel_run_write(uint16_t left, uint16_t right)
Definition kst_panel_run.c:133
gfx_rect_t kst_panel_close_rect(void)
CLOSE, 120 x 48px at the top right.
Definition kst_panel.c:410
void kst_panel_run_end(void)
Definition kst_panel_run.c:280
#define KST_PANEL_MSG_LINES
Definition kst_panel.h:54
const prog_page_set_t kst_panel_pages
Definition kst_panel.c:761
bool kst_panel_file_late(const char *text, size_t len)
Definition kst_panel.c:752
void kst_panel_render(gfx_canvas_t *c)
Draws the overlay: the keypad or the keyboard alone while one is open, else the warning,...
Definition kst_panel_draw.c:904
bool kst_panel_safe_at(int x, int y)
Definition kst_panel_touch.c:147
void kst_panel_back(void)
Definition kst_panel_touch.c:134
gfx_rect_t kst_panel_choice_rect(int i)
A list's entry, 48px tall at a 56px pitch under the title.
Definition kst_panel.c:430
const char * kst_panel_status_line(int i)
Definition kst_panel_draw.c:266
void kst_panel_bench_armed(bool armed)
Definition kst_panel.c:708
const char * kst_panel_run_backup(void)
Definition kst_panel_run.c:263
bool kst_panel_card_look(void)
Definition kst_panel.c:713
bool kst_panel_run_servo(uint16_t angle[2], uint16_t *lo, uint16_t *hi, bool *reversion, unsigned *type, uint16_t pulse_dus[3])
The servo as read.
Definition kst_panel_run.c:224
bool kst_panel_holds_port(void)
Definition kst_panel.c:593
void kst_panel_close(void)
Definition kst_panel_touch.c:121
size_t kst_panel_file_take(char *out, size_t n)
Takes the name of the file the card is to hold; the text itself is copied into out.
Definition kst_panel.c:733
kst_prog_msg_id_t kst_panel_run_pulses(uint16_t lower_dus, uint16_t upper_dus)
Write PULSE LOWER and PULSE UPPER and nothing else; as kst_panel_run_write() otherwise.
Definition kst_panel_run.c:138
kst_prog_msg_id_t kst_panel_run_leave(void)
Definition kst_panel_run.c:151
bool kst_panel_run_ready(void)
Definition kst_panel_run.c:268
void kst_panel_file_done(bool ok)
Gives the model the result of the file write the card made.
Definition kst_panel.c:738
uint32_t kst_panel_hold_revision(void)
Definition kst_panel.c:606
void kst_panel_screen_entry(void)
Definition kst_panel.c:569
int kst_panel_note_page(void)
Definition kst_panel_draw.c:651
const char * kst_panel_label(int page, int row, int col)
Definition kst_panel.c:493
bool kst_panel_file_load(const char *text, size_t len)
Loads the text of a servo file the card read into the draft.
Definition kst_panel.c:744
const char * kst_panel_rule_text(unsigned rule)
Definition kst_panel_text.c:235
void kst_panel_leave(void)
Definition kst_panel_touch.c:325
void kst_panel_run_begin(void)
Definition kst_panel_run.c:273
bool kst_panel_run_no_servo(void)
Whether the CONNECT of kst_panel_run_connect() ended with no servo answering.
Definition kst_panel_run.c:216
void kst_panel_open(void)
Opens the overlay and reads the programmer's options from the settings.
Definition kst_panel.c:576
void kst_panel_init(gfx_rect_t area)
Definition kst_panel.c:543
void kst_panel_card_done(const kst_prog_card_done_t *done)
Gives the model the outcome of a card operation.
Definition kst_panel.c:726
int kst_panel_pack_notes(const int *rows, const bool *standing, int count, int room, int *page)
The page each of count notes takes in room rows.
Definition kst_panel_draw.c:367
kst_panel_run_t
Definition kst_panel.h:207
@ KST_PANEL_RUN_FAILED
Definition kst_panel.h:211
@ KST_PANEL_RUN_NONE
Definition kst_panel.h:208
@ KST_PANEL_RUN_OK
Definition kst_panel.h:210
void kst_panel_feed(const kst_prog_feed_t *f)
Gives the model the link task's feed for this frame and updates the overlay's revision.
Definition kst_panel.c:673
const char * kst_panel_warning_line(int i)
Definition kst_panel.c:482
bool kst_panel_row_live(int page, int row, int col)
Definition kst_panel_edit.c:554
const char * kst_panel_choice_title(void)
Definition kst_panel.c:500
gfx_rect_t kst_panel_notes_drawn(void)
Definition kst_panel_draw.c:674
void kst_panel_gate(kst_prog_gate_t *g)
Definition kst_panel.c:526
bool kst_panel_is_open(void)
Returns whether the overlay is open.
Definition kst_panel.c:588
gfx_rect_t kst_panel_notes_rect(void)
Definition kst_panel_draw.c:638
void kst_panel_tick(float dt_s)
Advances the overlay by one frame: the warning's hold and the key repeats.
Definition kst_panel_touch.c:333
int kst_panel_page(void)
Definition kst_panel.c:510
gfx_rect_t kst_panel_tab_rect(int page)
A tab, one fifth of the row left of CLOSE, 48px tall.
Definition kst_panel.c:405
kst_prog_msg_id_t kst_panel_run_connect(bool supply, uint16_t mv, uint16_t ma)
Definition kst_panel_run.c:38
bool kst_panel_has_press(uint8_t id)
Definition kst_panel_touch.c:286
kst_panel_run_t kst_panel_run_poll(void)
Reports how the limit run's step ended and takes the end.
Definition kst_panel_run.c:172
void kst_panel_set_hv(bool on)
Definition kst_panel.c:679
const char * kst_panel_shown_note(int i)
Definition kst_panel_draw.c:657
The programmer for KST and Chaservo servos as the SERVO screen runs it: what is read from a servo,...
unsigned kst_prog_msg_id_t
What the screen says.
Definition kst_prog.h:164
The registry of programmers and runs: one static table that the PROGRAM (and later TEST) lists of a w...
Definition gfx.h:129
Definition gfx.h:81
The card side's answer to a request.
Definition kst_prog.h:380
A request to the card side.
Definition kst_prog.h:366
One call for the task that owns the link module.
Definition kst_prog.h:421
What the task that owns the link module publishes, every frame.
Definition kst_prog.h:500
The pass a START needs to be carried out.
Definition kst_prog.h:441
The last message the programmer says, with its id, level and argument.
Definition kst_prog.h:288
The state of the servo programmer.
Definition kst_prog.h:536
Definition prog_registry.h:129
A DOWN, MOVE or UP of one contact.
Definition touch_types.h:69
A numeric keypad: what it was opened with, what is typed, and the press it holds.
Definition ui_keypad.h:61
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....
A numeric keypad over part of a screen, for a value a slider is too coarse to place.
An on-screen keyboard for a short name: capitals, digits, space and the marks a name or a file needs,...