cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
Loading...
Searching...
No Matches
ui_widgets.cpp File Reference

Widget helpers shared by every screen, and the Wi-Fi signal mark. More...

#include "ui_internal.h"
Include dependency graph for ui_widgets.cpp:

Go to the source code of this file.

Macros

#define CHIP_SZ   16
#define BADGE_SZ   (COIN_SZ + 6) /* room for the chip to hang off the corner */
#define TAP_MARK_W   109
#define COL_TAP_MARK   COL_TEXT
#define PILL_TEXT_X   52 /* clears the BADGE_SZ icon at PILL_ICON_X */
#define PILL_TEXT_PAD_R   24
#define SIG_ARCS   3
#define SIG_AW   2 /* arc thickness */
#define SIG_R0   4 /* innermost arc radius; each ring adds SIG_RSTEP */
#define SIG_RSTEP   3
#define SIG_DOT   4
#define SIG_REACH   (SIG_R0 + ((SIG_ARCS - 1) * SIG_RSTEP) + (SIG_AW / 2))
#define SIG_W   (2 * SIG_REACH)
#define SIG_H   (SIG_REACH + ((SIG_DOT + 1) / 2))
#define SIG_INSET   14

Functions

lv_obj_t * make_button (lv_obj_t *parent, const char *label, lv_color_t bg, lv_color_t fg, lv_coord_t w, lv_coord_t h, lv_align_t align, lv_coord_t x, lv_coord_t y, BtnAction act, const lv_font_t *font)
lv_obj_t * make_label (lv_obj_t *parent, const char *txt, lv_color_t color, const lv_font_t *font, lv_align_t align, lv_coord_t x, lv_coord_t y)
lv_obj_t * make_ghost_button (lv_obj_t *parent, const char *label, lv_coord_t w, lv_align_t align, lv_coord_t x, lv_coord_t y, BtnAction act)
void make_divider (lv_obj_t *parent, lv_coord_t y)
lv_obj_t * make_glyph_disc (lv_obj_t *parent, const char *sym, lv_color_t bg, lv_coord_t sz)
static lv_obj_t * make_icon_box (lv_obj_t *parent, const lv_img_dsc_t *coin_src, const lv_img_dsc_t *chip_src)
static const lv_img_dsc_t * coin_icon (const pos_asset_t *a)
lv_obj_t * make_asset_badge (lv_obj_t *parent, pos_chain_t chain)
lv_obj_t * make_asset_button (lv_obj_t *parent)
void asset_btn_set_compact (bool compact)
lv_obj_t * make_net_badge (lv_obj_t *parent, pos_net_t net)
void make_tap_mark (lv_obj_t *parent, lv_coord_t y)
lv_obj_t * make_pill (lv_obj_t *parent, const char *title, const char *sub, lv_coord_t w, lv_coord_t y, BtnAction act, bool leaf)
lv_obj_t * make_field (lv_obj_t *parent, const char *caption, const char *value, lv_color_t col)
static void sheet_y_cb (void *obj, int32_t v)
static lv_obj_t * sheet_open (void)
static void sheet_slide_in (lv_obj_t *sh)
static void code_field_wipe (lv_obj_t *ta)
void clear_screen (void)
static void clock_refresh (void)
 Retext the band's clock from the system clock plus the stored offset.
void paint_page (lv_obj_t *obj)
 Lay the sale-flow chrome and return the white card to build into.
lv_obj_t * make_card (lv_obj_t *parent)
lv_obj_t * build_page (int step, bool band)
lv_obj_t * make_icon_button (const char *sym, BtnAction act, lv_obj_t *parent)
void add_test_chip (void)
lv_obj_t * make_title (const char *txt, bool has_icon, lv_obj_t *parent)
 Screen title, centred but never underneath the top-left icon button.
void build_header (const char *title)
static void signal_refresh (lv_timer_t *t)
void signal_init (void)
void render_requested_screen (void)

Variables

