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

PICK A PIN's private seam between picker_screen.c, the state, the touch handling and the screen's interface, picker_geometry.c, where the board, its pads, buttons and marks and the protocol list sit, and picker_draw.c, the drawing: the layout they work on, the state and the functions one calls in another. Nothing outside shared/ui includes this header; the screen's interface is picker_screen.h. More...

#include <stdbool.h>
#include <stdint.h>
#include "gfx.h"
#include "link_drawing.h"
#include "out_bind.h"
#include "outputs_screen.h"
#include "picker_screen.h"
#include "ui_cats.h"
#include "ui_layout.h"
#include "ui_screen.h"
#include "ui_widgets.h"

Go to the source code of this file.

Data Structures

struct  pk_state_t
 PICK A PIN's state: the binding shown, the callbacks that apply and select, the IOmcu's drawing of the board, the press, the open protocol list, the pins of each interface and the cat. More...

Macros

#define SCREEN_W   UI_PANEL_W
#define SCREEN_H   UI_BODY_H
#define MAX_FBS   3
#define FOOT   (UI_ALERT_Y - UI_BAND_H - 4)
 The lowest row the screen draws or takes a press on, in the screen's coordinates: 4px above the alert band, body y 492.
#define PK_FONT_LABEL   (&gfx_font_10x20)
 The faces of the 1024 x 600 type scale PICK A PIN draws in.
#define PK_FONT_FINE   (&gfx_font_8x16)
#define PK_FONT_PIN   (&gfx_font_16x28)
#define PK_FONT_HEAD   (&gfx_font_20x36)
#define PK_CELL   10
#define BOARD_W   600
 The board's box: 600px wide and as tall as its outline makes it, up to 240px, centred between the body's top and FOOT.
#define BOARD_MAX_H   240
#define TIERS   2
 Two staggered tiers of keys above the board and two below.
#define TGAP   6
#define BTNW   50
#define KEY_H   UI_BTN_H_TALL
#define GAP   6
#define GND_R   18
#define GND_DROP   40
#define RAIL_R   16
#define RAIL_DROP_0   30
 Distance of a rail marker from its pad at the first depth, px.
#define RAIL_DROP_1   78
#define RING   2
#define HEAD_X   8
 Over the PINS table, left of the first key above the board: the protocol list's face, the count, and the reason no pin can be added.
#define HEAD_Y   8
#define HEAD_W   350
#define FACE_W   280
#define FACE_H   56
#define COUNT_Y   (HEAD_Y + FACE_H + 8)
#define REASON_Y   (COUNT_Y + 24)
#define REASON_PITCH   22
#define HEAD_H   (REASON_Y + REASON_PITCH + 20 - HEAD_Y)
 The head's height, px.
#define POP_W   300
#define POP_ROW   UI_TAP_MIN
#define PINS_X   8
 The PINS table, left of the board: 171px, "CH7" in the label face (30px), "GPIO 28" in PK_FONT_PIN from PINS_NAME_X in (112px, to 146px), and the pad number right-aligned (20px, from 151px).
#define PINS_Y   (HEAD_Y + HEAD_H + 10)
#define PINS_W   171
#define PINS_NAME_X   34
#define PINS_TOP   (PINS_Y + 48)
#define ROW_H   36
#define USE_W   168
 The IN USE table, right of the board: 168px from x 848, 8px right of the rightmost a key can stand (x 837).
#define USE_X   (SCREEN_W - 8 - USE_W)
#define USE_Y   4
#define USE_TOP   (USE_Y + 56)
#define USE_FOOT   FOOT
#define USE_NAME_H   20
#define USE_PIN_H   28
#define USE_PIN_H_C   20
#define USE_PIN_H_D   16
#define NOART_W   640
 The panel PICK A PIN shows when it cannot draw the board: 640 x 180px, centred over the body above FOOT.
#define NOART_H   180
#define IVORY   GFX_RGB(236, 235, 228)
#define EBONY   GFX_RGB(22, 23, 28)
#define INK   GFX_RGB(10, 10, 14)
#define HALO   GFX_RGB(6, 6, 8)
#define s   pk_s
 Short name for pk_s inside the picker's files.

Enumerations

enum  { HIT_NONE = 0 , HIT_FACE , HIT_ROW , HIT_BUTTON }

Functions

void pk_touched (void)
 Count a change: every framebuffer's picture is stale.
const outbind_shape_t * pk_shape (void)
 The shape page of the board the binding names.
const link_drawing_t * pk_drawing (void)
 The drawing, while it is the one for the board the binding names.
uint8_t pk_proto_shown (void)
 The protocol shown: the binding's, OFF for one out of range.
