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

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.

Detailed Description

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

Macro Definition Documentation

◆ BTN_H

#define BTN_H   UI_TAP_MIN

a key's height, px: 48

◆ BTN_W

#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

◆ HUB_CATEGORY

#define HUB_CATEGORY ( cat_,
icon_ )
Value:
{ (icon_), (int8_t)(cat_), SCREEN_SETUP, TX_SET_COUNT }

Tile that opens category cat_ with icon icon_; its line counts the settings.

◆ HUB_COLS

#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

◆ HUB_ICON

#define HUB_ICON   36

the icon box's side, px

◆ HUB_ICON_DY

#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

◆ HUB_LINE_DY

#define HUB_LINE_DY   94

the line's top, px

◆ HUB_M

#define HUB_M   10

the margin around and between tiles, px

◆ HUB_NAME_DY

#define HUB_NAME_DY   60

the name's top, px

◆ HUB_ROWS

#define HUB_ROWS   3

the hub's rows

◆ HUB_SCREEN

#define HUB_SCREEN ( screen_,
line_,
icon_ )
Value:
{ (icon_), -1, (screen_), (line_) }

Tile that opens screen screen_ with icon icon_ and the line line_ under its name.

◆ HUB_TH

#define HUB_TH   130

a tile's height, px

◆ HUB_TW

#define HUB_TW   ((SCREEN_W - (HUB_COLS + 1) * HUB_M) / HUB_COLS)

a tile's width, px: 328

◆ LIST_H

#define LIST_H   (STRIP_Y - 8 - LIST_Y)

the list's height, px: 428

◆ LIST_W

#define LIST_W   (SCROLL_X - 8 - LIST_X)

the list's width, px: 984

◆ LIST_X

#define LIST_X   HUB_M

the list's left edge, px

◆ LIST_Y

#define LIST_Y   8

the list's top, px

◆ MINUS_X

#define MINUS_X   (PLUS_X - 8 - VALUE_FIELD - 8 - BTN_W)

the "-" key's left edge, px: 704

◆ PLUS_X

#define PLUS_X   (LIST_X + LIST_W - 12 - BTN_W)

the "+" key's left edge, px: 926

◆ 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_SLOW_HZ

#define REPEAT_SLOW_HZ   8.0f

repeat rate after the delay, 8Hz

◆ ROW_GAP

#define ROW_GAP   6

the gap between two rows, px

◆ ROW_H

#define ROW_H   64

a row's height, px

◆ ROW_HELP_DY

#define ROW_HELP_DY   40

the help line's top, px

◆ ROW_NAME_DY

#define ROW_NAME_DY   3

the name's top, px

◆ ROW_PITCH

#define ROW_PITCH   (ROW_H + ROW_GAP)

a row's pitch, px: 70

◆ SCROLL_W

#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

◆ SCROLL_X

#define SCROLL_X   (SCREEN_W - HUB_M - SCROLL_W)

the scroll bar's left edge, px: 1002

◆ STG_F_BODY

#define STG_F_BODY   (&gfx_font_12x24)

values and sentences: 12 x 24

◆ STG_F_HEAD

#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

◆ STG_F_LABEL

#define STG_F_LABEL   (&gfx_font_10x20)

help, units, keys, buttons, change lines: 10 x 20

◆ STRIP_H

#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

◆ STRIP_Y

#define STRIP_Y   (SCREEN_H - UI_ALERT_H - 4 - STRIP_H)

the strip's top, px: 444

◆ VALUE_FIELD

#define VALUE_FIELD   150

the value's field, px

◆ VALUE_R

#define VALUE_R   (PLUS_X - 8)

the value's and its unit's right edge, px

◆ WARN_H

#define WARN_H   (STRIP_Y - HUB_M - WARN_Y)

the card's height, px: 424

◆ WARN_LINE_Y

#define WARN_LINE_Y   116

the first change line

◆ WARN_NOTE_PITCH

#define WARN_NOTE_PITCH   26

the notes' pitch, px

◆ WARN_NOTE_Y

#define WARN_NOTE_Y   (WARN_LINE_Y + SETTINGS_WARN_LINES * WARN_PITCH + 4)

the first note

◆ WARN_PITCH

#define WARN_PITCH   24

the change lines' pitch, px

◆ WARN_TITLE_Y

#define WARN_TITLE_Y   12

the title's top

◆ WARN_W

#define WARN_W   (SCREEN_W - 2 * HUB_M)

the card's width, px: 1004

◆ WARN_WHY_PITCH

#define WARN_WHY_PITCH   26

those lines' pitch, px

◆ WARN_WHY_Y

#define WARN_WHY_Y   56

the first line on what unsaved means

◆ WARN_X

#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

◆ WARN_Y

#define WARN_Y   HUB_M

the card's top, px

Function Documentation

◆ stg_bench_armed()

bool stg_bench_armed ( void )

Returns whether the bench is ARMED; DISCARD changes nothing then.

Returns
true when ARMED

