|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
SETUP's private seam between settings_screen.c, the state, the touch handling and the screen's interface, and settings_draw.c, its drawing: the layout both work on, the hub's tiles, the state and the functions one calls in the other. Nothing outside shared/ui includes this header; the screen's interface is settings_screen.h. More...
#include <stdbool.h>#include <stdint.h>#include "gfx.h"#include "settings.h"#include "settings_rows_int.h"#include "settings_screen.h"#include "ui_icons.h"#include "ui_keypad.h"#include "ui_screen.h"#include "ui_text.h"#include "ui_textkey.h"Go to the source code of this file.
Data Structures | |
| struct | hub_tile_t |
| One tile of the hub: a category's list or a screen it opens. More... | |
| struct | stg_state_t |
| SETUP's state: the open list and its scroll, the contact that holds the screen, the key repeat, the warning, the keyboard and the keypad, and what the last frame drew of each. More... | |
| struct | [struct].k_text_ui |
Macros | |
| #define | SCREEN_W UI_PANEL_W |
| The screen's width, UI_PANEL_W px. | |
| #define | SCREEN_H UI_BODY_H |
| The screen's height, UI_BODY_H px: the body under the band. | |
| #define | MAX_FBS 3 |
| Frame buffers the router renders into. | |
| #define | HUB_COLS 3 |
| The hub: three columns by three rows of 328 x 130px tiles (49.2 x 19.5mm) with 10px margins, and under them the strip that holds SAVE. | |
| #define | HUB_ROWS 3 |
| #define | HUB_M 10 |
| #define | HUB_TW ((SCREEN_W - (HUB_COLS + 1) * HUB_M) / HUB_COLS) |
| #define | HUB_TH 130 |
| #define | HUB_ICON_DY 14 |
| Inside a hub tile, from its top: the 36px icon box at 14, the name in the body face (12 x 24) at 60, the line in the label face (10 x 20) at 94, which leaves 16px under the line. A line holds 32 characters on one row; the tile has no room for a second. | |
| #define | HUB_ICON 36 |
| #define | HUB_NAME_DY 60 |
| #define | HUB_LINE_DY 94 |
| #define | STG_F_HEAD (&gfx_font_20x36) |
| The faces of the list and the strip: a row's name and a heading in the head face (20 x 36); a value and the warning's sentences in the body face (12 x 24); help lines, units, keys, buttons and the warning's change lines in the label face (10 x 20). | |
| #define | STG_F_BODY (&gfx_font_12x24) |
| #define | STG_F_LABEL (&gfx_font_10x20) |
| #define | STRIP_H UI_BTN_H |
| The strip under the grid and under the list: three columns, the hub's, UI_BTN_H (48px) tall. | |
| #define | STRIP_Y (SCREEN_H - UI_ALERT_H - 4 - STRIP_H) |
| #define | SCROLL_W 12 |
| The list: from the first column's left edge to the scroll bar, from under the band to 8px above the strip. A row is 64px tall at a 70px pitch: 6 rows show whole. The scroll bar is SCROLL_W px wide at the third column's right edge and takes no touch. | |
| #define | SCROLL_X (SCREEN_W - HUB_M - SCROLL_W) |
| #define | LIST_X HUB_M |
| #define | LIST_W (SCROLL_X - 8 - LIST_X) |
| #define | LIST_Y 8 |
| #define | LIST_H (STRIP_Y - 8 - LIST_Y) |
| #define | ROW_H 64 |
| #define | ROW_GAP 6 |
| #define | ROW_PITCH (ROW_H + ROW_GAP) |
| #define | ROW_NAME_DY 3 |
| #define | ROW_HELP_DY 40 |
| #define | BTN_W 56 |
| A row's "-" and "+" keys: 56 x 48px (8.4 x 7.2mm), the "+" 12px in from the row's right edge, 166px between them: the value's 150px and 8px on each side. | |
| #define | BTN_H UI_TAP_MIN |
| #define | VALUE_FIELD 150 |
| #define | PLUS_X (LIST_X + LIST_W - 12 - BTN_W) |
| #define | MINUS_X (PLUS_X - 8 - VALUE_FIELD - 8 - BTN_W) |
| #define | VALUE_R (PLUS_X - 8) |
| #define | VALUE_X (MINUS_X + BTN_W) |
| The left edge of a number's value, px: the 166px between its "-" and its "+" key, over the row's height, where a tap opens the keypad. | |
| #define | VALUE_W (PLUS_X - VALUE_X) |
| The width of a number's value, px: 166. | |
| #define | REPEAT_DELAY_S 0.45f |
| #define | REPEAT_SLOW_HZ 8.0f |
| #define | REPEAT_FAST_S 1.8f |
| Time from the first repeat until the fast rate, 1.8s. | |
| #define | REPEAT_FAST_HZ 30.0f |
| #define | DRAG_SLOP 8 |
| A press that moves further than DRAG_SLOP px, 8px, is a scroll and no tap. | |
| #define | WARN_X HUB_M |
| The warning that holds a way out: a card over the body down to the strip. | |
| #define | WARN_Y HUB_M |
| #define | WARN_W (SCREEN_W - 2 * HUB_M) |
| #define | WARN_H (STRIP_Y - HUB_M - WARN_Y) |
| #define | WARN_TITLE_Y 12 |
| #define | WARN_WHY_Y 56 |
| #define | WARN_WHY_PITCH 26 |
| #define | WARN_LINE_Y 116 |
| #define | WARN_PITCH 24 |
| #define | WARN_NOTE_Y (WARN_LINE_Y + SETTINGS_WARN_LINES * WARN_PITCH + 4) |
| #define | WARN_NOTE_PITCH 26 |
| #define | HUB_CATEGORY(cat_, icon_) |
Tile that opens category cat_ with icon icon_; its line counts the settings. | |
| #define | HUB_SCREEN(screen_, line_, icon_) |
Tile that opens screen screen_ with icon icon_ and the line line_ under its name. | |
| #define | TILE_COUNT ((int)(sizeof(k_tiles) / sizeof(k_tiles[0]))) |
| Number of tiles, at most SETTINGS_HUB_SLOTS (9). | |
| #define | TK_AREA_H (STRIP_Y + STRIP_H - WARN_Y) |
| Height of the keyboard's area, px: from the warning's top to the strip's foot. | |
| #define | KP_AREA gfx_rect_make(WARN_X, WARN_Y, WARN_W, TK_AREA_H) |
| The keypad a number's value opens: the keyboard's area, 1004 x 482px, its foot 4px above the alert band. Nothing under it presses while it is open; OK, CANCEL and the home tag close it as they close the keyboard. | |
| #define | s stg_s |
| Short name for stg_s inside the SETUP files. | |
Enumerations | |
| enum | { HIT_NONE = 0 , HIT_TILE , HIT_MINUS , HIT_PLUS , HIT_RESET , HIT_LIST , HIT_SAVE , HIT_STAY , HIT_DISCARD , HIT_LEAVE_SAVE , HIT_TEXT , HIT_VALUE } |
Functions | |
| gfx_rect_t | stg_tile_rect (int i) |
Returns the rectangle of hub tile i. | |
| gfx_rect_t | stg_strip_rect (int col) |
Returns column col of the strip under the grid and the list. | |
| gfx_rect_t | stg_reset_rect (void) |
| Returns the rectangle of RESET, the strip's middle column. | |
| gfx_rect_t | stg_save_rect (void) |
| Returns the rectangle of SAVE, the strip's last column. | |
| bool | stg_save_offered (void) |
| Returns whether SAVE is offered: a setting is changed and no save is asked for. | |
| bool | stg_bench_armed (void) |
| Returns whether the bench is ARMED; DISCARD changes nothing then. | |
| gfx_rect_t | stg_stay_rect (void) |
| Returns the rectangle of STAY, the warning's first column. | |
| gfx_rect_t | stg_discard_rect (void) |
| Returns the rectangle of DISCARD, the warning's middle column. | |
| int | stg_row_count (void) |
| Returns the number of rows in the open category's list. | |
| void | stg_clamp_scroll (void) |
| Limits the list's scroll to 0 to the content's height less the list's. | |
| gfx_rect_t | stg_row_rect (int index) |
Returns the rectangle of list row index, from the list's scroll. | |
| settings_row_t | stg_row_entry (int index) |
Returns the entry of row index; a heading's carries heading or part >= 0, a string's text >= 0. | |
| void | stg_render (gfx_canvas_t *c, int buffer_index) |
| SETUP drawn: the keypad alone while it is open, else the warning, or the tiles or a list over the strip, and the keyboard over them. | |
Variables | |
| static const hub_tile_t | k_tiles [] |
| The hub's tiles in grid order, row by row. | |
| static const struct | k_text_ui [SETTING_TEXT_COUNT] |
| Per string setting: the name for the warning, a row and its keyboard's title, and the row's help line. The DUT name has no row on SETUP. | |
| stg_state_t | stg_s |
| SETUP's state, in settings_screen.c. | |
SETUP's private seam between settings_screen.c, the state, the touch handling and the screen's interface, and settings_draw.c, its drawing: the layout both work on, the hub's tiles, the state and the functions one calls in the other. Nothing outside shared/ui includes this header; the screen's interface is settings_screen.h.
Included last: its layout macros have short names (ROW_H, BTN_W) and it names the state s, which no header included after it may meet. The functions one file calls in the other carry the prefix stg_.
SPDX-License-Identifier: MIT
| #define BTN_H UI_TAP_MIN |
a key's height, px: 48
| #define BTN_W 56 |
A row's "-" and "+" keys: 56 x 48px (8.4 x 7.2mm), the "+" 12px in from the row's right edge, 166px between them: the value's 150px and 8px on each side.
a key's width, px
| #define HUB_CATEGORY | ( | cat_, | |
| icon_ ) |
Tile that opens category cat_ with icon icon_; its line counts the settings.
| #define HUB_COLS 3 |
The hub: three columns by three rows of 328 x 130px tiles (49.2 x 19.5mm) with 10px margins, and under them the strip that holds SAVE.
Coordinates are in the 540px body the router hands this screen; the band and the home tag are above it. The list has the same strip, so SAVE stays where it is between the two. The strip ends 4px above the router's alert band, which covers the bottom UI_ALERT_H px of the body: nothing that acts sits under it. the hub's columns
| #define HUB_ICON 36 |
the icon box's side, px
| #define HUB_ICON_DY 14 |
Inside a hub tile, from its top: the 36px icon box at 14, the name in the body face (12 x 24) at 60, the line in the label face (10 x 20) at 94, which leaves 16px under the line. A line holds 32 characters on one row; the tile has no room for a second.
the icon box's top, px
| #define HUB_LINE_DY 94 |
the line's top, px
| #define HUB_M 10 |
the margin around and between tiles, px
| #define HUB_NAME_DY 60 |
the name's top, px
| #define HUB_ROWS 3 |
the hub's rows
| #define HUB_SCREEN | ( | screen_, | |
| line_, | |||
| icon_ ) |
Tile that opens screen screen_ with icon icon_ and the line line_ under its name.
| #define HUB_TH 130 |
a tile's height, px
| #define LIST_X HUB_M |
the list's left edge, px
| #define LIST_Y 8 |
the list's top, px
| #define MINUS_X (PLUS_X - 8 - VALUE_FIELD - 8 - BTN_W) |
the "-" key's left edge, px: 704
| #define REPEAT_DELAY_S 0.45f |
delay before the first repeat, 0.45s
| #define REPEAT_FAST_HZ 30.0f |
repeat rate once fast, 30Hz
| #define REPEAT_SLOW_HZ 8.0f |
repeat rate after the delay, 8Hz
| #define ROW_GAP 6 |
the gap between two rows, px
| #define ROW_H 64 |
a row's height, px
| #define ROW_HELP_DY 40 |
the help line's top, px
| #define ROW_NAME_DY 3 |
the name's top, px
| #define SCROLL_W 12 |
The list: from the first column's left edge to the scroll bar, from under the band to 8px above the strip. A row is 64px tall at a 70px pitch: 6 rows show whole. The scroll bar is SCROLL_W px wide at the third column's right edge and takes no touch.
the scroll bar's width, px
| #define STG_F_BODY (&gfx_font_12x24) |
values and sentences: 12 x 24
| #define STG_F_HEAD (&gfx_font_20x36) |
The faces of the list and the strip: a row's name and a heading in the head face (20 x 36); a value and the warning's sentences in the body face (12 x 24); help lines, units, keys, buttons and the warning's change lines in the label face (10 x 20).
names and headings: 20 x 36
| #define STG_F_LABEL (&gfx_font_10x20) |
help, units, keys, buttons, change lines: 10 x 20
| #define STRIP_H UI_BTN_H |
The strip under the grid and under the list: three columns, the hub's, UI_BTN_H (48px) tall.
the strip's height, px
| #define STRIP_Y (SCREEN_H - UI_ALERT_H - 4 - STRIP_H) |
the strip's top, px: 444
| #define VALUE_FIELD 150 |
the value's field, px
| #define VALUE_R (PLUS_X - 8) |
the value's and its unit's right edge, px
| #define WARN_LINE_Y 116 |
the first change line
| #define WARN_NOTE_PITCH 26 |
the notes' pitch, px
| #define WARN_NOTE_Y (WARN_LINE_Y + SETTINGS_WARN_LINES * WARN_PITCH + 4) |
the first note
| #define WARN_PITCH 24 |
the change lines' pitch, px
| #define WARN_TITLE_Y 12 |
the title's top
| #define WARN_WHY_PITCH 26 |
those lines' pitch, px
| #define WARN_WHY_Y 56 |
the first line on what unsaved means
| #define WARN_X HUB_M |
The warning that holds a way out: a card over the body down to the strip.
Its title in the head face, up to two lines in the body face on what unsaved means, then one line per change in the label face and up to two notes in the body face under them. STAY, DISCARD and SAVE take the strip's three columns, SAVE where SAVE is on the tiles. SETTINGS_WARN_LINES lines of WARN_PITCH px fit; more changes than that leave the last line to their count. Offsets are from WARN_Y. the card's left edge, px
| #define WARN_Y HUB_M |
the card's top, px
| bool stg_bench_armed | ( | void | ) |
Returns whether the bench is ARMED; DISCARD changes nothing then.
| gfx_rect_t stg_discard_rect | ( | void | ) |
Returns the rectangle of DISCARD, the warning's middle column.
| void stg_render | ( | gfx_canvas_t * | c, |
| int | buffer_index ) |
SETUP drawn: the keypad alone while it is open, else the warning, or the tiles or a list over the strip, and the keyboard over them.
| c | The canvas. |
| buffer_index | The framebuffer, whose cached chrome it follows. |
| gfx_rect_t stg_reset_rect | ( | void | ) |
Returns the rectangle of RESET, the strip's middle column.
| int stg_row_count | ( | void | ) |
Returns the number of rows in the open category's list.
| settings_row_t stg_row_entry | ( | int | index | ) |
Returns the entry of row index; a heading's carries heading or part >= 0, a string's text >= 0.
| index | row index |
| gfx_rect_t stg_row_rect | ( | int | index | ) |
Returns the rectangle of list row index, from the list's scroll.
| index | row index |
Screen-space rect of a row, or an empty rect when it is scrolled away.
| bool stg_save_offered | ( | void | ) |
Returns whether SAVE is offered: a setting is changed and no save is asked for.
| gfx_rect_t stg_save_rect | ( | void | ) |
Returns the rectangle of SAVE, the strip's last column.
| gfx_rect_t stg_stay_rect | ( | void | ) |
Returns the rectangle of STAY, the warning's first column.
| gfx_rect_t stg_strip_rect | ( | int | col | ) |
Returns column col of the strip under the grid and the list.
| col | strip column, 0 to 2 |
| gfx_rect_t stg_tile_rect | ( | int | i | ) |
Returns the rectangle of hub tile i.
| i | tile index, 0 to TILE_COUNT - 1 |
| const struct [struct].k_text_ui k_text_ui[SETTING_TEXT_COUNT] |
Per string setting: the name for the warning, a row and its keyboard's title, and the row's help line. The DUT name has no row on SETUP.
|
static |
The hub's tiles in grid order, row by row.