bool pk_prog_taken (uint8_t index)
 Whether the programming port has pin index: it is the port's and no protocol holds it. A pin a stored slot holds is that slot's – the IOmcu gives the port no pin then – and can be unticked.
outputs_iface_t pk_iface_taken (uint8_t index)
 What SETUP > INTERFACES holds pin index for: no protocol and no port holds it, and the IOmcu does not reserve it. A pin a protocol holds is that protocol's, as against a port.
int8_t pk_channel_of (uint8_t index)
 The channel the OUTPUTS page gives catalogue entry index. Channels are allocated in pin order across every protocol, so a group's first pin is not its channel 0 unless it also holds the lowest pin.
void pk_board_box (int *x, int *y, int *w, int *h)
 Gives the box the board occupies: the drawing's outline or else the shape's, centred across the screen between the body's top and FOOT.
bool pk_pad_xy (uint8_t pad, int *px, int *py)
 Gives where a pad sits on screen, from the drawing's pad record or else the shape's grid.
bool pk_pad_is_top (uint8_t pad)
 Returns which of the two pad rows a pad is in.
bool pk_button_at (int i, gfx_rect_t *out, int *tier_out)
 Gives the button of catalogue entry i and its tier; only a pin an output may have gets one.
bool pk_marker_at (uint8_t e, int *mx, int *my, int *r)
 Gives the centre and radius of the marker of pad-list entry e.
int pk_pop_rows (void)
 Returns the rows of the protocol list: the protocols, then one PROG PORT entry per port.
gfx_rect_t pk_pop_rect (void)
 Returns the protocol list's rectangle: one column of POP_W px, two with PROG PORT entries.
void pk_render (gfx_canvas_t *c, int buffer_index)
 Draws the screen into frame buffer buffer_index.
void pk_cat_enter (void)
 A visit begins: roll for the cat, picked on its first frame.
void pk_cat_reset (void)
 Forget the cat: none until the next visit.
void pk_cat_render (gfx_canvas_t *c)
 Pick the cat on a visit's first frame and draw it while its box is clear; called last in a frame that draws the static parts.

Variables

pk_state_t pk_s
 The screen's state; picker_screen_int.h names it s.

Detailed Description

PICK A PIN's private seam between picker_screen.c, the state, the touch handling and the screen's interface, picker_geometry.c, where the board, its pads, buttons and marks and the protocol list sit, and picker_draw.c, the drawing: the layout they work on, the state and the functions one calls in another. Nothing outside shared/ui includes this header; the screen's interface is picker_screen.h.

Included last: its layout macros have short names (GAP, ROW_H, INK) and it names the state s, which no header included after it may meet. The functions one file calls in another carry the prefix pk_.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ BOARD_MAX_H

#define BOARD_MAX_H   240

The box's tallest, px.

◆ BOARD_W

#define BOARD_W   600

The board's box: 600px wide and as tall as its outline makes it, up to 240px, centred between the body's top and FOOT.

240px leaves 126px above and below for two tiers of 56px keys with their gaps. The RP2350-CAN's outline, 51 x 21mm, draws 582 x 240px, a 0.1 in pitch at 29px.

◆ BTNW

#define BTNW   50

A key's width, px.

◆ COUNT_Y

#define COUNT_Y   (HEAD_Y + FACE_H + 8)

The count's line.

◆ EBONY

#define EBONY   GFX_RGB(22, 23, 28)

board colour of the ebony (black) key

◆ FACE_H

#define FACE_H   56

Its height, px.

◆ FACE_W

#define FACE_W   280

The list's face, px.

◆ GAP

#define GAP   6

Board edge to the nearer tier, px.

◆ GND_DROP

#define GND_DROP   40

distance of a ground marker from its pad, px

◆ GND_R

#define GND_R   18

radius of a ground marker, px

◆ HALO

#define HALO   GFX_RGB(6, 6, 8)

halo colour around a marker's text

◆ HEAD_W

#define HEAD_W   350

The reason's first line: 35 cells.

◆ HEAD_X

#define HEAD_X   8

Over the PINS table, left of the first key above the board: the protocol list's face, the count, and the reason no pin can be added.

The face is 280 x 56px: the longest protocol name, "DSHOT600 BIDIR", draws in the 16 x 28 face there (224px of the 225px left of its chevron), every other name in 20 x 36. The reason takes a second line where it needs one: the first holds 35 cells (350px), beside the keys above the board; the second, beside the board itself, what is left of it, 17 cells at most (test_picker_screen_table holds every reason to it), so it ends at x 178, left of the widest board's edge at x 212. The head's left edge.

◆ HEAD_Y

#define HEAD_Y   8

Its top.

◆ INK

