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

WI-FI: wifi_screen.h says what the screen is for. PANEL UPDATE, the screen the same header declares, is update_screen.c. More...

#include "wifi_screen.h"
#include <stdio.h>
#include <string.h>
#include "ui_text.h"
#include "ui_textkey.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 area below the band: 1024 x 540px.
#define H   UI_BODY_H
 The body's height under the band, UI_BODY_H px.
#define WF_FONT_LABEL   (&gfx_font_10x20)
 The faces of the 1024 x 600 type scale the screen draws in: WF_FONT_LABEL (10 x 20) for the buttons, the row labels, the card's lines and the signal column; WF_FONT_BODY (12 x 24) for the lines under the rows, the network names of the list and the question's sentences; WF_FONT_HEAD (20 x 36) for the row values, the scan's heading and the question's title and versions.
#define WF_FONT_BODY   UI_FONT_BODY
#define WF_FONT_HEAD   (&gfx_font_20x36)
#define FOOT   (UI_ALERT_Y - UI_BAND_H - 4)
 The lowest body row anything is drawn on, plus one: 4px above the alert band, body y 492.
#define BX   16
#define BY   16
#define BW   460
#define BH   60
#define BPITCH   68
#define RX   (BX + BW + 16)
#define RY   16
#define RW   (W - UI_MARGIN - RX)
#define RH   (FOOT - RY)
#define CARD_P   24
#define LBL_X   16
#define LBL_W   240
#define VAL_X   (LBL_X + LBL_W + 8)
#define VAL_W   740
#define ROW_Y   16
#define ROW_P   56
#define LINE_P   28
#define OFF_Y   (FOOT - 8 - BH)
#define SC_X0   (UI_MARGIN + 4)
#define SC_X1   (W / 2 + 8)
#define SC_Y   (UI_MARGIN + 4)
#define SC_W   492
#define SC_H   48
#define SC_P   52
#define SC_ROWS   8
#define SC_BW   328
#define SC_BH   UI_BTN_H_TALL
#define SC_BY   (FOOT - SC_BH)
#define SC_BX(i)
 Scan button i's left edge.
#define Q_X   UI_MARGIN
#define Q_Y   UI_MARGIN
#define Q_W   (W - 2 * UI_MARGIN)
#define Q_H   (FOOT - Q_Y)
#define Q_BW   460
#define Q_BH   72
#define Q_BY   (Q_Y + Q_H - 16 - Q_BH)
#define KEY_AREA
 The keyboard, over the whole body, UI_MARGIN in from its sides and top, and ending 4px above the alert band: 1008 x 484px, keys of 93 x 71px.

Enumerations

enum  sub_t { SUB_MAIN = 0 , SUB_SCAN , SUB_KEY_SSID , SUB_KEY_PASS }
enum  {
  HIT_NONE = 0 , HIT_AP , HIT_JOIN , HIT_CHOOSE ,
  HIT_FORGET , HIT_CODE , HIT_OFF , HIT_Q_CANCEL ,
  HIT_INSTALL , HIT_RESCAN , HIT_HIDDEN , HIT_SCAN_CANCEL ,
  HIT_ROW
}
enum  view_t { VIEW_MAIN , VIEW_RUNNING , VIEW_SCAN , VIEW_QUESTION }

Functions

static void touched (void)
gfx_rect_t wifi_screen_key_area (void)
 Where the keyboard opens: the body less UI_MARGIN at its sides and top, ending 4px above the alert band, 1008 x 484px.
const ui_textkey_t * wifi_screen_textkey (void)
 The screen's keyboard, open or closed; for tests and the renderer, which check what a tap typed.
static void reset (void)
static bool staged (void)
static bool install_allowed (void)
static bool radio_on (void)
static void drop_hold_if_gone (void)
void wifi_screen_set (const wifi_view_t *v)
void wifi_screen_set_unavailable (void)
void wifi_screen_invalidate (void)
const wifi_view_t * wifi_screen_view (void)
unsigned wifi_screen_take (void)
void wifi_screen_net (char ssid[WIFI_SSID_MAX+1], char pass[WIFI_PASS_MAX+1])
static gfx_rect_t btn (int row)
 Button row of the radio-off view.
static gfx_rect_t off_rect (void)
 WI-FI OFF.
