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

Touchscreen UI implementation built on LVGL 8.x. More...

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

Go to the source code of this file.

Classes

struct  UiLock

Functions

const pos_asset_t * asset (pos_chain_t c)
const char * asset_name (pos_chain_t c)
const char * asset_network (pos_chain_t c)
const char * asset_caption (pos_chain_t c)
static void request_prov_stop (void)
void request_screen (ui_screen_t s)
void set_wifi_progress (const char *caption, const char *name)
uint64_t amount_cents_max (void)
static void open_admin_entry (void)
 Open the admin panel's front door — the code screen, not the panel.
void btn_event_cb (lv_event_t *e)
static void ui_task (void *arg)
void ui_init (ui_event_cb_t cb)
 Initialise display + touch and start the UI task.
void ui_show_splash (void)
 Switch to the splash screen.
void ui_show_amount_entry (void)
 Switch to the amount-entry screen (forces a value redraw).
void ui_show_confirm (uint64_t amount_units, const char *dest_addr, const char *fee)
 Switch to the confirm screen.
size_t ui_take_pin (char *out, size_t n)
 Copy the most recently entered PIN out and wipe the UI's copy.
void ui_show_wifi_list (const net_wifi_ap_t *aps, uint16_t n, const char *note)
 Show the scanned Wi-Fi networks for the user to pick from.
void ui_set_addresses (const char *token_contract, const char *dest_addr)
 Provide the token contract and destination addresses for the confirm screen and the settings "Tx" tab (pointers stored as-is; pass static/literal storage that outlives the call).
void ui_show_wifi_connecting (const char *ssid)
 Show a "Connecting to <ssid>…" screen while main associates.
void ui_set_boot_status (const char *step)
 Set the one-line progress note on the splash screen.
void ui_fees_changed (void)
 Note that the stored gas caps have changed, so the Tx tab can catch up.
void ui_clock_changed (void)
 Note that the stored UTC offset has changed, so the clock can catch up.
void ui_show_boot_error (ui_boot_err_t kind, const char *detail)
 Show a startup fault, naming the cause and what to do about it.
void ui_show_welcome (const char *sub)
 Greet the operator at the start of first-run setup, or after an update.
void ui_show_admin_set (void)
 Run the first-run admin-code creation (enter, then confirm).
size_t ui_take_wifi_creds (char *ssid, size_t ssid_n, char *pass, size_t pass_n)
 Fetch the selected SSID + entered password and wipe the UI's copy.
void ui_stage_wifi_creds (const char *ssid, const char *pass)
 Load credentials into the same handoff buffers the picker fills.
void ui_show_prov (int step)
 Show the setup screen: QR code, AP name and passphrase.
void ui_show_prov_confirm (void)
 Raise the modal that asks the operator to accept a value a browser proposed, reading the pending proposal from provision.h.
void ui_show_prov_auth (void)
 Demand the admin code so a browser can be authorised.
void ui_show_card_pin (void)
 Ask for the card PIN before reading an address off a Cryptnox card.
void ui_set_prov_note (const char *msg)
 Put a failure line on the setup screen, in red under the step title.
void ui_show_card_wait (const char *note)
 "Hold your card to the reader" while the address is read.
void ui_show_ota_confirm (void)
 Raise the modal that asks the operator to accept a firmware image the update page has uploaded, reading it from ota.h.
void ui_show_tx_status (ui_tx_state_t state, const char *info)
 Switch to the transaction-status screen.
void ui_set_tx_info (const char *info)
 Replace the transaction screen's info line without rebuilding it.

Variables

