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

The overlay of the programmer for servos by Hitec: its state, rows, geometry and the caller's side. See hitec_panel.h. More...

#include "hitec_panel.h"
#include <stdio.h>
#include <string.h>
#include "hitec_reg.h"
#include "settings.h"
#include "ui_tabs.h"
#include "ui_text.h"
#include "hitec_panel_int.h"

Macros

#define W_NAME   ((uint8_t)HITEC_P_COUNT)
 The classic model name row: no parameter of hitec_reg.

Functions

bool hpn_row_shown (const hpn_row_t *r)
 Whether row r is on the tab shown in the series and layout in use.
const hpn_row_t * hpn_row_at (int page, int row, int col)
 The row at (page, row, col) shown now, or NULL.
gfx_rect_t hpn_tabs_rect (void)
 The tabs' row.
int hpn_foot (void)
 Where a control at the foot ends: 8px above the area's foot, and HP_FOOT_GAP above the alert band at the most.
int hpn_notes_foot (void)
 Where the notes end: 6px above the area's foot, and HP_FOOT_GAP above the alert band at the most.
gfx_rect_t hpn_row_rect (const hpn_row_t *r)
 Row r's whole rectangle.
gfx_rect_t hpn_value_rect (const hpn_row_t *r)
 Row r's control.
int hpn_cells (void)
 The cells of HP_FONT a note's row has: the area less 10px a side.
static size_t row_len (const char *s)
 The bytes of s its first row takes: all of it where it fits, else up to the last space that leaves the row no wider than the line; a word longer than the line is cut.
static const char * next_row (const char *s, size_t len)
 The start of the row after one of len bytes at s.
int hitec_panel_text_rows (const char *s)
 The rows of 10 x 20 cells a line takes, wrapped at a space to the overlay's width less 10px a side: 60 cells on SERVO's left card.
int hpn_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 from (x, y).
gfx_rect_t hitec_panel_tab_rect (int page)
 A tab, one fifth of the row left of CLOSE, 48px tall.
gfx_rect_t hitec_panel_close_rect (void)
 CLOSE, 120 x 48px at the top right.
gfx_rect_t hitec_panel_value_rect (int page, int row, int col)
 The control of a row: a button, or the box of a value.
gfx_rect_t hitec_panel_choice_rect (int i)
 Entry i of the open list, 48px tall at a 56px pitch.
gfx_rect_t hitec_panel_choice_cancel_rect (void)
 A list's CANCEL, 150 x 48px at the foot's right.
gfx_rect_t hitec_panel_apply_rect (void)
 A hold page's button, 300 x 56px at the foot's left.
gfx_rect_t hitec_panel_cancel_rect (void)
 A hold page's CANCEL, 180 x 56px at the foot's right.
hitec_prog_t * hitec_panel_model (void)
 The model.
ui_keypad_t * hitec_panel_keypad (void)
 The keypad.
const char * hitec_panel_label (int page, int row, int col)
 The label of a row as it is drawn now.
const char * hitec_panel_value (int page, int row, int col)
 The text in the control of a row: a button's, or the value.
bool hitec_panel_row_live (int page, int row, int col)
 Whether the control of a row takes a tap now.
const char * hitec_panel_port_line (int i)
 Line i of the PORT row's label: 0 the port, the pin and the series, 1 the receive mode and the supply CONNECT asks.
int hitec_panel_editor (void)
 What is open over the page.
int hitec_panel_page (void)
 The tab shown.
const char * hitec_panel_choice_label (int i)
 The open list's entry i.
const char * hitec_panel_page_line (int i)
 Line i of the open hold page, its title first.
void hitec_panel_gate (hitec_prog_gate_t *g)
 The gate the link task claims each command at; kept over hitec_panel_init(). NULL for none.
void hitec_panel_init (gfx_rect_t area)
 Start over: closed, nothing held, laid out in area.
static void options_fresh (void)
 The options from the settings where they are loaded: at a screen entry and at an opening, not at hitec_panel_init(), which runs before the settings are loaded. A session keeps what it began with.
void hitec_panel_screen_entry (void)
 The SERVO screen was entered: the options are read from the settings, and ENABLE WRITE TO SERVO goes off.
void hitec_panel_open (void)
 Opens the overlay.
bool hitec_panel_is_open (void)
 Whether the overlay is open.
bool hitec_panel_holds_port (void)
 A port is held, by this panel or another session, or a request is on its way: the overlay is shown, no other row on the port opens and the bench takes no arm.
uint8_t hitec_panel_pin (void)
 The GPIO the port the overlay names drives.
bool hitec_panel_safe_at (int x, int y)
 None of the session's controls stops what the bench drives: it works on a SAFE bench only. Always false.
uint32_t hitec_panel_revision (void)
 Changes whenever a render would show something else.
