rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
prog_registry.c File Reference

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 []

Detailed Description

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

Function Documentation

◆ prog_list_build()

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.

◆ prog_reg_cap_name()

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_check()

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.

◆ prog_reg_detail()

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").

Parameters
rowsthe registry's rows
nrows at rows
ithe row
capsthe IOmcu's capability bits
outtakes at most size - 1 characters
sizebytes at out
Returns
whether the row is dimmed

◆ prog_reg_full_width()

bool prog_reg_full_width ( const prog_page_set_t * ps)

Whether a row that opens ps is full width.

◆ prog_reg_missing()

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.

◆ prog_reg_port()

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.

◆ prog_reg_servo_holds()

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.

Returns
true while either holds one

◆ prog_reg_sets()

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_reg_state()

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).

◆ prog_registry()

const prog_reg_row_t * prog_registry ( size_t * count)

The table, and its row count in count.

◆ prog_registry_set_ports()

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.

◆ prog_registry_use()

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.

◆ prog_view_cancel()

void prog_view_cancel ( prog_view_t * v)

Drop a press under way.

◆ prog_view_down_rect()

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.

Parameters
vthe view
lthe list it shows
Returns
its rectangle; empty when the list does not page

◆ prog_view_entry_rect()

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_event()

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()).

◆ prog_view_has_bar()

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.

◆ prog_view_render()

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.

Parameters
vthe view
lthe list
rowsthe registry's rows the list's entries index
ntheir count
capsthe IOmcu's capabilities, for each row's state
querythe search typed, NULL or "" for none
cthe canvas

◆ prog_view_search_rect()

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.

Parameters
vthe view
lthe list it shows
Returns
its rectangle; empty when not drawn

◆ prog_view_shown()

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.

◆ prog_view_top()

void prog_view_top ( prog_view_t * v)

The list was rebuilt (a search, another language): back to its top.

◆ prog_view_up_rect()

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".

Parameters
vthe view
lthe list it shows
Returns
its rectangle; empty when the list does not page

◆ room()

int room ( const prog_view_t * v,
bool bar )
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.

Parameters
vthe view
barwith the bar
Returns
the height, px

Variable Documentation

◆ k_cap_name

const char* const k_cap_name[]
static
Initial value:
= {
"ESC DRIVE", "ESC TELEMETRY", "SERVO PWM", "SERVO SENSE", "PACK SENSE",
"RECEIVER", "VIBRATION", "CELLS", "PROGRAM",
}

◆ k_rows

const prog_reg_row_t k_rows[]
static
Initial value:
= {
{ PROG_DEV_SERVO, UI_WB_PROGRAM, TX_PL_KST, TX_PL_GRP_PROG_PORT,
&kst_panel_pages, false },
{ PROG_DEV_SERVO, UI_WB_PROGRAM, TX_PL_HITEC, TX_PL_GRP_PROG_PORT,
&hitec_panel_pages, false },
{ PROG_DEV_MOTOR, UI_WB_PROGRAM, TX_PL_STICK, TX_PL_GRP_STICK,
TX_MO_SET_THROTTLE, PROG_REG_NO_PORT, 0u, &esc_stick_pages, true },
}
const prog_page_set_t esc_stick_pages
Definition esc_stick_pages.c:252
const prog_page_set_t hitec_panel_pages
The session's hooks for its row on SERVO > PROGRAM.
Definition hitec_panel.c:560
const prog_page_set_t kst_panel_pages
Definition kst_panel.c:761
#define PROG_REG_TESTER_PORT
Definition prog_registry.h:86
#define PROG_REG_NO_PORT
Definition prog_registry.h:78