const char * TAG = "ui"
ui_event_cb_t s_cb = NULL
static volatile bool s_screen_dirty = true
volatile ui_screen_t s_req_screen = UI_SCREEN_SPLASH
uint64_t s_amount_units = 0ULL
uint64_t s_confirm_amount = 0ULL
char s_confirm_addr [64] = ""
char s_confirm_fee [40] = ""
ui_tx_state_t s_tx_state = UI_TX_STATE_PLACE_CARD
char s_tx_info [72] = ""
lv_obj_t * s_tx_info_lbl = NULL
static volatile bool s_tx_info_dirty = false
uint8_t s_cal_step = 0U
int16_t s_cal_raw [2][2] = {{0, 0}, {0, 0}}
bool s_cal_pressed = false
int16_t s_cal_last_x = 0
int16_t s_cal_last_y = 0
static uint16_t s_cal_prev [4] = {0, 0, 0, 0}
uint32_t s_cal_deadline = 0U
lv_obj_t * s_cal_countdown = NULL
lv_obj_t * s_sheet = NULL
volatile bool s_sheet_pending = false
char s_card_note [64] = ""
lv_obj_t * s_amount_label = NULL
lv_obj_t * s_amount_cents_label = NULL
lv_obj_t * s_amount_row = NULL
uint64_t s_amount_cents = 0
lv_obj_t * s_asset_btn = NULL
lv_obj_t * s_asset_arrow = NULL
lv_obj_t * s_charge_btn = NULL
lv_obj_t * s_clock_lbl = NULL
bool s_charge_busy = false
lv_obj_t * s_pin_ta = NULL
char s_pin [16] = {0}
uint8_t s_pin_len = 0
net_wifi_ap_t s_aps [WIFI_MAX_APS]
uint16_t s_ap_count = 0
char s_wifi_ssid [33] = {0}
char s_wifi_pass [65] = {0}
char s_wifi_note [64] = {0}
lv_obj_t * s_wifi_pass_ta = NULL
lv_obj_t * s_wifi_eye_lbl = NULL
lv_obj_t * s_pin_eye_lbl = NULL
lv_obj_t * s_admin_eye_lbl = NULL
char s_wifi_caption [24] = {0}
char s_wifi_name [33] = {0}
char s_boot_step [40] = {0}
lv_obj_t * s_boot_step_lbl = NULL
static volatile bool s_boot_step_dirty = false
lv_obj_t * s_fee_max_lbl = NULL
lv_obj_t * s_fee_prio_lbl = NULL
static volatile bool s_fees_dirty = false
volatile int s_prov_step = 0
char s_prov_msg [64] = ""
static volatile bool s_addr_modal_dirty = false
static volatile bool s_ota_modal_dirty = false
ui_boot_err_t s_boot_err = UI_BOOT_ERR_NFC
char s_boot_detail [64] = {0}
lv_obj_t * s_admin_ta = NULL
lv_obj_t * s_admin_note_lbl = NULL
char s_admin_first [ADMIN_CODE_MAX+1] = {0}
char s_admin_note [48] = {0}
bool s_admin_confirming = false
static bool s_welcome_sent = false
char s_welcome_sub [96] = {0}
uint32_t s_admin_lock_start = 0
uint32_t s_admin_lock_ms = 0
bool s_admin_for_portal = false
bool s_pin_for_card = false
const char * s_addr_usdc = NULL
const char * s_addr_dest = NULL
lv_obj_t * s_reset_btn = NULL
lv_obj_t * s_close_btn = NULL
static ui_screen_t s_settings_return = UI_SCREEN_AMOUNT
uint16_t s_settings_tab = 0U
pos_chain_t s_view_chain = POS_CHAIN_ETH_USDC
static SemaphoreHandle_t s_ui_mx = NULL
static uint32_t s_prov_stop_at = 0U

Detailed Description

Touchscreen UI implementation built on LVGL 8.x.

TFT_eSPI is used only as the low-level panel driver (the LVGL flush callback pushes rendered pixels to it); XPT2046_Touchscreen feeds the LVGL pointer input device. All LVGL calls happen on the single UI task — the public ui_show_* entry points (called from the main task) only stage a screen request + its data and raise a dirty flag, which the UI task drains.

Definition in file ui.cpp.

Function Documentation

◆ amount_cents_max()

uint64_t amount_cents_max ( void )

Ceiling on what the keypad will accept, for the asset currently selected.

ETH and POL are 18-decimal and the signed value is a uint64 of wei, so a sale stops at 18.44 of either (see POS_AMOUNT_UNITS_MAX_NATIVE). Enforced at the keypad rather than at the confirm step, so the mistake is never keyed.

Definition at line 265 of file ui.cpp.

References amount_cents_cap(), pos_chain_is_native_evm(), and settings_get_chain().

Referenced by amount_kbd_cb(), and btn_event_cb().

◆ asset()

const pos_asset_t * asset ( pos_chain_t c)

An asset's row — ticker, standard, caption, network. Default: the sale's.

Definition at line 189 of file ui.cpp.

References pos_asset_of().

Referenced by asset_caption(), asset_name(), and asset_network().

◆ asset_caption()

const char * asset_caption ( pos_chain_t c)

Caption for the address row above "Send to": TRX has no contract to show.

Definition at line 210 of file ui.cpp.

References asset(), and pos_asset_t::caption.

Referenced by build_settings().

◆ asset_name()

const char * asset_name ( pos_chain_t c)

Ticker of the asset being charged, for the selector and the amount screens.

Definition at line 194 of file ui.cpp.

References asset(), and pos_asset_t::ticker.

Referenced by build_settings(), make_asset_button(), and tx_amount_row().

◆ asset_network()

const char * asset_network ( pos_chain_t c)

Which network that asset lives on — the selector's subtitle.

Names the deployment, not just the family ("Ethereum" vs "Ethereum Sepolia"): it decides whether a sale settles in real money.

Definition at line 204 of file ui.cpp.

References asset(), pos_net_info_t::long_main, pos_net_info_t::long_test, pos_net_info(), and settings_net_str().

Referenced by build_settings().

◆ btn_event_cb()

void btn_event_cb ( lv_event_t * e)

Definition at line 306 of file ui.cpp.