uint32_t hitec_panel_hold_revision (void)
 Changes while a page's hold fills; hitec_panel_apply_rect() is where.
static uint32_t signature (void)
 Everything of the model a render shows, as one number.
void hpn_moved (void)
 The state changed or an operation started: editors that asked for the state they were opened in close and the revision counts.
void hitec_panel_feed (const hitec_prog_feed_t *f)
 The link task's feed for this frame.
bool hitec_panel_take (hitec_prog_cmd_t *out)
 The next command for the link task.
void hitec_panel_bench_armed (bool armed)
 The bench is armed or asked to arm: CONNECT, READ ALL and every write are refused.
size_t hitec_panel_file_take (char *out, size_t n)
 The record's text for the card (hitec_prog_file_take()).
void hitec_panel_file_done (bool ok)
 How the card took it (hitec_prog_file_done()).
bool hitec_panel_file_load (const char *text, size_t len)
 The record's text as the card held it at the start (hitec_prog_file_load()).

Variables

const hpn_row_t hpn_rows []
 The rows of every tab and both series; hitec_panel_int.h.
static const ui_text_id_t k_tabs [HITEC_PANEL_PAGES]
 The tabs' labels.
hpn_state_t hitec_panel_h
 The state, in hitec_panel.c; the files read it as hp.
static hitec_prog_gate_t * s_gate
 Not part of hp: a start of the screens leaves it.
const prog_page_set_t hitec_panel_pages
 The session's hooks for its row on SERVO > PROGRAM.

Detailed Description

The overlay of the programmer for servos by Hitec: its state, rows, geometry and the caller's side. See hitec_panel.h.

Hitec is a name or trademark of its owner; it is used here only to say which servos this overlay works with.

The texts are hitec_panel_text.c, the actions and editors hitec_panel_edit.c, the presses hitec_panel_touch.c and the drawing hitec_panel_draw.c, with hitec_panel_int.h between them.

SPDX-License-Identifier: MIT

Function Documentation

◆ hitec_panel_apply_rect()

gfx_rect_t hitec_panel_apply_rect ( void )

A hold page's button, 300 x 56px at the foot's left.

Returns
its rectangle

◆ hitec_panel_bench_armed()

void hitec_panel_bench_armed ( bool armed)

The bench is armed or asked to arm: CONNECT, READ ALL and every write are refused.

Parameters
armedtrue while it is

◆ hitec_panel_cancel_rect()

gfx_rect_t hitec_panel_cancel_rect ( void )

A hold page's CANCEL, 180 x 56px at the foot's right.

Returns
its rectangle

◆ hitec_panel_choice_cancel_rect()

gfx_rect_t hitec_panel_choice_cancel_rect ( void )

A list's CANCEL, 150 x 48px at the foot's right.

Returns
its rectangle

◆ hitec_panel_choice_label()

const char * hitec_panel_choice_label ( int i)

The open list's entry i.

Parameters
ithe entry
Returns
its label; NULL past the last or with no list open

◆ hitec_panel_choice_rect()

gfx_rect_t hitec_panel_choice_rect ( int i)

Entry i of the open list, 48px tall at a 56px pitch.

Parameters
ithe entry
Returns
its rectangle

◆ hitec_panel_close_rect()

gfx_rect_t hitec_panel_close_rect ( void )

CLOSE, 120 x 48px at the top right.

Returns
its rectangle

◆ hitec_panel_editor()

int hitec_panel_editor ( void )

What is open over the page.

Returns
0 none, 1 keypad, 2 choice list, 3 a hold page

◆ hitec_panel_feed()

void hitec_panel_feed ( const hitec_prog_feed_t * f)

The link task's feed for this frame.

Parameters
fthe feed

◆ hitec_panel_file_done()

void hitec_panel_file_done ( bool ok)

How the card took it (hitec_prog_file_done()).

Parameters
oktrue when the card holds it whole

◆ hitec_panel_file_load()

bool hitec_panel_file_load ( const char * text,
size_t len )

The record's text as the card held it at the start (hitec_prog_file_load()).

Parameters
textthe text
lenits length in bytes
Returns
false for a text that does not parse

◆ hitec_panel_file_take()

size_t hitec_panel_file_take ( char * out,
size_t n )

The record's text for the card (hitec_prog_file_take()).

Parameters
outreceives the text
nbytes at out
Returns
its length; 0 for none

◆ hitec_panel_gate()

void hitec_panel_gate ( hitec_prog_gate_t * g)

The gate the link task claims each command at; kept over hitec_panel_init(). NULL for none.

Parameters
gthe gate

◆ hitec_panel_hold_revision()

uint32_t hitec_panel_hold_revision ( void )

