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

PICK A PIN's state, touch handling and interface: the board, with a button on every pin an output may have. See picker_screen.h. More...

#include "picker_screen.h"
#include <stdio.h>
#include <string.h>
#include "board_drawing.h"
#include "link_pages.h"
#include "outputs_screen.h"
#include "outputs_screen_int.h"
#include "picker_port.h"
#include "port_view.h"
#include "ui_text.h"
#include "picker_screen_int.h"

Functions

void pk_touched (void)
 Count a change: every framebuffer's picture is stale.
void picker_screen_invalidate (void)
const outbind_t * picker_screen_binding (void)
void picker_screen_set_binding (const outbind_t *b)
void picker_screen_follow (uint8_t proto, bool editable)
bool picker_screen_editable (void)
void picker_screen_set_apply (picker_apply_fn fn)
 Name the function a tick or untick applies the binding through.
void picker_screen_set_select (picker_select_fn fn)
 Name the function a pick in the list tells the Outputs screen by.
void picker_screen_set_drawing_source (picker_drawing_fn fn)
 Name the function that asks for the drawing of a board.
bool picker_screen_set_drawing (const uint8_t *data, uint32_t bytes, const char **why)
void picker_screen_set_prog_ports (uint8_t count, const uint8_t *pins)
void picker_screen_set_prog_pin (uint8_t gpio)
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.
bool picker_screen_has_drawing (void)
bool picker_screen_can_draw (void)
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.
uint8_t picker_screen_prog_listed (void)
picker_pin_t picker_screen_pin (uint8_t index, char *holder, size_t cap)
 The state of catalogue entry index, as the screen draws it.
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.
bool picker_screen_row (uint8_t k, picker_row_t *out)
void picker_screen_count (char *buf, size_t cap)
bool picker_screen_reason (char *buf, size_t cap)
static int button_under (int x, int y)
 The key under a point.
static void pick (uint8_t proto)
 Pick a protocol. A pick says which set is shown and which group the next tap joins. It changes no page, so nothing is written; the outputs screen is told, so the two screens show one selection.
static void pick_port (uint8_t port)
 Pick a port: its pin is the one a tap sets. The outputs screen shows the same entry.
void picker_screen_open_on_port (uint8_t port)
int picker_screen_port_shown (void)
static void event (const touch_event_t *evt)
 A touch event: the list, the face or a key.
static void reset (void)
 Forget everything: no binding, no list, no cat.
static void enter (void)
 A visit begins.
static void leave (void)
 The screen is left: no press, the list closed.
static bool back (void)
 The home tag closes an open protocol list without choosing; with none open it leaves the screen.
static void cancel (void)
 Forget the press under way.
const ui_screen_t * picker_screen (void)
 The pin picker.

Variables

pk_state_t pk_s
 The screen's state; picker_screen_int.h names it s.
static int g_open_port = -1
 The port the next entry opens on, -1 for OFF: picker_screen_open_on_port(), once.
static uint8_t g_prog_pins [LINK_PG_PORTS_MAX]
 The GPIOs the IOmcu's programming ports are bound to, PICKER_NO_PIN for none. Kept out of s so a reset of the screen does not forget them.
static const ui_screen_t s_screen
 The screen's hooks for the router.

Detailed Description

PICK A PIN's state, touch handling and interface: the board, with a button on every pin an output may have. See picker_screen.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ back()

bool back ( void )
static

The home tag closes an open protocol list without choosing; with none open it leaves the screen.

Returns
true when it closed the list

◆ button_under()

int button_under ( int x,
int y )
static

The key under a point.

Parameters
xthe point's column, screen coordinates
yits row
Returns
the key's pin index, or -1 for none

◆ cancel()

void cancel ( void )
static

Forget the press under way.

Touch events were lost between two frames, so the button recorded under the finger may not be under one any more. A release toggles the pin when it lands on the button the press began on, and a stale record turns the next release over that button into a binding change nobody asked for.

◆ enter()

void enter ( void )
static

A visit begins.

