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

The seam between the files of the KST and Chaservo programmer's overlay. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "gfx.h"
#include "kst_panel.h"
#include "kst_prog.h"
#include "touch_types.h"
#include "ui_card_text.h"
#include "ui_keypad.h"
#include "ui_layout.h"
#include "ui_tabs.h"
#include "ui_text.h"
#include "ui_textkey.h"
#include "ui_widgets.h"

Go to the source code of this file.

Data Structures

struct  row_t
 One row of the overlay: where it sits, what its control does and what it is called. More...
struct  kst_panel_state_t
 The overlay's state. More...

Macros

#define TAB_Y   8
 The overlay's layout, in pixels from the area's top left. Every width that is not a control's own comes from the area's width.
#define TAB_H   UI_TAP_MIN
#define CLOSE_W   120
#define ROW0   64
#define PITCH   56
#define ROW_H   UI_TAP_MIN
#define VAL_W   150
#define WIDE_W   260
#define STEP_W   56
#define KP_FONT   (&gfx_font_10x20)
 The faces: KP_FONT, the type scale's LABEL face (10 x 20), for the labels, the buttons, the notes and the warning pages' lines; KP_TITLE_FONT, the HEAD face (20 x 36), for a warning page's title. LINE_H is a wrapped row's pitch in KP_FONT and KP_CELL its cell's width.
#define KP_TITLE_FONT   (&gfx_font_20x36)
#define KP_CELL   10
#define LINE_H   20
#define FOOT_GAP   4
 The space between the bottom of a control at the foot and the alert band's top: 4px, as every screen's footer.
#define REPEAT_DELAY_S   0.45f
#define REPEAT_SLOW_HZ   8.0f
#define REPEAT_FAST_S   1.8f
#define REPEAT_FAST_HZ   30.0f
#define ROW_COUNT   33
 The rows of the five pages, in kst_panel.c, and their count.
#define FILES_SAVE   (-1)
#define FILES_NEXT   (-2)
 List entry value: the entry that pages on to the files behind these.
#define RESTORE_FORGET   ((int)KST_PROG_FROM_COUNT)
 List value of a restore's source list that forgets the restore.
#define KP_VOLTAGE   (-1)
#define KP_CURRENT   (-2)
 Keypad target: the supply current limit an ENTER asks for.
#define KP_WAIT   (-3)
#define CHOICE_MAX   7
 The entries a list holds: the fullest, FILES, has KST_PROG_FILES_MAX files between the entry that saves and the one that pages on; 7 rows of ROW_H at PITCH fit above CANCEL on SERVO's left card.
#define WARN_LINES   12
 Lines a warning page holds, WARN_LINES of KST_PANEL_LINE bytes.
#define WARN_ROWS   16
 The rows a page's lines take at most, wrapped to the page's width: 16 rows at LINE_H take 320px of the 356px from WARN_TOP to 8px above the buttons on SERVO's left card. A shorter area takes fewer (kpn_warn_room()).
#define WARN_RULES   7
 Lines of a warning page given to the soft limits' warnings.
#define FILE_VALUES   4
 Lines of a file's page given to its values.
#define WARN_TOP   64
 A warning page's first line under the area's top: the title in KP_TITLE_FONT from 16px, 36px tall, and 12px.
#define k   kst_panel_k
 Short name for kst_panel_k inside the overlay's seven files.

Enumerations

enum  {
  PG_SERVO = 0 , PG_TUNE , PG_PULSE , PG_FAILSAFE ,
  PG_LOCKED , PG_COUNT
}
enum  { K_FIELD = 0 , K_STEP , K_LOCKED , K_ACT }
enum  {
  A_PORT = 0 , A_READ , A_FILES , A_RESTORE ,
  A_MORE , A_ENABLE , A_WRITE
}
enum  {
  P_NONE = 0 , P_TAB , P_CLOSE , P_ROW ,
  P_MINUS , P_PLUS , P_KEYPAD , P_CHOICE ,
  P_CHOICE_CANCEL , P_APPLY , P_CANCEL , P_TEXTKEY ,
  P_NOTES
}
enum  { C_STRETCH = 0 , C_RESTORE , C_MORE , C_FILES }
enum  {
  MORE_VERIFY = 0 , MORE_DISCARD , MORE_RELEASE , MORE_VOLTAGE ,
  MORE_CURRENT , MORE_WAIT
}
enum  {
  W_SOFT = 0 , W_ENABLE , W_WRITE , W_RESTORE ,
  W_RELEASE , W_LEAVE , W_CHECK , W_HV
}