Changes while a page's hold fills; hitec_panel_apply_rect() is where.

Returns
the hold's revision

◆ hitec_panel_holds_port()

bool hitec_panel_holds_port ( void )

A port is held, by this panel or another session, or a request is on its way: the overlay is shown, no other row on the port opens and the bench takes no arm.

Returns
true while held

◆ hitec_panel_init()

void hitec_panel_init ( gfx_rect_t area)

Start over: closed, nothing held, laid out in area.

Parameters
areathe overlay's area, body pixels

◆ hitec_panel_is_open()

bool hitec_panel_is_open ( void )

Whether the overlay is open.

Returns
true when open

◆ hitec_panel_keypad()

ui_keypad_t * hitec_panel_keypad ( void )

The keypad.

Returns
the overlay's keypad

◆ hitec_panel_label()

const char * hitec_panel_label ( int page,
int row,
int col )

The label of a row as it is drawn now.

Parameters
pagethe tab
rowthe row
colthe column
Returns
the label; NULL for no row there

◆ hitec_panel_model()

hitec_prog_t * hitec_panel_model ( void )

The model.

Returns
the programmer's state

◆ hitec_panel_page()

int hitec_panel_page ( void )

The tab shown.

Returns
hitec_panel_page_t

◆ hitec_panel_page_line()

const char * hitec_panel_page_line ( int i)

Line i of the open hold page, its title first.

Parameters
ithe line
Returns
the line; NULL past the last or with no page open

◆ hitec_panel_pin()

uint8_t hitec_panel_pin ( void )

The GPIO the port the overlay names drives.

Returns
the pin, or PROG_REG_NO_PIN

◆ hitec_panel_port_line()

const char * hitec_panel_port_line ( int i)

Line i of the PORT row's label: 0 the port, the pin and the series, 1 the receive mode and the supply CONNECT asks.

Parameters
ithe line
Returns
the line; NULL past the last

◆ hitec_panel_revision()

uint32_t hitec_panel_revision ( void )

Changes whenever a render would show something else.

Returns
the revision

◆ hitec_panel_row_live()

bool hitec_panel_row_live ( int page,
int row,
int col )

Whether the control of a row takes a tap now.

Parameters
pagethe tab
rowthe row
colthe column
Returns
true when live

◆ hitec_panel_safe_at()

bool hitec_panel_safe_at ( int x,
int y )

None of the session's controls stops what the bench drives: it works on a SAFE bench only. Always false.

Parameters
xthe column, px
ythe row, px
Returns
false

◆ hitec_panel_tab_rect()

gfx_rect_t hitec_panel_tab_rect ( int page)

A tab, one fifth of the row left of CLOSE, 48px tall.

Parameters
pagehitec_panel_page_t
Returns
its rectangle

◆ hitec_panel_take()

bool hitec_panel_take ( hitec_prog_cmd_t * out)

The next command for the link task.

Parameters
outthe command
Returns
true when one was taken

◆ hitec_panel_text_rows()

int hitec_panel_text_rows ( const char * s)

The rows of 10 x 20 cells a line takes, wrapped at a space to the overlay's width less 10px a side: 60 cells on SERVO's left card.

Parameters
sthe line
Returns
its rows, 0 for an empty line

◆ hitec_panel_value()

const char * hitec_panel_value ( int page,
int row,
int col )

The text in the control of a row: a button's, or the value.

Parameters
pagethe tab
rowthe row
colthe column
Returns
the text; NULL for no row there

◆ hitec_panel_value_rect()

gfx_rect_t hitec_panel_value_rect ( int page,
int row,
int col )

The control of a row: a button, or the box of a value.

Parameters
pagethe tab
rowthe row, from the top
colthe column, 0 or 1
Returns
its rectangle; empty for no row there in the series shown

◆ hpn_cells()

int hpn_cells ( void )

The cells of HP_FONT a note's row has: the area less 10px a side.

Returns
the cells, 1 at least

◆ hpn_foot()

int hpn_foot ( void )

Where a control at the foot ends: 8px above the area's foot, and HP_FOOT_GAP above the alert band at the most.

Returns
the y, body pixels

◆ hpn_notes_foot()

int hpn_notes_foot ( void )

Where the notes end: 6px above the area's foot, and HP_FOOT_GAP above the alert band at the most.

Returns
the y, body pixels

◆ hpn_row_at()

const hpn_row_t * hpn_row_at ( int page,
int row,
int col )

The row at (page, row, col) shown now, or NULL.

Parameters
pagethe tab
rowthe row
colthe column
Returns
the row

◆ hpn_row_rect()

gfx_rect_t hpn_row_rect ( const hpn_row_t * r)

Row r's whole rectangle.

Parameters
rthe row
Returns
the rectangle

◆ hpn_row_shown()

