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

The TARGET row of a workbench's output card: what the screen drives now, read as protocol pins ("SERVO PWM GPIO 2 GPIO 4", "PROG PORT 1 GPIO 13"), and the control that picks it. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "gfx.h"
#include "touch_types.h"

Go to the source code of this file.

Data Structures

struct  ui_target_row_t
 A TARGET row: where it is and the press it holds. More...

Macros

#define UI_TARGET_LABEL_W   64
 The label's share of a row under UI_TARGET_TALL_H; the value box takes the rest.
#define UI_TARGET_TALL_H   40
 The row height from which the row draws its label and its value in the 10 x 20 face, 40px (6.0mm); a shorter row draws them in UI_FONT_LABEL (8 x 16). A screen takes the larger face with the row height its own layout gives.
#define UI_TARGET_LABEL_W_TALL   88
 The label's share of a row UI_TARGET_TALL_H tall or taller: 88px, "TARGET" in 10 x 20 and 28px clear.

Enumerations

enum  ui_target_ev_t { UI_TARGET_NONE = 0 , UI_TARGET_TAKEN , UI_TARGET_TAP }
 What a touch event was to the row. More...

Functions

void ui_target_row_init (ui_target_row_t *t, gfx_rect_t row)
 The row at row, with no press.
gfx_rect_t ui_target_row_value_rect (const ui_target_row_t *t)
 The value box: the row less the label's share.
const gfx_font_t * ui_target_row_font (const ui_target_row_t *t)
 The face the row draws its label and its value in.
unsigned ui_target_row_cells (const ui_target_row_t *t)
 How many cells of text the value box holds, in the row's face.
ui_target_ev_t ui_target_row_event (ui_target_row_t *t, const touch_event_t *evt, bool locked)
 A touch event.
void ui_target_row_cancel (ui_target_row_t *t)
 Drop a press under way, as touch events went missing.
void ui_target_row_render (const ui_target_row_t *t, gfx_canvas_t *c, const char *label, const char *value, bool warn, bool locked)
 The row: label at the left, value centred in its box, both in ui_target_row_font().
size_t ui_target_text (char *out, size_t size, const char *protocol, uint64_t pins, unsigned cells)
 protocol pins into out: "SERVO PWM GPIO 2 GPIO 4", with as many pins as fit after the protocol and a space, then "+N" (ui_pinlist()).

Detailed Description

The TARGET row of a workbench's output card: what the screen drives now, read as protocol pins ("SERVO PWM GPIO 2 GPIO 4", "PROG PORT 1 GPIO 13"), and the control that picks it.

The row is a label on the left and a value box on the right, the shape of a settings row: a tap on the box asks the screen to open its choice of targets. The row takes no press while it is locked – ARMED, a run or a sweep under way, a programmer holding the port: the screen says when – and it still names the target then. It is drawn in the warning colour when the screen says the target is none or not known.

Pure layout, text and touch logic; no state outside the struct.

SPDX-License-Identifier: MIT

Enumeration Type Documentation

◆ ui_target_ev_t

What a touch event was to the row.

Enumerator
UI_TARGET_NONE 

not the row's

UI_TARGET_TAKEN 

the row's press; nothing to do yet

UI_TARGET_TAP 

a tap on the value box: open the choice

Function Documentation

◆ ui_target_row_cancel()

void ui_target_row_cancel ( ui_target_row_t * t)

Drop a press under way, as touch events went missing.

Parameters
tThe row; NULL does nothing.

◆ ui_target_row_cells()

unsigned ui_target_row_cells ( const ui_target_row_t * t)

How many cells of text the value box holds, in the row's face.

Parameters
tThe row.
Returns
The box's width less 8px each side over the face's cell width; 0 for NULL or a box narrower than the padding.

◆ ui_target_row_event()

ui_target_ev_t ui_target_row_event ( ui_target_row_t * t,
const touch_event_t * evt,
bool locked )

A touch event.

A DOWN on the value box while not locked starts the row's press; its UP is a tap when it lands on the box as a tap (touch_event_is_tap_up()) and the row is still not locked. A DOWN while locked is taken and does nothing, so no control under the row sees it. A second contact does not take over a press under way.

Parameters
tThe row.
evtThe event.
lockedThe row takes no press now.
Returns
What the event was to the row; UI_TARGET_NONE for a NULL.

◆ ui_target_row_font()

const gfx_font_t * ui_target_row_font ( const ui_target_row_t * t)

The face the row draws its label and its value in.

Parameters
tThe row.
Returns
The 10 x 20 face from UI_TARGET_TALL_H on, UI_FONT_LABEL under it and for NULL.

◆ ui_target_row_init()

void ui_target_row_init ( ui_target_row_t * t,
gfx_rect_t row )

The row at row, with no press.

Parameters
tThe row; NULL does nothing.
rowWhere it is: the label at the left, the box the rest.

◆ ui_target_row_render()

void ui_target_row_render ( const ui_target_row_t * t,
gfx_canvas_t * c,
const char * label,
const char * value,
bool warn,
bool locked )

The row: label at the left, value centred in its box, both in ui_target_row_font().

Parameters
tThe row.
cCanvas.
labelThe label, or NULL for none.
valueThe value, or NULL for none.
warnThe label and the value in the warning colour.
lockedThe box as a control that takes no press, the value still legible.

◆ ui_target_row_value_rect()

gfx_rect_t ui_target_row_value_rect ( const ui_target_row_t * t)

The value box: the row less the label's share.

Parameters
tThe row.
Returns
The row less UI_TARGET_LABEL_W px at its left, or UI_TARGET_LABEL_W_TALL from UI_TARGET_TALL_H on; an empty rectangle for NULL or a row no wider than the label.

◆ ui_target_text()

size_t ui_target_text ( char * out,
size_t size,
const char * protocol,
uint64_t pins,
unsigned cells )

protocol pins into out: "SERVO PWM GPIO 2 GPIO 4", with as many pins as fit after the protocol and a space, then "+N" (ui_pinlist()).

With no pin, or no room for one after the protocol, the protocol alone; with a NULL or empty protocol, the pins alone.

Parameters
outWhere the text goes; NULL writes nothing.
sizeThe bytes at out; 0 writes nothing.
protocolThe protocol's name.
pinsThe pins, bit n for GPIO n.
cellsThe most characters, ui_target_row_cells().
Returns
The length written.