#define INK   GFX_RGB(10, 10, 14)

text colour on a marker

◆ IVORY

#define IVORY   GFX_RGB(236, 235, 228)

board colour of the ivory (white) key

◆ KEY_H

#define KEY_H   UI_BTN_H_TALL

A key's height, px.

◆ MAX_FBS

#define MAX_FBS   3

Framebuffers the chrome is cached for.

◆ NOART_H

#define NOART_H   180

Its height, px.

◆ PINS_NAME_X

#define PINS_NAME_X   34

A pin name's left edge in it, px.

◆ PINS_TOP

#define PINS_TOP   (PINS_Y + 48)

The first row's top.

◆ PINS_W

#define PINS_W   171

Its width, px.

◆ PINS_X

#define PINS_X   8

The PINS table, left of the board: 171px, "CH7" in the label face (30px), "GPIO 28" in PK_FONT_PIN from PINS_NAME_X in (112px, to 146px), and the pad number right-aligned (20px, from 151px).

It starts under the reason's second line; its 8 rows of 36px, the most a protocol holds, end at body y 484. A row is read, not tapped. It ends at x 179, 8px left of the leftmost a key can stand: half a key left of the widest board's edge (x 212), where a board that reports its own shape may put its first pad. The table's left edge.

◆ PINS_Y

#define PINS_Y   (HEAD_Y + HEAD_H + 10)

Its heading's top.

◆ PK_CELL

#define PK_CELL   10

PK_FONT_LABEL's cell width, px.

◆ PK_FONT_FINE

#define PK_FONT_FINE   (&gfx_font_8x16)

8 x 16: rails, 16px rows.

◆ PK_FONT_HEAD

#define PK_FONT_HEAD   (&gfx_font_20x36)

20 x 36: heads, key numbers.

◆ PK_FONT_LABEL

#define PK_FONT_LABEL   (&gfx_font_10x20)

The faces of the 1024 x 600 type scale PICK A PIN draws in.

PK_FONT_LABEL (10 x 20) for the count, the reason, the PAD head, a channel, a pad number, a name in IN USE and a pin there in the 20px rows; PK_FONT_FINE (8 x 16) for a rail's voltage, BY OTHERS and the 16px rows of IN USE; PK_FONT_PIN (16 x 28) for a ground's G and a pin in IN USE's 28px rows and a pin name under PINS; PK_FONT_HEAD (20 x 36) for PINS, IN USE and a key's GPIO number.

◆ PK_FONT_PIN

#define PK_FONT_PIN   (&gfx_font_16x28)

16 x 28: IN USE's pins.

◆ POP_ROW

#define POP_ROW   UI_TAP_MIN

A row, px.

◆ POP_W

#define POP_W   300

A column's width, px.

◆ RAIL_DROP_1

#define RAIL_DROP_1   78

distance at the second depth, px

◆ RAIL_R

#define RAIL_R   16

radius of a rail marker, px

◆ REASON_PITCH

#define REASON_PITCH   22

The reason's second line under its first.

◆ REASON_Y

#define REASON_Y   (COUNT_Y + 24)

The reason's first line.

◆ RING

#define RING   2

width of the dark ring around a marker, px

◆ ROW_H

#define ROW_H   36

A row, px.

◆ SCREEN_H

#define SCREEN_H   UI_BODY_H

The body under the band, px.

◆ SCREEN_W

#define SCREEN_W   UI_PANEL_W

The panel's width, px.

◆ TGAP

#define TGAP   6

Between the two tiers, px.

◆ TIERS

#define TIERS   2

Two staggered tiers of keys above the board and two below.

A key is 50 x 56px (7.5 x 8.4mm). The tier alternates along a pad row, so two keys in one tier stand two pads apart at least: 58px at the RP2350-CAN's pitch, 8px between them. TGAP is between the two tiers, GAP between the board's edge and the nearer tier. Tiers above and below.

◆ USE_FOOT

#define USE_FOOT   FOOT

Where its lines end.

◆ USE_NAME_H

#define USE_NAME_H   20

A name's line, px.

◆ USE_PIN_H

#define USE_PIN_H   28

A pin's line, px.

◆ USE_PIN_H_C

#define USE_PIN_H_C   20

A pin's line past the foot at 28.

◆ USE_PIN_H_D

#define USE_PIN_H_D   16

And where 20px does.

◆ USE_TOP

#define USE_TOP   (USE_Y + 56)

Its first line.

◆ USE_W

#define USE_W   168

The IN USE table, right of the board: 168px from x 848, 8px right of the rightmost a key can stand (x 837).