static const lv_img_dsc_t *const NET_ICON [POS_NET__COUNT]
static const lv_img_dsc_t *const NET_CHIP [POS_NET__COUNT]
static int16_t s_tz_off_min = 0
static uint8_t s_tz_dst = 0
volatile bool s_tz_dirty = true
static const uint16_t SIG_SWEEP [SIG_ARCS] = { 140, 110, 100 }
static lv_obj_t * s_sig_arc [SIG_ARCS]
static lv_obj_t * s_sig_dot = NULL
static lv_obj_t * s_sig_box = NULL

Detailed Description

Widget helpers shared by every screen, and the Wi-Fi signal mark.

Definition in file ui_widgets.cpp.

Macro Definition Documentation

◆ BADGE_SZ

#define BADGE_SZ   (COIN_SZ + 6) /* room for the chip to hang off the corner */

Definition at line 102 of file ui_widgets.cpp.

Referenced by make_icon_box().

◆ CHIP_SZ

#define CHIP_SZ   16

Definition at line 101 of file ui_widgets.cpp.

◆ COL_TAP_MARK

#define COL_TAP_MARK   COL_TEXT

Definition at line 251 of file ui_widgets.cpp.

Referenced by make_tap_mark().

◆ PILL_TEXT_PAD_R

#define PILL_TEXT_PAD_R   24

Definition at line 264 of file ui_widgets.cpp.

Referenced by make_pill().

◆ PILL_TEXT_X

#define PILL_TEXT_X   52 /* clears the BADGE_SZ icon at PILL_ICON_X */

Definition at line 261 of file ui_widgets.cpp.

Referenced by make_pill().

◆ SIG_ARCS

#define SIG_ARCS   3

Definition at line 636 of file ui_widgets.cpp.

Referenced by signal_init(), and signal_refresh().

◆ SIG_AW

#define SIG_AW   2 /* arc thickness */

Definition at line 637 of file ui_widgets.cpp.

Referenced by signal_init().

◆ SIG_DOT

#define SIG_DOT   4

Definition at line 645 of file ui_widgets.cpp.

Referenced by signal_init().

◆ SIG_H

#define SIG_H   (SIG_REACH + ((SIG_DOT + 1) / 2))

Definition at line 657 of file ui_widgets.cpp.

Referenced by signal_init().

◆ SIG_INSET

#define SIG_INSET   14

Definition at line 659 of file ui_widgets.cpp.

Referenced by signal_init().

◆ SIG_R0

#define SIG_R0   4 /* innermost arc radius; each ring adds SIG_RSTEP */

Definition at line 640 of file ui_widgets.cpp.

Referenced by signal_init().

◆ SIG_REACH

#define SIG_REACH   (SIG_R0 + ((SIG_ARCS - 1) * SIG_RSTEP) + (SIG_AW / 2))

Definition at line 655 of file ui_widgets.cpp.

Referenced by signal_init().

◆ SIG_RSTEP

#define SIG_RSTEP   3

Definition at line 641 of file ui_widgets.cpp.

Referenced by signal_init().

◆ SIG_W

#define SIG_W   (2 * SIG_REACH)

Definition at line 656 of file ui_widgets.cpp.

Referenced by signal_init().

◆ TAP_MARK_W

#define TAP_MARK_W   109

Definition at line 246 of file ui_widgets.cpp.

Function Documentation

◆ add_test_chip()

void add_test_chip ( void )

Definition at line 561 of file ui_widgets.cpp.

References CHIP_X, CHIP_Y, COL_BG, COL_DANGER, font_inter_14_medium, and settings_get_mainnet().

◆ asset_btn_set_compact()

void asset_btn_set_compact ( bool compact)

Definition at line 219 of file ui_widgets.cpp.

References s_asset_arrow.

Referenced by amount_update_display().

◆ build_header()

void build_header ( const char * title)

Definition at line 617 of file ui_widgets.cpp.

References HDR_DIVIDER_Y, make_divider(), and make_title().

Referenced by build_boot_error(), build_touch_cal(), and build_wifi_connecting().

◆ build_page()

◆ clear_screen()

◆ clock_refresh()

void clock_refresh ( void )
static

Retext the band's clock from the system clock plus the stored offset.

"--:--" until SNTP has set the clock: a till showing a confident wrong time (1970) is worse than one admitting it has none.