References ACT_ADMIN_CANCEL, ACT_ADMIN_REVEAL, ACT_CAL_CANCEL, ACT_CAL_SAVE, ACT_CANCEL, ACT_CHAIN_BASE, ACT_CHAIN_OF, ACT_CLOSE, ACT_CONFIRM, ACT_MODAL_CLOSE, ACT_NET_ETH, ACT_NET_PICK, ACT_NET_POLY, ACT_NET_TRON, ACT_NEW, ACT_OTA_NO, ACT_OTA_OK, ACT_PIN_CANCEL, ACT_PIN_REVEAL, ACT_PORTAL, ACT_PORTAL_CLOSE, ACT_PROV_FINISH, ACT_PROV_NO, ACT_PROV_OK, ACT_RESET, ACT_RESET_CONFIRM, ACT_SEND, ACT_TOUCH_CAL, ACT_TX_RECHECK, ACT_WELCOME_OK, ACT_WIFI, ACT_WIFI_CANCEL, ACT_WIFI_PASS_REVEAL, amount_cents_max(), charge_set_busy(), close_modal(), code_field_reveal(), open_coin_picker(), open_network_picker(), open_ota_gone(), open_portal_window(), open_reset_confirm(), ota_commit(), POS_CHAIN__COUNT, POS_NET_ETH, POS_NET_POLY, POS_NET_TRON, prov_auth_resolve(), prov_mode(), PROV_MODE_WIZARD, prov_pending_commit(), request_prov_stop(), request_screen(), s_admin_eye_lbl, s_admin_first, s_admin_for_portal, s_admin_ta, s_amount_cents, s_amount_units, s_cal_pressed, s_cal_prev, s_cal_step, s_cal_xmax, s_cal_xmin, s_cal_ymax, s_cal_ymin, s_cb, s_cb, s_pin, s_pin_eye_lbl, s_pin_for_card, s_pin_len, s_pin_ta, s_req_screen, s_settings_return, s_view_chain, s_welcome_sent, s_wifi_eye_lbl, s_wifi_pass, s_wifi_pass_ta, set_wifi_progress(), settings_factory_reset(), settings_persist(), settings_set_chain(), settings_set_touch_cal(), touch_cal_load(), UI_EVENT_AMOUNT_CONFIRMED, UI_EVENT_CONFIRM_CANCEL, UI_EVENT_PROV_FINISH, UI_EVENT_TX_RECHECK, UI_EVENT_TX_RETRY, UI_EVENT_WELCOME_DONE, UI_EVENT_WIFI_SCAN, ui_refresh_addresses(), UI_SCREEN_AMOUNT, UI_SCREEN_CONFIRM, UI_SCREEN_PIN, UI_SCREEN_PROV, UI_SCREEN_SETTINGS, UI_SCREEN_TOUCH_CAL, and UI_SCREEN_WIFI_CONNECTING.

Referenced by make_asset_button(), make_button(), make_icon_button(), and make_pill().

◆ open_admin_entry()

void open_admin_entry ( void )
static

Open the admin panel's front door — the code screen, not the panel.

One lock for the whole menu: Wi-Fi, fee caps and the factory reset are all merchant operations, and the reset in particular must not be one tap away from a customer left alone with the terminal.

No code stored means first-run setup has not finished, so the request is ignored rather than let through (reachable by backing out of the first-run Wi-Fi picker onto the amount screen).

Called from the swipe gesture, which arms the full lockout penalty: a gesture that skipped it would be a cheaper way in.

Definition at line 283 of file ui.cpp.

References admin_penalty_ms(), request_screen(), s_admin_confirming, s_admin_for_portal, s_admin_lock_ms, s_admin_lock_start, s_admin_note, s_req_screen, s_settings_return, s_settings_tab, s_sheet_pending, s_view_chain, settings_admin_fail_count(), settings_get_chain(), settings_has_admin_code(), and UI_SCREEN_ADMIN_UNLOCK.

Referenced by ui_task().

◆ request_prov_stop()

void request_prov_stop ( void )
static

Definition at line 236 of file ui.cpp.

References s_cb, s_cb, s_prov_stop_at, and UI_EVENT_PROV_STOP.

Referenced by btn_event_cb(), and ui_task().

◆ request_screen()

◆ set_wifi_progress()

void set_wifi_progress ( const char * caption,
const char * name )

Definition at line 247 of file ui.cpp.

References s_wifi_caption, and s_wifi_name.

Referenced by admin_submit(), btn_event_cb(), ui_show_wifi_connecting(), and wifi_pass_kb_cb().

◆ ui_clock_changed()

void ui_clock_changed ( void )

Note that the stored UTC offset has changed, so the clock can catch up.

Same handoff as ui_fees_changed and for the same reason: the config page writes the offset straight through from the HTTP task, and the band's clock caches it rather than opening NVS on every three-second tick. Without this the panel keeps the old hour until something rebuilds the screen.

Safe from the HTTP task: applied by the UI task on its next pass.

Definition at line 788 of file ui.cpp.

References s_tz_dirty.

Referenced by clock_post().

◆ ui_fees_changed()

void ui_fees_changed ( void )

Note that the stored gas caps have changed, so the Tx tab can catch up.

The caps are the one setting the config page writes straight through, and that page is opened from a card raised over the settings screen — so the two gas rows underneath keep the values they were built with until the operator leaves the screen and comes back. This retexts them in place.

Safe from the HTTP task: applied by the UI task on its next pass, and a no-op when the rows are not on screen (any other screen, or Tron, which has no caps).

Definition at line 783 of file ui.cpp.

References s_fees_dirty.

Referenced by fees_post().

◆ ui_init()

void ui_init ( ui_event_cb_t cb)

