|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The SUPPLY screen's private seam between supply_screen.c, the state, the commands and the screen's interface, supply_events.c, its touch events and frames, and supply_draw.c, its drawing: the layout the three work on, the rows of SETTINGS' page, the state and the functions one calls in another. Nothing outside shared/ui includes this header; the screen's interface is supply_screen.h. More...
#include <stdbool.h>#include <stdint.h>#include "gfx.h"#include "settings.h"#include "supply_screen.h"#include "touch_types.h"#include "ui_keypad.h"#include "ui_plot.h"#include "ui_slider.h"#include "ui_tabs.h"#include "ui_text.h"#include "ui_widgets.h"#include "ui_workbench.h"Go to the source code of this file.
Data Structures | |
| struct | limit_row_t |
| One row of SETTINGS' page: the setting it edits, its label, its column and its place from the overlay's top. More... | |
| struct | sup_state_t |
| The supply screen's state: the plot, the sliders, the set points and what the supply reports, the question about a change, the keypad and the revisions the two frame buffers last drew. More... | |
Macros | |
| #define | W UI_PANEL_W |
| #define | H UI_BODY_H |
| #define | PAD UI_MARGIN |
| #define | INNER 10 |
| #define | LEFT_W 620 |
| #define | LEFT_X PAD |
| #define | RIGHT_X (LEFT_X + LEFT_W + 8) |
| #define | RIGHT_W (W - PAD - RIGHT_X) |
| #define | RC_X (RIGHT_X + 12) |
| #define | RC_W (RIGHT_W - 24) |
| #define | SU_STRIP_X UI_WB_STRIP_X |
| The task strip, LIVE | SETTINGS, at SERVO's and MOTOR & ESC's sizes: tabs of 150 x 40px, 4px apart, from (9, 8); the page from y 56. The shared UI_WB_ figures plus the difference. | |
| #define | SU_STRIP_Y (UI_WB_STRIP_Y + 2) |
| #define | SU_STRIP_H (UI_WB_STRIP_H + 16) |
| #define | SU_TAB_W (UI_WB_TAB_W + 38) |
| #define | SU_TAB_GAP UI_WB_TAB_GAP |
| #define | SU_PAGE_Y (UI_WB_PAGE_Y + 18) |
| #define | STOP_FLOOR (UI_ALERT_Y - UI_BAND_H - 4) |
| The lowest row a control that stops what the bench drives, or a line of text, may reach: 4px above the alert band. | |
| #define | SU_FONT_LABEL (&gfx_font_10x20) |
| The faces of the 1024 x 600 type scale this screen draws in. | |
| #define | SU_FONT_FINE UI_FONT_FINE |
| #define | SU_FONT_BODY UI_FONT_BODY |
| #define | SU_FONT_HEAD (&gfx_font_20x36) |
| #define | SU_FONT_NUM (&gfx_font_num_32x44) |
| #define | LINE_H 20 |
| A line of SU_FONT_LABEL, px. | |
| #define | TASKS (UI_WB_HAS(UI_WB_LIVE) | UI_WB_HAS(UI_WB_SETTINGS)) |
| The strip's tasks: LIVE and SETTINGS. | |
| #define | INFO_X (SU_STRIP_X + 2 * SU_TAB_W + SU_TAB_GAP + 3 + 12) |
| The header's left edge: 12px right of the strip's trough. | |
| #define | INFO_Y (SU_STRIP_Y + (SU_STRIP_H - LINE_H) / 2) |
| Its top: centred on the strip's 40px. | |
| #define | TITLE_H 20 |
| A panel's title strip, the accent tag on its top edge, px. | |
| #define | RAIL_Y SU_PAGE_Y |
| #define | CARD_H 64 |
| #define | CARD_GAP 4 |
| #define | CTL_Y (RAIL_Y + 4 * CARD_H + 3 * CARD_GAP + 8) |
| The CONTROL card's top: 8px under the fourth reading card. | |
| #define | CTL_H (H - PAD - CTL_Y) |
| #define | BTN_H UI_TAP_MIN |
| #define | RESET_Y (CTL_Y + TITLE_H + 14) |
| #define | OUT_Y (RESET_Y + BTN_H + 10) |
| #define | OUT_H 60 |
| #define | UP_Y SU_PAGE_Y |
| #define | UP_H 240 |
| #define | LO_Y (UP_Y + UP_H + 8) |
| #define | LO_H (H - PAD - LO_Y) |
| #define | TAB_X (LEFT_X + INNER) |
| #define | TAB_Y (UP_Y + TITLE_H + 6) |
| #define | TAB_H 40 |
| #define | TAB_W 200 |
| #define | LEG_Y (TAB_Y + TAB_H + 4) |
| #define | LEG_H 20 |
| #define | PLOT_X (LEFT_X + INNER) |
| #define | PLOT_W (LEFT_W - 2 * INNER) |
| #define | PLOT_Y (LEG_Y + LEG_H + 4) |
| #define | PLOT_H (UP_Y + UP_H - INNER - PLOT_Y) |
| #define | TBL_SET_DX 150 |
| TABLE's SET column, from PLOT_X: SUP_TABLE_HEAD's cell 15. | |
| #define | TBL_NOW_DX 300 |
| #define | TBL_UNIT_DX 400 |
| #define | TBL_PITCH 30 |
| #define | SET_ROW_H 82 |
| #define | SET_Y0 (LO_Y + TITLE_H + 4) |
| #define | SET_TEXT_H LINE_H |
| #define | SET_CTRL_DY 26 |
| #define | SET_CTRL_H UI_TAP_MIN |
| #define | NUDGE_W 72 |
| #define | SET_VAL_W 120 |
| #define | SET_VAL_X (LEFT_X + LEFT_W - INNER - SET_VAL_W) |
| The value's box: at the card's padding on the right. | |
| #define | SET_UP_X (SET_VAL_X - 8 - NUDGE_W) |
| The fine step up: 8px left of the value. | |
| #define | SET_TRACK_X (LEFT_X + INNER + NUDGE_W + 8) |
| #define | SET_TRACK_W (SET_UP_X - 8 - SET_TRACK_X) |
| #define | NUDGE_V 0.1f |
| #define | NUDGE_I 0.1f |
| #define | OV_X LEFT_X |
| #define | OV_Y SU_PAGE_Y |
| #define | OV_W LEFT_W |
| #define | OV_H (H - OV_Y - PAD) |
| #define | OV_ROW_H UI_TAP_MIN |
| #define | OV_PITCH 56 |
| #define | OV_HEAD_H 28 |
| #define | OV_VAL_W 120 |
| #define | OV_COL_W 260 |
| #define | OV_COL0_X (OV_X + INNER) |
| #define | OV_COL1_X (OV_COL0_X + OV_COL_W + 16) |
| #define | OV_COL1_W (OV_X + OV_W - INNER - OV_COL1_X) |
| #define | OV_SAVE_Y (STOP_FLOOR - LINE_H) |
| #define | OV_HELP_PITCH 18 |
| #define | OV_CAPS_DY 8 |
| #define | OV_RESTART_DY 152 |
| #define | OV_HELP_DY 204 |
| #define | OV_CONFIRM_DY 268 |
| #define | OV_MODRESET_DY 300 |
| #define | ASK_BTN_W 240 |
| #define | ASK_BTN_H 60 |
| #define | ASK_BTN_Y (OV_Y + 240) |
| #define | ASK_PITCH 26 |
| #define | SAMPLE_HZ 20.0f |
| The panel loop's sample rate, 20Hz, which is the plot's time base. | |
| #define | ROW_COUNT ((int)(sizeof(k_rows) / sizeof(k_rows[0]))) |
| Number of rows in k_rows. | |
| #define | s sup_s |
| Short name for sup_s inside the supply screen's files. | |
Enumerations | |
| enum | { S_VOLT = 0 , S_CURR , S_POWER , S_READINGS , S_VSET = S_READINGS , S_ISET , S_COUNT } |
| enum | { P_NONE = 0 , P_OUTPUT , P_RESET , P_V_DOWN , P_V_UP , P_I_DOWN , P_I_UP , P_V_SLIDER , P_I_SLIDER , P_TABS , P_CARD_V , P_CARD_I , P_VALUE_V , P_VALUE_I , P_STRIP , P_ROW , P_KEYPAD , P_APPLY , P_DISCARD , P_MODRESET } |
| enum | { FROM_SLIDER = 0 , FROM_KEYPAD } |
| enum | { KP_NONE = 0 , KP_SET_V , KP_SET_I , KP_SETTING } |
Functions | |
| void | sup_bind_colours (void) |
| Sets the plot's series colours from the active theme. | |
| gfx_rect_t | sup_set_value_rect (int row) |
| A set point's value, at the right end of its controls: tapped, the keypad. | |
| gfx_rect_t | sup_card_rect (int i) |
Returns the rectangle of reading card i on the rail. | |
| gfx_rect_t | sup_strip_area (void) |
| The strip's row with its trough's 3px around it. | |
| bool | sup_on_live (void) |
| Returns whether the LIVE task shows. | |
| gfx_rect_t | sup_overlay_area (void) |
| Returns the area the keypad, the question and SETTINGS' page take. | |
| gfx_rect_t | sup_row_rect (int i) |
SETTINGS' row i: its label and its value, in its column. | |
| gfx_rect_t | sup_row_value_rect (int i) |
The value of SETTINGS' row i, at the row's right end: tapped, the keypad or a switch's flip. | |
| void | sup_refresh_limits (void) |
| Re-reads the operator's limits from the settings and narrows the caps. | |
| void | sup_owner_settle (void) |
| Clears the owner and any owed OFF once the output is off with no ON asked. | |
| void | sup_post_on (supply_by_t by) |
| Asks for the output ON, unless an OFF is pending or a programming port holds the supply. | |
| void | sup_post_off (void) |
| Asks for the output OFF. | |
| void | sup_let_go (void) |
| Ends the press on a slider or key and lets the set points follow the supply. | |
| bool | sup_confirm_needed (int from) |
| Returns whether a change waits for a confirmation: only while the output is on and as the operator's settings ask. | |
| void | sup_propose (int from) |
| Gives a set point change to the supply, or opens the question when one is needed. | |
| bool | sup_confirm_stands (void) |
| Returns whether the question about a live output still stands: the output on or an ON on its way, and no stop since it was asked. | |
| void | sup_confirm_close (bool apply) |
| Closes the question, applying the pending change or dropping it. | |
| void | sup_drop_press (void) |
| Drops the press as a lost release: a gesture asks for nothing, except a tap on OUTPUT OFF, which is sent. | |
| bool | sup_safe_at (int x, int y) |
Returns whether (x, y) is on OUTPUT OFF, the one control here whose press stops what the bench drives. | |
| void | sup_event (const touch_event_t *evt) |
| Takes a touch event: presses, drags and releases on the screen's controls. | |
| void | sup_tick (float dt_s) |
| Advances the screen by one frame: holds, repeats and the question about a live output. | |
| void | sup_render (gfx_canvas_t *c, int buffer_index) |
| A frame: the chrome once per framebuffer, then each part on its own counter. | |
Variables | |
| static const limit_row_t | k_rows [] |
| The settings SETTINGS' page edits, in two columns; a start value is capped like the set point it starts and a trip of 0 is off. | |
| sup_state_t | sup_s |
| The supply screen's state, in supply_screen.c. | |
| const ui_plot_series_t | sup_series [S_COUNT] |
| The plot's five series: voltage, current, power, and the voltage and current set points. | |
The SUPPLY screen's private seam between supply_screen.c, the state, the commands and the screen's interface, supply_events.c, its touch events and frames, and supply_draw.c, its drawing: the layout the three work on, the rows of SETTINGS' page, the state and the functions one calls in another. Nothing outside shared/ui includes this header; the screen's interface is supply_screen.h.
Included last: its layout macros have short names (W, H, PAD) and it names the state s, which no header included after it may meet. What one file calls or reads in another carries the prefix sup_.
SPDX-License-Identifier: MIT
| #define ASK_BTN_H 60 |
Their height, px.
| #define ASK_BTN_W 240 |
APPLY and CANCEL, px.
| #define ASK_BTN_Y (OV_Y + 240) |
Their top: y 296.
| #define ASK_PITCH 26 |
Its sentences' lines, px.
| #define BTN_H UI_TAP_MIN |
RESET PEAKS' height, px.
| #define CARD_GAP 4 |
Between two of them, px.
| #define CARD_H 64 |
A reading card's height.
| #define H UI_BODY_H |
The body's height under the band, px.
| #define INNER 10 |
A card's own padding, px.
| #define LEFT_W 620 |
The left column, px.
| #define LEFT_X PAD |
Its left edge, px.
| #define LEG_H 20 |
Its height, px.
| #define NUDGE_I 0.1f |
The current's step, A.
| #define NUDGE_V 0.1f |
The voltage's step, V.
| #define NUDGE_W 72 |
A step key's width, px.
| #define OUT_H 60 |
Its height: 9.0mm.
| #define OV_CAPS_DY 8 |
LIMITS and TRIPS, px.
| #define OV_COL_W 260 |
The left column, px.
| #define OV_CONFIRM_DY 268 |
CONFIRM WHILE ON, px.
| #define OV_HEAD_H 28 |
A heading's line, px.
| #define OV_HELP_DY 204 |
The trips' help, px.
| #define OV_HELP_PITCH 18 |
The help's lines, px.
| #define OV_MODRESET_DY 300 |
RESET PD MINI, px.
| #define OV_PITCH 56 |
From row to row, px.
| #define OV_RESTART_DY 152 |
AFTER RESTART, px.
| #define OV_ROW_H UI_TAP_MIN |
A row's height, px.
| #define OV_SAVE_Y (STOP_FLOOR - LINE_H) |
The save line, px.
| #define OV_VAL_W 120 |
A row's value, px.
| #define OV_W LEFT_W |
620px.
| #define OV_X LEFT_X |
The left column, px.
| #define OV_Y SU_PAGE_Y |
Under the strip: y 56.
| #define PAD UI_MARGIN |
The outer margin, px.
| #define RAIL_Y SU_PAGE_Y |
The first card, px.
| #define RC_W (RIGHT_W - 24) |
Its width: 356px.
| #define RC_X (RIGHT_X + 12) |
The rail's column: x 648.
| #define SET_CTRL_DY 26 |
From label to controls.
| #define SET_CTRL_H UI_TAP_MIN |
Keys, track, value, px.
| #define SET_ROW_H 82 |
From row to row, px.
| #define SET_TEXT_H LINE_H |
A label's line, px.
| #define SET_TRACK_W (SET_UP_X - 8 - SET_TRACK_X) |
Its length: 312.
| #define SET_VAL_W 120 |
The value's box, px.
| #define SU_FONT_BODY UI_FONT_BODY |
12 x 24: sentences.
| #define SU_FONT_FINE UI_FONT_FINE |
8 x 16: help lines.
| #define SU_FONT_HEAD (&gfx_font_20x36) |
20 x 36: MODE, titles.
| #define SU_FONT_LABEL (&gfx_font_10x20) |
The faces of the 1024 x 600 type scale this screen draws in.
SU_FONT_LABEL (10 x 20) for every label, button, row and value; SU_FONT_FINE (8 x 16) for SETTINGS' help lines; SU_FONT_BODY (12 x 24) for the question's sentences; SU_FONT_HEAD (20 x 36) for MODE's letters, the question's title and its change; SU_FONT_NUM (32 x 44, digits, sign, point and space only) for the readings.
| #define SU_FONT_NUM (&gfx_font_num_32x44) |
32 x 44: the readings.
| #define SU_PAGE_Y (UI_WB_PAGE_Y + 18) |
The page's top: 56px.
| #define SU_STRIP_H (UI_WB_STRIP_H + 16) |
A tab's height: 40px.
| #define SU_STRIP_Y (UI_WB_STRIP_Y + 2) |
The strip's top: 8px.
| #define SU_TAB_GAP UI_WB_TAB_GAP |
Between two tabs: 4px.
| #define SU_TAB_W (UI_WB_TAB_W + 38) |
A tab's width: 150px.
| #define TAB_H 40 |
Their height, px.
| #define TAB_W 200 |
The row: two of 100px.
| #define TBL_NOW_DX 300 |
NOW: its cell 30, px.
| #define TBL_PITCH 30 |
From row to row, px.
| #define TBL_UNIT_DX 400 |
The unit, px.
| #define UP_H 240 |
Its height, px.
| #define UP_Y SU_PAGE_Y |
The output card, px.
| #define W UI_PANEL_W |
The panel's width, px: the screen's own.
| gfx_rect_t sup_card_rect | ( | int | i | ) |
Returns the rectangle of reading card i on the rail.
| i | card index, 0 to 3 |
| void sup_confirm_close | ( | bool | apply | ) |
Closes the question, applying the pending change or dropping it.
| apply | true for APPLY, false for CANCEL |
| bool sup_confirm_needed | ( | int | from | ) |
Returns whether a change waits for a confirmation: only while the output is on and as the operator's settings ask.
| from | where the change came from, FROM_SLIDER or FROM_KEYPAD |
| bool sup_confirm_stands | ( | void | ) |
Returns whether the question about a live output still stands: the output on or an ON on its way, and no stop since it was asked.
| void sup_event | ( | const touch_event_t * | evt | ) |
Takes a touch event: presses, drags and releases on the screen's controls.
| evt | the event |
| bool sup_on_live | ( | void | ) |
Returns whether the LIVE task shows.
| gfx_rect_t sup_overlay_area | ( | void | ) |
Returns the area the keypad, the question and SETTINGS' page take.
| void sup_post_on | ( | supply_by_t | by | ) |
Asks for the output ON, unless an OFF is pending or a programming port holds the supply.
| by | the screen the ON belongs to |
| void sup_propose | ( | int | from | ) |
Gives a set point change to the supply, or opens the question when one is needed.
| from | where the change came from, FROM_SLIDER or FROM_KEYPAD |
| void sup_render | ( | gfx_canvas_t * | c, |
| int | buffer_index ) |
A frame: the chrome once per framebuffer, then each part on its own counter.
| c | the canvas |
| buffer_index | the framebuffer drawn into, 0 or 1 |
| gfx_rect_t sup_row_rect | ( | int | i | ) |
SETTINGS' row i: its label and its value, in its column.
| i | the row, an index of k_rows |
| gfx_rect_t sup_row_value_rect | ( | int | i | ) |
The value of SETTINGS' row i, at the row's right end: tapped, the keypad or a switch's flip.
| i | the row, an index of k_rows |
| bool sup_safe_at | ( | int | x, |
| int | y ) |
Returns whether (x, y) is on OUTPUT OFF, the one control here whose press stops what the bench drives.
| x | column, px |
| y | row, px |
| gfx_rect_t sup_set_value_rect | ( | int | row | ) |
A set point's value, at the right end of its controls: tapped, the keypad.
| row | 0 the voltage, 1 the current limit |
| gfx_rect_t sup_strip_area | ( | void | ) |
The strip's row with its trough's 3px around it.
| void sup_tick | ( | float | dt_s | ) |
Advances the screen by one frame: holds, repeats and the question about a live output.
| dt_s | time since the last tick, s |
|
static |
The settings SETTINGS' page edits, in two columns; a start value is capped like the set point it starts and a trip of 0 is off.