23#include <XPT2046_Touchscreen.h>
37#include "logo_small.h"
61#include "freertos/FreeRTOS.h"
63#include "freertos/task.h"
65#include "freertos/semphr.h"
73#include "esp_system.h"
75#include "driver/ledc.h"
118#define LOGO_X_NUDGE (-4)
123#define COL_BG lv_color_hex(0xFFFFFF)
125#define COL_SURFACE lv_color_hex(0xF2F2F2)
127#define COL_TEXT lv_color_hex(0x000000)
129#define COL_DIM lv_color_hex(0x9A9A9A)
131#define COL_TITLE lv_color_hex(0x424242)
136#define COL_ACCENT lv_color_hex(0x22303D)
141#define COL_ACTION lv_color_hex(0x101F2E)
146#define COL_PAGE lv_color_hex(0xE2F5FF)
148#define COL_PAGE_GRAD lv_color_hex(0xA8D8F0)
151#define COL_HOME_BAR COL_DIM
153#define COL_WARN lv_color_hex(0xE39A2D)
155#define COL_SUCCESS lv_color_hex(0x1E9E50)
157#define COL_DANGER lv_color_hex(0xD63A3A)
159#define COL_BORDER lv_color_hex(0xE0E0E0)
168#define HDR_TITLE_Y 11
171#define HDR_DIVIDER_Y 42
175#define ACT_BTN_Y (-8)
196#define ASSET_BTN_H 42
199#define ASSET_BTN_X (-8)
201#define ASSET_BTN_Y 10
205#define ASSET_BTN_PAD 8
209#define TAB_W (SCR_W - (2 * TAB_PAD))
214#define LV_TICK_PERIOD_MS 2
226#define CAL_VERIFY_MS 20000U
229#define WIFI_MAX_APS 16
239#define ADMIN_CODE_MIN 6
241#define ADMIN_CODE_MIN_STORED 4
243#define ADMIN_CODE_MAX 9
269#define ACT_CHAIN_OF(chain) \
270 static_cast<BtnAction>(ACT_CHAIN_BASE + static_cast<int>(chain))
272#define SETTINGS_TAB_COUNT 4
278#define AMOUNT_SMALL_CENTS_FROM 10000ULL
281#define AMOUNT_ROW_GAP 8
284#define AMOUNT_ROW_MIN_X 4
297#define CARD_W (SCR_W - (2 * CARD_X))
306#define CARD_BTN_Y (-10)
308#define CARD_BTN_W (CARD_W - (2 * CARD_PAD))
323#define CLOCK_Y BAND_Y
327#define CHIP_X (CLOCK_X + CLOCK_W + 6)
358#define PILL_ICON_X 10
364#define OTA_CARD_W 228
366#define OTA_TEXT_W 200
374#define CODE_EYE_GAP 6
376#define CODE_FIELD_W(kbd_w) ((kbd_w) - MENU_BTN_W - CODE_EYE_GAP)
378#define CODE_FIELD_X (-(MENU_BTN_W + CODE_EYE_GAP) / 2)
385#define CODE_KBD_W (CARD_W - (2 * CARD_PAD))
389extern const char *
TAG;
392extern XPT2046_Touchscreen
touch;
398void disp_flush(lv_disp_drv_t *drv,
const lv_area_t *area, lv_color_t *px);
409void indev_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
443extern char s_pin[16];
490lv_obj_t *
make_button(lv_obj_t *parent,
const char *label, lv_color_t bg,
491 lv_color_t fg, lv_coord_t w, lv_coord_t h,
492 lv_align_t align, lv_coord_t x, lv_coord_t y,
494lv_obj_t *
make_label(lv_obj_t *parent,
const char *txt, lv_color_t color,
495 const lv_font_t *font, lv_align_t align,
496 lv_coord_t x, lv_coord_t y);
498 lv_coord_t w, lv_align_t align,
499 lv_coord_t x, lv_coord_t y,
BtnAction act);
502 lv_color_t bg, lv_coord_t sz);
508lv_obj_t *
make_pill(lv_obj_t *parent,
const char *title,
const char *sub,
509 lv_coord_t w, lv_coord_t y,
BtnAction act,
511lv_obj_t *
make_field(lv_obj_t *parent,
const char *caption,
512 const char *value, lv_color_t col =
COL_TEXT);
517lv_obj_t *
build_page(
int step,
bool band =
true);
524lv_obj_t *
open_modal(lv_coord_t w, lv_coord_t h);
526lv_obj_t *
ota_text(lv_obj_t *card, lv_obj_t *above,
const char *txt,
527 lv_color_t col,
const lv_font_t *font);
528void ota_fit_card(lv_obj_t *card, lv_obj_t *last, lv_coord_t buttons_h);
535 lv_obj_t *parent = NULL);
537lv_obj_t *
make_title(
const char *txt,
bool has_icon,
538 lv_obj_t *parent = NULL);
550lv_obj_t *
make_code_row(lv_obj_t *host, lv_obj_t *kb, uint32_t max_len,
560void pop_in(lv_obj_t *obj);
What each selectable asset IS — one row per pos_chain_t.
pos_net_t
A network, as the picker's first step offers it.
TZ-independent calendar arithmetic and date-string parsing.
static const char *const TAG
lv_font_t font_inter_14_medium
lv_font_t font_pjs_20_medium
lv_font_t font_pjs_20_semibold
lv_font_t font_pjs_28_light
lv_font_t font_pjs_28_semibold
The sale's arithmetic: keypad cents, base units, wei, fees, calldata.
Firmware slot handling: receive an image into the idle slot, verify it, and install it only once some...
Dotted version comparison, for deciding whether an update goes forwards or backwards.
static net_wifi_ap_t s_aps[PROV_MAX_APS]
static uint16_t s_ap_count
static ui_event_cb_t s_cb
The config portal: one web app for setting a terminal up and for administering it afterwards,...
pos_chain_t settings_get_chain(void)
Selected chain, or POS_CHAIN_ETH_USDC if never set.
Persistent device settings stored in NVS (backlight, Wi-Fi creds).
pos_chain_t
Which chain (and therefore which asset) the terminal charges in.
A scanned access point (subset of fields the UI needs).
Touch arithmetic: two-point calibration, and the second-contact guard.
uint32_t s_admin_lock_start
char s_admin_first[ADMIN_CODE_MAX+1]
volatile bool s_sheet_pending
lv_obj_t * s_cal_countdown
lv_obj_t * s_amount_cents_label
lv_obj_t * s_fee_prio_lbl
lv_obj_t * s_amount_label
lv_obj_t * s_wifi_eye_lbl
lv_obj_t * s_boot_step_lbl
volatile ui_screen_t s_req_screen
uint64_t s_confirm_amount
lv_obj_t * s_admin_eye_lbl
lv_obj_t * s_admin_note_lbl
lv_obj_t * s_wifi_pass_ta
Touchscreen UI API: screens, events and transaction states for the CYD (ILI9341 + XPT2046) payment fl...
ui_screen_t
Top-level screens of the payment flow.
ui_tx_state_t
States shown on the transaction-status screen.
ui_boot_err_t
Startup faults shown on UI_SCREEN_BOOT_ERROR.
void(* ui_event_cb_t)(ui_event_t event, uint64_t payload)
Callback invoked from the UI task on user interaction.
volatile bool s_swipe_admin
lv_indev_drv_t s_indev_drv
lv_disp_draw_buf_t s_draw_buf
uint32_t s_input_block_until
lv_color_t s_buf[SCR_W *40]
const char * asset_network(pos_chain_t c=settings_get_chain())
void build_admin_set(void)
void open_network_picker(void)
lv_obj_t * make_glyph_disc(lv_obj_t *parent, const char *sym, lv_color_t bg, lv_coord_t sz)
lv_obj_t * build_page(int step, bool band=true)
void build_wifi_list(void)
void build_admin_unlock(void)
void set_wifi_progress(const char *caption, const char *name)
bool touch_raw(int16_t *rx, int16_t *ry)
lv_obj_t * make_asset_badge(lv_obj_t *parent, pos_chain_t chain)
uint32_t admin_penalty_ms(uint8_t fails)
void pop_in(lv_obj_t *obj)
void settings_persist(void)
const char * asset_caption(pos_chain_t c=settings_get_chain())
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)
XPT2046_Touchscreen touch
lv_obj_t * make_code_row(lv_obj_t *host, lv_obj_t *kb, uint32_t max_len, const char *hint, BtnAction eye_act, lv_obj_t **eye_lbl)
void asset_btn_set_compact(bool compact)
lv_obj_t * make_icon_button(const char *sym, BtnAction act, lv_obj_t *parent=NULL)
void touch_cal_poll(void)
void btn_event_cb(lv_event_t *e)
void make_divider(lv_obj_t *parent, lv_coord_t y)
lv_obj_t * make_net_badge(lv_obj_t *parent, pos_net_t net)
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 request_screen(ui_screen_t s)
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)
void build_wifi_pass(void)
void build_card_wait(void)
uint64_t amount_cents_max(void)
void build_settings(void)
void backlight_set_pct(uint8_t pct)
void touch_cal_load(void)
void code_field_reveal(lv_obj_t *ta, lv_obj_t *eye_lbl)
void make_tap_mark(lv_obj_t *parent, lv_coord_t y)
void open_coin_picker(pos_net_t net)
lv_obj_t * make_card(lv_obj_t *parent)
const pos_asset_t * asset(pos_chain_t c=settings_get_chain())
void build_tx_status(void)
void build_boot_error(void)
void render_requested_screen(void)
void build_prov_confirm(void)
lv_obj_t * open_modal(lv_coord_t w, lv_coord_t h)
void indev_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
const char * asset_name(pos_chain_t c=settings_get_chain())
void charge_set_busy(void)
lv_obj_t * make_numeric_keypad(lv_event_cb_t cb, lv_obj_t *parent=NULL, lv_coord_t w=CODE_KBD_W, lv_coord_t h=210)
void paint_page(lv_obj_t *obj)
Lay the sale-flow chrome and return the white card to build into.
void build_header(const char *title)
void build_wifi_connecting(void)
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=false)
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 build_ota_confirm(void)
void ota_fit_card(lv_obj_t *card, lv_obj_t *last, lv_coord_t buttons_h)
lv_obj_t * make_title(const char *txt, bool has_icon, lv_obj_t *parent=NULL)
Screen title, centred but never underneath the top-left icon button.
lv_obj_t * make_field(lv_obj_t *parent, const char *caption, const char *value, lv_color_t col=COL_TEXT)
void build_touch_cal(void)
void theme_init(void)
Install the theme. After lv_disp_drv_register(), before any object.
void disp_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *px)
lv_obj_t * make_asset_button(lv_obj_t *parent)
void open_reset_confirm(void)
void open_portal_window(void)
void backlight_init(uint8_t pct)
Task-watchdog feed that is safe to call from any task.