Initialise display + touch and start the UI task.

Parameters
[in]cbEvent callback; must remain valid for the program lifetime.

Definition at line 696 of file ui.cpp.

References s_cb, s_req_screen, s_screen_dirty, s_ui_mx, UI_SCREEN_SPLASH, and ui_task().

Referenced by pos_boot().

◆ ui_set_addresses()

void ui_set_addresses ( const char * token_contract,
const char * dest_addr )

Provide the token contract and destination addresses for the confirm screen and the settings "Tx" tab (pointers stored as-is; pass static/literal storage that outlives the call).

Definition at line 764 of file ui.cpp.

References s_addr_dest, and s_addr_usdc.

Referenced by ui_refresh_addresses_for().

◆ ui_set_boot_status()

void ui_set_boot_status ( const char * step)

Set the one-line progress note on the splash screen.

Updates the splash in place instead of switching screens. Safe from the main task: applied by the UI task on its next pass.

Parameters
[in]stepShort label ("Starting NFC reader"), copied internally. NULL or "" clears the line.

Definition at line 776 of file ui.cpp.

References s_boot_step, and s_boot_step_dirty.

Referenced by app_main(), pos_boot(), run_wizard(), and wifi_try_saved().

◆ ui_set_prov_note()

void ui_set_prov_note ( const char * msg)

Put a failure line on the setup screen, in red under the step title.

For the card read: a refused card, a wrong PIN or sixty seconds with no tap all end with the panel back on the step it started from, and without a reason there that reads as the terminal having reset itself mid-read. The browser gets the same sentence through prov_set_note — this is the copy for the person actually holding the card.

Cleared by ui_show_card_pin, so each attempt starts clean.

Parameters
[in]msgMessage, copied. NULL or "" clears it.

Definition at line 880 of file ui.cpp.

References s_prov_msg.

Referenced by run_wizard().

◆ ui_set_tx_info()

void ui_set_tx_info ( const char * info)

Replace the transaction screen's info line without rebuilding it.

For progress on a state that lasts: the receipt poll can run for two minutes, and calling ui_show_tx_status per pass would restart the spinner the operator is reading as "still working". No-op unless the transaction screen is up in one of its spinner states.

Parameters
[in]infoLine to show; copied internally, may be NULL to clear.

Definition at line 910 of file ui.cpp.

References s_tx_info, and s_tx_info_dirty.

Referenced by settle_inflight(), and sign_and_broadcast().

◆ ui_show_admin_set()

void ui_show_admin_set ( void )

Run the first-run admin-code creation (enter, then confirm).

Deliberately has no way out: everything behind the burger menu — Wi-Fi, fees, factory reset — sits behind this code, so the terminal must not become usable without one. Emits UI_EVENT_ADMIN_SET once stored.

Definition at line 818 of file ui.cpp.

References request_screen(), s_admin_confirming, s_admin_first, s_admin_note, and UI_SCREEN_ADMIN_SET.

Referenced by pos_boot().

◆ ui_show_amount_entry()

void ui_show_amount_entry ( void )

Switch to the amount-entry screen (forces a value redraw).

Definition at line 711 of file ui.cpp.

References request_screen(), s_amount_cents, s_amount_units, and UI_SCREEN_AMOUNT.

Referenced by app_main().

◆ ui_show_boot_error()

void ui_show_boot_error ( ui_boot_err_t kind,
const char * detail )

Show a startup fault, naming the cause and what to do about it.

Parameters
[in]kindWhich bring-up step failed.
[in]detailOptional technical detail for a technician (an esp_err_t name, say); copied internally, may be NULL.

Definition at line 795 of file ui.cpp.

References request_screen(), s_boot_detail, s_boot_err, and UI_SCREEN_BOOT_ERROR.

Referenced by boot_fault().

◆ ui_show_card_pin()

void ui_show_card_pin ( void )

Ask for the card PIN before reading an address off a Cryptnox card.

The card will not export a public key without a verified PIN, so deriving a payout address needs one exactly as signing does. Emits UI_EVENT_CARD_PIN, or UI_EVENT_CONFIRM_CANCEL if the operator backs out.

Definition at line 873 of file ui.cpp.

References request_screen(), s_pin_for_card, s_prov_msg, and UI_SCREEN_PIN.

Referenced by app_main(), and run_wizard().

◆ ui_show_card_wait()

void ui_show_card_wait ( const char * note)

"Hold your card to the reader" while the address is read.

Its own screen rather than the transaction one: nothing is being paid here, and the tx screen's wording and its Cancel semantics both belong to a sale.

Parameters
[in]noteOptional line under the prompt, copied internally.

Definition at line 886 of file ui.cpp.

References request_screen(), s_card_note, and UI_SCREEN_CARD_WAIT.

Referenced by card_connect().

◆ ui_show_confirm()

void ui_show_confirm ( uint64_t amount_units,
const char * dest_addr,
const char * fee )

Switch to the confirm screen.

Parameters
[in]amount_unitsAmount in USDC base units (6 decimals).
[in]dest_addr"0x..."-prefixed destination address; copied internally, may be NULL for none.
[in]feeThe network-fee ceiling as a line ("Fee up to 0.0013 ETH"), copied; NULL or "" for none.