Its lines start under the heading, the rule and the BY OTHERS line and end at FOOT. A name is 20px; a pin is 28px with the GPIO in PK_FONT_PIN, or 20px with it in the label face when the 28px rows run past the foot, and 16px in 8 x 16 when the 20px rows do. Its width, px.

◆ USE_X

#define USE_X   (SCREEN_W - 8 - USE_W)

The table's left edge.

◆ USE_Y

#define USE_Y   4

Its heading's top.

Function Documentation

◆ pk_board_box()

void pk_board_box ( int * x,
int * y,
int * w,
int * h )

Gives the box the board occupies: the drawing's outline or else the shape's, centred across the screen between the body's top and FOOT.

Parameters
xtakes the left edge, px
ytakes the top edge, px
wtakes the width, px
htakes the height, px

◆ pk_button_at()

bool pk_button_at ( int i,
gfx_rect_t * out,
int * tier_out )

Gives the button of catalogue entry i and its tier; only a pin an output may have gets one.

Parameters
icatalogue entry
outtakes the button's rectangle
tier_outtakes the tier, 0 for the row nearer the board
Returns
true when the entry has a button

◆ pk_cat_render()

void pk_cat_render ( gfx_canvas_t * c)

Pick the cat on a visit's first frame and draw it while its box is clear; called last in a frame that draws the static parts.

Parameters
cthe screen's canvas

◆ pk_channel_of()

int8_t pk_channel_of ( uint8_t index)

The channel the OUTPUTS page gives catalogue entry index. Channels are allocated in pin order across every protocol, so a group's first pin is not its channel 0 unless it also holds the lowest pin.

Parameters
indexthe pin's index in the board's catalogue
Returns
the channel, or -1

◆ pk_drawing()

const link_drawing_t * pk_drawing ( void )

The drawing, while it is the one for the board the binding names.

Returns
the drawing, or NULL

◆ pk_iface_taken()

outputs_iface_t pk_iface_taken ( uint8_t index)

What SETUP > INTERFACES holds pin index for: no protocol and no port holds it, and the IOmcu does not reserve it. A pin a protocol holds is that protocol's, as against a port.

Parameters
indexthe pin's index in the board's catalogue
Returns
the interface, or OUTPUTS_IFACE_NONE

◆ pk_marker_at()

bool pk_marker_at ( uint8_t e,
int * mx,
int * my,
int * r )

Gives the centre and radius of the marker of pad-list entry e.

Parameters
epad-list entry
mxtakes the centre x, px
mytakes the centre y, px
rtakes the radius, px
Returns
true when the pad has a marker

◆ pk_pad_is_top()

bool pk_pad_is_top ( uint8_t pad)

Returns which of the two pad rows a pad is in.

Parameters
padthe pad
Returns
true for the upper row

◆ pk_pad_xy()

bool pk_pad_xy ( uint8_t pad,
int * px,
int * py )

Gives where a pad sits on screen, from the drawing's pad record or else the shape's grid.

Parameters
padthe pad
pxtakes the x of the pad's ring centre, px
pytakes the y of the pad's ring centre, px
Returns
true when the pad is on the board

◆ pk_pop_rect()

gfx_rect_t pk_pop_rect ( void )

Returns the protocol list's rectangle: one column of POP_W px, two with PROG PORT entries.

Returns
the rectangle

◆ pk_pop_rows()

int pk_pop_rows ( void )

Returns the rows of the protocol list: the protocols, then one PROG PORT entry per port.

Returns
the row count

◆ pk_prog_taken()

bool pk_prog_taken ( uint8_t index)

Whether the programming port has pin index: it is the port's and no protocol holds it. A pin a stored slot holds is that slot's – the IOmcu gives the port no pin then – and can be unticked.

Parameters
indexthe pin's index in the board's catalogue
Returns
true when the port has it

◆ pk_proto_shown()

uint8_t pk_proto_shown ( void )

The protocol shown: the binding's, OFF for one out of range.

Returns
its index in the catalogue

◆ pk_render()

void pk_render ( gfx_canvas_t * c,
int buffer_index )

Draws the screen into frame buffer buffer_index.

Parameters
ccanvas drawn on
buffer_indexthe frame buffer

◆ pk_shape()

const outbind_shape_t * pk_shape ( void )

The shape page of the board the binding names.

Returns
the shape, or NULL for a board without one

◆ pk_touched()

void pk_touched ( void )

Count a change: every framebuffer's picture is stale.

A change invalidates every framebuffer, and a render validates the one it drew. Not a counter compared against the last frame drawn: with two buffers alternating, a counter that is satisfied by the first of them leaves the second holding the old picture, and clearing the others on every paint instead makes the screen repaint for ever.

A repaint draws the board, every button and both tables; a picker that never settled would spend that on every frame for as long as it is open.