|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The settings screen: a hub of tiles, and one renderer over the whole schema. More...
#include "settings_screen.h"#include <stdio.h>#include <string.h>#include "hitec_rx_link.h"#include "link_pages.h"#include "sense_link.h"#include "sensors_rows.h"#include "settings.h"#include "settings_rows_int.h"#include "settings_sensors.h"#include "tone_link.h"#include "ui_icons.h"#include "ui_keypad.h"#include "ui_pinlist.h"#include "ui_setting_keypad.h"#include "ui_text.h"#include "ui_textkey.h"#include "ui_widgets.h"#include "settings_screen_int.h"Functions | |
| void | settings_screen_invalidate (void) |
| void | settings_apply_ui (void) |
| void | settings_screen_set_unheld (uint16_t sense_rows, uint8_t tone_rows) |
| void | settings_screen_set_hitec_rx (uint8_t mark) |
| const char * | settings_screen_help (setting_id_t id) |
| bool | settings_screen_unheld (setting_id_t id) |
| static void | drop_press (void) |
| bool | settings_hub_slot (int index, gfx_rect_t *out) |
| int | settings_hub_tiles (void) |
| bool | settings_screen_opens (ui_screen_id_t id) |
| int | settings_screen_category (void) |
| gfx_rect_t | stg_tile_rect (int i) |
Returns the rectangle of hub tile i. | |
| static int | tile_at (int x, int y) |
| 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. | |
| static bool | leave_held (void) |
| 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. | |
| static void | leave_value (setting_id_t id, float value, char *out, size_t n) |
A value of id as the leave question says it: with its unit, joined to a symbol ("6.00V"), a space before a word ("2 cells") and the pin word before its number ("GPIO 4"); no unit after OFF, a SENSORS shunt's 0; and a pin's -1 in the words of the row's help, "open". | |
| static void | change_line (int k, char *line, size_t n) |
| bool | settings_screen_warning (void) |
| bool | settings_screen_warn_line (int i, char *line, size_t n) |
| static bool | hold (ui_screen_id_t to) |
| 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. | |
| gfx_rect_t | settings_screen_list_rect (void) |
| The open list's pane, in the screen's own coordinates (the body under the band): the rows show inside it and nowhere else. | |
| gfx_rect_t | settings_screen_row_rect (int row) |
Where list row row lies at the list's present scroll, in the screen's own coordinates; partly or wholly outside the pane for a row scrolled out of it. | |
| gfx_rect_t | settings_screen_row_part (int row, settings_row_part_t part) |
Where part of list row row lies; settings_row_part_t says which part. Whether the row has keys or a keypad is the row's own: the rectangle is where they are when it does. | |
| static int | row_at (int x, int y) |
| 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. | |
| static bool | row_is_heading (int index) |
| static int | row_text (int index) |
| static setting_id_t | row_setting (int index) |
| static bool | on_key (int kind, int index, int x, int y) |
| static bool | on_value (int index, int x, int y) |
Whether (x, y) is on the value of row index: the gap between its "-" and "+" keys, over the row's own height, on a number the keypad takes (ui_setting_keypad_offered()). | |
| static void | value_changed (setting_id_t id) |
| A setting changed by a step or by the keypad: the PANEL rows reach the interface at once, and the list is drawn again. | |
| static void | step_row (int index, int steps) |
The "-" or "+" key of row index stepped steps times through settings_adjust(); a heading's and a string's row take none. | |
| static void | close_keypad (void) |
| The keypad closes, with nothing typed taken. | |
| static void | open_keypad (int index) |
A tap on the value of row index: the keypad of its number, over the list and the strip. | |
| static void | reset (void) |
| The screen's state cleared: the tiles, PANEL's list kept for the first tap, no press, the keyboard and the keypad closed. | |
| static void | enter (void) |
| SETUP shown: it opens on its tiles, from the menu and from a screen a tile opened alike. The list keeps its category and its scroll; the keyboard and the keypad are closed. | |
| static void | leave (void) |
| SETUP left: the warning, the keyboard and the keypad close, and what was typed is not taken. | |
| static bool | back (void) |
| The home tag: on a list it goes back to the tiles; on the tiles it leaves, through hold(). Over the warning it is STAY, over the keyboard and the keypad CANCEL. | |
| static void | tick (float dt_s) |
| A frame: the save button's inputs followed, a keypad whose row is held since it opened closed, and a held "-" or "+" repeated. | |
| static void | open_tile (int index) |
| static void | open_text (setting_text_id_t id) |
| static void | press (const touch_event_t *evt, int x, int y) |
| The DOWN of the contact that holds the screen: what it presses. | |
| static void | release (int kind, int index, bool repeated, int x, int y) |
| The UP of a tap the finger made: what it activates. | |
| static void | textkey_event (const touch_event_t *evt) |
| static void | keypad_event (const touch_event_t *evt) |
| An event while the keypad is open goes to the keypad alone. OK sets the value through settings_set(), as a step does, and SAVE keeps it; a value the steps never reach keeps the keypad open, refused (ui_setting_keypad_ok()). | |
| static void | event (const touch_event_t *evt) |
| One touch event: to the keypad or the keyboard while one is open, else to the press, the scroll and the release it ends in. | |
| static void | cancel (void) |
| Touch events were lost between two frames, so this screen's record of what is on the glass cannot be trusted. | |
| const ui_screen_t * | settings_screen (void) |
| int | settings_screen_scroll (int *max) |
| How far the open category's list is scrolled. | |
| const ui_textkey_t * | settings_screen_textkey (void) |
| const ui_keypad_t * | settings_screen_keypad (void) |
| The keypad a tap on a number's value opens: over the list and the strip until OK sets the value (settings_set(), as a step does), CANCEL or the home tag drops it, or SETUP is left. | |
| int | settings_screen_keypad_setting (void) |
| The setting the open keypad types. | |
Variables | |
| stg_state_t | stg_s |
| SETUP's state, in settings_screen.c. | |
| static uint16_t | s_sense_unheld |
| static uint8_t | s_tone_unheld |
| static uint8_t | s_hitec_rx_mark |
| static const ui_screen_t | s_screen |
The settings screen: a hub of tiles, and one renderer over the whole schema.
SETUP opens on a grid of tiles, the menu's kind: one per category it holds (PANEL, INTERFACES, SD CARD, SENSORS), and one per screen of its own that SETUP reaches (OUTPUTS, PICK A PIN, WI-FI, UPDATES). A category's tile opens its list across the screen's width. The list walks the rows shared/settings declares (settings_rows.c; SENSORS lists a fitted part's rows only, sensors_rows.h) and draws each row by its type: a stepper for a number, a toggle for a bool, a choice for an enum. A tap on a number's value, between its "-" and "+" keys, opens the keypad over the list (ui_setting_keypad.h); its OK sets the value through settings_set(), as a step does. A category's strings follow its settings, each a row that shows its text and opens the on-screen keyboard on a tap (SD CARD's two log folders, in the keyboard's folder mode). A new setting is a schema row, and a new tile is a line of k_tiles (settings_screen_int.h); nothing else here changes. settings_draw.c draws the screen.
The home tag that leaves SETUP with settings unsaved and no save asked is held: a warning lists what differs from the stored values and offers SAVE, DISCARD and STAY. A tile that opens a screen of its own is not a way out, and no route the application takes is held (ui_screen_t.hold).
SPDX-License-Identifier: MIT
|
static |
The home tag: on a list it goes back to the tiles; on the tiles it leaves, through hold(). Over the warning it is STAY, over the keyboard and the keypad CANCEL.
|
static |
Touch events were lost between two frames, so this screen's record of what is on the glass cannot be trusted.
A hit held open acts on its release and a drag owns its track id, and the GT911 reuses ids: a later contact that began somewhere else would be taken for this one and press a control nobody touched. The repeat on the plus and minus keys runs on the frame timer while a hit stands, so it stops here too. A key held on the keyboard or the keypad is let go; what was typed stays.
|
static |
One touch event: to the keypad or the keyboard while one is open, else to the press, the scroll and the release it ends in.
| evt | The event, in the screen's coordinates. |
|
static |
An event while the keypad is open goes to the keypad alone. OK sets the value through settings_set(), as a step does, and SAVE keeps it; a value the steps never reach keeps the keypad open, refused (ui_setting_keypad_ok()).
| evt | The event. |
|
static |
A value of id as the leave question says it: with its unit, joined to a symbol ("6.00V"), a space before a word ("2 cells") and the pin word before its number ("GPIO 4"); no unit after OFF, a SENSORS shunt's 0; and a pin's -1 in the words of the row's help, "open".
| id | the setting |
| value | its value |
| out | takes the text |
| n | bytes at out |
|
static |
Whether (x, y) is on the value of row index: the gap between its "-" and "+" keys, over the row's own height, on a number the keypad takes (ui_setting_keypad_offered()).
| index | The row. |
| x | The point's x, in the screen's coordinates. |
| y | The point's y. |
|
static |
A tap on the value of row index: the keypad of its number, over the list and the strip.
| index | The row. |
|
static |
The DOWN of the contact that holds the screen: what it presses.
| evt | The DOWN. |
| x | Its x, in the screen's coordinates. |
| y | Its y. |
|
static |
The UP of a tap the finger made: what it activates.
| kind | The HIT_ kind the press took. |
| index | The tile or row it took. |
| repeated | Whether a held key has repeated, which adds no step. |
| x | The UP's x, in the screen's coordinates. |
| y | Its y. |
| void settings_apply_ui | ( | void | ) |
Push the display-related settings – language, theme, brightness and contrast – into the interface and repaint every screen. Call at startup, and whenever an application setting changes.
| bool settings_hub_slot | ( | int | index, |
| gfx_rect_t * | out ) |
Where the hub draws its entry index, in the screen's own coordinates (the body under the band), into out when it is not NULL. False for an index outside 0 to SETTINGS_HUB_SLOTS - 1: a tenth entry has no slot on the page.
| int settings_hub_tiles | ( | void | ) |
The entries of the hub's tile table: its categories and its screens.
| int settings_screen_category | ( | void | ) |
The category whose list is open, or -1 while the hub's tiles show.
| const char * settings_screen_help | ( | setting_id_t | id | ) |
The help line of the row of id: PD mini TX and RX on one pin first, then a mark's line, then the setting's help. Hitec D receive's help follows its value: PULL-UP the setting's, PRECHARGE its own.
| const ui_keypad_t * settings_screen_keypad | ( | void | ) |
The keypad a tap on a number's value opens: over the list and the strip until OK sets the value (settings_set(), as a step does), CANCEL or the home tag drops it, or SETUP is left.
| int settings_screen_keypad_setting | ( | void | ) |
The setting the open keypad types.
| gfx_rect_t settings_screen_list_rect | ( | void | ) |
The open list's pane, in the screen's own coordinates (the body under the band): the rows show inside it and nowhere else.
| bool settings_screen_opens | ( | ui_screen_id_t | id | ) |
Whether a tile of the hub opens screen id. The home tag of such a screen leads back to SETUP rather than to the menu.
| gfx_rect_t settings_screen_row_part | ( | int | row, |
| settings_row_part_t | part ) |
Where part of list row row lies; settings_row_part_t says which part. Whether the row has keys or a keypad is the row's own: the rectangle is where they are when it does.
| row | The row, from 0. |
| part | The part. |
| gfx_rect_t settings_screen_row_rect | ( | int | row | ) |
Where list row row lies at the list's present scroll, in the screen's own coordinates; partly or wholly outside the pane for a row scrolled out of it.
| row | The row, from 0. |
| int settings_screen_scroll | ( | int * | max | ) |
How far the open category's list is scrolled.
| max | Its scroll range into, when not NULL: 0 for a list that fits its 428px. |
| void settings_screen_set_hitec_rx | ( | uint8_t | mark | ) |
What the IOmcu holds of Hitec D receive (SET_HITEC_RX), a hitec_rx_link_mark_t: HITEC_RX_LINK_HELD draws the row plain, the others mark it as an unheld row; HITEC_RX_LINK_OLD says in its help line that the IOmcu receives with PULL-UP.
| void settings_screen_set_unheld | ( | uint16_t | sense_rows, |
| uint8_t | tone_rows ) |
The INTERFACES rows whose value the IOmcu does not hold: sense_rows is sense_link_unheld()'s SENSE_LINK_ROW_* and tone_rows tone_link_unheld()'s TONE_LINK_ROWS_*. Such a row is drawn marked – its edge and its value in the warning colour, and "Not taken by the
IOmcu" in place of its help line – until a call names it no longer. Sensor SDA and Sensor SCL are one mark: the pins are one frame.
| const ui_textkey_t * settings_screen_textkey | ( | void | ) |
The keyboard a string's row opens, in folder mode for SD CARD's log folders (ui_textkey.h): open over the list and the strip until OK takes the text, CANCEL or the home tag drops it, or SETUP is left. OK sets the string as an edit; SAVE keeps it.
| bool settings_screen_unheld | ( | setting_id_t | id | ) |
Whether the row of id is marked by settings_screen_set_unheld() or settings_screen_set_hitec_rx().
| bool settings_screen_warn_line | ( | int | i, |
| char * | line, | ||
| size_t | n ) |
Line i of the warning's changes into line, as drawn: "name: saved
-> now", the values as the list shows them, each with its unit; the values in schema order, then the strings. With more changes than SETTINGS_WARN_LINES, the last line counts the rest. False past the last line, and while the warning does not show.
| bool settings_screen_warning | ( | void | ) |
Whether the warning shows: the home tag left SETUP with settings unsaved and no save asked (settings_dirty() and not settings_save_asked()), and nothing has answered it yet. STAY, the home tag again, SAVE, DISCARD and any change of screen close it.
|
static |
The "-" or "+" key of row index stepped steps times through settings_adjust(); a heading's and a string's row take none.
| index | The row. |
| steps | The steps, negative for "-". |
| 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.
| 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.
Screen-space rect of a row, or an empty rect when it is scrolled away.
| index | row index |
| 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 |
|
static |
A frame: the save button's inputs followed, a keypad whose row is held since it opened closed, and a held "-" or "+" repeated.
| dt_s | The frame's time, s. |
|
static |
A setting changed by a step or by the keypad: the PANEL rows reach the interface at once, and the list is drawn again.
| id | The setting that changed. |
|
static |