Functions

ui_text_id_t kpn_card_text_id (ui_card_at_t at)
 The card's words for at, for the slot as the feed says it.
const char * kpn_card_tr (ui_card_at_t at)
 The same words, translated.
unsigned kpn_ones (uint64_t v)
 The bits set in v.
uint8_t kpn_port_no (void)
 The programming port the overlay works on: the SERVO screen's target, and the first port while that is the servo outputs.
bool kpn_on_port (void)
 Whether the SERVO screen's tester drives a programming port.
bool kpn_flag (uint16_t f)
 Whether flag f is set in the port's report.
bool kpn_programming (void)
 Whether the port is in programming.
unsigned kpn_servo_type (void)
 The servo's type as the card names it; 0 without a servo.
const char * kpn_row_label (const row_t *r)
 A row's label: its text, or for PORT and SERVO what they hold now.
const char * kpn_field_name (unsigned id)
 The name a field has on its row; NULL for one without a row.
bool kpn_in_set (kst_field_set_t set, unsigned id)
 Whether field id is in set.
const char * kpn_unit_of (kst_field_id_t id)
 A field's unit as its value shows it; "" for none.
int kpn_decimals_of (kst_field_id_t id)
 Digits after the point a field's displayed value has.
void kpn_fmt_value (kst_field_id_t id, uint16_t raw, char *out, size_t n, bool unit)
 A field's value as its row shows it.
void kpn_fmt_field (kst_field_id_t id, uint16_t raw, char *out, size_t n)
 kpn_fmt_value() with the unit.
bool kpn_changed (kst_field_id_t id)
 Whether the draft holds another value of id than the servo.
int kpn_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, a row each LINE_H.
gfx_rect_t kpn_tabs_rect (void)
 The tabs.
int kpn_foot (void)
 Where a control at the area's foot ends.
int kpn_notes_foot (void)
 Where the notes and the message under a page end.
gfx_rect_t kpn_row_rect (const row_t *r)
 Row r, its label and its control.
gfx_rect_t kpn_value_rect (const row_t *r)
 Row r's value, between its keys where it has them.
gfx_rect_t kpn_step_rect (const row_t *r, bool up)
 Row r's plus key (up) or minus key.
const row_t * kpn_row_at (int page, int row, int col)
 The row at (row, col) of page page, or NULL.
const char * kpn_shown (const char *name)
 A file name as a line shows it: whole up to KST_PANEL_NAME_TYPED characters, else its start and "..".
void kpn_stay_line (char *out, unsigned n)
 Into out, KST_PANEL_LINE bytes: how many values stay as they are, n.
void kpn_journal_line (char *out, int text, unsigned arg)
 Into out: a line of the interrupted write's record, the GPIO or the port of kst_prog_journal_arg() in arg.
void kpn_kind_line (char *out, int text)
 Into out: what an edited file is, with the fields it gives a value for where the card's side counted them.
void kpn_write_n (char *out, size_t size, unsigned n)
 Into out, size bytes: the title of a write of n values.
int kpn_warn_rows (void)
 The rows the page's lines take.
int kpn_warn_room (void)
 The rows a warning page's lines may take in the area: those that fit between WARN_TOP and 8px above the buttons, WARN_ROWS at most; 14 in an area 420px tall.
void kpn_warn_soft (const row_t *r)
 The page of an edit of row r that passes a soft limit.
void kpn_warn_enable (void)
 The page of ENABLE WRITE TO SERVO.
void kpn_warn_file (void)
 The page of a file whose values pass soft limits: its warnings, and the draft takes it after the hold.
void kpn_warn_write (void)
 The page of WRITE: the values, the horn and the card.
ui_text_id_t kpn_from_text (unsigned from)
 The words for where a restore's values come from.
void kpn_warn_restore (const kst_prog_restore_t *plan)
 The page of a restore by plan.
void kpn_warn_check (const kst_prog_restore_t *plan)
 The page of a backup whose values pass soft limits the servo keeps: its warnings first, the restore's page after the hold.
void kpn_warn_release (void)
 The page of RELEASE.
void kpn_warn_leave (void)
 The page of the way back to PWM, with and without a PD mini.
void kpn_warn_hv (uint16_t mv)
 The page of a programming voltage mv, mV, above what a standard servo is rated for.
void kpn_warn_apply (void)
 The hold completed: what the page asked for.
void kpn_close_editors (void)
 Every editor shut: the keypad, the keyboard, the list and the page; a soft limit's edit is cancelled.