Definition at line 718 of file ui.cpp.

References request_screen(), s_confirm_addr, s_confirm_amount, s_confirm_fee, and UI_SCREEN_CONFIRM.

Referenced by app_main().

◆ ui_show_ota_confirm()

void ui_show_ota_confirm ( void )

Raise the modal that asks the operator to accept a firmware image the update page has uploaded, reading it from ota.h.

Call after UI_EVENT_OTA_STAGED. Accepting reboots into the new firmware and does not return; declining discards the staging and leaves the running firmware alone. The panel is the only place either can happen — an upload on its own changes nothing about what boots.

Definition at line 893 of file ui.cpp.

References s_ota_modal_dirty.

Referenced by app_main().

◆ ui_show_prov()

void ui_show_prov ( int step)

Show the setup screen: QR code, AP name and passphrase.

The same screen at every wizard step, captioned with whichever one is current. There is deliberately no "use this screen instead" escape any more: the whole wizard past the admin code happens in the browser, so the panel's job here is to carry the QR code and to report progress.

Parameters
[in]stepThe prov_step_t the portal is serving. Typed as int to keep this header free of provision.h, which includes this one.

Definition at line 850 of file ui.cpp.

References request_screen(), s_prov_step, and UI_SCREEN_PROV.

Referenced by run_wizard().

◆ ui_show_prov_auth()

void ui_show_prov_auth ( void )

Demand the admin code so a browser can be authorised.

Same screen as the settings unlock, but a correct code calls prov_auth_resolve(true) instead of opening the menu, and backing out refuses the request rather than silently leaving the browser waiting.

Definition at line 861 of file ui.cpp.

References admin_penalty_ms(), request_screen(), s_admin_confirming, s_admin_for_portal, s_admin_lock_ms, s_admin_lock_start, s_admin_note, settings_admin_fail_count(), and UI_SCREEN_ADMIN_UNLOCK.

Referenced by app_main(), and run_wizard().

◆ ui_show_prov_confirm()

void ui_show_prov_confirm ( void )

Raise the modal that asks the operator to accept a value a browser proposed, reading the pending proposal from provision.h.

Call after UI_EVENT_PROV_VALUE. Accepting emits UI_EVENT_PROV_VALUE_SET; rejecting emits nothing and drops the proposal, so a caller waiting on the step stays where it is and can be offered another.

Definition at line 856 of file ui.cpp.

References s_addr_modal_dirty.

Referenced by app_main(), and run_wizard().

◆ ui_show_splash()

void ui_show_splash ( void )

Switch to the splash screen.

Definition at line 706 of file ui.cpp.

References request_screen(), and UI_SCREEN_SPLASH.

Referenced by pos_boot().

◆ ui_show_tx_status()

void ui_show_tx_status ( ui_tx_state_t state,
const char * info )

Switch to the transaction-status screen.

Parameters
[in]stateTransaction state to display.
[in]infoOptional info line (tx hash, error message); copied internally, may be NULL for none.

Definition at line 898 of file ui.cpp.

References request_screen(), s_tx_info, s_tx_state, and UI_SCREEN_TX_STATUS.

Referenced by app_main(), card_connect(), settle_inflight(), sign_and_broadcast(), and sign_and_broadcast_tron().

◆ ui_show_welcome()

void ui_show_welcome ( const char * sub)

Greet the operator at the start of first-run setup, or after an update.

Shown on a virgin or factory-reset terminal, before the Wi-Fi and admin-code steps, and again on the first boot of a freshly installed image. Emits UI_EVENT_WELCOME_DONE when Start is tapped.

Parameters
[in]subLine under the product name, copied internally. NULL keeps the first-run wording ("Let's configure your terminal.").

Definition at line 807 of file ui.cpp.

References request_screen(), s_welcome_sent, s_welcome_sub, and UI_SCREEN_WELCOME.

Referenced by pos_boot().

◆ ui_show_wifi_connecting()

void ui_show_wifi_connecting ( const char * ssid)

Show a "Connecting to <ssid>…" screen while main associates.

Interactive picker only; unattended boot reports through ui_set_boot_status and stays on the splash.

Definition at line 770 of file ui.cpp.

References request_screen(), set_wifi_progress(), and UI_SCREEN_WIFI_CONNECTING.

Referenced by app_main(), run_wizard(), and wifi_picker().

◆ ui_show_wifi_list()

void ui_show_wifi_list ( const net_wifi_ap_t * aps,
uint16_t n,
const char * note )

Show the scanned Wi-Fi networks for the user to pick from.

Parameters
[in]apsArray of scanned APs (copied internally).
[in]nNumber of entries in aps.
[in]noteOptional one-line reason the picker (re)opened, shown above the list; copied internally, NULL for none. Applied on every call, so a stale note cannot survive a later render.

Definition at line 747 of file ui.cpp.

References request_screen(), s_ap_count, s_aps, s_wifi_note, UI_SCREEN_WIFI_LIST, and WIFI_MAX_APS.

Referenced by app_main(), and wifi_picker().

◆ ui_stage_wifi_creds()

void ui_stage_wifi_creds ( const char * ssid,
const char * pass )