Every visit opens on the overview, as the Outputs screen's does: OFF selected here for the first frame, and on the Outputs screen through the select hook, which this screen follows every frame. Without the hook the next follow puts the Outputs screen's protocol back; without the line here the first frame shows the protocol before.

◆ event()

void event ( const touch_event_t * evt)
static

A touch event: the list, the face or a key.

Parameters
evtthe event, or NULL

◆ pick()

void pick ( uint8_t proto)
static

Pick a protocol. A pick says which set is shown and which group the next tap joins. It changes no page, so nothing is written; the outputs screen is told, so the two screens show one selection.

Parameters
protothe protocol's index in the catalogue

◆ pick_port()

void pick_port ( uint8_t port)
static

Pick a port: its pin is the one a tap sets. The outputs screen shows the same entry.

Parameters
portthe port, from 0

◆ picker_screen()

const ui_screen_t * picker_screen ( void )

The pin picker.

Returns
its hooks

◆ picker_screen_binding()

const outbind_t * picker_screen_binding ( void )

The current choice, for anything that has to write it.

◆ picker_screen_can_draw()

bool picker_screen_can_draw ( void )

Whether this board can be drawn at all: it has a catalogue, and a drawing or a shape.

◆ picker_screen_count()

void picker_screen_count ( char * buf,
size_t cap )

The count under the protocol list: slots in use of 8, every protocol.

◆ picker_screen_editable()

bool picker_screen_editable ( void )

Whether a tap on a button can change the binding.

◆ picker_screen_follow()

void picker_screen_follow ( uint8_t proto,
bool editable )

Follow the outputs screen: the protocol selected there is the group a tap here joins, and a binding that is not confirmed there (outputs_screen_editable() false) is not edited here either. Called every frame; it repaints only on a change.

While editable is false every button is drawn as not offered, NOT READ stands under the protocol list, and a tap changes nothing and calls nothing.

◆ picker_screen_has_drawing()

bool picker_screen_has_drawing ( void )

Whether the board is drawn from the IOmcu's drawing.

◆ picker_screen_invalidate()

void picker_screen_invalidate ( void )

Repaint the cached chrome in every framebuffer.

◆ picker_screen_open_on_port()

void picker_screen_open_on_port ( uint8_t port)

The next entry to this screen opens on PROG PORT port (0 for port 1), as the OUTPUTS entry's PIN button asks, instead of on OFF; once.

With a port picked, in this list or on OUTPUTS, a button is the port's pin: its own pin is ticked and a tap on it asks the IOmcu for no pin, a tap on a free pin asks for that pin (port_view_ask()). A SERVO PWM port is refused the slice of a bound PWM output and the compare register of another SERVO PWM port; a NONE port takes any free pin. The pins are the IOmcu's to take: the ask waits for a bench at rest, and the line under the count says how it stands.

◆ picker_screen_pin()

picker_pin_t picker_screen_pin ( uint8_t index,
char * holder,
size_t cap )

The state of catalogue entry index, as the screen draws it.

Parameters
indexthe pin's catalogue entry
holderNULL, or takes what holds the pin: the protocol's name, PROG PORT, or the pin a PWM pin clashes with (outputs_clash_label(): "SLICE OF GPIO 13", "PWM CH OF GPIO 0") for PICKER_PIN_HELD, the reserving function for PICKER_PIN_RESERVED, and an empty string otherwise
capbytes at holder
Returns
the pin's state

◆ picker_screen_port_shown()

int picker_screen_port_shown ( void )

The port picked, 0 for port 1, or -1 for a protocol.

◆ picker_screen_prog_listed()

uint8_t picker_screen_prog_listed ( void )

The first GPIO IN USE lists under PROG PORT, or PICKER_NO_PIN.

◆ picker_screen_reason()

bool picker_screen_reason ( char * buf,
size_t cap )

The amber line under the count: NOT READ while the binding is not confirmed, else the reason the protocol selected can take no more pins (outputs_reason_of()), else why the PWM generator cannot take the pin last tapped (outputs_clash_reason()), until another pick or tick. False and an empty string when there is none.

