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

upd_screen.h says what these two screens are for. More...

#include "upd_screen.h"
#include <stdio.h>
#include <string.h>
#include "settings.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...
struct  [struct].s_rem

Macros

#define UPD_FONT_LABEL   (&gfx_font_10x20)
 The buttons and the IOmcu section: 10 x 20.
#define UPD_FONT_BODY   UI_FONT_BODY
 The card's text and the reminder's lines: 12 x 24.
#define BX   16
 The buttons' left edge.
#define BW   460
 The buttons' width, px.
#define BH   56
 The buttons' height, px.
#define BPITCH   64
 The step from one button to the next, px.
#define RX   484
 The card's left edge.
#define RY   16
 The card's top, and the first button's.
#define RW   532
 The card's width, px.
#define RH   472
 The card's height, px.
#define RPAD   16
 The card's inner padding, px.
#define PITCH   28
 A UPD_FONT_BODY line's pitch, px.
#define DL_ROW   3
 The download's hold's row.
#define CU_HEAD_Y   280
 The IOmcu section's heading.
#define CU_RUN_Y   304
 The version the IOmcu runs.
#define CU_CAR_Y   328
 The version this panel carries.
#define CU_LINE_Y   356
 The first line of state.
#define CU_PITCH   24
 The state's line pitch, px.
#define CU_BTN   gfx_rect_make(BX, 428, BW, BH)
 HOLD 2s: UPDATE IOMCU.
#define R_BOX   gfx_rect_make(82, 8, 860, 480)
 The reminder's box, in the body.
#define R_IGNORE   gfx_rect_make(106, 328, 398, 56)
 NOT NOW.
#define R_NEVER   gfx_rect_make(520, 328, 398, 56)
 NEVER REMIND ME.
#define R_HOLD   gfx_rect_make(106, 400, 812, 64)
 The reminder's hold.
#define UPD_FLOOR   (UI_ALERT_Y - UI_BAND_H - 4)
 The body row 4px above the alert band: every control ends over it.

Enumerations

enum  {
  HIT_NONE = 0 , HIT_CHECK , HIT_REMIND , HIT_CHANNEL ,
  HIT_DOWNLOAD , HIT_IGNORE , HIT_NEVER , HIT_COPROC
}

Functions

static void touched (void)
void upd_screen_invalidate (void)
bool upd_busy (const upd_view_t *v)
static bool have_newer (void)
static bool download_allowed (void)
static bool check_allowed (void)
static bool cancel_allowed (void)
static bool coproc_allowed (void)
static void drop_holds_if_gone (void)
void upd_screen_set (const upd_view_t *v)
const upd_view_t * upd_screen_view (void)
void upd_screen_set_coproc (const upd_cu_view_t *v)
const upd_cu_view_t * upd_screen_coproc (void)
bool upd_screen_take_coproc (void)
 Whether HOLD 2s: UPDATE IOMCU completed, once.
unsigned upd_screen_take (void)
static const char * rel_text (const upd_view_t *v)
static const char * join_text (const upd_view_t *v)
static void blocked_text (upd_why_t why, char *out, size_t n, char *second, size_t n2)
static const char * aborted_text (upd_why_t why)
static const char * phase_text (upd_phase_t ph)
bool upd_result_said_above (const upd_view_t *v)
 Whether the result card leaves out upd_result_text()'s lines because the status lines above already say them: a check that ended for want of a home network while the card shows "No home network saved." (Wi-Fi set up, no network kept).
void upd_result_text (const upd_view_t *v, char *out, size_t n, char *second, size_t n2)
 The line that says how the last job ended, or what it does now, and the line under it.
static gfx_color_t result_colour (void)
static void text_in (gfx_canvas_t *c, int x, int y, int w, const char *t, const gfx_font_t *f, gfx_color_t col)
 One line of t in f at (x, y), w wide.
static int para (gfx_canvas_t *c, int x, int y, int w, const char *t, gfx_color_t col)
 t in UPD_FONT_BODY from y, as many lines of w as it takes, PITCH apart.
static gfx_color_t hold_fill (const ui_hold_t *h)
static void button (gfx_canvas_t *c, gfx_rect_t r, const char *label, gfx_color_t fill, bool pressed, bool enabled)
 A button of these screens: ui_button_font() in UPD_FONT_LABEL.
