rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
hitec_panel_int.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <limits.h>
18#include <stdbool.h>
19#include <stddef.h>
20#include <stdint.h>
21
22#include "gfx.h"
23#include "hitec_panel.h"
24#include "hitec_prog.h"
25#include "touch_types.h"
26#include "ui_keypad.h"
27#include "ui_layout.h"
28#include "ui_tabs.h"
29#include "ui_text.h"
30#include "ui_widgets.h"
31
32/* ------------------------------------------------------------------ geometry */
33
41#define HP_TAB_Y 8
42#define HP_TAB_H UI_TAP_MIN
43#define HP_CLOSE_W 120
44#define HP_ROW0 64
45#define HP_PITCH 56
46#define HP_ROW_H UI_TAP_MIN
47#define HP_VAL_W 150
48#define HP_WIDE_W 260
51#define HP_WRITE_W 220
54#define HP_FONT (&gfx_font_10x20)
56#define HP_TITLE_FONT (&gfx_font_20x36)
57#define HP_CELL 10
58#define HP_LINE_H 20
60#define HP_FOOT_GAP 4
63#define HP_PAGE_TOP 64
65#define HP_PAGE_LINES 12
68#define HP_PAGE_VALUES 6
71#define HP_CHOICE_MAX 6
72
74enum { K_ACT = 0, K_SHOW };
75
77enum { A_PORT = 0, A_SERIES, A_READ, A_MORE, A_CLEAR, A_ENABLE, A_RESTORE,
78 A_WRITE };
79
81enum { S_D = 1, S_C = 2, S_ANY = 3 };
82
84typedef struct {
85 uint8_t page;
86 uint8_t row;
87 uint8_t col;
88 uint8_t wide;
89 uint8_t kind;
90 uint8_t what;
91 uint8_t series;
92 int16_t label;
93 const char *name;
94} hpn_row_t;
95
97#define HP_ROW_COUNT 43
99extern const hpn_row_t hpn_rows[HP_ROW_COUNT];
100
101/* -------------------------------------------------------------------- state */
102
104enum {
105 P_NONE = 0, P_TAB, P_CLOSE, P_ROW, P_KEYPAD, P_CHOICE, P_CHOICE_CANCEL,
106 P_APPLY, P_CANCEL
107};
108
110enum { C_SERIES = 0, C_MORE, C_RESTORE, C_VALUE };
113enum { MORE_VOLTAGE = 0, MORE_CURRENT, MORE_DISCARD, MORE_REPAIR };
115enum { RS_RESTORE = 0, RS_FORGET };
117#define HP_FS_POSITION (-1)
119enum { W_LEAVE = 0, W_RELEASE, W_ENABLE, W_WRITE, W_SOFT, W_REPAIR,
120 W_RESTORE };
122enum { KP_NONE = 0, KP_VOLTAGE, KP_CURRENT, KP_VALUE };
123
125typedef struct {
128 bool open;
129 bool loaded;
133 uint8_t ed_id;
135
136 struct {
137 bool open;
138 int kind;
139 int count;
140 char title[64];
142 int values[HP_CHOICE_MAX];
143 int current;
145 } ch;
146
147 struct {
148 bool open;
149 int kind;
150 bool down;
152 int count;
153 bool danger;
154 char title[64];
155 char apply[64];
157 uint8_t level[HP_PAGE_LINES];
158 } page;
159
160 bool have;
161 uint8_t id;
163 int row;
164
166 uint32_t sig;
167 uint32_t rev;
168 uint32_t hold_rev;
170
174#define hp hitec_panel_h
175
176/* --- the functions one file calls of another ---------------------------- */
177
178/* hitec_panel.c */
179
186bool hpn_row_shown(const hpn_row_t *r);
194const hpn_row_t *hpn_row_at(int page, int row, int col);
217int hpn_foot(void);
223int hpn_notes_foot(void);
228int hpn_cells(void);
238int hpn_text_rows(gfx_canvas_t *c, int x, int y, const char *s,
239 gfx_color_t color);
244void hpn_moved(void);
245
246/* hitec_panel_text.c */
247
253const char *hpn_label(const hpn_row_t *r);
261void hpn_value_text(const hpn_row_t *r, char *out, size_t n, bool *warn);
269bool hpn_port_line(int i, char *out, size_t n);
274bool hpn_port_unbound(void);
280void hpn_state_line(char *out, size_t n);
289void hpn_fmt_param(uint8_t id, int32_t value, char *out, size_t n);
296const char *hpn_choice_text(uint8_t id, int32_t value);
302const char *hpn_param_label(uint8_t id);
311void hpn_change_line(uint8_t id, const hitec_image_t *img, char *out,
312 size_t n);
318bool hpn_row_edited(const hpn_row_t *r);
319
320/* hitec_panel_edit.c */
321
323void hpn_close_editors(void);
328void hpn_act(const hpn_row_t *r);
333void hpn_choice_done(int value);
338void hpn_keypad_done(float v);
344bool hpn_row_live(const hpn_row_t *r);
346void hpn_page_leave(void);
348void hpn_page_release(void);
350void hpn_page_enable(void);
352void hpn_page_write(void);
354void hpn_page_soft(void);
356void hpn_page_repair(void);
358void hpn_page_restore(void);
364void hpn_page_add(unsigned level, const char *s);
372void hpn_page_open(int kind, bool danger, const char *title,
373 const char *apply);
378void hpn_edit_open(const hpn_row_t *r);
384hitec_prog_edit_t hpn_edit_take(int32_t value);
386void hpn_page_apply(void);
388void hpn_options_load(void);
389
390/* hitec_panel_touch.c */
391
394void hpn_supply_sync(void);
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
gfx_rect_t hpn_tabs_rect(void)
The tabs' row.
Definition hitec_panel.c:159
const hpn_row_t * hpn_row_at(int page, int row, int col)
The row at (page, row, col) shown now, or NULL.
Definition hitec_panel.c:144
gfx_rect_t hpn_row_rect(const hpn_row_t *r)
Row r's whole rectangle.
Definition hitec_panel.c:183
void hpn_moved(void)
The state changed or an operation started: editors that asked for the state they were opened in close...
Definition hitec_panel.c:503
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 ...
Definition hitec_panel.c:167
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).
Definition hitec_panel.c:259
hpn_state_t hitec_panel_h
The state, in hitec_panel.c; the files read it as hp.
Definition hitec_panel.c:122
gfx_rect_t hpn_value_rect(const hpn_row_t *r)
Row r's control.
Definition hitec_panel.c:194
bool hpn_row_shown(const hpn_row_t *r)
Whether row r is on the tab shown in the series and layout in use.
Definition hitec_panel.c:129
const hpn_row_t hpn_rows[]
The rows of every tab and both series; hitec_panel_int.h.
Definition hitec_panel.c:33
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.
Definition hitec_panel.c:175
int hpn_cells(void)
The cells of HP_FONT a note's row has: the area less 10px a side.
Definition hitec_panel.c:205
The overlay of the programmer for servos by Hitec on SERVO: its interface.
#define HITEC_PANEL_LINE
The bytes of one line of a message, a note or a page.
Definition hitec_panel.h:53
void hpn_act(const hpn_row_t *r)
The action of a SERVO row.
Definition hitec_panel_edit.c:381
void hpn_close_editors(void)
Every editor shut: the keypad, the list and the page.
Definition hitec_panel_edit.c:32
void hpn_keypad_done(float v)
The keypad's value v.
Definition hitec_panel_edit.c:518
hitec_prog_edit_t hpn_edit_take(int32_t value)
An edit's value to the model; CHECK THIS CHANGE where it waits.
Definition hitec_panel_edit.c:104
void hpn_edit_open(const hpn_row_t *r)
The editor of a value row: its list or its keypad.
Definition hitec_panel_edit.c:198
void hpn_options_load(void)
The programmer's options from the settings.
Definition hitec_panel_edit.c:89
void hpn_choice_done(int value)
The list's choice value.
Definition hitec_panel_edit.c:469
bool hpn_row_live(const hpn_row_t *r)
Whether row r's control takes a tap now.
Definition hitec_panel_edit.c:265
void hpn_page_release(void)
The page of RELEASE PORT.
Definition hitec_panel_page.c:59
const char * hpn_choice_text(uint8_t id, int32_t value)
The words of a CHOICE value of id: "CW", "ON".
Definition hitec_panel_text.c:66
void hpn_page_write(void)
The page of WRITE n VALUES.
Definition hitec_panel_page.c:153
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.
Definition hitec_panel_text.c:224
void hpn_page_restore(void)
The page of RESTORE from the record.
Definition hitec_panel_page.c:249
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....
Definition hitec_panel_text.c:177
void hpn_page_add(unsigned level, const char *s)
Adds a line to the open page at level.
Definition hitec_panel_page.c:38
void hpn_page_repair(void)
The page of REPAIR CHECKSUM.
Definition hitec_panel_page.c:231
bool hpn_port_unbound(void)
Whether the PORT row names no pin: the warning colour.
Definition hitec_panel_text.c:354
void hpn_page_enable(void)
The page of ENABLE WRITE TO SERVO.
Definition hitec_panel_page.c:185
void hpn_state_line(char *out, size_t n)
The state line of the SERVO tab into out.
Definition hitec_panel_text.c:500
void hpn_page_apply(void)
A page's hold completed: what it asked for.
Definition hitec_panel_page.c:262
const char * hpn_label(const hpn_row_t *r)
A row's label as it is drawn now.
Definition hitec_panel_text.c:43
void hpn_page_soft(void)
CHECK THIS CHANGE for the edit that waits.
Definition hitec_panel_page.c:203
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 an...
Definition hitec_panel_touch.c:216
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.
Definition hitec_panel_text.c:314
#define HP_ROW_COUNT
The rows' count.
Definition hitec_panel_int.h:97
bool hpn_port_line(int i, char *out, size_t n)
Line i of the PORT row into out.
Definition hitec_panel_text.c:381
#define HP_CHOICE_MAX
The entries a list holds: OVERLOAD PROTECTION's OFF and 10% to 50%.
Definition hitec_panel_int.h:71
void hpn_page_leave(void)
The page of LEAVE.
Definition hitec_panel_page.c:47
bool hpn_row_edited(const hpn_row_t *r)
Whether row r shows a value the draft changes.
Definition hitec_panel_text.c:235
const char * hpn_param_label(uint8_t id)
The label of parameter id's row in the series in use.
Definition hitec_panel_text.c:189
void hpn_page_open(int kind, bool danger, const char *title, const char *apply)
Opens a hold page of kind.
Definition hitec_panel_page.c:26
#define HP_PAGE_LINES
The lines a hold page holds.
Definition hitec_panel_int.h:65
The programmer for servos by Hitec as the SERVO screen runs it: the session with one servo,...
hitec_prog_state_t
Where the programmer is.
Definition hitec_prog.h:127
hitec_prog_edit_t
What an edit came to.
Definition hitec_prog.h:365
#define KP_VOLTAGE
Definition kst_panel_int.h:133
#define KP_CURRENT
Keypad target: the supply current limit an ENTER asks for.
Definition kst_panel_int.h:135
Definition gfx.h:129
Definition gfx.h:81
The registers or cells of one servo, as read.
Definition hitec_reg.h:95
The programmer's state.
Definition hitec_prog.h:389
One row: where it sits, what it shows, what it is called.
Definition hitec_panel_int.h:84
const char * name
Definition hitec_panel_int.h:93
uint8_t col
Definition hitec_panel_int.h:87
int16_t label
Definition hitec_panel_int.h:92
uint8_t row
Definition hitec_panel_int.h:86
uint8_t what
Definition hitec_panel_int.h:90
uint8_t series
Definition hitec_panel_int.h:91
uint8_t kind
Definition hitec_panel_int.h:89
uint8_t wide
Definition hitec_panel_int.h:88
uint8_t page
Definition hitec_panel_int.h:85
int values[HP_CHOICE_MAX]
char labels[HP_CHOICE_MAX][HITEC_PANEL_LINE]
char lines[HP_PAGE_LINES][HITEC_PANEL_LINE]
uint8_t level[HP_PAGE_LINES]
The overlay's state.
Definition hitec_panel_int.h:125
int kp_what
Definition hitec_panel_int.h:132
int row
Definition hitec_panel_int.h:163
uint32_t hold_rev
Definition hitec_panel_int.h:168
uint8_t id
Definition hitec_panel_int.h:161
ui_tabs_t tabs
Definition hitec_panel_int.h:130
uint8_t ed_id
Definition hitec_panel_int.h:133
uint32_t sig
Definition hitec_panel_int.h:166
gfx_rect_t area
Definition hitec_panel_int.h:127
ui_keypad_t kp
Definition hitec_panel_int.h:131
bool have
Definition hitec_panel_int.h:160
hitec_prog_t prog
Definition hitec_panel_int.h:126
hitec_prog_state_t state_seen
Definition hitec_panel_int.h:165
bool loaded
Definition hitec_panel_int.h:129
uint32_t rev
Definition hitec_panel_int.h:167
int pressed
Definition hitec_panel_int.h:162
bool open
Definition hitec_panel_int.h:128
Definition ui_widgets.h:415
A numeric keypad: what it was opened with, what is typed, and the press it holds.
Definition ui_keypad.h:61
A row of tabs: their labels, where they are, which is selected and the press under way.
Definition ui_tabs.h:27
Plain data types shared by the touch controller driver, the coordinate mapper and the event tracker....
A numeric keypad over part of a screen, for a value a slider is too coarse to place.
The panel's geometry, in one place.
The pane selector: one bench, several views of it.
The interface's words, one table per language.
Stateless drawing helpers shared by every screen.