gmtime_r on an already-offset instant, not localtime_r: newlib's timezone machinery costs 64 KB of the app slot. DST comes from civil_local_offset_min(). Minute resolution, so the 3 s Wi-Fi status timer drives it.

Definition at line 431 of file ui_widgets.cpp.

References civil_local_offset_min(), s_clock_lbl, s_tz_dirty, s_tz_dst, s_tz_off_min, settings_get_tz_dst(), and settings_get_tz_offset_min().

Referenced by build_page(), and signal_refresh().

◆ code_field_wipe()

void code_field_wipe ( lv_obj_t * ta)
static

Definition at line 371 of file ui_widgets.cpp.

Referenced by clear_screen().

◆ coin_icon()

const lv_img_dsc_t * coin_icon ( const pos_asset_t * a)
static

◆ make_asset_badge()

lv_obj_t * make_asset_badge ( lv_obj_t * parent,
pos_chain_t chain )

◆ make_asset_button()

◆ make_button()

lv_obj_t * make_button ( lv_obj_t * parent,
const char * label,
lv_color_t bg,
lv_color_t fg,
lv_coord_t w,
lv_coord_t h,
lv_align_t align,
lv_coord_t x,
lv_coord_t y,
BtnAction act,
const lv_font_t * font )

◆ make_card()

lv_obj_t * make_card ( lv_obj_t * parent)

Definition at line 481 of file ui_widgets.cpp.

References CARD_H, CARD_W, CARD_X, CARD_Y, and COL_BG.

Referenced by build_admin_screen(), and build_page().

◆ make_divider()

void make_divider ( lv_obj_t * parent,
lv_coord_t y )

Definition at line 91 of file ui_widgets.cpp.

References COL_BORDER, and SCR_W.

Referenced by build_header(), and build_header_back().

◆ make_field()

lv_obj_t * make_field ( lv_obj_t * parent,
const char * caption,
const char * value,
lv_color_t col )

Definition at line 316 of file ui_widgets.cpp.

References COL_DIM, font_inter_14, font_inter_14_medium, make_label(), and TAB_W.

Referenced by build_settings().

◆ make_ghost_button()

lv_obj_t * make_ghost_button ( lv_obj_t * parent,
const char * label,
lv_coord_t w,
lv_align_t align,
lv_coord_t x,
lv_coord_t y,
BtnAction act )

Definition at line 78 of file ui_widgets.cpp.

References CARD_BTN_H, COL_BG, COL_BORDER, COL_TEXT, font_pjs_20_semibold, and make_button().

Referenced by build_card_wait().

◆ make_glyph_disc()

lv_obj_t * make_glyph_disc ( lv_obj_t * parent,
const char * sym,
lv_color_t bg,
lv_coord_t sz )

Definition at line 103 of file ui_widgets.cpp.

References COL_BG, and font_inter_14.

Referenced by build_settings().

◆ make_icon_box()

lv_obj_t * make_icon_box ( lv_obj_t * parent,
const lv_img_dsc_t * coin_src,
const lv_img_dsc_t * chip_src )
static

Definition at line 129 of file ui_widgets.cpp.

References BADGE_SZ, and COIN_SZ.

Referenced by make_asset_badge(), and make_net_badge().

◆ make_icon_button()

lv_obj_t * make_icon_button ( const char * sym,
BtnAction act,
lv_obj_t * parent )

◆ make_label()

lv_obj_t * make_label ( lv_obj_t * parent,
const char * txt,
lv_color_t color,
const lv_font_t * font,
lv_align_t align,
lv_coord_t x,
lv_coord_t y )

◆ make_net_badge()

lv_obj_t * make_net_badge ( lv_obj_t * parent,
pos_net_t net )

Definition at line 227 of file ui_widgets.cpp.

References make_icon_box(), and NET_ICON.

Referenced by open_network_picker().

◆ make_pill()

lv_obj_t * make_pill ( lv_obj_t * parent,
const char * title,
const char * sub,
lv_coord_t w,
lv_coord_t y,
BtnAction act,
bool leaf )

◆ make_tap_mark()

void make_tap_mark ( lv_obj_t * parent,
lv_coord_t y )

Definition at line 252 of file ui_widgets.cpp.

References COL_TAP_MARK, and tap_icon.