bool hpn_row_shown ( const hpn_row_t * r)

Whether row r is on the tab shown in the series and layout in use.

Parameters
rthe row
Returns
true when shown

◆ hpn_tabs_rect()

gfx_rect_t hpn_tabs_rect ( void )

The tabs' row.

Returns
its rectangle

◆ hpn_text_rows()

int hpn_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 from (x, y).

Parameters
cthe canvas
xthe left, px
ythe top, px
sthe text
colorits colour
Returns
the y under the last row

◆ hpn_value_rect()

gfx_rect_t hpn_value_rect ( const hpn_row_t * r)

Row r's control.

Parameters
rthe row
Returns
the rectangle

◆ next_row()

const char * next_row ( const char * s,
size_t len )
static

The start of the row after one of len bytes at s.

Parameters
sthe row
lenits bytes
Returns
the next row

◆ row_len()

size_t row_len ( const char * s)
static

The bytes of s its first row takes: all of it where it fits, else up to the last space that leaves the row no wider than the line; a word longer than the line is cut.

Parameters
sthe text
Returns
the bytes

Variable Documentation

◆ hitec_panel_pages

const prog_page_set_t hitec_panel_pages
Initial value:
= {
.is_open = hitec_panel_is_open,
.holds_port = hitec_panel_holds_port,
.has_press = hitec_panel_has_press,
.render = hitec_panel_render,
.revision = hitec_panel_revision,
.hold_revision = hitec_panel_hold_revision,
.hold_rect = hitec_panel_apply_rect,
.cancel = hitec_panel_cancel,
.safe_at = hitec_panel_safe_at,
}
bool hitec_panel_holds_port(void)
A port is held, by this panel or another session, or a request is on its way: the overlay is shown,...
Definition hitec_panel.c:443
bool hitec_panel_safe_at(int x, int y)
None of the session's controls stops what the bench drives: it works on a SAFE bench only....
Definition hitec_panel.c:455
void hitec_panel_init(gfx_rect_t area)
Start over: closed, nothing held, laid out in area.
Definition hitec_panel.c:397
gfx_rect_t hitec_panel_apply_rect(void)
A hold page's button, 300 x 56px at the foot's left.
Definition hitec_panel.c:306
uint8_t hitec_panel_pin(void)
The GPIO the port the overlay names drives.
Definition hitec_panel.c:448
void hitec_panel_bench_armed(bool armed)
The bench is armed or asked to arm: CONNECT, READ ALL and every write are refused.
Definition hitec_panel.c:535
bool hitec_panel_is_open(void)
Whether the overlay is open.
Definition hitec_panel.c:438
uint32_t hitec_panel_hold_revision(void)
Changes while a page's hold fills; hitec_panel_apply_rect() is where.
Definition hitec_panel.c:469
void hitec_panel_open(void)
Opens the overlay.
Definition hitec_panel.c:429
uint32_t hitec_panel_revision(void)
Changes whenever a render would show something else.
Definition hitec_panel.c:464
void hitec_panel_screen_entry(void)
The SERVO screen was entered: the options are read from the settings, and ENABLE WRITE TO SERVO goes ...
Definition hitec_panel.c:421
void hitec_panel_render(gfx_canvas_t *c)
Draws the overlay.
Definition hitec_panel_draw.c:455
void hitec_panel_leave(void)
The screen is left: presses and editors go; the port stays.
Definition hitec_panel_touch.c:251
bool hitec_panel_has_press(uint8_t id)
Whether a press that began in the overlay is on the glass.
Definition hitec_panel_touch.c:211
void hitec_panel_back(void)
The home tag or BACK: an editor closes as its CANCEL does, otherwise as hitec_panel_close().
Definition hitec_panel_touch.c:114
void hitec_panel_cancel(void)
Touch events were lost: the press and its hold are dropped.
Definition hitec_panel_touch.c:241
void hitec_panel_event(const touch_event_t *evt)
A press in the overlay's area, or the rest of one it owns.
Definition hitec_panel_touch.c:226
void hitec_panel_tick(float dt_s)
One frame: the hold of a page.
Definition hitec_panel_touch.c:258

The session's hooks for its row on SERVO > PROGRAM.

◆ hpn_rows

const hpn_row_t hpn_rows[]

The rows of every tab and both series; hitec_panel_int.h.

The rows, in hitec_panel.c.

The rows of every tab and both series; hitec_panel_int.h.

◆ k_tabs

const ui_text_id_t k_tabs[HITEC_PANEL_PAGES]
static
Initial value:
= {
TX_KP_TAB_SERVO, TX_HP_TAB_MOTION, TX_HP_TAB_TRAVEL, TX_HP_TAB_PROTECT,
TX_HP_TAB_INFO,
}

The tabs' labels.