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

The seam between the files of the Hitec programmer's overlay. More...

#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "gfx.h"
#include "hitec_panel.h"
#include "hitec_prog.h"
#include "touch_types.h"
#include "ui_keypad.h"
#include "ui_layout.h"
#include "ui_tabs.h"
#include "ui_text.h"
#include "ui_widgets.h"

Go to the source code of this file.

Data Structures

struct  hpn_row_t
 One row: where it sits, what it shows, what it is called. More...
struct  hpn_state_t
 The overlay's state. More...

Macros

#define HP_TAB_Y   8
 The overlay's layout, in pixels from the area's top left, the KST overlay's: on SERVO's left card of 620px five tabs of 95px and CLOSE of 120px in one row 48px tall, rows 48px tall at a 56px pitch, two columns of 295px, a button or value of 150px, a wide row's of 260px. Every control ends at hpn_foot().
#define HP_TAB_H   UI_TAP_MIN
#define HP_CLOSE_W   120
#define HP_ROW0   64
#define HP_PITCH   56
#define HP_ROW_H   UI_TAP_MIN
#define HP_VAL_W   150
#define HP_WIDE_W   260
#define HP_WRITE_W   220
 WRITE n VALUES, a row with no label: 22 cells, "20 WERTE SCHREIBEN" and room.
#define HP_FONT   (&gfx_font_10x20)
 The face of labels, buttons, values, notes and pages' lines: the type scale's LABEL face, 10 x 20.
#define HP_TITLE_FONT   (&gfx_font_20x36)
 A hold page's title: the HEAD face, 20 x 36.
#define HP_CELL   10
#define HP_LINE_H   20
#define HP_FOOT_GAP   4
 The space between a control at the foot and the alert band.
#define HP_PAGE_TOP   64
 A hold page's first line: under its title, 36px from 16px, and 12px.
#define HP_PAGE_LINES   12
 The lines a hold page holds.
#define HP_PAGE_VALUES   6
 The changed values a write page lists, the count of the rest after them.
#define HP_CHOICE_MAX   6
 The entries a list holds: OVERLOAD PROTECTION's OFF and 10% to 50%.
#define HP_ROW_COUNT   43
 The rows' count.
#define HP_FS_POSITION   (-1)
 A D series FAILSAFE list's POSITION: its keypad follows.
#define hp   hitec_panel_h
 Short name for hitec_panel_h inside the overlay's files.

Enumerations

enum  { K_ACT = 0 , K_SHOW }
 What a row is.
enum  {
  A_PORT = 0 , A_SERIES , A_READ , A_MORE ,
  A_CLEAR , A_ENABLE , A_RESTORE , A_WRITE
}
 The actions of the SERVO tab's rows.
enum  { S_D = 1 , S_C = 2 , S_ANY = 3 }
 The series a row is for.
enum  {
  P_NONE = 0 , P_TAB , P_CLOSE , P_ROW ,
  P_KEYPAD , P_CHOICE , P_CHOICE_CANCEL , P_APPLY ,
  P_CANCEL
}
 What a press is on.
enum  { C_SERIES = 0 , C_MORE , C_RESTORE , C_VALUE }
 What a list was opened for.
enum  { MORE_VOLTAGE = 0 , MORE_CURRENT , MORE_DISCARD , MORE_REPAIR }
 The entries of MORE: the supply's in PWM, the session's while held.
enum  { RS_RESTORE = 0 , RS_FORGET }
 The entries of RESTORE.
enum  {
  W_LEAVE = 0 , W_RELEASE , W_ENABLE , W_WRITE ,
  W_SOFT , W_REPAIR , W_RESTORE
}
 The hold pages.
enum  { KP_NONE = 0 , KP_VOLTAGE , KP_CURRENT , KP_VALUE }
 What the keypad edits.

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_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.
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.
int hpn_cells (void)
 The cells of HP_FONT a note's row has: the area less 10px a side.
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).
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.
const char * hpn_label (const hpn_row_t *r)
 A row's label as it is drawn now.
void hpn_value_text (const hpn_row_t *r, char *out, size_t n, bool *warn)
 The text in a row's control into out.
