|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The overlay of the programmer for KST and Chaservo servos: its state, rows, shared helpers, geometry and the caller's side. More...
#include "kst_panel.h"#include <stdio.h>#include <string.h>#include "kst_card.h"#include "kst_port.h"#include "kst_reg.h"#include "link_pages.h"#include "settings.h"#include "ui_card_text.h"#include "ui_tabs.h"#include "ui_text.h"#include "ui_textkey.h"#include "ui_widgets.h"#include "kst_panel_int.h"Functions | |
| static card_state_t | card_state (void) |
| ui_text_id_t | kpn_card_text_id (ui_card_at_t at) |
The card's words for at, for the slot as the feed says it. | |
| const char * | kpn_card_tr (ui_card_at_t at) |
| The same words, translated. | |
| unsigned | kpn_ones (uint64_t v) |
The bits set in v. | |
| uint8_t | kpn_port_no (void) |
| The programming port the overlay works on: the SERVO screen's target, and the first port while that is the servo outputs. | |
| bool | kpn_on_port (void) |
| Whether the SERVO screen's tester drives a programming port. | |
| bool | kpn_flag (uint16_t f) |
Whether flag f is set in the port's report. | |
| bool | kpn_programming (void) |
| Whether the port is in programming. | |
| unsigned | kpn_servo_type (void) |
| The servo's type as the card names it; 0 without a servo. | |
| const char * | kpn_row_label (const row_t *r) |
| A row's label: its text, or for PORT and SERVO what they hold now. | |
| const char * | kpn_field_name (unsigned id) |
| The name a field has on its row; NULL for one without a row. | |
| bool | kpn_in_set (kst_field_set_t set, unsigned id) |
Whether field id is in set. | |
| const char * | kpn_unit_of (kst_field_id_t id) |
| A field's unit as its value shows it; "" for none. | |
| int | kpn_decimals_of (kst_field_id_t id) |
| Digits after the point a field's displayed value has. | |
| void | kpn_fmt_value (kst_field_id_t id, uint16_t raw, char *out, size_t n, bool unit) |
| A field's value as its row shows it. | |
| void | kpn_fmt_field (kst_field_id_t id, uint16_t raw, char *out, size_t n) |
| kpn_fmt_value() with the unit. | |
| bool | kpn_changed (kst_field_id_t id) |
Whether the draft holds another value of id than the servo. | |
| static int | text_cells (void) |
| The cells of KP_FONT a line of text has: the area less 10px on each side, 60 on SERVO's left card of 620px. | |
| static size_t | row_len (const char *s) |
| static const char * | next_row (const char *s, size_t len) |
| 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 the overlay's width less 10px a side, one cell a row at least (before kst_panel_init(), say): 60 cells a row on SERVO's left card of 620px. | |
| int | kpn_text_rows (gfx_canvas_t *c, int x, int y, const char *s, gfx_color_t color) |
s in rows of the area's width, a row each LINE_H. | |
| gfx_rect_t | kpn_tabs_rect (void) |
| The tabs. | |
| int | kpn_foot (void) |
| Where a control at the area's foot ends. | |
| int | kpn_notes_foot (void) |
| Where the notes and the message under a page end. | |
| gfx_rect_t | kpn_row_rect (const row_t *r) |
Row r, its label and its control. | |
| static gfx_rect_t | control_rect (const row_t *r) |
| gfx_rect_t | kpn_value_rect (const row_t *r) |
Row r's value, between its keys where it has them. | |
| gfx_rect_t | kpn_step_rect (const row_t *r, bool up) |
Row r's plus key (up) or minus key. | |
| const row_t * | kpn_row_at (int page, int row, int col) |
The row at (row, col) of page page, or NULL. | |
| gfx_rect_t | kst_panel_tab_rect (int page) |
| A tab, one fifth of the row left of CLOSE, 48px tall. | |
| gfx_rect_t | kst_panel_close_rect (void) |
| CLOSE, 120 x 48px at the top right. | |
| 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. | |
| gfx_rect_t | kst_panel_step_rect (int page, int row, bool up) |
| A stepped row's minus or plus key, 56 x 48px. | |
| gfx_rect_t | kst_panel_choice_rect (int i) |
| A list's entry, 48px tall at a 56px pitch under the title. | |
| gfx_rect_t | kst_panel_choice_cancel_rect (void) |
| A list's CANCEL, 150 x 48px at the foot's right. | |
| gfx_rect_t | kst_panel_apply_rect (void) |
| A warning page's hold button, 300 x 56px at the foot's left. | |
| gfx_rect_t | kst_panel_cancel_rect (void) |
| A warning page's CANCEL, 180 x 56px at the foot's right. | |
| ui_keypad_t * | kst_panel_keypad (void) |
| const char * | kpn_shown (const char *name) |
| A file name as a line shows it: whole up to KST_PANEL_NAME_TYPED characters, else its start and "..". | |
| ui_textkey_t * | kst_panel_textkey (void) |
| const char * | kst_panel_warning_line (int i) |
| int | kst_panel_warning_level (int i) |
| const char * | kst_panel_label (int page, int row, int col) |
| const char * | kst_panel_choice_title (void) |
| const char * | kst_panel_choice_label (int i) |
| int | kst_panel_page (void) |
| int | kst_panel_editor (void) |
| void | kst_panel_gate (kst_prog_gate_t *g) |
| static bool | holds_setting (setting_id_t id) |
| The settings that reach the port: what the tester drives and whether the port renders its pulse. Held while nothing but the programmer reaches the port. | |
| void | kst_panel_init (gfx_rect_t area) |
| static void | options_fresh (void) |
| The options are read where the settings are there: at a screen entry and at an opening, never at kst_panel_init(), which runs before the settings are loaded. A session keeps the values it began with, except one found running by a panel that has read none yet. | |
| void | kst_panel_screen_entry (void) |
| void | kst_panel_open (void) |
| Opens the overlay and reads the programmer's options from the settings. | |
| bool | kst_panel_is_open (void) |
| Returns whether the overlay is open. | |
| bool | kst_panel_holds_port (void) |
| uint32_t | kst_panel_revision (void) |
| uint32_t | kst_panel_hold_revision (void) |
| static uint32_t | signature (void) |
| Everything of the model a render shows, as one number. | |
| static void | model_moved (void) |
| Follows the model's state after a feed or an operation: closes editors that asked for the state they were opened in and counts the revision when the picture changes. | |
| 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. | |
| void | kst_panel_set_hv (bool on) |
| bool | kst_panel_take (kst_prog_cmd_t *out) |
| Takes the next command for the link task. | |
| void | kst_panel_bench_armed (bool armed) |
| bool | kst_panel_card_look (void) |
| bool | kst_panel_card_take (kst_prog_card_req_t *out) |
| void | kst_panel_card_done (const kst_prog_card_done_t *done) |
| Gives the model the outcome of a card operation. | |
| 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. | |
| void | kst_panel_file_done (bool ok) |
| Gives the model the result of the file write the card made. | |
| bool | kst_panel_file_load (const char *text, size_t len) |
| Loads the text of a servo file the card read into the draft. | |
| bool | kst_panel_file_late (const char *text, size_t len) |
Variables | |
| const row_t | kpn_rows [] |
| The overlay's rows, ROW_COUNT of them. | |
| static const ui_text_id_t | k_pages [PG_COUNT] |
| kst_panel_state_t | kst_panel_k |
| The state, kst_panel_k, in kst_panel.c, so its .bss stays where psram_bss.lf puts kst_panel's. The files read it as k, the name it had as the one file's static: the object's own name keeps it apart from every other screen's state. | |
| static kst_prog_gate_t * | s_gate |
| Not part of k: a start of the screens leaves it. | |
| const prog_page_set_t | kst_panel_pages |
The overlay of the programmer for KST and Chaservo servos: its state, rows, shared helpers, geometry and the caller's side.
The overlay of the programmer for KST and Chaservo servos. See kst_panel.h.
This file is the state, the rows, the helpers the other files share, the geometry, and the caller's side: the feed, the hooks and the page set. The texts are kst_panel_text.c, the warning pages kst_panel_warn.c, the editors kst_panel_edit.c, the presses kst_panel_touch.c, the limit run's sessions kst_panel_run.c and the drawing kst_panel_draw.c, with kst_panel_int.h between them.
SPDX-License-Identifier: MIT
| ui_text_id_t kpn_card_text_id | ( | ui_card_at_t | at | ) |
The card's words for at, for the slot as the feed says it.
| at | where the card is |
| const char * kpn_card_tr | ( | ui_card_at_t | at | ) |
The same words, translated.
| at | where the card is |
| bool kpn_changed | ( | kst_field_id_t | id | ) |
Whether the draft holds another value of id than the servo.
| id | the field |
| int kpn_decimals_of | ( | kst_field_id_t | id | ) |
Digits after the point a field's displayed value has.
| id | the field |
| const char * kpn_field_name | ( | unsigned | id | ) |
The name a field has on its row; NULL for one without a row.
| id | the field id |
| bool kpn_flag | ( | uint16_t | f | ) |
Whether flag f is set in the port's report.
| f | the flag |
| void kpn_fmt_field | ( | kst_field_id_t | id, |
| uint16_t | raw, | ||
| char * | out, | ||
| size_t | n ) |
kpn_fmt_value() with the unit.
| id | the field |
| raw | its raw value |
| out | the text |
| n | the size of out, bytes |
| void kpn_fmt_value | ( | kst_field_id_t | id, |
| uint16_t | raw, | ||
| char * | out, | ||
| size_t | n, | ||
| bool | unit ) |
A field's value as its row shows it.
| id | the field |
| raw | its raw value |
| out | the text |
| n | the size of out, bytes |
| unit | with the unit; without where a line gives it once behind two values |
| int kpn_foot | ( | void | ) |
Where a control at the area's foot ends.
| bool kpn_in_set | ( | kst_field_set_t | set, |
| unsigned | id ) |
Whether field id is in set.
| set | the set of fields |
| id | the field id |
| int kpn_notes_foot | ( | void | ) |
Where the notes and the message under a page end.
| bool kpn_on_port | ( | void | ) |
Whether the SERVO screen's tester drives a programming port.
| unsigned kpn_ones | ( | uint64_t | v | ) |
The bits set in v.
| v | the bit set |
| uint8_t kpn_port_no | ( | void | ) |
The programming port the overlay works on: the SERVO screen's target, and the first port while that is the servo outputs.
| bool kpn_programming | ( | void | ) |
Whether the port is in programming.
| const row_t * kpn_row_at | ( | int | page, |
| int | row, | ||
| int | col ) |
The row at (row, col) of page page, or NULL.
| page | the page |
| row | the row on the page |
| col | the column in the row |
| const char * kpn_row_label | ( | const row_t * | r | ) |
A row's label: its text, or for PORT and SERVO what they hold now.
| r | the row |
| gfx_rect_t kpn_row_rect | ( | const row_t * | r | ) |
Row r, its label and its control.
| r | the row |
| unsigned kpn_servo_type | ( | void | ) |
The servo's type as the card names it; 0 without a servo.
| const char * kpn_shown | ( | const char * | name | ) |
A file name as a line shows it: whole up to KST_PANEL_NAME_TYPED characters, else its start and "..".
| name | the file name |
| gfx_rect_t kpn_step_rect | ( | const row_t * | r, |
| bool | up ) |
Row r's plus key (up) or minus key.
| r | the row |
| up | true for the plus key, false for the minus key |
| gfx_rect_t kpn_tabs_rect | ( | void | ) |
The tabs.
| int kpn_text_rows | ( | gfx_canvas_t * | c, |
| int | x, | ||
| int | y, | ||
| const char * | s, | ||
| gfx_color_t | color ) |
s in rows of the area's width, a row each LINE_H.
| c | the canvas |
| x | the left edge, px |
| y | the top edge, px |
| s | the text |
| color | the text colour |
| const char * kpn_unit_of | ( | kst_field_id_t | id | ) |
A field's unit as its value shows it; "" for none.
| id | the field |
| gfx_rect_t kpn_value_rect | ( | const row_t * | r | ) |
Row r's value, between its keys where it has them.
| r | the row |
| gfx_rect_t kst_panel_apply_rect | ( | void | ) |
A warning page's hold button, 300 x 56px at the foot's left.
| void kst_panel_bench_armed | ( | bool | armed | ) |
The bench is armed or asked to arm: CONNECT and every operation that sends frames are refused with KST_PROG_MSG_NEED_DISARM. No screen takes an arm while kst_panel_holds_port(): ARM on the SERVO and MOTOR screens takes no press, and the ESC stick programmer starts no run.
| gfx_rect_t kst_panel_cancel_rect | ( | void | ) |
A warning page's CANCEL, 180 x 56px at the foot's right.
| void kst_panel_card_done | ( | const kst_prog_card_done_t * | done | ) |
Gives the model the outcome of a card operation.
| done | the outcome |
| bool kst_panel_card_look | ( | void | ) |
True once after the overlay was opened or one of its actions tapped with a feed: the caller, which has the card, looks at the slot, mounts a card put in or swapped and lets one taken out go.
| bool kst_panel_card_take | ( | kst_prog_card_req_t * | out | ) |
The servo files: a request for the task that has the card, and what it made of it (kst_card_run()).
| gfx_rect_t kst_panel_choice_cancel_rect | ( | void | ) |
A list's CANCEL, 150 x 48px at the foot's right.
| gfx_rect_t kst_panel_choice_rect | ( | int | i | ) |
A list's entry, 48px tall at a 56px pitch under the title.
| i | the entry, from 0 |
| const char * kst_panel_choice_title | ( | void | ) |
The open list's title; NULL while none is open.
| gfx_rect_t kst_panel_close_rect | ( | void | ) |
CLOSE, 120 x 48px at the top right.
| int kst_panel_editor | ( | void | ) |
What is open over the page: 0 none, 1 keypad, 2 choice list, 3 warning, 4 the keyboard for a file's name.
| 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.
| f | the feed |
| void kst_panel_file_done | ( | bool | ok | ) |
Gives the model the result of the file write the card made.
| ok | true when the card wrote the file |
| bool kst_panel_file_late | ( | const char * | text, |
| size_t | len ) |
The same for the file of a card mounted after the start. A record the model holds already stands, before and after the read that follows the interrupted write: the text is not used then, and false is returned with nothing said.
| bool kst_panel_file_load | ( | const char * | text, |
| size_t | len ) |
Loads the text of a servo file the card read into the draft.
| text | the file's text |
| len | the length of text, bytes |
| 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.
| out | buffer written to |
| n | size of out, bytes |
| void kst_panel_gate | ( | kst_prog_gate_t * | g | ) |
The gate the task that owns the link module claims each START at (kst_prog_gate_set()). Kept over kst_panel_init(). NULL for none.
| uint32_t kst_panel_hold_revision | ( | void | ) |
Changes while a warning's button fills; kst_panel_apply_rect() is where.
| bool kst_panel_holds_port | ( | void | ) |
The port is in programming, or moves: the overlay is shown.
| void kst_panel_init | ( | gfx_rect_t | area | ) |
Start over: closed, no servo, nothing stored. area is the overlay's.
| bool kst_panel_is_open | ( | void | ) |
Returns whether the overlay is open.
| const char * kst_panel_label | ( | int | page, |
| int | row, | ||
| int | col ) |
The label of the row at page, row, col as it is drawn now.
| int kst_panel_page | ( | void | ) |
The tab shown: 0 SERVO, 1 TUNE, 2 PULSE, 3 FAILSAFE, 4 LOCKED.
| uint32_t kst_panel_revision | ( | void | ) |
Changes whenever a render would show something else.
| void kst_panel_screen_entry | ( | void | ) |
The SERVO screen was entered: ENABLE WRITE TO SERVO goes off.
| void kst_panel_set_hv | ( | bool | on | ) |
HV SERVO of the SERVO screen: off, the programming voltage stays at or below KST_PANEL_STD_MV, and one set above it goes back to KST_PROG_SUPPLY_MV. On, it allows a voltage above KST_PANEL_STD_MV through the warning page and its hold; no such voltage is stored or loaded.
| gfx_rect_t kst_panel_step_rect | ( | int | page, |
| int | row, | ||
| bool | up ) |
A stepped row's minus or plus key, 56 x 48px.
| page | the tab |
| row | the row, from the top; column 0 |
| up | the plus key; else the minus key |
| gfx_rect_t kst_panel_tab_rect | ( | int | page | ) |
A tab, one fifth of the row left of CLOSE, 48px tall.
| page | the tab, PG_SERVO to PG_LOCKED; another is the first |
| bool kst_panel_take | ( | kst_prog_cmd_t * | out | ) |
Takes the next command for the link task.
| out | the command |
| 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 the overlay's width less 10px a side, one cell a row at least (before kst_panel_init(), say): 60 cells a row on SERVO's left card of 620px.
| s | the line |
| 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.
| page | the tab |
| row | the row, from the top |
| col | the column, 0 or 1 |
| int kst_panel_warning_level | ( | int | i | ) |
The level line i of the open warning page is drawn in: a kst_prog_level_t; KST_PROG_INFO past the last.
| const char * kst_panel_warning_line | ( | int | i | ) |
Line i of the open warning page, entry i of the open list; NULL past the last and while none is open.
|
static |
| const prog_page_set_t kst_panel_pages |
The session's hooks for its row on SERVO > PROGRAM.