Load credentials into the same handoff buffers the picker fills.

Lets the setup page hand Wi-Fi credentials to main through the existing UI_EVENT_WIFI_TRY path, so a form submission and a screen tap reach the connect-and-verify loop identically. The caller emits the event afterwards.

Parameters
[in]ssidNetwork name.
[in]passPassphrase; the caller wipes its own copy.

Definition at line 842 of file ui.cpp.

References s_wifi_pass, and s_wifi_ssid.

Referenced by wifi_post().

◆ ui_take_pin()

size_t ui_take_pin ( char * out,
size_t n )

Copy the most recently entered PIN out and wipe the UI's copy.

Call once after UI_EVENT_PIN_ENTERED. The internal buffer is secure-wiped on read, so a second call returns 0.

Parameters
[out]outDestination buffer (NUL-terminated on return).
[in]nCapacity of out.
Returns
number of PIN digits copied (0 if none available).

Definition at line 733 of file ui.cpp.

References s_pin, and s_pin_len.

Referenced by app_main(), and run_wizard().

◆ ui_take_wifi_creds()

size_t ui_take_wifi_creds ( char * ssid,
size_t ssid_n,
char * pass,
size_t pass_n )

Fetch the selected SSID + entered password and wipe the UI's copy.

Call once after UI_EVENT_WIFI_TRY.

Parameters
[out]ssidSSID buffer (>= 33 bytes).
[in]ssid_nCapacity of ssid.
[out]passPassword buffer (>= 65 bytes).
[in]pass_nCapacity of pass.
Returns
length of the SSID (0 if none available).

Definition at line 827 of file ui.cpp.

References s_wifi_pass, and s_wifi_ssid.

Referenced by app_main(), run_wizard(), and wifi_picker().

◆ ui_task()

Variable Documentation

◆ s_addr_dest

const char* s_addr_dest = NULL

Definition at line 168 of file ui.cpp.

Referenced by build_settings(), and ui_set_addresses().

◆ s_addr_modal_dirty

volatile bool s_addr_modal_dirty = false
static

Definition at line 137 of file ui.cpp.

Referenced by ui_show_prov_confirm(), and ui_task().

◆ s_addr_usdc

const char* s_addr_usdc = NULL

Definition at line 167 of file ui.cpp.

Referenced by build_settings(), and ui_set_addresses().

◆ s_admin_confirming

bool s_admin_confirming = false

◆ s_admin_eye_lbl

lv_obj_t* s_admin_eye_lbl = NULL

Definition at line 109 of file ui.cpp.

Referenced by btn_event_cb(), and build_admin_screen().

◆ s_admin_first

char s_admin_first[ADMIN_CODE_MAX+1] = {0}

Definition at line 147 of file ui.cpp.

Referenced by admin_submit(), btn_event_cb(), and ui_show_admin_set().

◆ s_admin_for_portal

bool s_admin_for_portal = false

◆ s_admin_lock_ms

uint32_t s_admin_lock_ms = 0

Definition at line 156 of file ui.cpp.

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

◆ s_admin_lock_start

uint32_t s_admin_lock_start = 0

Definition at line 155 of file ui.cpp.

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

◆ s_admin_note

char s_admin_note[48] = {0}

◆ s_admin_note_lbl

lv_obj_t* s_admin_note_lbl = NULL

Definition at line 146 of file ui.cpp.

Referenced by admin_set_note(), build_admin_screen(), and clear_screen().

◆ s_admin_ta

lv_obj_t* s_admin_ta = NULL

Definition at line 145 of file ui.cpp.

Referenced by admin_kbd_cb(), admin_submit(), btn_event_cb(), build_admin_screen(), and clear_screen().

◆ s_amount_cents

uint64_t s_amount_cents = 0

Definition at line 77 of file ui.cpp.

Referenced by amount_kbd_cb(), amount_update_display(), btn_event_cb(), and ui_show_amount_entry().

◆ s_amount_cents_label

lv_obj_t* s_amount_cents_label = NULL

Definition at line 73 of file ui.cpp.

Referenced by amount_update_display(), and clear_screen().

◆ s_amount_label

lv_obj_t* s_amount_label = NULL

Definition at line 72 of file ui.cpp.

Referenced by amount_update_display(), and clear_screen().

◆ s_amount_row

lv_obj_t* s_amount_row = NULL

Definition at line 76 of file ui.cpp.

Referenced by amount_row_place(), and clear_screen().

◆ s_amount_units

uint64_t s_amount_units = 0ULL

Definition at line 37 of file ui.cpp.

Referenced by amount_update_display(), btn_event_cb(), and ui_show_amount_entry().

◆ s_ap_count

uint16_t s_ap_count = 0

Definition at line 102 of file ui.cpp.

◆ s_aps

Definition at line 101 of file ui.cpp.

◆ s_asset_arrow

lv_obj_t* s_asset_arrow = NULL

Definition at line 82 of file ui.cpp.

Referenced by asset_btn_set_compact(), clear_screen(), and make_asset_button().

◆ s_asset_btn

lv_obj_t* s_asset_btn = NULL

Definition at line 81 of file ui.cpp.

Referenced by amount_row_place(), clear_screen(), and make_asset_button().

