rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
ui_keypad.h
Go to the documentation of this file.
1
22#pragma once
23
24#include <stdbool.h>
25#include <stddef.h>
26#include <stdint.h>
27
28#include "gfx.h"
29#include "touch_types.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
37#define UI_KEYPAD_ENTRY_MAX 7
38
43typedef enum {
44 UI_KEY_7 = 0, UI_KEY_8, UI_KEY_9, UI_KEY_DEL,
45 UI_KEY_4, UI_KEY_5, UI_KEY_6, UI_KEY_CLR,
46 UI_KEY_1, UI_KEY_2, UI_KEY_3, UI_KEY_CANCEL,
47 UI_KEY_0, UI_KEY_DOT, UI_KEY_OK,
48 UI_KEY_SIGN,
49 UI_KEY_COUNT
50} ui_key_t;
51
58
61typedef struct {
62 bool open;
64 char title[48];
65 char unit[6];
66 float value;
67 float min,
72 int len;
73 bool refused;
76 char reason[64];
77 bool sign;
78 int pressed;
79 uint8_t press_id;
81 uint32_t revision;
83
85void ui_keypad_open(ui_keypad_t *k, gfx_rect_t area, const char *title,
86 const char *unit, float value, float min, float max,
87 int decimals);
88
101void ui_keypad_open_signed(ui_keypad_t *k, gfx_rect_t area, const char *title,
102 const char *unit, float value, float min,
103 float max, int decimals);
104
105void ui_keypad_close(ui_keypad_t *k);
106
110
117 float *out);
118
127
136void ui_keypad_refuse_why(ui_keypad_t *k, const char *reason);
137
148
158
169
180const char *ui_keypad_range(const ui_keypad_t *k, char *buf, size_t n);
181
193
194#ifdef __cplusplus
195}
196#endif
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
#define k
Short name for kst_panel_k inside the overlay's seven files.
Definition kst_panel_int.h:238
Definition gfx.h:129
Definition gfx.h:250
Definition gfx.h:81
A DOWN, MOVE or UP of one contact.
Definition touch_types.h:69
A numeric keypad: what it was opened with, what is typed, and the press it holds.
Definition ui_keypad.h:61
uint8_t press_id
Definition ui_keypad.h:79
float max
Definition ui_keypad.h:68
float min
Definition ui_keypad.h:67
char reason[64]
Why the caller refused the last OK, drawn in place of the range while refused; "" for a value outside...
Definition ui_keypad.h:76
int pressed
Definition ui_keypad.h:78
uint32_t revision
Bumped on every change a render would show.
Definition ui_keypad.h:81
int decimals
Definition ui_keypad.h:69
int len
Definition ui_keypad.h:72
char title[48]
Definition ui_keypad.h:64
bool refused
Definition ui_keypad.h:73
char unit[6]
Definition ui_keypad.h:65
bool sign
Definition ui_keypad.h:77
bool open
Definition ui_keypad.h:62
float value
Definition ui_keypad.h:66
char entry[UI_KEYPAD_ENTRY_MAX+1]
What has been typed, '\0'-ended.
Definition ui_keypad.h:71
gfx_rect_t area
Definition ui_keypad.h:63
Plain data types shared by the touch controller driver, the coordinate mapper and the event tracker....
gfx_rect_t ui_keypad_key_rect(const ui_keypad_t *k, ui_key_t key)
Where a key is drawn and hit: the grid ends 8px inside the area, or at UI_KEYS_FOOT (4px above the al...
Definition ui_keypad.c:129
const gfx_font_t * ui_keypad_digit_font(const ui_keypad_t *k)
The face of the digits and the point: the largest of 20 x 36, 16 x 28, 12 x 24 and 10 x 20 whose cell...
Definition ui_keypad.c:395
void ui_keypad_open(ui_keypad_t *k, gfx_rect_t area, const char *title, const char *unit, float value, float min, float max, int decimals)
Definition ui_keypad.c:48
ui_keypad_result_t ui_keypad_event(ui_keypad_t *k, const touch_event_t *evt, float *out)
Definition ui_keypad.c:313
void ui_keypad_refuse(ui_keypad_t *k)
Refuse the value the last OK handed back, after the caller has judged it by a rule of its own: the ke...
Definition ui_keypad.c:89
#define UI_KEYPAD_ENTRY_MAX
Characters an entry holds, a minus sign included: "21.00" with room for a longer integer part,...
Definition ui_keypad.h:37
void ui_keypad_open_signed(ui_keypad_t *k, gfx_rect_t area, const char *title, const char *unit, float value, float min, float max, int decimals)
Open k as ui_keypad_open() does, with the +/- key: for a value whose range reaches below 0 by more th...
Definition ui_keypad.c:69
void ui_keypad_cancel_press(ui_keypad_t *k)
Definition ui_keypad.c:121
ui_key_t
The keys, in reading order; OK spans the last two columns, or the last one on a signed keypad,...
Definition ui_keypad.h:43
const gfx_font_t * ui_keypad_word_font(const ui_keypad_t *k)
The face of the word keys (DEL, CLR, CANCEL, OK, +/-) in the language shown: the largest of 20 x 36,...
Definition ui_keypad.c:400
const char * ui_keypad_range(const ui_keypad_t *k, char *buf, size_t n)
The range line of the keypad's header: "3.30 to 21.00V", the unit joined to a symbol and after a spac...
Definition ui_keypad.c:477
ui_keypad_result_t
What an event on the keypad came to.
Definition ui_keypad.h:53
@ UI_KEYPAD_CANCEL
Definition ui_keypad.h:56
@ UI_KEYPAD_OK
Definition ui_keypad.h:55
@ UI_KEYPAD_NONE
Definition ui_keypad.h:54
void ui_keypad_refuse_why(ui_keypad_t *k, const char *reason)
Refuse as ui_keypad_refuse() does, with the reason drawn in place of the range, in the warning colour...
Definition ui_keypad.c:101
void ui_keypad_render(const ui_keypad_t *k, gfx_canvas_t *c)
The whole keypad over its area: the title and the range in 10 x 20 (8 x 16 where they do not fit side...
Definition ui_keypad.c:496