static gfx_rect_t btn (int row)
 UPDATES' button in row row.
static bool testing_set (void)
static int hit_at (int x, int y)
static void act (int hit)
static void reset (void)
static void event (const touch_event_t *evt)
static void tick (float dt_s)
static void cancel (void)
static void enter (void)
static void leave (void)
void upd_cu_text (const upd_cu_view_t *v, const char **line, gfx_color_t *col)
static void cu_version_text (char *out, size_t n, bool known, cu_version_t v)
static void render_coproc (gfx_canvas_t *c)
 The IOmcu section: heading, versions, state, hold.
static void render (gfx_canvas_t *c, int buffer_index)
 UPDATES, drawn whole once per framebuffer and again after every change and through a hold.
const ui_screen_t * upd_screen (void)
static int r_hit_at (int x, int y)
static void r_reset (void)
static void r_event (const touch_event_t *evt)
static void r_tick (float dt_s)
static void r_cancel (void)
static void r_enter (void)
static void r_leave (void)
static void r_render (gfx_canvas_t *c, int buffer_index)
 The reminder, drawn whole once per framebuffer and again after every change and through the hold's flash.
const ui_screen_t * upd_remind_screen (void)
bool upd_startup_due (upd_driver_t *d, const upd_feed_t *f)
void upd_remind_drive (upd_driver_t *d, const upd_feed_t *f)

Variables

static upd_view_t s_v
static unsigned s_req
static upd_cu_view_t s_cu
static bool s_cu_req
static struct  s
static struct  s_rem
static const ui_screen_t k_screen
static const ui_screen_t k_remind

Detailed Description

upd_screen.h says what these two screens are for.

SPDX-License-Identifier: MIT

Function Documentation

◆ btn()

gfx_rect_t btn ( int row)
static

UPDATES' button in row row.

Parameters
row0 CHECK, 1 the reminder, 2 RELEASES, DL_ROW the download.
Returns
Its rectangle in the body.

◆ button()

void button ( gfx_canvas_t * c,
gfx_rect_t r,
const char * label,
gfx_color_t fill,
bool pressed,
bool enabled )
static

A button of these screens: ui_button_font() in UPD_FONT_LABEL.

Parameters
cCanvas, the body.
rThe button.
labelIts label.
fillIts fill.
pressedWhether a finger is on it.
enabledWhether it takes a press.

◆ para()

int para ( gfx_canvas_t * c,
int x,
int y,
int w,
const char * t,
gfx_color_t col )
static

t in UPD_FONT_BODY from y, as many lines of w as it takes, PITCH apart.

Parameters
cCanvas, the body, or NULL to count the lines only.
xThe lines' left edge.
yThe first line's top.
wThe column's width.
tThe text.
colIts colour.
Returns
The y one PITCH under its last line.

◆ r_render()

void r_render ( gfx_canvas_t * c,
int buffer_index )
static

The reminder, drawn whole once per framebuffer and again after every change and through the hold's flash.

Parameters
cCanvas, the body.
buffer_indexThe framebuffer drawn into.

◆ render()

void render ( gfx_canvas_t * c,
int buffer_index )
static

UPDATES, drawn whole once per framebuffer and again after every change and through a hold.

Parameters
cCanvas, the body.
buffer_indexThe framebuffer drawn into.

◆ render_coproc()

void render_coproc ( gfx_canvas_t * c)
static

The IOmcu section: heading, versions, state, hold.

Parameters
cCanvas, the body.

◆ text_in()

void text_in ( gfx_canvas_t * c,
int x,
int y,
int w,
const char * t,
const gfx_font_t * f,
gfx_color_t col )
static

One line of t in f at (x, y), w wide.

Parameters
cCanvas, the body.
xIts left edge.
yIts top.
wIts width.
tThe text.
fIts face.
colIts colour.

◆ upd_busy()

bool upd_busy ( const upd_view_t * v)

Whether a job runs: joining to checking.

◆ upd_cu_text()

void upd_cu_text ( const upd_cu_view_t * v,
const char ** line,
gfx_color_t * col )

The section's state line for v, and its colour.

◆ upd_remind_drive()

