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

The TARGET row: its box, its touch, its look and its text. See ui_target_row.h. More...

#include "ui_target_row.h"
#include <stdio.h>
#include <string.h>
#include "ui_pinlist.h"
#include "ui_theme.h"

Functions

void ui_target_row_init (ui_target_row_t *t, gfx_rect_t row)
 The row at row, with no press.
static bool row_tall (const ui_target_row_t *t)
 Whether the row is tall enough for the 10 x 20 face.
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: its box, its touch, its look and its text. See ui_target_row.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ row_tall()

bool row_tall ( const ui_target_row_t * t)
static

Whether the row is tall enough for the 10 x 20 face.

Parameters
tThe row, not NULL.
Returns
True from UI_TARGET_TALL_H on.

◆ 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.