Files
ESP32-S3-Touch-LCD-5B/src/modules/ui_kit.h
T
julian e68fad73b6
Firmware / build (push) Successful in 3m58s
Hand-coded Settings + tabbed Gauge Tuning; remembered Wi-Fi; on-screen updates
Settings (replaces the SquareLine screen, now deleted): sidebar with
Wi-Fi (switch, status card with failure reasons, networks nearby,
full-screen password page), Updates (installed vs latest, Check, Install
behind a confirm dialog) and System (CAN / link / perf overlay switches,
live link, CAN, memory, uptime).

Gauge Tuning: tabs Tachometer / Coolant gauge / Alerts / Simulation,
56 px -/+ rows with hints and real units, accelerating hold-to-repeat,
per-tab Reset with confirm, save indicator, SIMULATION ON chip, swipe
left to go back.

WiFiManager rewritten without LVGL code: one remembered network (NVS
"wifi"), auto-join at boot, scans only on request, no endless reconnect
(keeps the ESP-NOW channel stable), failure reasons from the disconnect
event, password never logged. Ota gains getStatus()/requestCheck()/
requestInstall() for the screen. CAN/UART switches become setEnabled().
Shared ui_kit (header, buttons, switches, confirm dialog); Montserrat
20/24 enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 07:38:17 +02:00

60 lines
2.2 KiB
C++

/*
* UI kit - shared look for the hand-coded screens (Settings, Gauge Tuning).
*
* Car-sized touch targets (>= 56 px), 20/24 px body text, no shadows or
* animated transitions (every extra redraw of this 1024x600 PSRAM framebuffer
* costs frame time). All functions need the LVGL lock, like any LVGL call.
*/
#pragma once
#include <Arduino.h>
#include <lvgl.h>
#define UI_COL_BG lv_color_hex(0x101418)
#define UI_COL_PANEL lv_color_hex(0x1B2128)
#define UI_COL_PANEL2 lv_color_hex(0x252D36) // pressed / selected rows
#define UI_COL_TEXT lv_color_hex(0xE8EDF2)
#define UI_COL_MUTED lv_color_hex(0x8894A0)
#define UI_COL_ACCENT lv_color_hex(0x3DA9FC)
#define UI_COL_OK lv_color_hex(0x3DD68C)
#define UI_COL_WARN lv_color_hex(0xE5484D)
#define UI_COL_AMBER lv_color_hex(0xF5A524)
namespace UiKit {
typedef enum { BTN_PRIMARY, BTN_SECONDARY, BTN_DANGER, BTN_SUCCESS } btn_style_t;
/** Plain full-screen background object. */
lv_obj_t* screen();
/** Title top-left and a "< Driveline" button top-right that calls back_cb. */
void header(lv_obj_t* scr, const char* title, lv_event_cb_t back_cb);
lv_obj_t* label(lv_obj_t* parent, const char* text, const lv_font_t* font, lv_color_t color);
/** Button with a centred label; the label is the button's first child. */
lv_obj_t* button(lv_obj_t* parent, const char* text, lv_coord_t w, lv_coord_t h,
btn_style_t style, lv_event_cb_t cb, void* user);
void setButtonText(lv_obj_t* btn, const char* text);
lv_obj_t* toggle(lv_obj_t* parent, lv_event_cb_t cb, void* user);
void setChecked(lv_obj_t* obj, bool on);
/** Transparent flex row/column container without padding or scrolling. */
lv_obj_t* box(lv_obj_t* parent, lv_flex_flow_t flow);
/** Rounded panel (card). */
lv_obj_t* card(lv_obj_t* parent);
/** lv_label_set_text only when the text changed - avoids needless redraws. */
void setText(lv_obj_t* lbl, const char* text);
void setTextColor(lv_obj_t* lbl, lv_color_t c);
void setVisible(lv_obj_t* obj, bool visible);
/** Modal Cancel / OK dialog; cb(true, user) on OK, cb(false, user) on Cancel. */
void confirm(const char* title, const char* text, const char* ok_text,
void (*cb)(bool ok, void* user), void* user);
} // namespace UiKit