◆ s_boot_detail

char s_boot_detail[64] = {0}

Definition at line 144 of file ui.cpp.

Referenced by build_boot_error(), and ui_show_boot_error().

◆ s_boot_err

Definition at line 143 of file ui.cpp.

Referenced by build_boot_error(), and ui_show_boot_error().

◆ s_boot_step

char s_boot_step[40] = {0}

Definition at line 119 of file ui.cpp.

Referenced by ui_set_boot_status(), and ui_task().

◆ s_boot_step_dirty

volatile bool s_boot_step_dirty = false
static

Definition at line 121 of file ui.cpp.

Referenced by ui_set_boot_status(), and ui_task().

◆ s_boot_step_lbl

lv_obj_t* s_boot_step_lbl = NULL

Definition at line 120 of file ui.cpp.

Referenced by clear_screen(), and ui_task().

◆ s_cal_countdown

lv_obj_t* s_cal_countdown = NULL

Definition at line 57 of file ui.cpp.

Referenced by build_touch_cal(), clear_screen(), and ui_task().

◆ s_cal_deadline

uint32_t s_cal_deadline = 0U

Definition at line 56 of file ui.cpp.

Referenced by build_touch_cal(), and ui_task().

◆ s_cal_last_x

int16_t s_cal_last_x = 0

Definition at line 53 of file ui.cpp.

Referenced by touch_cal_poll().

◆ s_cal_last_y

int16_t s_cal_last_y = 0

Definition at line 54 of file ui.cpp.

Referenced by touch_cal_poll().

◆ s_cal_pressed

bool s_cal_pressed = false

Definition at line 52 of file ui.cpp.

Referenced by btn_event_cb(), and touch_cal_poll().

◆ s_cal_prev

uint16_t s_cal_prev[4] = {0, 0, 0, 0}
static

Definition at line 55 of file ui.cpp.

Referenced by btn_event_cb(), and ui_task().

◆ s_cal_raw

int16_t s_cal_raw[2][2] = {{0, 0}, {0, 0}}

Definition at line 51 of file ui.cpp.

Referenced by cal_apply(), and touch_cal_poll().

◆ s_cal_step

uint8_t s_cal_step = 0U

Definition at line 50 of file ui.cpp.

Referenced by btn_event_cb(), build_touch_cal(), touch_cal_poll(), and ui_task().

◆ s_card_note

char s_card_note[64] = ""

Definition at line 67 of file ui.cpp.

Referenced by build_card_wait(), pin_submit(), and ui_show_card_wait().

◆ s_cb

ui_event_cb_t s_cb = NULL

Definition at line 31 of file ui.cpp.

Referenced by btn_event_cb(), and request_prov_stop().

◆ s_charge_btn

lv_obj_t* s_charge_btn = NULL

Definition at line 86 of file ui.cpp.

Referenced by charge_set_busy(), charge_set_enabled(), and clear_screen().

◆ s_charge_busy

bool s_charge_busy = false

Definition at line 94 of file ui.cpp.

Referenced by amount_update_display(), charge_set_busy(), and clear_screen().

◆ s_clock_lbl

lv_obj_t* s_clock_lbl = NULL

Definition at line 90 of file ui.cpp.

Referenced by build_page(), clear_screen(), and clock_refresh().

◆ s_close_btn

lv_obj_t* s_close_btn = NULL

Definition at line 172 of file ui.cpp.

Referenced by build_settings(), clear_screen(), and settings_bottom_bar().

◆ s_confirm_addr

char s_confirm_addr[64] = ""

Definition at line 41 of file ui.cpp.

Referenced by ui_show_confirm().

◆ s_confirm_amount

uint64_t s_confirm_amount = 0ULL

Definition at line 40 of file ui.cpp.

Referenced by ui_show_confirm().

◆ s_confirm_fee

char s_confirm_fee[40] = ""

Definition at line 42 of file ui.cpp.

Referenced by ui_show_confirm().

◆ s_fee_max_lbl

lv_obj_t* s_fee_max_lbl = NULL

Definition at line 126 of file ui.cpp.

Referenced by build_settings(), clear_screen(), and ui_task().

◆ s_fee_prio_lbl

lv_obj_t* s_fee_prio_lbl = NULL

Definition at line 127 of file ui.cpp.

Referenced by build_settings(), clear_screen(), and ui_task().

◆ s_fees_dirty

volatile bool s_fees_dirty = false
static

Definition at line 128 of file ui.cpp.

Referenced by ui_fees_changed(), and ui_task().

◆ s_ota_modal_dirty

volatile bool s_ota_modal_dirty = false
static

Definition at line 140 of file ui.cpp.

Referenced by ui_show_ota_confirm(), and ui_task().

◆ s_pin

char s_pin[16] = {0}

Definition at line 99 of file ui.cpp.

Referenced by btn_event_cb(), pin_submit(), and ui_take_pin().

◆ s_pin_eye_lbl

lv_obj_t* s_pin_eye_lbl = NULL

Definition at line 108 of file ui.cpp.

Referenced by btn_event_cb(), and clear_screen().

◆ s_pin_for_card

bool s_pin_for_card = false