Referenced by build_card_wait().

◆ make_title()

lv_obj_t * make_title ( const char * txt,
bool has_icon,
lv_obj_t * parent )

Screen title, centred but never underneath the top-left icon button.

The title gets the gap between two symmetric gutters; if it does not fit at 20px it drops to the 14px face rather than overlapping the icon or eliding. The width cap and LONG_DOT are the backstop for a title too long even at 14px.

Parameters
has_icontrue when make_icon_button() has put a glyph in the top-left.

Definition at line 586 of file ui_widgets.cpp.

References COL_TITLE, font_inter_14_medium, font_pjs_20_medium, HDR_TITLE_Y, make_label(), MENU_BTN_W, MENU_BTN_X, and SCR_W.

Referenced by build_admin_screen(), build_header(), and build_header_back().

◆ paint_page()

void paint_page ( lv_obj_t * obj)

Lay the sale-flow chrome and return the white card to build into.

Parameters
stepWhich step of the sale this is (PAY_STEP_*). Currently unused.
Returns
The card. Children use ITS coordinates: (0,0) is the card's top-left, CARD_W x CARD_H.

Definition at line 470 of file ui_widgets.cpp.

References COL_PAGE, and COL_PAGE_GRAD.

Referenced by build_admin_screen(), and build_page().

◆ render_requested_screen()

◆ sheet_open()

lv_obj_t * sheet_open ( void )
static

Definition at line 341 of file ui_widgets.cpp.

References COL_BG, SCR_H, and SCR_W.

Referenced by render_requested_screen().

◆ sheet_slide_in()

void sheet_slide_in ( lv_obj_t * sh)
static

Definition at line 354 of file ui_widgets.cpp.

References SCR_H, and sheet_y_cb().

Referenced by render_requested_screen().

◆ sheet_y_cb()

void sheet_y_cb ( void * obj,
int32_t v )
static

Definition at line 334 of file ui_widgets.cpp.

Referenced by sheet_slide_in().

◆ signal_init()

void signal_init ( void )

◆ signal_refresh()

Variable Documentation

◆ NET_CHIP

const lv_img_dsc_t* const NET_CHIP[POS_NET__COUNT]
static
Initial value:
= {
}
const lv_img_dsc_t chip_eth
const lv_img_dsc_t chip_tron
const lv_img_dsc_t chip_poly

Definition at line 156 of file ui_widgets.cpp.

Referenced by make_asset_badge().

◆ NET_ICON

const lv_img_dsc_t* const NET_ICON[POS_NET__COUNT]
static
Initial value:
= {
}
const lv_img_dsc_t icon_eth
const lv_img_dsc_t icon_tron
const lv_img_dsc_t icon_poly

Definition at line 153 of file ui_widgets.cpp.

Referenced by coin_icon(), make_asset_badge(), and make_net_badge().

◆ s_sig_arc

lv_obj_t* s_sig_arc[SIG_ARCS]
static

Definition at line 661 of file ui_widgets.cpp.

Referenced by signal_init(), and signal_refresh().

◆ s_sig_box

lv_obj_t* s_sig_box = NULL
static

Definition at line 663 of file ui_widgets.cpp.

Referenced by render_requested_screen(), signal_init(), and signal_refresh().

◆ s_sig_dot

lv_obj_t* s_sig_dot = NULL
static

Definition at line 662 of file ui_widgets.cpp.

Referenced by signal_init(), and signal_refresh().

◆ s_tz_dirty

volatile bool s_tz_dirty = true

Definition at line 419 of file ui_widgets.cpp.

Referenced by clock_refresh(), and ui_clock_changed().

◆ s_tz_dst

uint8_t s_tz_dst = 0
static

Definition at line 418 of file ui_widgets.cpp.

Referenced by clock_refresh().

◆ s_tz_off_min

int16_t s_tz_off_min = 0
static

Definition at line 417 of file ui_widgets.cpp.

Referenced by clock_refresh().

◆ SIG_SWEEP

const uint16_t SIG_SWEEP[SIG_ARCS] = { 140, 110, 100 }
static

Definition at line 651 of file ui_widgets.cpp.

Referenced by signal_init().