Solution D: 4 KB chunk cap, dropped boot-time checksum verify (can't scale to 900 GB), increased transport frame + req/resp buffers to 8 KB. test_otp_sd.py: 10/10 pass (ASCII + binary round-trips, offset advance, 2 KB large plaintext, tamper detection). Phase 6: ui_pick_pad() LVGL pad-selection screen with chksum prefix + size display, Skip button, 30s timeout. otp_pad_sd_list_pads() scans /pads and returns chksums + sizes. Wired into the non-debug boot flow in signer.ino (DEBUG_AUTO_GENERATE=0 path). DEBUG_AUTO_GENERATE=1 stays headless with auto-bind_first. README: added comprehensive memory management section documenting the FlexRAM architecture, custom linker script, .rodata-to-FLASH move, build-time stack gauge, and current memory layout.
88 lines
3.7 KiB
C
88 lines
3.7 KiB
C
/* ui.h — LVGL 9 screen functions for the Teensy 4.1 n_signer firmware.
|
|
*
|
|
* Phase 4 (remaining) of plans/teensy41_signer_implementation.md.
|
|
*
|
|
* Each function builds a screen on the active LVGL display (480x320 landscape,
|
|
* ST7796S) and runs a modal event loop until the user picks an action. The
|
|
* caller is responsible for calling lv_tick_inc() / lv_timer_handler() before
|
|
* invoking these — except for the modal functions (ui_show_mnemonic,
|
|
* ui_enter_mnemonic, ui_approve) which pump LVGL themselves while waiting.
|
|
*
|
|
* Aesthetics (from ~/lt/aesthetics/WEB.md):
|
|
* - Black background (0x000000), white text (0xFFFFFF)
|
|
* - Red accent (0xFF0000) for active/pressed/selection
|
|
* - Grey (0x888888) for muted/secondary text
|
|
* - Rounded corners (6px) on buttons, 2px white borders
|
|
*
|
|
* Ported from firmware/cyd_esp32_2432s028/main/ui.c (LVGL 8.3, 320x240
|
|
* portrait) to LVGL 9.5 on 480x320 landscape. The CYD's lv_btn_create /
|
|
* LV_EVENT_RELEASED / lv_scr_act calls have been replaced with the LVGL 9
|
|
* equivalents (lv_button_create / LV_EVENT_CLICKED / lv_screen_active).
|
|
*/
|
|
#ifndef FIRMWARE_TEENSY41_SIGNER_UI_H
|
|
#define FIRMWARE_TEENSY41_SIGNER_UI_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Approval decision returned by ui_approve(). */
|
|
typedef enum {
|
|
UI_APPROVAL_DENY = 0,
|
|
UI_APPROVAL_APPROVE = 1,
|
|
UI_APPROVAL_TIMEOUT = 2,
|
|
} ui_approval_decision_t;
|
|
|
|
/* Display a freshly-generated 12-word mnemonic in a 4x3 grid so the user can
|
|
* write it down. Each word is numbered ("1. word1", "2. word2", ...). A
|
|
* "Tap to continue" footer is shown; tapping anywhere returns. Blocks
|
|
* (pumping LVGL) until the user taps. */
|
|
void ui_show_mnemonic(const char *mnemonic);
|
|
|
|
/* On-screen keyboard for entering a 12-word BIP-39 mnemonic. Builds a custom
|
|
* A-Z button grid (with backspace + done), a prefix display, a BIP-39
|
|
* suggestion row, a committed-words display, and a checksum indicator.
|
|
* Blocks (pumping LVGL) until either 12 valid words are entered and the
|
|
* checksum verifies, or the user cancels.
|
|
*
|
|
* On success: writes the NUL-terminated mnemonic (words separated by single
|
|
* spaces) to `out` and returns 0.
|
|
* On cancel: returns -1 and leaves `out` untouched. */
|
|
int ui_enter_mnemonic(char *out, size_t out_len);
|
|
|
|
/* The resting/idle screen. Shows the "n_signer" header, the npub (npub1...)
|
|
* centered, and the version string in the footer. Does not block — the caller
|
|
* keeps pumping LVGL afterwards. */
|
|
void ui_show_idle(const char *npub, const char *version);
|
|
|
|
/* Approval prompt for a signing request. Shows `verb` (e.g. "sign_event")
|
|
* and `summary` (event details) with "Approve" and "Deny" buttons. A
|
|
* 30-second countdown is shown; expiry counts as deny. Blocks (pumping
|
|
* LVGL) until the user taps a button or the timeout fires.
|
|
*
|
|
* Returns UI_APPROVAL_DENY, UI_APPROVAL_APPROVE, or UI_APPROVAL_TIMEOUT. */
|
|
ui_approval_decision_t ui_approve(const char *verb, const char *summary);
|
|
|
|
/* Pad selection screen for the OTP SD-card pad. Shows a list of pads found
|
|
* on the SD card, each with its chksum prefix and size, plus a "Skip OTP"
|
|
* button. Blocks (pumping LVGL) until the user picks a pad or skips.
|
|
*
|
|
* `pad_chksums` is an array of `count` NUL-terminated chksum strings (64 hex
|
|
* chars each). `pad_sizes` is an array of `count` sizes in bytes.
|
|
*
|
|
* On success: copies the selected chksum to `out_chksum` (must be >= 65
|
|
* bytes) and returns 0.
|
|
* On skip: returns 1 (out_chksum untouched).
|
|
* On timeout (30s): returns 2. */
|
|
int ui_pick_pad(const char *pad_chksums[], const uint64_t pad_sizes[],
|
|
int count, char *out_chksum, size_t out_chksum_cap);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* FIRMWARE_TEENSY41_SIGNER_UI_H */
|