void kpn_name_done (const char *name)
 A file's name typed: the save, or the keyboard again for a name the card's side does not take.
void kpn_card_moved (void)
 What the card's side brought: the list, the name again, a file's warnings.
void kpn_edit_field (const row_t *r)
 Row r's editor: a toggle, the list or the keypad.
void kpn_options_keep (void)
 The programmer's options into the settings.
void kpn_options_load (void)
 The programmer's options from the settings.
void kpn_keypad_done (float v)
 The keypad's value v for the row or the supply it edits.
void kpn_step (const row_t *r, bool up)
 One step of a plus (up) or minus key on row r.
bool kpn_leave_waits (const kst_prog_t *p)
 Whether a LEAVE's wait runs: an abort keeps the session.
void kpn_act (const row_t *r)
 The action of row r of the SERVO page.
void kpn_choice_done (int value)
 The list's choice value for what the list was opened for.
bool kpn_row_live (const row_t *r)
 Whether row r's control takes a tap now.
void kpn_supply_sync (void)
 The supply's own controls follow the port: while one is out of PWM they offer an OFF and nothing else.
bool kpn_notes_paged_at (int x, int y)
 Whether (x, y) is on notes that take more than one page.

Variables

const row_t kpn_rows [ROW_COUNT]
 The overlay's rows, ROW_COUNT of them.
const int16_t kpn_rule [KST_RULE_COUNT]
 A soft limit's words, by rule, in kst_panel_text.c.
kst_panel_state_t kst_panel_k
 The state, kst_panel_k, in kst_panel.c, so its .bss stays where psram_bss.lf puts kst_panel's. The files read it as k, the name it had as the one file's static: the object's own name keeps it apart from every other screen's state.

Detailed Description

The seam between the files of the KST and Chaservo programmer's overlay.

The private seam between the files of the programmer's overlay for KST and Chaservo servos: kst_panel.c, the state, the rows, the helpers and the caller's side; kst_panel_text.c, the texts of the messages; kst_panel_warn.c, the warning pages; kst_panel_edit.c, the editors and the actions; kst_panel_touch.c, the presses; kst_panel_run.c, the limit run's sessions; and kst_panel_draw.c, the notes and the pages drawn. The layout they draw on, the rows, the state they read and write, and the functions one calls of another, prefixed kpn_. Nothing outside these seven files includes this header; the interface is kst_panel.h.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ CLOSE_W

#define CLOSE_W   120

CLOSE's width

◆ FILES_SAVE

#define FILES_SAVE   (-1)

list entry value: the entry that saves a new file

◆ KP_CELL

#define KP_CELL   10

KP_FONT's cell, px

◆ KP_FONT

#define KP_FONT   (&gfx_font_10x20)

The faces: KP_FONT, the type scale's LABEL face (10 x 20), for the labels, the buttons, the notes and the warning pages' lines; KP_TITLE_FONT, the HEAD face (20 x 36), for a warning page's title. LINE_H is a wrapped row's pitch in KP_FONT and KP_CELL its cell's width.

labels, buttons, lines

◆ KP_TITLE_FONT

#define KP_TITLE_FONT   (&gfx_font_20x36)

a warning page's title

◆ KP_VOLTAGE

#define KP_VOLTAGE   (-1)

keypad target: the supply voltage an ENTER asks for

◆ KP_WAIT

#define KP_WAIT   (-3)

keypad target: the wait before ENTER

◆ LINE_H

#define LINE_H   20

a wrapped row's pitch, px

◆ PITCH

#define PITCH   56

a row's pitch: 8px between two

◆ REPEAT_DELAY_S

#define REPEAT_DELAY_S   0.45f

delay before the first repeat, 0.45s

◆ REPEAT_FAST_HZ

#define REPEAT_FAST_HZ   30.0f

repeat rate once fast, 30Hz

◆ REPEAT_FAST_S

#define REPEAT_FAST_S   1.8f

time from the first press until the fast rate, 1.8s

◆ REPEAT_SLOW_HZ

#define REPEAT_SLOW_HZ   8.0f

repeat rate after the delay, 8Hz

◆ ROW0

#define ROW0   64

the first row's top: the tabs and 8px

◆ ROW_H

#define ROW_H   UI_TAP_MIN

a row's height, 48px

◆ STEP_W

#define STEP_W   56

a stepped row's minus and plus keys

◆ TAB_H

#define TAB_H   UI_TAP_MIN

their height, 48px, as every row's

◆ TAB_Y

#define TAB_Y   8