◆ picker_screen_row()

bool picker_screen_row ( uint8_t k,
picker_row_t * out )

Line k of the PINS table, in catalogue order; false past the last.

◆ picker_screen_set_apply()

void picker_screen_set_apply ( picker_apply_fn fn)

Name the function a tick or untick applies the binding through.

Parameters
fnthe function, or NULL for none

◆ picker_screen_set_binding()

void picker_screen_set_binding ( const outbind_t * b)

Set the choice: this screen and the outputs screen are two views of one. A binding that names another board asks the drawing source (picker_screen_set_drawing_source()) for that board's drawing.

◆ picker_screen_set_drawing()

bool picker_screen_set_drawing ( const uint8_t * data,
uint32_t bytes,
const char ** why )

The IOmcu's drawing of the board the binding names (LINK_ART_DRAWING bytes, link_drawing.h), or NULL to draw its outline instead.

Parsed and checked against the board's catalogue, pads and shape here; a drawing that fails either is not shown, and why (may be NULL) names the first thing found. The bytes are not copied and must stay unchanged until the next call. Returns whether the drawing is shown.

◆ picker_screen_set_drawing_source()

void picker_screen_set_drawing_source ( picker_drawing_fn fn)

Name the function that asks for the drawing of a board.

Parameters
fnthe function, or NULL for none

◆ picker_screen_set_prog_pin()

void picker_screen_set_prog_pin ( uint8_t gpio)

The GPIO the IOmcu's programming port is bound to, as its page reads it, or PICKER_NO_PIN (the start value): picker_screen_set_prog_ports() with that one port. While no protocol holds that pin its button is drawn held, a tap on it does nothing, and IN USE lists it first under PROG PORT. A pin a slot holds is that slot's: the IOmcu gives the port no pin then. It stays across a reset of the screen.

◆ picker_screen_set_prog_ports()

void picker_screen_set_prog_ports ( uint8_t count,
const uint8_t * pins )

Every programming port's pin: count of them (at most LINK_PG_PORTS_MAX are kept) from pins, PICKER_NO_PIN for a port without one; NULL or 0 for none. Each pin is held as picker_screen_set_prog_pin() holds one, IN USE lists them all under the one PROG PORT name, and a PWM pin is refused beside any of them (outbind_pwm_clash_ports()). It stays across a reset of the screen.

◆ picker_screen_set_select()

void picker_screen_set_select ( picker_select_fn fn)

Name the function a pick in the list tells the Outputs screen by.

Parameters
fnthe function, or NULL for none

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

Variable Documentation

◆ g_prog_pins

uint8_t g_prog_pins[LINK_PG_PORTS_MAX]
static
Initial value:
= {
}
#define PICKER_NO_PIN
Definition picker_screen.h:91

The GPIOs the IOmcu's programming ports are bound to, PICKER_NO_PIN for none. Kept out of s so a reset of the screen does not forget them.

◆ s_screen

const ui_screen_t s_screen
static
Initial value:
= {
.title = "PICK A PIN",
.reset = reset,
.enter = enter,
.leave = leave,
.tick = NULL,
.event = event,
.cancel = cancel,
.render = pk_render,
.back = back,
}
static void enter(void)
On the way in: both panes read, from their first pages the first time and as they were left after tha...
Definition files_screen.c:1026
static bool back(void)
The home tag: a box or the keyboard closes, a job's box cancels a copy and stays; with the panes on t...
Definition files_screen.c:1096
static void leave(void)
On the way out: the keyboard and the boxes close; a job under way goes on, and its box shows again on...
Definition files_screen.c:1045
static void reset(void)
The screen as a start leaves it: the card's root on the left, USER LOG FOLDER on the right,...
Definition files_screen.c:1006
static void cancel(void)
The panel could not hand over every touch event, so this screen's record of the glass is stale....
Definition log_viewer_screen.c:545
void pk_render(gfx_canvas_t *c, int buffer_index)
Draws the screen into frame buffer buffer_index.
Definition picker_draw.c:507

The screen's hooks for the router.