|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
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. | |
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
|
static |
The home tag closes an open protocol list without choosing; with none open it leaves the screen.
|
static |
The key under a point.
| x | the point's column, screen coordinates |
| y | its row |
|
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.
|
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.
|
static |
A touch event: the list, the face or a key.
| evt | the event, or NULL |
|
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.
| proto | the protocol's index in the catalogue |
|
static |
Pick a port: its pin is the one a tap sets. The outputs screen shows the same entry.
| port | the port, from 0 |
| const ui_screen_t * picker_screen | ( | void | ) |
The pin picker.
| const outbind_t * picker_screen_binding | ( | void | ) |
The current choice, for anything that has to write it.
| bool picker_screen_can_draw | ( | void | ) |
Whether this board can be drawn at all: it has a catalogue, and a drawing or a shape.
| void picker_screen_count | ( | char * | buf, |
| size_t | cap ) |
The count under the protocol list: slots in use of 8, every protocol.
| bool picker_screen_editable | ( | void | ) |
Whether a tap on a button can change the binding.
| 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.
| bool picker_screen_has_drawing | ( | void | ) |
Whether the board is drawn from the IOmcu's drawing.
| void picker_screen_invalidate | ( | void | ) |
Repaint the cached chrome in every framebuffer.
| 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_pin_t picker_screen_pin | ( | uint8_t | index, |
| char * | holder, | ||
| size_t | cap ) |
The state of catalogue entry index, as the screen draws it.
| index | the pin's catalogue entry |
| holder | NULL, 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 |
| cap | bytes at holder |
| int picker_screen_port_shown | ( | void | ) |
The port picked, 0 for port 1, or -1 for a protocol.
| uint8_t picker_screen_prog_listed | ( | void | ) |
The first GPIO IN USE lists under PROG PORT, or PICKER_NO_PIN.
| 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.
| bool picker_screen_row | ( | uint8_t | k, |
| picker_row_t * | out ) |
Line k of the PINS table, in catalogue order; false past the last.
| void picker_screen_set_apply | ( | picker_apply_fn | fn | ) |
Name the function a tick or untick applies the binding through.
| fn | the function, or NULL for none |
| 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.
| 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.
| void picker_screen_set_drawing_source | ( | picker_drawing_fn | fn | ) |
Name the function that asks for the drawing of a board.
| fn | the function, or NULL for none |
| 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.
| 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.
| void picker_screen_set_select | ( | picker_select_fn | fn | ) |
Name the function a pick in the list tells the Outputs screen by.
| fn | the function, or NULL for none |
| 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.
| index | the pin's index in the board's catalogue |
| const link_drawing_t * pk_drawing | ( | void | ) |
The drawing, while it is the one for the board the binding names.
| 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.
| index | the pin's index in the board's catalogue |
| 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.
| index | the pin's index in the board's catalogue |
| uint8_t pk_proto_shown | ( | void | ) |
The protocol shown: the binding's, OFF for one out of range.
| const outbind_shape_t * pk_shape | ( | void | ) |
The shape page of the board the binding names.
| 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.
|
static |
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 |
The screen's hooks for the router.