bool hpn_port_line (int i, char *out, size_t n)
 Line i of the PORT row into out.
bool hpn_port_unbound (void)
 Whether the PORT row names no pin: the warning colour.
void hpn_state_line (char *out, size_t n)
 The state line of the SERVO tab into out.
void hpn_fmt_param (uint8_t id, int32_t value, char *out, size_t n)
 A value of parameter id in its unit, without the stored value: "30%", "CW", "1500.00us".
const char * hpn_choice_text (uint8_t id, int32_t value)
 The words of a CHOICE value of id: "CW", "ON".
const char * hpn_param_label (uint8_t id)
 The label of parameter id's row in the series in use.
void hpn_change_line (uint8_t id, const hitec_image_t *img, char *out, size_t n)
 "LABEL: was -> now" of parameter id, the servo's value and img's.
bool hpn_row_edited (const hpn_row_t *r)
 Whether row r shows a value the draft changes.
void hpn_close_editors (void)
 Every editor shut: the keypad, the list and the page.
void hpn_act (const hpn_row_t *r)
 The action of a SERVO row.
void hpn_choice_done (int value)
 The list's choice value.
void hpn_keypad_done (float v)
 The keypad's value v.
bool hpn_row_live (const hpn_row_t *r)
 Whether row r's control takes a tap now.
void hpn_page_leave (void)
 The page of LEAVE.
void hpn_page_release (void)
 The page of RELEASE PORT.
void hpn_page_enable (void)
 The page of ENABLE WRITE TO SERVO.
void hpn_page_write (void)
 The page of WRITE n VALUES.
void hpn_page_soft (void)
 CHECK THIS CHANGE for the edit that waits.
void hpn_page_repair (void)
 The page of REPAIR CHECKSUM.
void hpn_page_restore (void)
 The page of RESTORE from the record.
void hpn_page_add (unsigned level, const char *s)
 Adds a line to the open page at level.
void hpn_page_open (int kind, bool danger, const char *title, const char *apply)
 Opens a hold page of kind.
void hpn_edit_open (const hpn_row_t *r)
 The editor of a value row: its list or its keypad.
hitec_prog_edit_t hpn_edit_take (int32_t value)
 An edit's value to the model; CHECK THIS CHANGE where it waits.
void hpn_page_apply (void)
 A page's hold completed: what it asked for.
void hpn_options_load (void)
 The programmer's options from the settings.
void hpn_supply_sync (void)
 The supply's own controls follow the port: held, SUPPLY and the SERVO screen's SET row take an OFF and nothing else.

Variables

const hpn_row_t hpn_rows [HP_ROW_COUNT]
 The rows, in hitec_panel.c.
hpn_state_t hitec_panel_h
 The state, in hitec_panel.c; the files read it as hp.

Detailed Description

The seam between the files of the Hitec programmer's overlay.

hitec_panel.c holds the state, the rows, the geometry and the caller's side; hitec_panel_text.c the texts of the messages and the values; hitec_panel_edit.c the actions, the lists and the keypad; hitec_panel_page.c the hold pages; hitec_panel_touch.c the presses; hitec_panel_draw.c the notes and the pages drawn. The functions one calls of another are prefixed hpn_. Nothing outside these six files includes this header; the interface is hitec_panel.h.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ HP_CELL

#define HP_CELL   10

HP_FONT's cell, px

◆ HP_CLOSE_W

#define HP_CLOSE_W   120

CLOSE's width

◆ HP_LINE_H

#define HP_LINE_H   20

a wrapped row's pitch, px

◆ HP_PITCH

#define HP_PITCH   56

a row's pitch: 8px between two

◆ HP_ROW0

#define HP_ROW0   64

the first row's top

◆ HP_ROW_H

#define HP_ROW_H   UI_TAP_MIN

a row's height, 48px

◆ HP_TAB_H

#define HP_TAB_H   UI_TAP_MIN

their height, 48px

◆ HP_TAB_Y

#define HP_TAB_Y   8

