rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_theme.h
Go to the documentation of this file.
1
19
20
#pragma once
21
22
#include <stdint.h>
23
24
#include "
gfx.h
"
25
#include "
ui_layout.h
"
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
31
typedef
enum
{
32
UI_C_BG = 0,
33
UI_C_PANEL,
34
UI_C_PANEL_HI,
35
UI_C_PANEL_SUNK,
36
UI_C_EDGE,
37
UI_C_EDGE_HI,
38
UI_C_GRID,
39
UI_C_GRID_STRONG,
40
UI_C_TEXT,
41
UI_C_TEXT_DIM,
42
UI_C_TEXT_FAINT,
43
UI_C_TEXT_ON_LIGHT,
44
UI_C_ACCENT,
45
UI_C_OK,
46
UI_C_WARN,
47
UI_C_DANGER,
48
UI_C_VOLT,
49
UI_C_CURR,
50
UI_C_POWER,
51
UI_C_RPM,
52
UI_C_LILAC,
53
UI_C_TEAL,
54
UI_C_COUNT
55
} ui_color_id_t;
56
57
typedef
enum
{
58
UI_THEME_DARK = 0,
59
UI_THEME_LIGHT,
60
UI_THEME_COUNT
61
} ui_theme_id_t;
62
64
extern
gfx_color_t
g_ui_palette
[UI_C_COUNT];
65
66
static
inline
gfx_color_t ui_theme_color(ui_color_id_t
id
)
67
{
68
return
(
id
>= 0 &&
id
< UI_C_COUNT) ?
g_ui_palette
[id] : 0;
69
}
70
72
void
ui_theme_set
(ui_theme_id_t theme);
77
void
ui_theme_set_brightness
(
int
percent);
82
void
ui_theme_set_contrast
(
int
percent);
83
84
ui_theme_id_t ui_theme_get(
void
);
85
int
ui_theme_brightness(
void
);
86
int
ui_theme_contrast(
void
);
87
88
/* ---------------------------------------------------------------- surfaces */
89
90
#define UI_BG ui_theme_color(UI_C_BG)
91
#define UI_PANEL ui_theme_color(UI_C_PANEL)
92
#define UI_PANEL_HI ui_theme_color(UI_C_PANEL_HI)
93
#define UI_PANEL_SUNK ui_theme_color(UI_C_PANEL_SUNK)
94
#define UI_EDGE ui_theme_color(UI_C_EDGE)
95
#define UI_EDGE_HI ui_theme_color(UI_C_EDGE_HI)
96
#define UI_GRID ui_theme_color(UI_C_GRID)
97
#define UI_GRID_STRONG ui_theme_color(UI_C_GRID_STRONG)
98
99
/* -------------------------------------------------------------------- text */
100
101
#define UI_TEXT ui_theme_color(UI_C_TEXT)
102
#define UI_TEXT_DIM ui_theme_color(UI_C_TEXT_DIM)
103
#define UI_TEXT_FAINT ui_theme_color(UI_C_TEXT_FAINT)
104
#define UI_TEXT_ON_LIGHT ui_theme_color(UI_C_TEXT_ON_LIGHT)
105
106
/* ------------------------------------------------------------------ accent */
107
108
#define UI_ACCENT ui_theme_color(UI_C_ACCENT)
109
#define UI_OK ui_theme_color(UI_C_OK)
110
#define UI_WARN ui_theme_color(UI_C_WARN)
111
#define UI_DANGER ui_theme_color(UI_C_DANGER)
112
113
/* ------------------------------------------------------- telemetry series */
114
115
#define UI_VOLT ui_theme_color(UI_C_VOLT)
116
#define UI_CURR ui_theme_color(UI_C_CURR)
117
#define UI_POWER ui_theme_color(UI_C_POWER)
118
#define UI_RPM ui_theme_color(UI_C_RPM)
119
#define UI_LILAC ui_theme_color(UI_C_LILAC)
120
#define UI_TEAL ui_theme_color(UI_C_TEAL)
121
122
/* ----------------------------------------------------------------- metrics */
123
125
#define UI_CHAMFER 10
127
#define UI_CHAMFER_SM 5
128
129
/*
130
* Corner radii (UI_R_CARD, UI_R_CTL, UI_R_CHIP, in ui_layout.h) are one scale
131
* for the whole interface, so a card, a button and a track read as the same
132
* material. UI_CHAMFER is the 45-degree cut ui_panel and the home tag use.
133
*/
134
135
/*
136
* The bench's numeral style, in one place: the four readings and the throttle
137
* share it. Thickness is an eighth of the height; a fatter segment makes the
138
* horizontals, which only span the gap between the two verticals, shorter
139
* than they are thick. The slant of 3px is the lean of a panel meter.
140
*/
141
static
inline
gfx_seg_style_t
ui_seg_hero(
void
)
142
{
143
gfx_seg_style_t
st = { .digit_w = 22, .digit_h = 32, .thickness = 4,
144
.gap = 5, .slant = 3, .ghost =
true
};
145
return
st;
146
}
147
148
/* Fonts by role rather than by size, so a face can be swapped in one place. */
149
#define UI_FONT_LABEL (&gfx_font_8x16)
150
#define UI_FONT_HEAD (&gfx_font_16x28)
151
#define UI_FONT_NUM (&gfx_font_num_24x30)
152
153
/*
154
* Roles of the faces of the 1024 x 600 type scale. LABEL, HEAD and NUM
155
* above are the faces the screens are laid out in, 8px cells. The band,
156
* the home tag, the help bubbles and the alert band draw with the scale's
157
* faces: UI_FONT_BAND and UI_FONT_TAG.
158
*/
161
#define UI_FONT_BAND (&gfx_font_10x20)
163
#define UI_FONT_TAG (&gfx_font_20x36)
166
#define UI_FONT_FINE (&gfx_font_8x16)
169
#define UI_FONT_BODY (&gfx_font_12x24)
170
171
#ifdef __cplusplus
172
}
173
#endif
gfx.h
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
gfx_seg_style_t
Definition
gfx.h:292
ui_layout.h
The panel's geometry, in one place.
ui_theme_set_brightness
void ui_theme_set_brightness(int percent)
Scales the whole palette.
Definition
ui_theme.c:130
ui_theme_set_contrast
void ui_theme_set_contrast(int percent)
Pushes colours away from mid-grey, or pulls them toward it.
Definition
ui_theme.c:136
g_ui_palette
gfx_color_t g_ui_palette[UI_C_COUNT]
Definition
ui_theme.c:77
ui_theme_set
void ui_theme_set(ui_theme_id_t theme)
Definition
ui_theme.c:121
shared
ui
include
ui_theme.h
Generated by
1.18.0