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

The overlay of the programmer for servos by Hitec on SERVO: its interface. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "gfx.h"
#include "hitec_prog.h"
#include "prog_registry.h"
#include "touch_types.h"
#include "ui_keypad.h"

Go to the source code of this file.

Macros

#define HITEC_PANEL_MSG_LINES   2
 Lines a message takes at most, and the bytes of one.
#define HITEC_PANEL_LINE   128
 The bytes of one line of a message, a note or a page.

Enumerations

enum  hitec_panel_page_t {
  HITEC_PANEL_SERVO = 0 , HITEC_PANEL_MOTION , HITEC_PANEL_TRAVEL , HITEC_PANEL_PROTECT ,
  HITEC_PANEL_INFO , HITEC_PANEL_PAGES
}
 The tabs.

Functions

void hitec_panel_init (gfx_rect_t area)
 Start over: closed, nothing held, laid out in area.
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.
void hitec_panel_close (void)
 CLOSE: closes while the port is not held; asks for LEAVE on this panel's port and for RELEASE PORT on another's.
void hitec_panel_back (void)
 The home tag or BACK: an editor closes as its CANCEL does, otherwise as hitec_panel_close().
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.
void hitec_panel_leave (void)
 The screen is left: presses and editors go; the port stays.
void hitec_panel_cancel (void)
 Touch events were lost: the press and its hold are dropped.
void hitec_panel_tick (float dt_s)
 One frame: the hold of a page.
bool hitec_panel_has_press (uint8_t id)
 Whether a press that began in the overlay is on the glass.
void hitec_panel_event (const touch_event_t *evt)
 A press in the overlay's area, or the rest of one it owns.
void hitec_panel_render (gfx_canvas_t *c)
 Draws the overlay.
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.
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_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_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()).
hitec_prog_t * hitec_panel_model (void)
 The model.
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.
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.
const char * hitec_panel_note (int i)
 The note lines of the tab shown, from the top, the message's lines after them.
gfx_rect_t hitec_panel_notes_drawn (void)
 The rows the notes and the message of the tab shown take, from the first note's top to the last line's foot.
int hitec_panel_message_lines (const hitec_prog_msg_t *m, char out[HITEC_PANEL_MSG_LINES][HITEC_PANEL_LINE])
 A message's lines, in the language in force.
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 hitec_panel_editor (void)
 What is open over the page.
int hitec_panel_page (void)
 The tab shown.
gfx_rect_t hitec_panel_choice_rect (int i)
 Entry i of the open list, 48px tall at a 56px pitch.
const char * hitec_panel_choice_label (int i)
 The open list's entry i.
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.
const char * hitec_panel_page_line (int i)
 Line i of the open hold page, its title first.
ui_keypad_t * hitec_panel_keypad (void)
 The keypad.

Variables

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 on SERVO: its interface.

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

A session over the SERVO screen's left column, opened from its row on SERVO > PROGRAM (prog_registry.h) one level down. It draws hitec_prog.h's model and turns touches into its calls. Its controls are the screen's: tabs, rows, the number keypad, the choice list and a page whose button is held UI_HOLD_S.

Five tabs. SERVO: the port and the pin it drives, the series, the read, the programming voltage and current, CLEAR after a stop. MOTION, TRAVEL, PROTECT and INFO: the servo's values, the rows of the series in use; a decoded value shows its stored value beside it, and a stored value that fits no encoding shows raw. A writable value takes a tap: its list or the keypad edits the draft, and an edit is marked *. The SERVO tab's ENABLE WRITE TO SERVO, WRITE n VALUES and RESTORE and MORE's REPAIR CHECKSUM write to the servo, each from a page held UI_HOLD_S (hitec_prog.h).

The overlay stays open while the port is held, by this panel or by another session: PWM and programming are exclusive states of the pin, and CLOSE asks for LEAVE, or for RELEASE PORT, first.

The panel's control task owns the link. It hands this a feed every frame and takes the commands.

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

void hitec_panel_event ( const touch_event_t * evt)

A press in the overlay's area, or the rest of one it owns.

Parameters
evtthe event

◆ 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_has_press()

bool hitec_panel_has_press ( uint8_t id)

Whether a press that began in the overlay is on the glass.

Parameters
idthe touch id
Returns
true for the overlay's press

◆ 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_message_lines()

int hitec_panel_message_lines ( const hitec_prog_msg_t * m,
char out[HITEC_PANEL_MSG_LINES][HITEC_PANEL_LINE] )

A message's lines, in the language in force.

Parameters
mthe message
outreceives the lines
Returns
the lines used, 0 for no message

◆ hitec_panel_model()

hitec_prog_t * hitec_panel_model ( void )

The model.

Returns
the programmer's state

◆ hitec_panel_note()

const char * hitec_panel_note ( int i)

The note lines of the tab shown, from the top, the message's lines after them.

Parameters
ithe line
Returns
the line; NULL past the last

◆ hitec_panel_notes_drawn()

gfx_rect_t hitec_panel_notes_drawn ( void )

The rows the notes and the message of the tab shown take, from the first note's top to the last line's foot.

Returns
the rectangle; 0 high when nothing is drawn

◆ 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_render()

void hitec_panel_render ( gfx_canvas_t * c)

Draws the overlay.

Parameters
cthe canvas

◆ 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_tick()

void hitec_panel_tick ( float dt_s)

One frame: the hold of a page.

Parameters
dt_sthe time since the last frame, s

◆ 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