The overlay's layout, in pixels from the area's top left, the KST overlay's: on SERVO's left card of 620px five tabs of 95px and CLOSE of 120px in one row 48px tall, rows 48px tall at a 56px pitch, two columns of 295px, a button or value of 150px, a wide row's of 260px. Every control ends at hpn_foot().

the tabs' and CLOSE's top

◆ HP_VAL_W

#define HP_VAL_W   150

a button or value, 15 cells

◆ HP_WIDE_W

#define HP_WIDE_W   260

a wide row's, 26 cells

Function Documentation

◆ hpn_act()

void hpn_act ( const hpn_row_t * r)

The action of a SERVO row.

Parameters
rthe row

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

void hpn_change_line ( uint8_t id,
const hitec_image_t * img,
char * out,
size_t n )

"LABEL: was -> now" of parameter id, the servo's value and img's.

Parameters
idhitec_param_t
imgthe image the write leaves
outthe text
nbytes at out

◆ hpn_choice_done()

void hpn_choice_done ( int value)

The list's choice value.

Parameters
valuethe entry's value

◆ hpn_choice_text()

const char * hpn_choice_text ( uint8_t id,
int32_t value )

The words of a CHOICE value of id: "CW", "ON".

Parameters
idhitec_param_t
valuethe value
Returns
the text

◆ hpn_edit_open()

void hpn_edit_open ( const hpn_row_t * r)

The editor of a value row: its list or its keypad.

Parameters
rthe row

◆ hpn_edit_take()

hitec_prog_edit_t hpn_edit_take ( int32_t value)

An edit's value to the model; CHECK THIS CHANGE where it waits.

Parameters
valuethe value in the parameter's unit
Returns
what the edit came to

◆ hpn_fmt_param()

void hpn_fmt_param ( uint8_t id,
int32_t value,
char * out,
size_t n )

A value of parameter id in its unit, without the stored value: "30%", "CW", "1500.00us".

Parameters
idhitec_param_t
valuethe decoded value
outthe text
nbytes at out

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

void hpn_keypad_done ( float v)

The keypad's value v.

Parameters
vthe value

◆ hpn_label()

const char * hpn_label ( const hpn_row_t * r)

A row's label as it is drawn now.

Parameters
rthe row
Returns
the label, static for the PORT and SERVO rows

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

void hpn_page_add ( unsigned level,
const char * s )

Adds a line to the open page at level.

Parameters
levelhitec_prog_level_t
sthe line

◆ hpn_page_open()

void hpn_page_open ( int kind,
bool danger,
const char * title,
const char * apply )

Opens a hold page of kind.

Parameters
kindW_*
dangerthe edge in the danger colour
titleits title
applythe hold button's label

◆ hpn_param_label()

const char * hpn_param_label ( uint8_t id)

The label of parameter id's row in the series in use.

Parameters
idhitec_param_t
Returns
the label; "" for none

◆ hpn_port_line()

bool hpn_port_line ( int i,
char * out,
size_t n )

Line i of the PORT row into out.

Parameters
i0 or 1
outthe text
nbytes at out
Returns
false for no such line

◆ hpn_port_unbound()

bool hpn_port_unbound ( void )

Whether the PORT row names no pin: the warning colour.

Returns
true when no pin is known

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

bool hpn_row_edited ( const hpn_row_t * r)

Whether row r shows a value the draft changes.

Parameters
rthe row
Returns
true when edited

◆ hpn_row_live()

bool hpn_row_live ( const hpn_row_t * r)

Whether row r's control takes a tap now.

Parameters
rthe row
Returns
true when live

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

void hpn_state_line ( char * out,
size_t n )

The state line of the SERVO tab into out.

Parameters
outthe text
nbytes at out

◆ 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

◆ hpn_value_text()

void hpn_value_text ( const hpn_row_t * r,
char * out,
size_t n,
bool * warn )

The text in a row's control into out.

Parameters
rthe row
outthe text
nbytes at out
warnset when the value shows raw, as it fits no encoding

Variable Documentation

◆ hpn_rows

const hpn_row_t hpn_rows[HP_ROW_COUNT]
extern

The rows, in hitec_panel.c.

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

The rows, in hitec_panel.c.