|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The programmers' registry: the rows of SERVO's and MOTOR & ESC's PROGRAM lists, the list built from them and the view that draws it. More...
#include "prog_registry.h"#include <stdio.h>#include <string.h>#include "esc_profile.h"#include "esc_stick_panel.h"#include "hitec_panel.h"#include "kst_panel.h"#include "link_pages.h"#include "ui_layout.h"#include "ui_pinlist.h"#include "ui_theme.h"#include "ui_widgets.h"Functions | |
| void | prog_registry_set_ports (uint8_t tester_port, uint8_t held) |
| uint8_t | prog_reg_port (const prog_reg_row_t *r) |
| bool | prog_reg_servo_holds (void) |
| Whether a servo programmer holds a port: the KST programmer's session, or the Hitec programmer's, whose word counts a port the HITEC page names held by another session too. ARM, the motor's TARGET row and a run that arms the bench wait for neither. | |
| const prog_reg_row_t * | prog_registry (size_t *count) |
| void | prog_registry_use (const prog_reg_row_t *rows, size_t count) |
| static bool | hooks_filled (const prog_page_set_t *p) |
| static bool | filled (ui_text_id_t id) |
| static bool | same_list (const prog_reg_row_t *a, const prog_reg_row_t *b) |
| prog_reg_fault_t | prog_reg_check (const prog_reg_row_t *rows, size_t n, size_t *at) |
| int | prog_reg_sets (uint8_t device, const prog_page_set_t *out[PROG_LIST_MAX]) |
| bool | prog_reg_full_width (const prog_page_set_t *ps) |
| PROG_ONE_CALL void | prog_ps_init (const prog_page_set_t *ps, gfx_rect_t area) |
| PROG_ONE_CALL void | prog_ps_entry (const prog_page_set_t *ps) |
| PROG_ONE_CALL void | prog_ps_open (const prog_page_set_t *ps) |
| PROG_ONE_CALL bool | prog_ps_is_open (const prog_page_set_t *ps) |
| PROG_ONE_CALL void | prog_ps_back (const prog_page_set_t *ps) |
| PROG_ONE_CALL bool | prog_ps_holds (const prog_page_set_t *ps) |
| PROG_ONE_CALL void | prog_ps_armed (const prog_page_set_t *ps, bool armed) |
| PROG_ONE_CALL void | prog_ps_tick (const prog_page_set_t *ps, float dt_s) |
| PROG_ONE_CALL bool | prog_ps_has_press (const prog_page_set_t *ps, uint8_t id) |
| PROG_ONE_CALL void | prog_ps_event (const prog_page_set_t *ps, const touch_event_t *evt) |
| PROG_ONE_CALL void | prog_ps_render (const prog_page_set_t *ps, gfx_canvas_t *c) |
| PROG_ONE_CALL uint32_t | prog_ps_revision (const prog_page_set_t *ps) |
| PROG_ONE_CALL uint32_t | prog_ps_hold_revision (const prog_page_set_t *ps) |
| PROG_ONE_CALL gfx_rect_t | prog_ps_hold_rect (const prog_page_set_t *ps) |
| PROG_ONE_CALL void | prog_ps_leave (const prog_page_set_t *ps) |
| PROG_ONE_CALL void | prog_ps_cancel (const prog_page_set_t *ps) |
| PROG_ONE_CALL uint8_t | prog_ps_pin (const prog_page_set_t *ps) |
| PROG_ONE_CALL bool | prog_ps_safe_at (const prog_page_set_t *ps, int x, int y) |
| uint16_t | prog_reg_missing (const prog_reg_row_t *row, uint16_t caps) |
| prog_row_state_t | prog_reg_state (const prog_reg_row_t *rows, size_t n, size_t i, uint16_t caps) |
| const char * | prog_reg_cap_name (uint16_t bit) |
| bool | prog_reg_detail (const prog_reg_row_t *rows, size_t n, size_t i, uint16_t caps, char *out, size_t size) |
The text right of row i's name: for a live row on a port its number and the session's pin ("PROG PORT 2 GPIO 14", "PROG PORT
2" with the pin not known), its transport and the pin for any other ("PROG PORT GPIO 13", "PROG PORT" with the tester's port not known); its reason for a dimmed one ("IOMCU HAS NO SERVO PWM", "PORT IN USE"). | |
| void | prog_list_build (prog_list_t *l, const prog_reg_row_t *rows, size_t n, uint8_t device, uint8_t task, const char *query) |
| void | prog_view_init (prog_view_t *v, gfx_rect_t area) |
| void | prog_view_top (prog_view_t *v) |
| static int | entry_h (const prog_list_t *l, int k) |
| static int | room (const prog_view_t *v, bool bar) |
| The pitches the entries may add up to under the bar, if any: to PROG_VIEW_PAD above the area's foot or 4px above the alert band, whichever is higher, and a heading's 4px gap, the smaller one, so the last entry shown ends above that line. | |
| bool | prog_view_has_bar (const prog_view_t *v, const prog_list_t *l) |
| static int | shown_from (const prog_view_t *v, const prog_list_t *l, int top) |
| int | prog_view_shown (const prog_view_t *v, const prog_list_t *l) |
| static int | list_y (const prog_view_t *v, const prog_list_t *l) |
| gfx_rect_t | prog_view_entry_rect (const prog_view_t *v, const prog_list_t *l, int k) |
| gfx_rect_t | prog_view_search_rect (const prog_view_t *v, const prog_list_t *l) |
| SEARCH on the bar, PROG_VIEW_SEARCH_W wide from the left. | |
| static bool | pages (const prog_view_t *v, const prog_list_t *l) |
| gfx_rect_t | prog_view_up_rect (const prog_view_t *v, const prog_list_t *l) |
| "^" on the bar, PROG_VIEW_KEY_W wide, 8px left of "v". | |
| gfx_rect_t | prog_view_down_rect (const prog_view_t *v, const prog_list_t *l) |
| "v" on the bar, PROG_VIEW_KEY_W wide at the right. | |
| static int | page_up_top (const prog_view_t *v, const prog_list_t *l) |
| static int | hit (const prog_view_t *v, const prog_list_t *l, int x, int y) |
| prog_view_ev_t | prog_view_event (prog_view_t *v, const prog_list_t *l, const touch_event_t *evt, uint8_t *row) |
| void | prog_view_cancel (prog_view_t *v) |
| void | prog_view_render (const prog_view_t *v, const prog_list_t *l, const prog_reg_row_t *rows, size_t n, uint16_t caps, const char *query, gfx_canvas_t *c) |
Draws the list in PROG_VIEW_FONT: query in the SEARCH box ("SEARCH" while empty), each row's name and prog_reg_detail(), a live row with ">" at its right end, a dimmed one in the dim colour with its reason in the warning colour. | |
Variables | |
| static const prog_reg_row_t | k_rows [] |
| static const prog_reg_row_t * | s_rows = k_rows |
| static size_t | s_count = sizeof(k_rows) / sizeof(k_rows[0]) |
| static uint8_t | s_tester_port = PROG_REG_NO_PORT |
| static uint8_t | s_held |
| static const char *const | k_cap_name [] |
The programmers' registry: the rows of SERVO's and MOTOR & ESC's PROGRAM lists, the list built from them and the view that draws it.
SPDX-License-Identifier: MIT
| void prog_list_build | ( | prog_list_t * | l, |
| const prog_reg_row_t * | rows, | ||
| size_t | n, | ||
| uint8_t | device, | ||
| uint8_t | task, | ||
| const char * | query ) |
The list of device's task from n rows of rows, narrowed to the names query finds (esc_text_matches(): letters without regard to case, "*" any text; NULL or "" finds all). SEARCH stays offered while a search narrows the list. With headings, the groups come in the order the table first names them and the rows keep the table's order inside each. Rows past PROG_LIST_MAX are not listed.
| const char * prog_reg_cap_name | ( | uint16_t | bit | ) |
A capability bit's name as the link names it ("SERVO PWM"), the same in every language; "" for a bit with no name, or for 0.
| prog_reg_fault_t prog_reg_check | ( | const prog_reg_row_t * | rows, |
| size_t | n, | ||
| size_t * | at ) |
Checks n rows of rows: every field filled and in range, names in the language in force, no two rows of one list named alike, no list over PROG_LIST_MAX, each row laid out as its device's host draws it. The first fault found, with its row in at (may be NULL); PROG_REG_OK with at untouched for a sound table.
| bool prog_reg_detail | ( | const prog_reg_row_t * | rows, |
| size_t | n, | ||
| size_t | i, | ||
| uint16_t | caps, | ||
| char * | out, | ||
| size_t | size ) |
The text right of row i's name: for a live row on a port its number and the session's pin ("PROG PORT 2 GPIO 14", "PROG PORT
2" with the pin not known), its transport and the pin for any other ("PROG PORT GPIO 13", "PROG PORT" with the tester's port not known); its reason for a dimmed one ("IOMCU HAS NO SERVO PWM", "PORT IN USE").
| rows | the registry's rows |
| n | rows at rows |
| i | the row |
| caps | the IOmcu's capability bits |
| out | takes at most size - 1 characters |
| size | bytes at out |
| bool prog_reg_full_width | ( | const prog_page_set_t * | ps | ) |
Whether a row that opens ps is full width.
| uint16_t prog_reg_missing | ( | const prog_reg_row_t * | row, |
| uint16_t | caps ) |
The lowest link_cap_t bit row i needs and caps lacks; 0 none.
| uint8_t prog_reg_port | ( | const prog_reg_row_t * | r | ) |
Row r's port as it stands: its own, the tester's for PROG_REG_TESTER_PORT, or PROG_REG_NO_PORT.
| bool prog_reg_servo_holds | ( | void | ) |
Whether a servo programmer holds a port: the KST programmer's session, or the Hitec programmer's, whose word counts a port the HITEC page names held by another session too. ARM, the motor's TARGET row and a run that arms the bench wait for neither.
| int prog_reg_sets | ( | uint8_t | device, |
| const prog_page_set_t * | out[PROG_LIST_MAX] ) |
The page sets device's rows open, each once in the table's order, into out: at most PROG_LIST_MAX. Their count.
| prog_row_state_t prog_reg_state | ( | const prog_reg_row_t * | rows, |
| size_t | n, | ||
| size_t | i, | ||
| uint16_t | caps ) |
Row i of rows with the IOmcu reporting caps (link_cap_t).
| const prog_reg_row_t * prog_registry | ( | size_t * | count | ) |
The table, and its row count in count.
| void prog_registry_set_ports | ( | uint8_t | tester_port, |
| uint8_t | held ) |
The ports as the panel last read them: tester_port, the port the SERVO screen's tester drives (0 to 3), PROG_REG_NO_PORT with the standard outputs or the target not known; held, bit n for port n held by an IOmcu page no row's session drives (the HITEC page, opened from the bench console). Both start as none.
| void prog_registry_use | ( | const prog_reg_row_t * | rows, |
| size_t | count ) |
For the tests: the lists are built from count rows of rows; NULL goes back to the table as it ships.
| void prog_view_cancel | ( | prog_view_t * | v | ) |
Drop a press under way.
| gfx_rect_t prog_view_down_rect | ( | const prog_view_t * | v, |
| const prog_list_t * | l ) |
"v" on the bar, PROG_VIEW_KEY_W wide at the right.
| v | the view |
| l | the list it shows |
| gfx_rect_t prog_view_entry_rect | ( | const prog_view_t * | v, |
| const prog_list_t * | l, | ||
| int | k ) |
Entry k's rectangle, empty when it is not shown.
| prog_view_ev_t prog_view_event | ( | prog_view_t * | v, |
| const prog_list_t * | l, | ||
| const touch_event_t * | evt, | ||
| uint8_t * | row ) |
A touch event. "^" and "v" page the list themselves. A heading takes a press and does nothing. A row tap is reported whatever its state: the host opens a live row only (prog_reg_state()).
| bool prog_view_has_bar | ( | const prog_view_t * | v, |
| const prog_list_t * | l ) |
Whether the bar is drawn: SEARCH, or a list longer than the area.
| void prog_view_render | ( | const prog_view_t * | v, |
| const prog_list_t * | l, | ||
| const prog_reg_row_t * | rows, | ||
| size_t | n, | ||
| uint16_t | caps, | ||
| const char * | query, | ||
| gfx_canvas_t * | c ) |
Draws the list in PROG_VIEW_FONT: query in the SEARCH box ("SEARCH" while empty), each row's name and prog_reg_detail(), a live row with ">" at its right end, a dimmed one in the dim colour with its reason in the warning colour.
| v | the view |
| l | the list |
| rows | the registry's rows the list's entries index |
| n | their count |
| caps | the IOmcu's capabilities, for each row's state |
| query | the search typed, NULL or "" for none |
| c | the canvas |
| gfx_rect_t prog_view_search_rect | ( | const prog_view_t * | v, |
| const prog_list_t * | l ) |
SEARCH on the bar, PROG_VIEW_SEARCH_W wide from the left.
| v | the view |
| l | the list it shows |
| int prog_view_shown | ( | const prog_view_t * | v, |
| const prog_list_t * | l ) |
The entries shown from the top, at least 1 for a list that has one.
| void prog_view_top | ( | prog_view_t * | v | ) |
The list was rebuilt (a search, another language): back to its top.
| gfx_rect_t prog_view_up_rect | ( | const prog_view_t * | v, |
| const prog_list_t * | l ) |
"^" on the bar, PROG_VIEW_KEY_W wide, 8px left of "v".
| v | the view |
| l | the list it shows |
|
static |
The pitches the entries may add up to under the bar, if any: to PROG_VIEW_PAD above the area's foot or 4px above the alert band, whichever is higher, and a heading's 4px gap, the smaller one, so the last entry shown ends above that line.
| v | the view |
| bar | with the bar |
|
static |
|
static |