static gfx_rect_t q_cancel_rect (void)
 The question's CANCEL.
static gfx_rect_t install_rect (void)
 HOLD 2s: INSTALL.
static gfx_rect_t row_rect (int i)
 Row i of the scan list: eight a column.
static gfx_rect_t rescan_rect (void)
 SCAN AGAIN.
static gfx_rect_t hidden_rect (void)
 HIDDEN NETWORK.
static gfx_rect_t scan_cancel_rect (void)
 The scan list's CANCEL.
static bool in (gfx_rect_t r, int x, int y)
static view_t view_of (void)
static int hit_at (int x, int y)
static gfx_rect_t hit_rect (int hit)
static void act (int hit)
static void key_event (const touch_event_t *evt)
static void event (const touch_event_t *evt)
static void tick (float dt_s)
static void cancel (void)
static void enter (void)
static bool back (void)
static void leave (void)
static void text_in (gfx_canvas_t *c, int x, int y, int w, int h, const char *t, const gfx_font_t *f, gfx_color_t col)
 t left aligned in face f, in a box of w x h px from (x, y), centred in its height.
static int para (gfx_canvas_t *c, int y, const char *t, gfx_color_t col)
 t in the card from y, broken into lines of its 49 cells CARD_P px apart.
static void jobs_text (char *out, size_t n)
 What the page is for: one sentence, given in two parts, wrapped once.
int wifi_screen_jobs_lines (void)
static const char * why_text (void)
static void button (gfx_canvas_t *c, gfx_rect_t r, const char *label, gfx_color_t fill, int hit, bool enabled)
 A button in WF_FONT_LABEL.
static void draw_main (gfx_canvas_t *c)
 The radio-off view: the buttons and the card.
static void row (gfx_canvas_t *c, int i, const char *label, const char *value)
 Row i of the running view: its label and its value.
static int line_at (gfx_canvas_t *c, int y, const char *t, gfx_color_t col)
 A line under the rows of the running view, WF_FONT_BODY across the body.
static void draw_running (gfx_canvas_t *c)
 The radio-on view: the rows, the lines under them, WI-FI OFF.
static void draw_scan (gfx_canvas_t *c)
 The scan: the heading or the list, and its buttons.
static gfx_color_t install_fill (void)
static int q_para (gfx_canvas_t *c, int y, const char *t, gfx_color_t col)
 t in the question from y, broken into lines of its 80 cells LINE_P px apart.
static void draw_question (gfx_canvas_t *c)
 The question about a staged image.
static void render (gfx_canvas_t *c, int buffer_index)
const ui_screen_t * wifi_screen (void)
 The WI-FI screen, for the router.

Variables

static struct  s
static const ui_screen_t k_screen

Detailed Description

WI-FI: wifi_screen.h says what the screen is for. PANEL UPDATE, the screen the same header declares, is update_screen.c.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ BH

#define BH   60

A button's height, px.

◆ BPITCH

#define BPITCH   68

The buttons' pitch, px.

◆ BW

#define BW   460

A button's width, px.

◆ BX

#define BX   16

The buttons' left edge.

◆ BY

#define BY   16

The first button's top.

◆ CARD_P

#define CARD_P   24

The card's line pitch, px.

◆ KEY_AREA

