|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Protocol on the left, pins on the right. See outputs_screen.h. More...
#include "outputs_screen.h"#include "outputs_screen_int.h"#include <stdio.h>#include <string.h>#include "link_pages.h"#include "ui_pinlist.h"#include "ui_screen.h"#include "ui_text.h"#include "ui_theme.h"#include "ui_widgets.h"Data Structures | |
| struct | [struct].s |
| Driver state of the UART: the claimed machines and the pins. More... | |
Macros | |
| #define | SCREEN_W UI_PANEL_W |
| The screen's width: the panel's 1024px. | |
| #define | SCREEN_H UI_BODY_H |
| #define | MAX_FBS 3 |
| #define | COUNT_Y (DD_Y + DD_H + 8) |
| The count under the protocol list ("4 OF 8 PINS"), and under it the channels a pin carries, for a protocol of more than one. | |
| #define | CHAN_Y (COUNT_Y + 24) |
| #define | REASON_Y (CHAN_Y + 26) |
| Why no pin can be ticked: two lines OU_LINE apart under the counts. | |
| #define | CLR_Y (REASON_Y + 2 * OU_LINE + 8) |
| UNBIND ALL PINS, shown only while the pages read describe no binding: held for UI_HOLD_S, it writes a binding with no pin. Below the reason's second line, 300 x 56px; its label on two lines where it needs them. | |
| #define | CLR_H UI_BTN_H_TALL |
| #define | RESULT_PITCH 40 |
| LAST WRITE, and under it the result in OU_FONT_HEAD on one line, or two RESULT_PITCH apart where it is wider than the column; the last ends at OU_FOOT. LAST_Y is the label's top over two lines, the highest it goes. | |
| #define | RESULT_Y (OU_FOOT - RESULT_PITCH - 36) |
| The result's first of two lines. | |
| #define | LAST_ABOVE 26 |
| #define | LAST_Y (RESULT_Y - LAST_ABOVE) |
| #define | GRID_X (COL_X + COL_W + 8) |
| #define | GRID_W (SCREEN_W - 8 - GRID_X) |
| The pin grid's width, to 8px from the right edge: 692px. | |
| #define | GRID_Y 8 |
| #define | GRID_COLS 4 |
| #define | GRID_ROWS 7 |
| #define | CELL_GAP 8 |
| #define | ROW_GAP 6 |
| #define | CELL_W ((GRID_W - (GRID_COLS - 1) * CELL_GAP) / GRID_COLS) |
| A cell's width: 167px. | |
| #define | CELL_H 64 |
| #define | BOX 24 |
| #define | CELL_PAD 8 |
| #define | CELL_LABEL_Y 44 |
| #define | CELL_CELLS 18 |
| #define | POP_X COL_X |
| #define | POP_W COL_W |
| #define | POP_Y DD_Y |
| #define | POP_ROW UI_TAP_MIN |
Enumerations | |
| enum | { HIT_NONE = 0 , HIT_DD , HIT_POP , HIT_CELL , HIT_CLEAR } |
Functions | |
| static void | touched (void) |
| static const outbind_proto_t * | chosen_proto (void) |
| static bool | prog_taken (uint8_t index) |
| static outputs_iface_t | iface_taken (uint8_t index) |
| static uint8_t | shown_port_pin (void) |
| static bool | clashes (uint8_t index) |
| void | outputs_screen_invalidate (void) |
| const outbind_t * | outputs_screen_binding (void) |
| static void | drop_clear_hold (void) |
| void | outputs_screen_set_binding (const outbind_t *b) |
| void | outputs_screen_set_reading (const bind_reading_t *r) |
| bind_read_t | outputs_screen_read_state (void) |
| bool | outputs_screen_editable (void) |
| void | outputs_screen_set_apply (outputs_apply_fn fn) |
| void | outputs_screen_set_result (outputs_result_t r) |
| void | outputs_screen_select (uint8_t proto) |
| static void | changed (void) |
| static gfx_rect_t | dd_rect (void) |
| static int | pop_rows (void) |
| static gfx_rect_t | pop_rect (void) |
| static gfx_rect_t | pop_row_rect (int i) |
| static gfx_rect_t | clear_rect (void) |
| static bool | clear_offered (void) |
| static gfx_rect_t | cell_rect (int i) |
| static bool | inside (gfx_rect_t r, int x, int y) |
| static int | cell_at (int x, int y) |
| static void | reset (void) |
| static void | enter (void) |
| static void | leave (void) |
| static bool | back (void) |
| static void | unbind_all (void) |
| static void | tick (float dt_s) |
| static void | event (const touch_event_t *evt) |
| static bool | number_follows (const char *brk) |
Whether the word after the spaces at brk is digits alone. | |
| int | outputs_wrap (gfx_canvas_t *c, gfx_rect_t box, int pitch, const char *text, int max_lines, const gfx_font_t *font, gfx_color_t ink, bool centre) |
Draw text in lines of font no wider than box. | |
| static const char * | result_text (void) |
| static gfx_color_t | result_color (void) |
| bool | outputs_screen_reason (char *buf, size_t cap) |
| bool | outputs_reason_of (const outbind_t *b, char *buf, size_t cap) |
| outputs_cell_t | outputs_screen_cell (uint8_t index, char *label, size_t cap) |
| static void | draw_left (gfx_canvas_t *c) |
| static void | draw_cell (gfx_canvas_t *c, int i) |
| static void | draw_popup (gfx_canvas_t *c) |
| static void | render (gfx_canvas_t *c, int buffer_index) |
| static void | cancel (void) |
| const ui_screen_t * | outputs_screen (void) |
Variables | |
| static struct | s |
| static const ui_screen_t | s_screen |
Protocol on the left, pins on the right. See outputs_screen.h.
SPDX-License-Identifier: MIT
| #define BOX 24 |
The tick box, px.
| #define CELL_CELLS 18 |
The sub-line's cells of OU_FONT_FINE.
| #define CELL_GAP 8 |
Between columns, px.
| #define CELL_H 64 |
Its height, px (9.6mm).
| #define CELL_LABEL_Y 44 |
The sub-line's top in the cell.
| #define CELL_PAD 8 |
The tick box and the sub-line from the edge.
| #define CHAN_Y (COUNT_Y + 24) |
The channels line.
| #define CLR_H UI_BTN_H_TALL |
Its height, px (8.4mm).
| #define GRID_COLS 4 |
Columns of cells.
| #define GRID_ROWS 7 |
Cells down a column.
| #define GRID_Y 8 |
Its top.
| #define LAST_ABOVE 26 |
LAST WRITE's top over the result's.
| #define LAST_Y (RESULT_Y - LAST_ABOVE) |
LAST WRITE over two lines.
| #define MAX_FBS 3 |
Framebuffers the chrome is cached for.
| #define POP_ROW UI_TAP_MIN |
A row, px.
| #define POP_W COL_W |
A column's width, px.
| #define POP_X COL_X |
The open list's left edge.
| #define POP_Y DD_Y |
Its top: the face's.
| #define RESULT_PITCH 40 |
LAST WRITE, and under it the result in OU_FONT_HEAD on one line, or two RESULT_PITCH apart where it is wider than the column; the last ends at OU_FOOT. LAST_Y is the label's top over two lines, the highest it goes.
The result's line pitch, px.
| #define ROW_GAP 6 |
Between rows, px.
| #define SCREEN_H UI_BODY_H |
The body under the band: 540px.
|
static |
Whether the word after the spaces at brk is digits alone.
| brk | A break: a space, and the rest of the text after it. |
| bool outputs_reason_of | ( | const outbind_t * | b, |
| char * | buf, | ||
| size_t | cap ) |
The part of that line the protocol's rules give, for binding b: OFF edits nothing, the protocol has all its pins, all 8 slots are in use, or the protocol needs more channels than are free. The pin picker draws the same line from its own binding. An empty string and false when a pin can still be added.
| const outbind_t * outputs_screen_binding | ( | void | ) |
The binding shown: the last one read, plus edits not yet read back.
| outputs_cell_t outputs_screen_cell | ( | uint8_t | index, |
| char * | label, | ||
| size_t | cap ) |
The state of the cell of catalogue entry index and the line printed under its GPIO name, as the screen draws them. label may be NULL.
| bool outputs_screen_editable | ( | void | ) |
Whether a tap on a pin can change the binding: the last reading was BIND_READ_OK.
| void outputs_screen_invalidate | ( | void | ) |
Repaint the cached chrome in every framebuffer.
| bind_read_t outputs_screen_read_state | ( | void | ) |
The state of the last reading; BIND_READ_OK after a set_binding().
| bool outputs_screen_reason | ( | char * | buf, |
| size_t | cap ) |
The line under the protocol that says why no pin can be ticked, or why the PWM pin last tapped cannot be (outputs_clash_reason()), until another pick or tick, as the screen draws it in the language in force; an empty string when there is none. Returns whether there is one.
| void outputs_screen_select | ( | uint8_t | proto | ) |
Select protocol proto, as a pick in the list does: the set shown and the group the next tick joins. Writes nothing and calls nothing. OFF (0) is the overview: entering this screen or the pin picker selects it, and so does a change of board. It stays selected across readings until another protocol is selected. An index past the table is ignored. The pin picker's list selects through this, so the two screens show one selection.
| void outputs_screen_set_binding | ( | const outbind_t * | b | ) |
A binding read from the IOmcu, or one the screen is posed with. The screen then holds a confirmed binding and takes edits. A binding for another board than the one shown selects OFF, whatever was selected, unless b names a protocol its pins do not.
| void outputs_screen_set_reading | ( | const bind_reading_t * | r | ) |
What a read of the two output pages gave (bind_link_read()).
BIND_READ_OK is outputs_screen_set_binding() of the binding read. BIND_READ_NONE and BIND_READ_ODD leave the screen on the last binding a read confirmed, with any edit made since taken back, drawn dimmed with the reason under the protocol; no pin can be ticked or unticked until a read is BIND_READ_OK again. A reading for another board than the one shown has no last binding to keep, shows that board with nothing bound, and selects OFF. BIND_READ_NO_BOARD shows no pins and selects OFF.
| int outputs_wrap | ( | gfx_canvas_t * | c, |
| gfx_rect_t | box, | ||
| int | pitch, | ||
| const char * | text, | ||
| int | max_lines, | ||
| const gfx_font_t * | font, | ||
| gfx_color_t | ink, | ||
| bool | centre ) |
Draw text in lines of font no wider than box.
The lines run from the box's top down by pitch, broken after the last space that fits or inside a word where none does, left-aligned or with centre centred in the box. A word of digits alone after the break goes down with the word before it, so "PORT 1" stays together. At most max_lines lines, the last taking the rest. Both screens draw the line under the protocol with it.
| c | The canvas; NULL only counts the lines. |
| box | The first line's box: its x, y and width. |
| pitch | From one line's top to the next, px. |
| text | The text; NULL draws nothing. |
| max_lines | The most lines drawn. |
| font | The face. |
| ink | The colour. |
| centre | true centres each line in the box. |
|
static |