The overlay's layout, in pixels from the area's top left. Every width that is not a control's own comes from the area's width.

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 value of 150px (15 cells of KP_FONT), a wide row's of 260px with minus and plus keys of 56px. Every control ends at kpn_foot(). the tabs' and CLOSE's top

◆ VAL_W

#define VAL_W   150

a value, 15 cells of KP_FONT

◆ WIDE_W

#define WIDE_W   260

a wide row's value, keys included

Function Documentation

◆ kpn_act()

void kpn_act ( const row_t * r)

The action of row r of the SERVO page.

Parameters
rthe row

◆ kpn_card_text_id()

ui_text_id_t kpn_card_text_id ( ui_card_at_t at)

The card's words for at, for the slot as the feed says it.

Parameters
atwhere the card is
Returns
the text id

◆ kpn_card_tr()

const char * kpn_card_tr ( ui_card_at_t at)

The same words, translated.

Parameters
atwhere the card is
Returns
the text

◆ kpn_changed()

bool kpn_changed ( kst_field_id_t id)

Whether the draft holds another value of id than the servo.

Parameters
idthe field
Returns
true when the draft differs from the servo

◆ kpn_choice_done()

void kpn_choice_done ( int value)

The list's choice value for what the list was opened for.

Parameters
valuethe entry's value

◆ kpn_decimals_of()

int kpn_decimals_of ( kst_field_id_t id)

Digits after the point a field's displayed value has.

Parameters
idthe field
Returns
the number of digits

◆ kpn_edit_field()

void kpn_edit_field ( const row_t * r)

Row r's editor: a toggle, the list or the keypad.

Parameters
rthe row

◆ kpn_field_name()

const char * kpn_field_name ( unsigned id)

The name a field has on its row; NULL for one without a row.

Parameters
idthe field id
Returns
the name, or NULL

◆ kpn_flag()

bool kpn_flag ( uint16_t f)

Whether flag f is set in the port's report.

Parameters
fthe flag
Returns
true when the flag is set

◆ kpn_fmt_field()

void kpn_fmt_field ( kst_field_id_t id,
uint16_t raw,
char * out,
size_t n )

kpn_fmt_value() with the unit.

Parameters
idthe field
rawits raw value
outthe text
nthe size of out, bytes

◆ kpn_fmt_value()

void kpn_fmt_value ( kst_field_id_t id,
uint16_t raw,
char * out,
size_t n,
bool unit )

A field's value as its row shows it.

Parameters
idthe field
rawits raw value
outthe text
nthe size of out, bytes
unitwith the unit; without where a line gives it once behind two values

◆ kpn_foot()

int kpn_foot ( void )

Where a control at the area's foot ends.

Returns
the lower of 8px above the area's foot and FOOT_GAP above the alert band, in the area's coordinates (body pixels)

◆ kpn_from_text()

ui_text_id_t kpn_from_text ( unsigned from)

The words for where a restore's values come from.

Parameters
fromthe source
Returns
the text id

◆ kpn_in_set()

bool kpn_in_set ( kst_field_set_t set,
unsigned id )

Whether field id is in set.

Parameters
setthe set of fields
idthe field id
Returns
true when the field is in the set

◆ kpn_journal_line()

void kpn_journal_line ( char * out,
int text,
unsigned arg )

Into out: a line of the interrupted write's record, the GPIO or the port of kst_prog_journal_arg() in arg.

Parameters
outthe text
textthe text id of the line
argthe journal's argument

◆ kpn_keypad_done()

void kpn_keypad_done ( float v)

The keypad's value v for the row or the supply it edits.

Parameters
vthe value

◆ kpn_kind_line()

void kpn_kind_line ( char * out,
int text )

Into out: what an edited file is, with the fields it gives a value for where the card's side counted them.

Parameters
outthe text
textthe text id of the line

◆ kpn_leave_waits()

bool kpn_leave_waits ( const kst_prog_t * p)

Whether a LEAVE's wait runs: an abort keeps the session.

Parameters
pthe session
Returns
true when the wait runs

◆ kpn_name_done()

void kpn_name_done ( const char * name)

A file's name typed: the save, or the keyboard again for a name the card's side does not take.

Parameters
namethe name typed

◆ kpn_notes_foot()

int kpn_notes_foot ( void )

Where the notes and the message under a page end.

Returns
the lower of 6px above the area's foot and FOOT_GAP above the alert band, in the area's coordinates (body pixels): no text lies under the band

◆ kpn_notes_paged_at()

bool kpn_notes_paged_at ( int x,
int y )

