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

The settings page, touch calibration and the admin-code screens. More...

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

Go to the source code of this file.

Macros

#define OTA_GAP   8
#define OTA_CARD_PAD   8 /* open_modal()'s pad_all */
#define PICK_W   206
#define ADMIN_PENALTY_MAX_S   3600U
 Wait imposed after repeated wrong admin codes.

Functions

void settings_persist (void)
static void brightness_event_cb (lv_event_t *e)
static void settings_bottom_bar (uint16_t tab)
static void tab_change_cb (lv_event_t *e)
void build_settings (void)
static void cal_target (lv_coord_t cx, lv_coord_t cy)
static bool cal_apply (void)
void build_touch_cal (void)
void touch_cal_poll (void)
void close_modal (void)
lv_obj_t * open_modal (lv_coord_t w, lv_coord_t h)
void open_reset_confirm (void)
lv_obj_t * ota_text (lv_obj_t *card, lv_obj_t *above, const char *txt, lv_color_t col, const lv_font_t *font)
void ota_fit_card (lv_obj_t *card, lv_obj_t *last, lv_coord_t buttons_h)
void open_portal_window (void)
void open_ota_gone (void)
void build_ota_confirm (void)
static void pill_disable (lv_obj_t *p)
void open_network_picker (void)
void open_coin_picker (pos_net_t net)
uint32_t admin_penalty_ms (uint8_t fails)
static void wait_text (char *out, size_t n, uint32_t secs)
static uint32_t admin_lock_remaining_s (void)
static void admin_set_note (const char *msg)
static void admin_submit (void)
static void admin_kbd_cb (lv_event_t *e)
static void build_admin_screen (const char *title, bool allow_cancel, const char *hint)
void build_admin_set (void)
void build_admin_unlock (void)

Variables

static lv_obj_t * s_modal = NULL
bool s_portal_modal = false
static const BtnAction NET_ACT [POS_NET__COUNT]

Detailed Description

The settings page, touch calibration and the admin-code screens.

Definition in file ui_admin.cpp.

Macro Definition Documentation

◆ ADMIN_PENALTY_MAX_S

#define ADMIN_PENALTY_MAX_S   3600U

Wait imposed after repeated wrong admin codes.

Free for the first three tries, then doubling — 1 s, 2 s, 4 s ... — and still doubling past a minute, up to an hour per attempt from the fifteenth wrong code on. The count is in NVS, so a power cycle restarts the current wait rather than resetting it. Never a permanent lock: the code gates the factory reset too, so locking for good would leave no way back in short of a USB reflash.

Definition at line 738 of file ui_admin.cpp.

Referenced by admin_penalty_ms().

◆ OTA_CARD_PAD

#define OTA_CARD_PAD   8 /* open_modal()'s pad_all */

Definition at line 474 of file ui_admin.cpp.

Referenced by ota_fit_card().

◆ OTA_GAP

#define OTA_GAP   8

Definition at line 473 of file ui_admin.cpp.

Referenced by ota_fit_card(), and ota_text().

◆ PICK_W

#define PICK_W   206

Definition at line 634 of file ui_admin.cpp.

Referenced by open_coin_picker(), and open_network_picker().

Function Documentation

◆ admin_kbd_cb()

void admin_kbd_cb ( lv_event_t * e)
static

Definition at line 872 of file ui_admin.cpp.

References admin_submit(), and s_admin_ta.

Referenced by build_admin_screen().

◆ admin_lock_remaining_s()

uint32_t admin_lock_remaining_s ( void )
static

Definition at line 756 of file ui_admin.cpp.

References s_admin_lock_ms, and s_admin_lock_start.

Referenced by admin_submit().

◆ admin_penalty_ms()

uint32_t admin_penalty_ms ( uint8_t fails)

Definition at line 739 of file ui_admin.cpp.

References ADMIN_PENALTY_MAX_S.

Referenced by admin_submit(), open_admin_entry(), and ui_show_prov_auth().

◆ admin_set_note()

void admin_set_note ( const char * msg)
static

Definition at line 766 of file ui_admin.cpp.

References s_admin_note, and s_admin_note_lbl.

Referenced by admin_submit().

◆ admin_submit()

◆ brightness_event_cb()

void brightness_event_cb ( lv_event_t * e)
static

Definition at line 23 of file ui_admin.cpp.

References backlight_set_pct(), and s_brightness.

Referenced by build_settings().

◆ build_admin_screen()

◆ build_admin_set()

void build_admin_set ( void )

Definition at line 922 of file ui_admin.cpp.

References build_admin_screen(), and s_admin_confirming.

Referenced by render_requested_screen().

◆ build_admin_unlock()

void build_admin_unlock ( void )

Definition at line 929 of file ui_admin.cpp.

References build_admin_screen(), prov_pair_code(), and s_admin_for_portal.

