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

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

Detailed Description

Protocol on the left, pins on the right. See outputs_screen.h.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ BOX

#define BOX   24

The tick box, px.

◆ CELL_CELLS

#define CELL_CELLS   18

The sub-line's cells of OU_FONT_FINE.

◆ CELL_GAP

#define CELL_GAP   8

Between columns, px.

◆ CELL_H

#define CELL_H   64

Its height, px (9.6mm).

◆ CELL_LABEL_Y

#define CELL_LABEL_Y   44

The sub-line's top in the cell.

◆ CELL_PAD

#define CELL_PAD   8

The tick box and the sub-line from the edge.

◆ CHAN_Y

#define CHAN_Y   (COUNT_Y + 24)

The channels line.

◆ CLR_H

#define CLR_H   UI_BTN_H_TALL

Its height, px (8.4mm).

◆ GRID_COLS

#define GRID_COLS   4

Columns of cells.

◆ GRID_ROWS

#define GRID_ROWS   7

Cells down a column.

◆ GRID_X

#define GRID_X   (COL_X + COL_W + 8)

The grid's left edge.

◆ GRID_Y

#define GRID_Y   8

Its top.

◆ LAST_ABOVE

#define LAST_ABOVE   26

LAST WRITE's top over the result's.

◆ LAST_Y

#define LAST_Y   (RESULT_Y - LAST_ABOVE)

LAST WRITE over two lines.

◆ MAX_FBS

#define MAX_FBS   3

Framebuffers the chrome is cached for.

◆ POP_ROW

#define POP_ROW   UI_TAP_MIN

A row, px.

◆ POP_W

#define POP_W   COL_W

A column's width, px.

◆ POP_X

#define POP_X   COL_X

The open list's left edge.

◆ POP_Y

#define POP_Y   DD_Y

Its top: the face's.

◆ RESULT_PITCH

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

◆ ROW_GAP

#define ROW_GAP   6

Between rows, px.

◆ SCREEN_H

#define SCREEN_H   UI_BODY_H

The body under the band: 540px.

Function Documentation

◆ number_follows()

bool number_follows ( const char * brk)
static

Whether the word after the spaces at brk is digits alone.

Parameters
brkA break: a space, and the rest of the text after it.
Returns
true when one or more digits follow the spaces and end at a space or at the end of the text.

◆ outputs_reason_of()

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.

◆ outputs_screen_binding()

const outbind_t * outputs_screen_binding ( void )

The binding shown: the last one read, plus edits not yet read back.

◆ outputs_screen_cell()

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.

◆ outputs_screen_editable()

bool outputs_screen_editable ( void )

Whether a tap on a pin can change the binding: the last reading was BIND_READ_OK.

◆ outputs_screen_invalidate()

void outputs_screen_invalidate ( void )

Repaint the cached chrome in every framebuffer.

◆ outputs_screen_read_state()

bind_read_t outputs_screen_read_state ( void )

The state of the last reading; BIND_READ_OK after a set_binding().

◆ outputs_screen_reason()

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.

◆ outputs_screen_select()

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.

◆ outputs_screen_set_binding()

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.

◆ outputs_screen_set_reading()

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.

◆ outputs_wrap()

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.

Parameters
cThe canvas; NULL only counts the lines.
boxThe first line's box: its x, y and width.
pitchFrom one line's top to the next, px.
textThe text; NULL draws nothing.
max_linesThe most lines drawn.
fontThe face.
inkThe colour.
centretrue centres each line in the box.
Returns
The lines the text takes.

Variable Documentation

◆ s_screen

const ui_screen_t s_screen
static
Initial value:
= {
.title = "OUTPUTS",
.reset = reset,
.enter = enter,
.leave = leave,
.tick = tick,
.event = event,
.cancel = cancel,
.render = 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 void tick(float dt_s)
Time passed: the answer taken when it is in, the progress and the gate followed for the drawing.
Definition files_screen.c:1059
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