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

busfault_screen.h says what this screen is for. More...

#include "busfault_screen.h"
#include <stdio.h>
#include <string.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 W   UI_PANEL_W
 The panel's width, UI_PANEL_W px.
#define H   UI_PANEL_H
 The panel's height, UI_PANEL_H px.
#define BF_FONT_HEAD   (&gfx_font_20x36)
 The bar's title and the verdict: 20 x 36.
#define BF_FONT_BODY   UI_FONT_BODY
 The meaning, the checks and the notes: 12 x 24.
#define BF_FONT_LABEL   (&gfx_font_10x20)
 The headings, the number column and the button: 10 x 20.
#define BODY_CELL   12
#define BAR_H   64
 The red bar's height, px.
#define VERDICT_Y   (BAR_H + 12)
 The verdict's top.
#define COLS_Y   (VERDICT_Y + 48)
 The two columns' top.
#define COL_X   24
#define NUM_W   240
 The number column's width, px: 24 cells of BF_FONT_LABEL.
#define NUM_X   (W - 24 - NUM_W)
#define COL_W   (NUM_X - 24 - COL_X)
 The left column's width, px.
#define COL_CELLS   (COL_W / BODY_CELL)
 The left column's cells of BF_FONT_BODY.
#define WRAP_PITCH   28
 A wrapped BF_FONT_BODY line's pitch, px.
#define NUM_PITCH   22
 The number column's line pitch, px.
#define NUM_HEAD   24
 The step under a number column heading, px.
#define NUM_GAP   28
 The step between two number column sections, px.
#define MEANING_LINES   2
 The lines the meaning takes at most.
#define HEAD_Y   (COLS_Y + MEANING_LINES * WRAP_PITCH + 8)
#define LIST_Y   (HEAD_Y + 28)
 The first check's top.
#define LIST_PITCH   32
 The step from one check to the next, px.
#define LIST_MAX   5
#define LIST_INDENT   16
 A check's text right of its bullet, px.
#define LIST_CELLS   ((COL_W - LIST_INDENT) / BODY_CELL)
 A check's cells of BF_FONT_BODY.
#define NOTE_Y   (LIST_Y + LIST_MAX * LIST_PITCH + 2 * WRAP_PITCH)
 The first note's top: under the fullest list.
#define ACK_H   56
 The acknowledgement's height, px.
#define ACK_Y   (H - ACK_H - 16)
 The acknowledgement's top, 16px above the panel's edge.
#define ACK_X   COL_X
#define ACK_W   (W - 2 * COL_X)
#define RULE_Y   (ACK_Y - 8)
 The rule over the acknowledgement.

Functions

void busfault_screen_invalidate (void)
static void reset (void)
void busfault_screen_set (const busfault_report_t *r)
const busfault_report_t * busfault_screen_report (void)
bool busfault_screen_take_ack (void)
static const char * bus_text (busfault_bus_t b)
static const char * bus_word (busfault_bus_t b)
static const char * bus_meaning (busfault_bus_t b)
static int bus_checks (busfault_bus_t b, const char *out[LIST_MAX])
static const char * meaning_of (can_selftest_verdict_t v)
static int checks_for (can_selftest_verdict_t v, const char *out[LIST_MAX])
const char * busfault_verdict_text (can_selftest_verdict_t v)
static bool in_ack (int16_t x, int16_t y)
static void event (const touch_event_t *evt)
static void tick (float dt_s)
 Time passed: the acknowledge flash runs on by dt_s.
static size_t line_len (const char *at, int cells)
static int wrap_text (gfx_canvas_t *c, int x, int y, const char *text, int cells, gfx_color_t ink)
 text in lines of at most cells of BF_FONT_BODY, broken after a space, from (x, y) down by WRAP_PITCH.
static gfx_color_t ack_fill (void)
 The acknowledge button's fill.
static void draw_link_numbers (gfx_canvas_t *c)
 The right-hand column for a link that dropped: this end's controller, and how long it has been quiet.
static void draw_numbers (gfx_canvas_t *c)
 The right-hand column for the start-up test: the probes, this panel's controller and the IOmcu's.
static void render (gfx_canvas_t *c, int buffer_index)
 The screen: the bar, the verdict, both columns and the notes once per framebuffer, the acknowledgement every frame.
static void cancel (void)
const ui_screen_t * busfault_screen (void)

Variables

static struct  s
static const ui_screen_t k_screen

Detailed Description

busfault_screen.h says what this screen is for.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ BODY_CELL

#define BODY_CELL   12

BF_FONT_BODY's cell width, px

Function Documentation

◆ ack_fill()

gfx_color_t ack_fill ( void )
static

The acknowledge button's fill.

Danger red while it is waiting to be held, fading to the OK green it settles on, and the same 150ms flash ARM gives as the command goes. The direction is the other way round from ARM because what it does is the other way round: this one leaves a fault behind rather than entering one.

Returns
The fill for this frame.

◆ busfault_screen_report()

const busfault_report_t * busfault_screen_report ( void )

What was handed in, for the application deciding whether to show it.

◆ busfault_screen_set()

void busfault_screen_set ( const busfault_report_t * r)

Hand the screen what to show. A NULL report clears it.

◆ busfault_screen_take_ack()

bool busfault_screen_take_ack ( void )

True once the acknowledgement hold has completed, and clears when read.

A latch rather than a jump: which screen an acknowledged fault leads to is the application's business, not the screen's.

◆ busfault_verdict_text()

const char * busfault_verdict_text ( can_selftest_verdict_t v)

The self-test's verdict as the screen heads it, in the language showing. can_selftest_text() is the console's English.

◆ draw_link_numbers()

void draw_link_numbers ( gfx_canvas_t * c)
static

The right-hand column for a link that dropped: this end's controller, and how long it has been quiet.

Different numbers from the start-up test's – there was no echo run, so there is nothing to count probes against.

Parameters
cCanvas, the whole panel.

◆ draw_numbers()

void draw_numbers ( gfx_canvas_t * c)
static

The right-hand column for the start-up test: the probes, this panel's controller and the IOmcu's.

Parameters
cCanvas, the whole panel.

◆ render()

void render ( gfx_canvas_t * c,
int buffer_index )
static

The screen: the bar, the verdict, both columns and the notes once per framebuffer, the acknowledgement every frame.

Parameters
cCanvas, the whole panel.
buffer_indexThe framebuffer drawn into.

◆ tick()

void tick ( float dt_s)
static

Time passed: the acknowledge flash runs on by dt_s.

Parameters
dt_sThe time since the last tick, in seconds.

◆ wrap_text()

int wrap_text ( gfx_canvas_t * c,
int x,
int y,
const char * text,
int cells,
gfx_color_t ink )
static

text in lines of at most cells of BF_FONT_BODY, broken after a space, from (x, y) down by WRAP_PITCH.

Parameters
cCanvas, the whole panel.
xThe lines' left edge.
yThe first line's top.
textThe text.
cellsThe cells a line holds.
inkIts colour.
Returns
The lines drawn.

Variable Documentation

◆ k_screen

const ui_screen_t k_screen
static
Initial value:
= {
.title = "CAN BUS FAULT",
.reset = reset,
.enter = NULL,
.leave = NULL,
.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 tick(float dt_s)
Time passed: the acknowledge flash runs on by dt_s.
Definition busfault_screen.c:359

◆ s

struct [struct].s s

the report and the hold