#define KEY_AREA
Value:
gfx_rect_make(UI_MARGIN, UI_MARGIN, W - 2 * UI_MARGIN, \
#define W
Definition analyser_screen.c:23
#define FOOT
The lowest row the screen draws or takes a press on, in the screen's coordinates: 4px above the alert...
Definition picker_screen_int.h:39
#define UI_MARGIN
A screen's outer margin, in pixels.
Definition ui_layout.h:53

The keyboard, over the whole body, UI_MARGIN in from its sides and top, and ending 4px above the alert band: 1008 x 484px, keys of 93 x 71px.

◆ LBL_W

#define LBL_W   240

Its width, px.

◆ LBL_X

#define LBL_X   16

The label column's left edge.

◆ LINE_P

#define LINE_P   28

The pitch of the lines under the rows, px.

◆ OFF_Y

#define OFF_Y   (FOOT - 8 - BH)

WI-FI OFF's top: body y 424.

◆ Q_BH

#define Q_BH   72

Its height, px.

◆ Q_BW

#define Q_BW   460

A button's width, px.

◆ Q_BY

#define Q_BY   (Q_Y + Q_H - 16 - Q_BH)

The buttons' top: body y 404.

◆ Q_H

#define Q_H   (FOOT - Q_Y)

Its height, px.

◆ Q_W

#define Q_W   (W - 2 * UI_MARGIN)

Its width, px.

◆ Q_X

#define Q_X   UI_MARGIN

The question's left edge.

◆ Q_Y

#define Q_Y   UI_MARGIN

Its top.

◆ RH

#define RH   (FOOT - RY)

Its height: 476px.

◆ ROW_P

#define ROW_P   56

The rows' pitch, px.

◆ ROW_Y

#define ROW_Y   16

The first row's top.

◆ RW

#define RW   (W - UI_MARGIN - RX)

Its width: 524px.

◆ RX

#define RX   (BX + BW + 16)

The card's left edge.

◆ RY

#define RY   16

Its top.

◆ SC_BH

#define SC_BH   UI_BTN_H_TALL

Its height, px.

◆ SC_BW

#define SC_BW   328

A scan button's width, px.

◆ SC_BX

#define SC_BX ( i)
Value:
(UI_MARGIN + (i) * (SC_BW + 12))
#define SC_BW
Definition wifi_screen.c:89

Scan button i's left edge.

◆ SC_BY

#define SC_BY   (FOOT - SC_BH)

The scan buttons' top: body y 436.

◆ SC_H

#define SC_H   48

A row's height, px.

◆ SC_P

#define SC_P   52

The rows' pitch, px.

◆ SC_ROWS

#define SC_ROWS   8

Rows a column.

◆ SC_W

#define SC_W   492

A row's width, px.

◆ SC_X0

#define SC_X0   (UI_MARGIN + 4)

The left column's rows' left edge.

◆ SC_X1

#define SC_X1   (W / 2 + 8)

The right column's.

◆ SC_Y

#define SC_Y   (UI_MARGIN + 4)

The first row's top.

◆ VAL_W

#define VAL_W   740

Its width, px.

◆ VAL_X

#define VAL_X   (LBL_X + LBL_W + 8)

The value column's left edge.

◆ WF_FONT_BODY

#define WF_FONT_BODY   UI_FONT_BODY

12 x 24: sentences.

◆ WF_FONT_HEAD

#define WF_FONT_HEAD   (&gfx_font_20x36)

20 x 36: values.

Function Documentation

◆ btn()

gfx_rect_t btn ( int row)
static

Button row of the radio-off view.

Parameters
row0 ACCESS POINT to 4 ACCESS CODE.
Returns
Its rectangle, body coordinates.

◆ button()

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

A button in WF_FONT_LABEL.

Parameters
cCanvas.
rWhere.
labelIts text.
fillIts fill.
hitThe hit it answers, drawn pressed while held.
enabledWhether it takes a press.

◆ draw_main()

void draw_main ( gfx_canvas_t * c)
static

The radio-off view: the buttons and the card.

Parameters
cCanvas.

◆ draw_question()

void draw_question ( gfx_canvas_t * c)
static

The question about a staged image.

Parameters
cCanvas.

◆ draw_running()

void draw_running ( gfx_canvas_t * c)
static

The radio-on view: the rows, the lines under them, WI-FI OFF.

Parameters
cCanvas.

◆ draw_scan()

void draw_scan ( gfx_canvas_t * c)
static

The scan: the heading or the list, and its buttons.

Parameters
cCanvas.

◆ hidden_rect()

gfx_rect_t hidden_rect ( void )
static

HIDDEN NETWORK.

Returns
Its rectangle.

◆ install_rect()

gfx_rect_t install_rect ( void )
static

HOLD 2s: INSTALL.

Returns
Its rectangle.

◆ jobs_text()

void jobs_text ( char * out,
size_t n )
static

What the page is for: one sentence, given in two parts, wrapped once.

Parameters
outWhere it goes.
nThe bytes at out.

◆ line_at()

int line_at ( gfx_canvas_t * c,
int y,
const char * t,
gfx_color_t col )
static

A line under the rows of the running view, WF_FONT_BODY across the body.

Parameters
cCanvas.
yIts top.
tThe text.
colIts colour.
Returns
The y of the next line.

◆ off_rect()

gfx_rect_t off_rect ( void )
static

WI-FI OFF.

Returns
Its rectangle.

◆ para()

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

t in the card from y, broken into lines of its 49 cells CARD_P px apart.

Parameters
cCanvas, or NULL to count the lines only.
yThe first line's top.
tThe text.
colIts colour.
Returns
The y under its last line.

◆ q_cancel_rect()

gfx_rect_t q_cancel_rect ( void )
static

The question's CANCEL.

Returns
Its rectangle.

◆ q_para()

int q_para ( gfx_canvas_t * c,
int y,
const char * t,
gfx_color_t col )
static

t in the question from y, broken into lines of its 80 cells LINE_P px apart.

Parameters
cCanvas.
yThe first line's top.
tThe text.
colIts colour.
Returns
The y under its last line.

◆ rescan_rect()

gfx_rect_t rescan_rect ( void )
static

SCAN AGAIN.

Returns
Its rectangle.

◆ row()

void row ( gfx_canvas_t * c,
int i,
const char * label,
const char * value )
static

Row i of the running view: its label and its value.

Parameters
cCanvas.
iThe row, 0 at the top.
labelThe label, WF_FONT_LABEL.
valueThe value, WF_FONT_HEAD.

◆ row_rect()

gfx_rect_t row_rect ( int i)
static

Row i of the scan list: eight a column.

Parameters
i0 to WIFI_SCAN_ROWS - 1.
Returns
Its rectangle.

◆ scan_cancel_rect()

gfx_rect_t scan_cancel_rect ( void )
static

The scan list's CANCEL.

Returns
Its rectangle.

◆ text_in()

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

t left aligned in face f, in a box of w x h px from (x, y), centred in its height.

Parameters
cCanvas.
xLeft edge.
yTop edge.
wWidth.
hHeight.
tThe text.
fThe face.
colIts colour.

◆ wifi_screen()

const ui_screen_t * wifi_screen ( void )

The WI-FI screen, for the router.

Returns
The screen.

◆ wifi_screen_invalidate()

void wifi_screen_invalidate ( void )

Repaint on the next frame.

◆ wifi_screen_jobs_lines()

int wifi_screen_jobs_lines ( void )

The lines the card's first sentence takes, WF_JOBS_1 and WF_JOBS_2 joined by a space and wrapped once; for tests.

◆ wifi_screen_key_area()

gfx_rect_t wifi_screen_key_area ( void )

Where the keyboard opens: the body less UI_MARGIN at its sides and top, ending 4px above the alert band, 1008 x 484px.

Returns
The area, in the screen's coordinates.

◆ wifi_screen_net()

void wifi_screen_net ( char ssid[WIFI_SSID_MAX+1],
char pass[WIFI_PASS_MAX+1] )

The network WIFI_REQ_SAVE_NET keeps: its name and its password.

◆ wifi_screen_set()

void wifi_screen_set ( const wifi_view_t * v)

Hand the screen what to show.

◆ wifi_screen_set_unavailable()

void wifi_screen_set_unavailable ( void )

Wi-Fi could not be set up at start: show WIFI_WHY_UNAVAILABLE with every control off. Needs no view from the caller, so it holds when the memory for one is what ran out.

◆ wifi_screen_take()

unsigned wifi_screen_take ( void )

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

◆ wifi_screen_textkey()

const ui_textkey_t * wifi_screen_textkey ( void )

The screen's keyboard, open or closed; for tests and the renderer, which check what a tap typed.

Returns
The keyboard.

◆ wifi_screen_view()

const wifi_view_t * wifi_screen_view ( void )

What is showing, for the application and the tests.

Variable Documentation

◆ k_screen

const ui_screen_t k_screen
static
Initial value:
= {
.title = "WI-FI",
.reset = reset,
.enter = enter,
.leave = leave,
.tick = tick,
.event = event,
.cancel = cancel,
.render = render,
.back = back,
}
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 bool back(void)
The home tag: over the keypad it is CANCEL.
Definition balance_screen.c:251
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

◆ s

struct [struct].s s

the screen's state: the view, the keyboard, the press