Whether (x, y) is on notes that take more than one page.

Parameters
xthe column, px
ythe row, px
Returns
true when the point is on paged notes

◆ kpn_on_port()

bool kpn_on_port ( void )

Whether the SERVO screen's tester drives a programming port.

Returns
true when the tester drives a programming port

◆ kpn_ones()

unsigned kpn_ones ( uint64_t v)

The bits set in v.

Parameters
vthe bit set
Returns
the number of ones

◆ kpn_port_no()

uint8_t kpn_port_no ( void )

The programming port the overlay works on: the SERVO screen's target, and the first port while that is the servo outputs.

Returns
the port number

◆ kpn_programming()

bool kpn_programming ( void )

Whether the port is in programming.

Returns
true when the port is in programming

◆ kpn_row_at()

const row_t * kpn_row_at ( int page,
int row,
int col )

The row at (row, col) of page page, or NULL.

Parameters
pagethe page
rowthe row on the page
colthe column in the row
Returns
the row, or NULL

◆ kpn_row_label()

const char * kpn_row_label ( const row_t * r)

A row's label: its text, or for PORT and SERVO what they hold now.

Parameters
rthe row
Returns
the label

◆ kpn_row_live()

bool kpn_row_live ( const row_t * r)

Whether row r's control takes a tap now.

Parameters
rthe row
Returns
true when the control takes a tap

◆ kpn_row_rect()

gfx_rect_t kpn_row_rect ( const row_t * r)

Row r, its label and its control.

Parameters
rthe row
Returns
the rectangle

◆ kpn_servo_type()

unsigned kpn_servo_type ( void )

The servo's type as the card names it; 0 without a servo.

Returns
the type, 0 for none

◆ kpn_shown()

const char * kpn_shown ( const char * name)

A file name as a line shows it: whole up to KST_PANEL_NAME_TYPED characters, else its start and "..".

Parameters
namethe file name
Returns
the text, static

◆ kpn_stay_line()

void kpn_stay_line ( char * out,
unsigned n )

Into out, KST_PANEL_LINE bytes: how many values stay as they are, n.

Parameters
outthe text
nthe number of values

◆ kpn_step()

void kpn_step ( const row_t * r,
bool up )

One step of a plus (up) or minus key on row r.

Parameters
rthe row
uptrue for plus, false for minus

◆ kpn_step_rect()

gfx_rect_t kpn_step_rect ( const row_t * r,
bool up )

Row r's plus key (up) or minus key.

Parameters
rthe row
uptrue for the plus key, false for the minus key
Returns
the key's rectangle

◆ kpn_tabs_rect()

gfx_rect_t kpn_tabs_rect ( void )

The tabs.

Returns
the tabs' rectangle

◆ kpn_text_rows()

int kpn_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, a row each LINE_H.

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

◆ kpn_unit_of()

const char * kpn_unit_of ( kst_field_id_t id)

A field's unit as its value shows it; "" for none.

Parameters
idthe field
Returns
the unit

◆ kpn_value_rect()

gfx_rect_t kpn_value_rect ( const row_t * r)

Row r's value, between its keys where it has them.

Parameters
rthe row
Returns
the rectangle

◆ kpn_warn_check()

void kpn_warn_check ( const kst_prog_restore_t * plan)

The page of a backup whose values pass soft limits the servo keeps: its warnings first, the restore's page after the hold.

Parameters
planthe restore

◆ kpn_warn_hv()

void kpn_warn_hv ( uint16_t mv)

The page of a programming voltage mv, mV, above what a standard servo is rated for.

Parameters
mvthe voltage, mV

◆ kpn_warn_restore()

void kpn_warn_restore ( const kst_prog_restore_t * plan)

The page of a restore by plan.

Parameters
planthe restore

◆ kpn_warn_room()

int kpn_warn_room ( void )

The rows a warning page's lines may take in the area: those that fit between WARN_TOP and 8px above the buttons, WARN_ROWS at most; 14 in an area 420px tall.

Returns
the rows

◆ kpn_warn_rows()

int kpn_warn_rows ( void )

The rows the page's lines take.

Returns
the number of rows

◆ kpn_warn_soft()

void kpn_warn_soft ( const row_t * r)

The page of an edit of row r that passes a soft limit.

Parameters
rthe row

◆ kpn_write_n()

void kpn_write_n ( char * out,
size_t size,
unsigned n )

Into out, size bytes: the title of a write of n values.

Parameters
outthe text
sizethe size of out, bytes
nthe number of values