void upd_remind_drive ( upd_driver_t * d,
const upd_feed_t * f )

The reminder, once a frame, whichever screen is current. Opens it on OVERVIEW when the start-up check found a newer release, the reminder is on, it was not answered at this start, and the bench is not unsafe and the IOmcu's update not offered or running. Takes it down again, unanswered, for any of those changing under it. Drains its answers.

◆ upd_result_said_above()

bool upd_result_said_above ( const upd_view_t * v)

Whether the result card leaves out upd_result_text()'s lines because the status lines above already say them: a check that ended for want of a home network while the card shows "No home network saved." (Wi-Fi set up, no network kept).

Parameters
vthe view; NULL is false
Returns
true when the result is not drawn

◆ upd_result_text()

void upd_result_text ( const upd_view_t * v,
char * out,
size_t n,
char * second,
size_t n2 )

The line that says how the last job ended, or what it does now, and the line under it.

Both screens and the download's progress draw these. Nothing is written when out or second is NULL or has no room. A job stopped for WI-FI (UPD_WHY_FILES) gives two empty lines once the view's radio_free is set: its line says WI-FI is using Wi-Fi, which then no longer holds.

Parameters
vthe view; NULL gives two empty lines
outthe first line, empty for none
nbytes of out
secondthe line under it, or empty
n2bytes of second

◆ upd_screen_coproc()

const upd_cu_view_t * upd_screen_coproc ( void )

What the section shows, for the driver and the tests.

◆ upd_screen_invalidate()

void upd_screen_invalidate ( void )

Repaint on the next frame.

◆ upd_screen_set()

void upd_screen_set ( const upd_view_t * v)

Hand the screens what to show.

◆ upd_screen_set_coproc()

void upd_screen_set_coproc ( const upd_cu_view_t * v)

Hand UPDATES its IOmcu section; a hold the state no longer allows ends unfired.

◆ upd_screen_take()

unsigned upd_screen_take ( void )

The requests since the last call, as UPD_REQ_* bits; cleared.

◆ upd_screen_take_coproc()

bool upd_screen_take_coproc ( void )

Whether HOLD 2s: UPDATE IOMCU completed, once.

Returns
true once after the hold completed; false until the next one

◆ upd_screen_view()

const upd_view_t * upd_screen_view ( void )

What is showing, for the application and the tests.

◆ upd_startup_due()

bool upd_startup_due ( upd_driver_t * d,
const upd_feed_t * f )

Whether the start-up check starts now: once per start, with the reminder on, a home network kept, Wi-Fi available, the gate open, FILES & UPDATE closed, the IOmcu's update neither offered nor running, the router past the splash, and within UPD_START_WAIT_MS of the first drive. True once; the caller starts the check.

Variable Documentation

◆ k_remind

const ui_screen_t k_remind
static
Initial value:
= {
.title = "UPDATE",
.reset = r_reset,
.enter = r_enter,
.leave = r_leave,
.tick = r_tick,
.event = r_event,
.cancel = r_cancel,
.render = r_render,
}
static void r_render(gfx_canvas_t *c, int buffer_index)
The reminder, drawn whole once per framebuffer and again after every change and through the hold's fl...
Definition upd_screen.c:1035

◆ k_screen

const ui_screen_t k_screen
static
Initial value:
= {
.title = "UPDATES",
.reset = reset,
.enter = enter,
.leave = leave,
.tick = tick,
.event = event,
.cancel = cancel,
.render = render,
}
static void event(const touch_event_t *evt)
One touch event: the tabs are the screen's one control.
Definition analyser_screen.c:242
static void cancel(void)
The panel could not hand over every touch event, so this screen's record of the glass is stale.
Definition analyser_screen.c:658
static void reset(void)
The screen's state cleared: CHANNELS shown, nothing decoded, the tabs laid out.
Definition analyser_screen.c:176
static void render(gfx_canvas_t *c, int buffer_index)
The screen drawn on a revision not yet drawn: both cards once per framebuffer, then the tabs,...
Definition analyser_screen.c:618
static void leave(void)
The screen is left: the keypad closes, with nothing typed taken.
Definition balance_screen.c:264
static void tick(float dt_s)
Time passed: the acknowledge flash runs on by dt_s.
Definition busfault_screen.c:359