Definition at line 164 of file ui.cpp.

Referenced by btn_event_cb(), pin_submit(), signal_refresh(), and ui_show_card_pin().

◆ s_pin_len

uint8_t s_pin_len = 0

Definition at line 100 of file ui.cpp.

Referenced by btn_event_cb(), pin_submit(), and ui_take_pin().

◆ s_pin_ta

lv_obj_t* s_pin_ta = NULL

Definition at line 98 of file ui.cpp.

Referenced by btn_event_cb(), clear_screen(), pin_kbd_cb(), and pin_submit().

◆ s_prov_msg

char s_prov_msg[64] = ""

Definition at line 136 of file ui.cpp.

Referenced by build_prov(), ui_set_prov_note(), and ui_show_card_pin().

◆ s_prov_step

volatile int s_prov_step = 0

Definition at line 132 of file ui.cpp.

Referenced by build_prov(), and ui_show_prov().

◆ s_prov_stop_at

uint32_t s_prov_stop_at = 0U
static

Definition at line 234 of file ui.cpp.

Referenced by request_prov_stop().

◆ s_req_screen

◆ s_reset_btn

lv_obj_t* s_reset_btn = NULL

Definition at line 171 of file ui.cpp.

Referenced by build_settings(), clear_screen(), and settings_bottom_bar().

◆ s_screen_dirty

volatile bool s_screen_dirty = true
static

Definition at line 33 of file ui.cpp.

Referenced by request_screen(), ui_init(), and ui_task().

◆ s_settings_return

ui_screen_t s_settings_return = UI_SCREEN_AMOUNT
static

Definition at line 177 of file ui.cpp.

Referenced by btn_event_cb(), and open_admin_entry().

◆ s_settings_tab

uint16_t s_settings_tab = 0U

Definition at line 180 of file ui.cpp.

Referenced by build_settings(), open_admin_entry(), and tab_change_cb().

◆ s_sheet

lv_obj_t* s_sheet = NULL

Definition at line 62 of file ui.cpp.

Referenced by build_admin_screen(), and render_requested_screen().

◆ s_sheet_pending

volatile bool s_sheet_pending = false

Definition at line 63 of file ui.cpp.

Referenced by open_admin_entry(), and render_requested_screen().

◆ s_tx_info

char s_tx_info[72] = ""

Definition at line 47 of file ui.cpp.

Referenced by pin_submit(), ui_set_tx_info(), ui_show_tx_status(), and ui_task().

◆ s_tx_info_dirty

volatile bool s_tx_info_dirty = false
static

Definition at line 49 of file ui.cpp.

Referenced by ui_set_tx_info(), and ui_task().

◆ s_tx_info_lbl

lv_obj_t* s_tx_info_lbl = NULL

Definition at line 48 of file ui.cpp.

Referenced by clear_screen(), and ui_task().

◆ s_tx_state

Definition at line 46 of file ui.cpp.

Referenced by pin_submit(), render_requested_screen(), and ui_show_tx_status().

◆ s_ui_mx

SemaphoreHandle_t s_ui_mx = NULL
static

Definition at line 222 of file ui.cpp.

Referenced by ui_init(), UiLock::UiLock(), and UiLock::~UiLock().

◆ s_view_chain

Definition at line 186 of file ui.cpp.

Referenced by admin_submit(), btn_event_cb(), build_settings(), and open_admin_entry().

◆ s_welcome_sent

bool s_welcome_sent = false
static

Definition at line 150 of file ui.cpp.

Referenced by btn_event_cb(), and ui_show_welcome().

◆ s_welcome_sub

char s_welcome_sub[96] = {0}

Definition at line 151 of file ui.cpp.

Referenced by build_welcome(), and ui_show_welcome().

◆ s_wifi_caption

char s_wifi_caption[24] = {0}

Definition at line 114 of file ui.cpp.

Referenced by build_wifi_connecting(), and set_wifi_progress().

◆ s_wifi_eye_lbl

lv_obj_t* s_wifi_eye_lbl = NULL

Definition at line 107 of file ui.cpp.

Referenced by btn_event_cb(), build_wifi_pass(), and clear_screen().

◆ s_wifi_name

char s_wifi_name[33] = {0}

Definition at line 115 of file ui.cpp.

Referenced by build_wifi_connecting(), and set_wifi_progress().

◆ s_wifi_note

char s_wifi_note[64] = {0}

Definition at line 105 of file ui.cpp.

Referenced by build_wifi_list(), and ui_show_wifi_list().

◆ s_wifi_pass

char s_wifi_pass[65] = {0}

Definition at line 104 of file ui.cpp.

Referenced by btn_event_cb(), ui_stage_wifi_creds(), ui_take_wifi_creds(), and wifi_pass_kb_cb().

◆ s_wifi_pass_ta

lv_obj_t* s_wifi_pass_ta = NULL

Definition at line 106 of file ui.cpp.

Referenced by btn_event_cb(), build_wifi_pass(), clear_screen(), and wifi_pass_kb_cb().

◆ s_wifi_ssid

char s_wifi_ssid[33] = {0}

◆ TAG

const char* TAG = "ui"

Definition at line 23 of file ui.cpp.