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

ESC STICK's private seam between esc_stick_pages.c, the page set MOTOR & ESC opens from PROGRAM's list (the session's state, its tap walk and its hooks), and esc_stick_panel.c, the stick programmer's pages: the layout both draw on, the state both read and write, the tap walk, the text helpers both draw with, and the panel's side the page set calls. Nothing outside shared/ui includes this header; the interface is esc_stick_panel.h. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "gfx.h"
#include "prog_registry.h"
#include "touch_types.h"
#include "ui_layout.h"
#include "ui_screen.h"
#include "ui_text.h"
#include "ui_theme.h"
#include "ui_widgets.h"

Go to the source code of this file.

Data Structures

struct  stick_shared_t

Macros

#define W   UI_PANEL_W
 The panel's width, UI_PANEL_W px.
#define H   UI_BODY_H
 The body's height under the band, UI_BODY_H px.
#define SP_FONT   (&gfx_font_10x20)
 The faces: SP_FONT, the type scale's LABEL face (10 x 20, cells of SP_CELL px), for every label, button, row, value and line; SP_FONT_CRUMB, the BODY face (12 x 24), for the crumb's trail; SP_FONT_HEAD (20 x 36) for a run's phase and a panel's title; SP_FONT_NUM (32 x 44) for the beeps counted. LINE_P is the pitch of the lines a page wraps in SP_FONT.
#define SP_CELL   10
#define SP_FONT_CRUMB   (&gfx_font_12x24)
#define SP_CRUMB_CELL   12
#define SP_FONT_HEAD   (&gfx_font_20x36)
#define SP_FONT_NUM   (&gfx_font_num_32x44)
#define LINE_P   20
#define PAD   UI_MARGIN
 A full-width session's layout (prog_registry.h), in body pixels: MOTOR & ESC draws the output strip's line above PROG_FULL_Y and the pages lay out under it.
#define SP_FOOT   (H - UI_ALERT_H - 4)
#define CRUMB_Y   (PROG_FULL_Y + 2)
#define CRUMB_H   UI_TAP_MIN
#define BACK_W   120
#define BTN_H   UI_BTN_H_TALL
#define BTN_Y   (SP_FOOT - BTN_H)
 The foot row's top: 4px over the alert band, BTN_H tall.
#define FOOT_BTN_W   168
#define CARD_Y   (CRUMB_Y + CRUMB_H + 6)
#define CARD_B   (BTN_Y - 8)
#define PARM_W   660
 A profile's page and TIMING: the parameter card on the left, PARM_W wide from CARD_Y to CARD_B, with ROWS_MAX rows of ROW_H at a ROW_P pitch, so 8px lie between the keys of two rows; the side column right of it (SIDE_X, SIDE_W) with the page keys' row at PAGE_Y, MANUAL INTERVENTION REQUIRED at HAND_Y, and the device lines and the help of the row picked under them.
#define ROW_Y0   (CARD_Y + 8)
#define ROW_H   UI_TAP_MIN
#define ROW_P   56
#define ROWS_MAX   6
#define ROW_X   (PAD + 8)
#define ROW_TY   ((ROW_H - 20) / 2)
#define NAME_X   (PAD + 46)
#define STEP_W   UI_TAP_MIN
#define STEP_UP_X   (PAD + PARM_W - 8 - STEP_W)
#define STEP_DN_X   (STEP_UP_X - 8 - STEP_W)
#define CTRL_W   250
#define CTRL_X   (STEP_DN_X - 8 - CTRL_W)
#define SIDE_X   (PAD + PARM_W + 8)
#define SIDE_W   (W - PAD - SIDE_X)
#define SIDE_IN   (SIDE_X + 12)
#define SIDE_CELLS   ((SIDE_W - 24) / SP_CELL)
#define PAGE_Y   (CARD_Y + 8)
#define PAGE_KEY_W   48
#define HAND_Y   (PAGE_Y + UI_TAP_MIN + 8)
#define SIDE_B   (CARD_B - 6)
#define DEV_Y   CARD_Y
 A run and its result: the device card across the body from DEV_Y, DEV_H tall, the run's card under it to HELP_Y - 6, and two help lines across the body from HELP_Y above the foot row.
#define DEV_H   48
#define RUN_Y   (DEV_Y + DEV_H + 4)
#define HELP_P   22
#define HELP_Y   (BTN_Y - 4 - 20 - HELP_P)
#define RUN_H   (HELP_Y - 6 - RUN_Y)
#define RUN_L0   (RUN_Y + 84)
#define RUN_LINES   8
#define SP_PANEL_Y   PROG_FULL_Y
#define SP_PANEL_H   (H - PAD - SP_PANEL_Y)
#define SP_PBTN_H   UI_TAP_MIN
#define SP_PBTN_Y   (BTN_Y - 4 - SP_PBTN_H)
 A panel's buttons' top: they end 4px over the foot row.
#define DRAWER   __attribute__((noinline))
#define TAP_SLOP   8
#define SP_SHARED   static __attribute__((unused))

Enumerations

enum  prog_stage_t { STAGE_CLOSED = 0 , STAGE_LIST , STAGE_PAGE }
enum  { PASS_PRESS = 0 , PASS_TAP }

Functions

SP_SHARED bool hit (gfx_rect_t r, int px, int py)
SP_SHARED void draw_crumb (gfx_canvas_t *c, const char *trail)
 The crumb row: BACK, and trail in SP_FONT_CRUMB beside it.
SP_SHARED void widget_enum (gfx_canvas_t *c, int y, const char *text, gfx_color_t ink)
 A row's value, right-aligned in the value column.
SP_SHARED void sp_cut (char *buf, size_t n, int max_chars)
SP_SHARED void sp_copy (char *dst, size_t n, const char *src)
SP_SHARED size_t sp_line_len (const char *at, int cells)
SP_SHARED int sp_wrap (gfx_canvas_t *c, int x, int y, int pitch, const char *text, int cells, int max_lines, gfx_color_t ink)
static int sp_wrap_lines (const char *text, int cells, int max_lines)
SP_SHARED void sp_note (gfx_canvas_t *c, int x, int right, const char *text, gfx_color_t ink)
 A note at the foot of a page, from x to right, left of the buttons there: on one line level with their labels, or where it needs more, on two at LINE_P from 6px under their top.
void esc_stick_panel_reset (void)
 The page set's init: the panel's state cleared and its controls laid out, TIMING's keypad closed.
void esc_stick_panel_enter (void)
 The host's entry.
void esc_stick_panel_leave (void)
 The host is left: a run ends, the warning, the search's keyboard and TIMING's keypad close, and TIMING asks for a save of what it changed.
void esc_stick_panel_tick (float dt_s)
 A frame.
void esc_stick_panel_cancel (void)
 Touches were lost: a press that may become a tap ends, a hold ends, a key held on the keyboard or the keypad is let go with what was typed kept, and a run whose arm is not yet in force ends.
bool esc_stick_panel_down (const touch_event_t *evt)
 A DOWN on the session's pages, in the walk of hit(). TIMING's keypad, while open, takes the DOWN and nothing under it does.
bool esc_stick_panel_safe_at (int px, int py)
bool esc_stick_panel_back (void)
 The home tag in the session: TIMING's keypad closes as CANCEL does; otherwise what covers the page closes, a run ends or the session climbs a level, as BACK does; from the makers it closes the session (STAGE_CLOSED).
void esc_stick_panel_follow (const touch_event_t *evt)
 A MOVE or an UP: the search's keys, TIMING's keypad and the warning's hold follow it.
bool esc_stick_panel_holds_press (uint8_t id)
 Whether contact id holds the warning's hold, a key of the search's keyboard or a key of TIMING's keypad.
void esc_stick_panel_open (void)
 The session opens on the makers, from the top, the search as typed; TIMING and its keypad closed.
uint32_t esc_stick_panel_showing (uint32_t h)
 The panel's part of what decides which control lies under a point: the level, the pages' scrolls, what covers the page, the keyboard and TIMING's keypad.
void esc_stick_panel_render (gfx_canvas_t *c)
 Draws the page set by the stage: the manual steps, the prompt, the warning, the list or the profile's page.

Variables

stick_shared_t pg

Detailed Description

ESC STICK's private seam between esc_stick_pages.c, the page set MOTOR & ESC opens from PROGRAM's list (the session's state, its tap walk and its hooks), and esc_stick_panel.c, the stick programmer's pages: the layout both draw on, the state both read and write, the tap walk, the text helpers both draw with, and the panel's side the page set calls. Nothing outside shared/ui includes this header; the interface is esc_stick_panel.h.

The helpers below are static, and marked unused for esc_stick_pages.c, which draws none of them: esc_stick_panel.c has its own copy, and GCC inlines them or not.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ BACK_W

#define BACK_W   120

BACK's width

◆ BTN_H

#define BTN_H   UI_BTN_H_TALL

the foot row, 56px

◆ CARD_B

#define CARD_B   (BTN_Y - 8)

428: their foot

◆ CARD_Y

#define CARD_Y   (CRUMB_Y + CRUMB_H + 6)

84: the cards' top

◆ CRUMB_H

#define CRUMB_H   UI_TAP_MIN

its height, 48px

◆ CRUMB_Y

#define CRUMB_Y   (PROG_FULL_Y + 2)

the crumb row's top

◆ CTRL_W

#define CTRL_W   250

the value, 25 cells

◆ CTRL_X

#define CTRL_X   (STEP_DN_X - 8 - CTRL_W)

298

◆ DEV_H

#define DEV_H   48

its two lines

◆ DEV_Y

#define DEV_Y   CARD_Y

A run and its result: the device card across the body from DEV_Y, DEV_H tall, the run's card under it to HELP_Y - 6, and two help lines across the body from HELP_Y above the foot row.

the device card

◆ FOOT_BTN_W

#define FOOT_BTN_W   168

a foot button's width

◆ HAND_Y

#define HAND_Y   (PAGE_Y + UI_TAP_MIN + 8)

MANUAL INTERVENTION

◆ HELP_P

#define HELP_P   22

the help lines' pitch

◆ HELP_Y

#define HELP_Y   (BTN_Y - 4 - 20 - HELP_P)

390

◆ LINE_P

#define LINE_P   20

a wrapped line's pitch

◆ NAME_X

#define NAME_X   (PAD + 46)

a row's name

◆ PAD

#define PAD   UI_MARGIN

A full-width session's layout (prog_registry.h), in body pixels: MOTOR & ESC draws the output strip's line above PROG_FULL_Y and the pages lay out under it.

From the top: the crumb row (BACK 120 x 48, the trail, SEARCH or TIMING) from CRUMB_Y, the cards from CARD_Y to CARD_B, and the foot row of buttons UI_BTN_H_TALL tall from BTN_Y, which ends SP_FOOT, 4px above the alert band (UI_ALERT_H): RUN, ABORT and OK are body y 436 to 491, and an alert covers none of them. the outer margin

◆ PAGE_KEY_W

#define PAGE_KEY_W   48

"^" and "v"

◆ PAGE_Y

#define PAGE_Y   (CARD_Y + 8)

the page keys' row

◆ PARM_W

#define PARM_W   660

A profile's page and TIMING: the parameter card on the left, PARM_W wide from CARD_Y to CARD_B, with ROWS_MAX rows of ROW_H at a ROW_P pitch, so 8px lie between the keys of two rows; the side column right of it (SIDE_X, SIDE_W) with the page keys' row at PAGE_Y, MANUAL INTERVENTION REQUIRED at HAND_Y, and the device lines and the help of the row picked under them.

A row from the left: its number, the mark of a change, its name (the row's own tap, up to CTRL_X - 8), the value (CTRL_X, CTRL_W: 25 cells, TIMING's keypad), then "-" and "+" of UI_TAP_MIN, 8px apart. the parameter card

◆ ROW_H

#define ROW_H   UI_TAP_MIN

a row, 48px

◆ ROW_P

#define ROW_P   56

its pitch

◆ ROW_TY

#define ROW_TY   ((ROW_H - 20) / 2)

its text, from its top

◆ ROW_X

#define ROW_X   (PAD + 8)

a row's left

◆ ROW_Y0

#define ROW_Y0   (CARD_Y + 8)

the first row's top

◆ ROWS_MAX

#define ROWS_MAX   6

the rows a page holds

◆ RUN_H

#define RUN_H   (HELP_Y - 6 - RUN_Y)

248px

◆ RUN_L0

#define RUN_L0   (RUN_Y + 84)

its first line

◆ RUN_LINES

#define RUN_LINES   8

the lines it holds

◆ RUN_Y

#define RUN_Y   (DEV_Y + DEV_H + 4)

136: the run's card

◆ SIDE_B

#define SIDE_B   (CARD_B - 6)

the side text's end

◆ SIDE_CELLS

#define SIDE_CELLS   ((SIDE_W - 24) / SP_CELL)

31 cells a line

◆ SIDE_IN

#define SIDE_IN   (SIDE_X + 12)

its text's left

◆ SIDE_W

#define SIDE_W   (W - PAD - SIDE_X)

340px

◆ SIDE_X

#define SIDE_X   (PAD + PARM_W + 8)

676: the side column

◆ SP_CELL

#define SP_CELL   10

its cell, px

◆ SP_CRUMB_CELL

#define SP_CRUMB_CELL   12

its cell, px

◆ SP_FONT

#define SP_FONT   (&gfx_font_10x20)

The faces: SP_FONT, the type scale's LABEL face (10 x 20, cells of SP_CELL px), for every label, button, row, value and line; SP_FONT_CRUMB, the BODY face (12 x 24), for the crumb's trail; SP_FONT_HEAD (20 x 36) for a run's phase and a panel's title; SP_FONT_NUM (32 x 44) for the beeps counted. LINE_P is the pitch of the lines a page wraps in SP_FONT.

labels, rows, lines

◆ SP_FONT_CRUMB

#define SP_FONT_CRUMB   (&gfx_font_12x24)

the crumb's trail

◆ SP_FONT_HEAD

#define SP_FONT_HEAD   (&gfx_font_20x36)

a phase, a title

◆ SP_FONT_NUM

#define SP_FONT_NUM   (&gfx_font_num_32x44)

the beeps counted

◆ SP_FOOT

#define SP_FOOT   (H - UI_ALERT_H - 4)

492: controls end

◆ SP_PANEL_H

#define SP_PANEL_H   (H - PAD - SP_PANEL_Y)

its height

◆ SP_PANEL_Y

#define SP_PANEL_Y   PROG_FULL_Y

a panel's top

◆ SP_PBTN_H

#define SP_PBTN_H   UI_TAP_MIN

its buttons, 48px

◆ STEP_DN_X

#define STEP_DN_X   (STEP_UP_X - 8 - STEP_W)

556: "-"

◆ STEP_UP_X

#define STEP_UP_X   (PAD + PARM_W - 8 - STEP_W)

612: "+"

◆ STEP_W

#define STEP_W   UI_TAP_MIN

"-" and "+"

Function Documentation

◆ draw_crumb()

SP_SHARED void draw_crumb ( gfx_canvas_t * c,
const char * trail )

The crumb row: BACK, and trail in SP_FONT_CRUMB beside it.

Parameters
cThe canvas.
trailThe trail, cut to its room by the caller.

◆ esc_stick_panel_back()

bool esc_stick_panel_back ( void )

The home tag in the session: TIMING's keypad closes as CANCEL does; otherwise what covers the page closes, a run ends or the session climbs a level, as BACK does; from the makers it closes the session (STAGE_CLOSED).

Returns
True: it always acts.

◆ esc_stick_panel_down()

bool esc_stick_panel_down ( const touch_event_t * evt)

A DOWN on the session's pages, in the walk of hit(). TIMING's keypad, while open, takes the DOWN and nothing under it does.

Parameters
evtThe DOWN, or the press a tap replays.
Returns
True: the pages take every DOWN.

◆ esc_stick_panel_follow()

void esc_stick_panel_follow ( const touch_event_t * evt)

A MOVE or an UP: the search's keys, TIMING's keypad and the warning's hold follow it.

Parameters
evtThe event.

◆ esc_stick_panel_holds_press()

bool esc_stick_panel_holds_press ( uint8_t id)

Whether contact id holds the warning's hold, a key of the search's keyboard or a key of TIMING's keypad.

Parameters
idThe contact.
Returns
True when it does.

◆ esc_stick_panel_render()

void esc_stick_panel_render ( gfx_canvas_t * c)

Draws the page set by the stage: the manual steps, the prompt, the warning, the list or the profile's page.

Parameters
cthe canvas

◆ esc_stick_panel_safe_at()

bool esc_stick_panel_safe_at ( int px,
int py )

A DOWN at (x, y) lands on the ABORT of a run under way, which esc_stick_panel_down() acts on at the press.

◆ esc_stick_panel_showing()

uint32_t esc_stick_panel_showing ( uint32_t h)

The panel's part of what decides which control lies under a point: the level, the pages' scrolls, what covers the page, the keyboard and TIMING's keypad.

Parameters
hThe hash so far.
Returns
h hashed on with the panel's part.

◆ esc_stick_panel_tick()

void esc_stick_panel_tick ( float dt_s)

A frame.

Parameters
dt_sThe frame's time, s.

◆ sp_note()

SP_SHARED void sp_note ( gfx_canvas_t * c,
int x,
int right,
const char * text,
gfx_color_t ink )

A note at the foot of a page, from x to right, left of the buttons there: on one line level with their labels, or where it needs more, on two at LINE_P from 6px under their top.

Parameters
cThe canvas.
xIts left.
rightWhere it ends.
textThe note.
inkIts colour.

◆ widget_enum()

SP_SHARED void widget_enum ( gfx_canvas_t * c,
int y,
const char * text,
gfx_color_t ink )

A row's value, right-aligned in the value column.

Parameters
cThe canvas.
yThe row's top.
textThe value.
inkIts colour.