Referenced by render_requested_screen().

◆ build_ota_confirm()

◆ build_settings()

◆ build_touch_cal()

◆ cal_apply()

◆ cal_target()

void cal_target ( lv_coord_t cx,
lv_coord_t cy )
static

Definition at line 302 of file ui_admin.cpp.

References COL_DANGER.

Referenced by build_touch_cal().

◆ close_modal()

void close_modal ( void )

Definition at line 424 of file ui_admin.cpp.

References s_modal, and s_portal_modal.

Referenced by btn_event_cb(), open_modal(), render_requested_screen(), and ui_task().

◆ open_coin_picker()

◆ open_modal()

lv_obj_t * open_modal ( lv_coord_t w,
lv_coord_t h )

◆ open_network_picker()

◆ open_ota_gone()

void open_ota_gone ( void )

Accept or refuse firmware that the update page has uploaded.

The upload is already verified (SHA-256, and the signature on a signed build), so this asks whether the person holding the terminal wants this version, which a browser cannot answer. A downgrade is called out: it is properly signed too, and returning to firmware with a known fault is something to be talked into. Install was tapped and there was nothing left to install.

Says so, so a terminal that stayed on the old firmware does not look updated.

Definition at line 581 of file ui_admin.cpp.

References ACT_MODAL_CLOSE, COL_ACTION, COL_BG, COL_TEXT, font_inter_14, font_pjs_20_semibold, make_button(), open_modal(), OTA_CARD_W, ota_fit_card(), ota_text(), and OTA_TEXT_W.

Referenced by btn_event_cb().

◆ open_portal_window()

◆ open_reset_confirm()

void open_reset_confirm ( void )

◆ ota_fit_card()

void ota_fit_card ( lv_obj_t * card,
lv_obj_t * last,
lv_coord_t buttons_h )

Resize the card to the text it ended up with, leaving room for the buttons.

buttons_h is how far the button block reaches up from the content bottom — 42 for one 40 px button at -2, 86 for two. Clamped to the screen, so a pathological string elides off the bottom rather than drawing a card taller than the panel.

Definition at line 502 of file ui_admin.cpp.

References OTA_CARD_PAD, OTA_GAP, and SCR_H.

Referenced by build_ota_confirm(), build_prov_confirm(), open_ota_gone(), and open_portal_window().

◆ ota_text()

lv_obj_t * ota_text ( lv_obj_t * card,
lv_obj_t * above,
const char * txt,
lv_color_t col,
const lv_font_t * font )

Wrapped, centred body text stacked under above (or the card top).

Definition at line 477 of file ui_admin.cpp.

References make_label(), OTA_GAP, and OTA_TEXT_W.

Referenced by build_ota_confirm(), build_prov_confirm(), open_ota_gone(), and open_portal_window().

◆ pill_disable()

void pill_disable ( lv_obj_t * p)
static

Grey a row out and make it inert.

For a network whose payout address nobody has set. Shown rather than hidden, so the dimmed row tells the operator what to go and do.

Definition at line 642 of file ui_admin.cpp.

References COL_DIM.

Referenced by open_network_picker().

◆ settings_bottom_bar()

void settings_bottom_bar ( uint16_t tab)
static

Definition at line 38 of file ui_admin.cpp.

References ACT_BTN_Y, s_close_btn, s_reset_btn, and TAB_ABOUT.

Referenced by build_settings(), and tab_change_cb().

◆ settings_persist()

void settings_persist ( void )

Definition at line 19 of file ui_admin.cpp.

References s_brightness, and settings_set_brightness().

Referenced by btn_event_cb().

◆ tab_change_cb()

void tab_change_cb ( lv_event_t * e)
static

Definition at line 55 of file ui_admin.cpp.

References s_settings_tab, settings_bottom_bar(), and SETTINGS_TAB_COUNT.

Referenced by build_settings().

◆ touch_cal_poll()

void touch_cal_poll ( void )

◆ wait_text()

void wait_text ( char * out,
size_t n,
uint32_t secs )
static

Definition at line 750 of file ui_admin.cpp.

Referenced by admin_submit().

Variable Documentation

◆ NET_ACT

const BtnAction NET_ACT[POS_NET__COUNT]
static
Initial value:
= {
}
@ ACT_NET_POLY
@ ACT_NET_ETH
@ ACT_NET_TRON

Step 1 — the network.

Definition at line 653 of file ui_admin.cpp.

Referenced by open_network_picker().

◆ s_modal

lv_obj_t* s_modal = NULL
static

Definition at line 418 of file ui_admin.cpp.

Referenced by close_modal(), and open_modal().

◆ s_portal_modal

bool s_portal_modal = false

Definition at line 423 of file ui_admin.cpp.

Referenced by build_ota_confirm(), close_modal(), open_portal_window(), and ui_task().