◆ stg_discard_rect()

gfx_rect_t stg_discard_rect ( void )

Returns the rectangle of DISCARD, the warning's middle column.

Returns
the rectangle

◆ stg_render()

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.

Parameters
cThe canvas.
buffer_indexThe framebuffer, whose cached chrome it follows.

◆ stg_reset_rect()

gfx_rect_t stg_reset_rect ( void )

Returns the rectangle of RESET, the strip's middle column.

Returns
the rectangle

◆ stg_row_count()

int stg_row_count ( void )

Returns the number of rows in the open category's list.

Returns
the row count

◆ stg_row_entry()

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.

Parameters
indexrow index
Returns
the entry

◆ stg_row_rect()

gfx_rect_t stg_row_rect ( int index)

Returns the rectangle of list row index, from the list's scroll.

Parameters
indexrow index
Returns
the row's rectangle

Screen-space rect of a row, or an empty rect when it is scrolled away.

◆ stg_save_offered()

bool stg_save_offered ( void )

Returns whether SAVE is offered: a setting is changed and no save is asked for.

Returns
true when SAVE is enabled

◆ stg_save_rect()

gfx_rect_t stg_save_rect ( void )

Returns the rectangle of SAVE, the strip's last column.

Returns
the rectangle

◆ stg_stay_rect()

gfx_rect_t stg_stay_rect ( void )

Returns the rectangle of STAY, the warning's first column.

Returns
the rectangle

◆ stg_strip_rect()

gfx_rect_t stg_strip_rect ( int col)

Returns column col of the strip under the grid and the list.

Parameters
colstrip column, 0 to 2
Returns
the column's rectangle

◆ stg_tile_rect()

gfx_rect_t stg_tile_rect ( int i)

Returns the rectangle of hub tile i.

Parameters
itile index, 0 to TILE_COUNT - 1
Returns
the tile's rectangle

Variable Documentation

◆ k_text_ui

const struct [struct].k_text_ui k_text_ui[SETTING_TEXT_COUNT]
Initial value:
= {
[SET_TEXT_DUT_NAME] = { TX_SET_DUT_NAME, TX_COUNT },
[SET_TEXT_LOG_AUTO_DIR] = { TX_SET_AUTO_DIR, TX_SET_AUTO_DIR_HELP },
[SET_TEXT_LOG_USER_DIR] = { TX_SET_USER_DIR, TX_SET_USER_DIR_HELP },
}
@ SET_TEXT_LOG_USER_DIR
Definition settings.h:233
@ SET_TEXT_LOG_AUTO_DIR
Definition settings.h:232
@ SET_TEXT_DUT_NAME
Definition settings.h:231

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.

◆ k_tiles

const hub_tile_t k_tiles[]
static
Initial value:
= {
HUB_SCREEN(SCREEN_OUTPUTS, TX_SET_HUB_OUTPUTS, ui_icon_list),
HUB_SCREEN(SCREEN_PICKER, TX_SET_HUB_PICKER, ui_icon_board),
HUB_SCREEN(SCREEN_WIFI, TX_SET_HUB_WIFI, ui_icon_wifi),
HUB_SCREEN(SCREEN_UPDATES, TX_SET_HUB_UPDATES, ui_icon_record),
HUB_SCREEN(SCREEN_FILES, TX_SET_HUB_FILES, ui_icon_folder),
}
@ SET_CAT_IFACE
Definition settings.h:31
@ SET_CAT_SENSORS
Definition settings.h:33
@ SET_CAT_CARD
Definition settings.h:32
@ SET_CAT_APP
Definition settings.h:29
#define HUB_CATEGORY(cat_, icon_)
Tile that opens category cat_ with icon icon_; its line counts the settings.
Definition settings_screen_int.h:200
#define HUB_SCREEN(screen_, line_, icon_)
Tile that opens screen screen_ with icon icon_ and the line line_ under its name.
Definition settings_screen_int.h:206
void ui_icon_sliders(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The settings glyph: three sliders.
Definition ui_icons.c:160
void ui_icon_supply(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The supply glyph: a bench supply's front.
Definition ui_icons.c:217
void ui_icon_board(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The board glyph: a board from above with its pads.
Definition ui_icons.c:253
void ui_icon_wifi(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The Wi-Fi glyph: arcs over a dot.
Definition ui_icons.c:270
void ui_icon_record(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The record glyph: a recorder with its tray.
Definition ui_icons.c:114
void ui_icon_chart(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The chart glyph: a trace over its axes.
Definition ui_icons.c:90
void ui_icon_chip(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The chip glyph: a package and its pins.
Definition ui_icons.c:138
void ui_icon_list(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
The pin list glyph: three rows, each a pin and its line.
Definition ui_icons.c:234
void ui_icon_folder(gfx_canvas_t *c, int x, int y, int size, gfx_color_t color)
A folder: its tab and its body.
Definition ui_icons.c:287

The hub's tiles in grid order, row by row.