diff --git a/CLAUDE.md b/CLAUDE.md index 27faba4..733b7c0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -99,8 +99,6 @@ include/ can_driver.h # CAN Bus driver interface protocol/ automotive_data.h # UART protocol and CAN ID mappings - ui/ - ui*.c/h # SquareLine Studio generated UI files ``` **src/main.cpp** (~1530 lines) @@ -133,9 +131,7 @@ include/ - LVGL 8.4.0 configuration file - Memory settings, theme configuration, widget enables -**include/ui/** directory (SquareLine Studio exports) - now only `ui_init()` (theme + an empty placeholder screen) and helpers -- **No SquareLine screens remain**: Home was removed 2026-09-21, Settings on 2026-09-27 (replaced by `settings_screen.cpp`). Every screen is hand-coded in `src/modules`. If SquareLine ever re-exports a screen, delete it from the SquareLine project - do not wire it back in -- **Important**: SquareLine Studio exports to `include/ui/` directory to avoid overwriting custom code in `src/` +**UI**: every screen is hand-coded in `src/modules` (see Screens). SquareLine Studio was decommissioned on 2026-09-27 (`include/ui/` deleted); the LVGL theme is set in `display_init.cpp`. Don't reintroduce a UI generator. ### NVS Persistent Storage @@ -223,7 +219,7 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage): ### Screens -All hand-coded in `src/modules`, built once and kept (never deleted - SquareLine's delete-on-leave caused dangling pointers and the 2026-09-27 freezes). Shared look in `ui_kit.cpp` (20/24 px text, >= 56 px touch targets, no shadows/animations, `UiKit::confirm()` modal dialog). Each screen has a `tick()` called from `loop()` that refreshes values under the LVGL lock, only while it is shown, and only re-sets label text that changed. +All hand-coded in `src/modules`, built once and kept (never deleted - the old generated screens were deleted on leave, which left dangling pointers and caused the 2026-09-27 freezes). Shared look in `ui_kit.cpp` (20/24 px text, >= 56 px touch targets, no shadows/animations, `UiKit::confirm()` modal dialog). Each screen has a `tick()` called from `loop()` that refreshes values under the LVGL lock, only while it is shown, and only re-sets label text that changed. - **Driveline** (boot) - swipe left: Settings, swipe right: Gauge Tuning - **Settings** (`settings_screen.cpp`) - sidebar: **Wi-Fi** (switch, status card, networks nearby, full-screen password page), **Updates** (installed vs latest, Check, Install behind a confirm dialog -> `Ota::requestCheck/requestInstall`), **System** (CAN / link to B / performance overlay switches, live ESP-NOW, CAN, memory, uptime). Swipe right or the Driveline button goes back @@ -362,7 +358,6 @@ xTaskCreatePinnedToCore( ## Important Notes -- **SquareLine Studio Export**: ALWAYS export UI files to `ui/` directory, NEVER to `src/` (prevents overwriting main.cpp) - **Adding a setting**: add a row to the right page in `settings_screen.cpp` (`makeSettingRow()` + `UiKit::toggle()`), persist it via `SettingsManager`, and sync it in that page's `refresh*()` function - **CAN Bus Integration**: BMW CAN IDs are defined in `automotive_data.h` (all 11-bit standard frames, verified live on the swap bus). The CAN driver runs in `TWAI_MODE_NORMAL` (it ACKs frames; not LISTEN_ONLY). Evidence and confidence labels live in `wiki/pages/can-id-candidates.md`. Never add a second caller of `CANDriver::transmit()` without a design discussion — transmitting on the vehicle bus is a safety decision - **Security**: the Wi-Fi password field is cleared when the password page closes; the saved password lives only in NVS and is never logged (the pre-2026-09-27 code printed it on every join) diff --git a/README.md b/README.md index 44a05bd..2327007 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,13 @@ Automotive display controller for Waveshare ESP32-S3-Touch-LCD-5B (1024x600 RGB ## Features -- ✅ **WiFi** - Network scanning with dynamic SSID list -- ✅ **UART** - Automotive data transmission @ 5Hz (GPIO 43/44) -- ✅ **Debug Mode** - FPS and CPU metrics display -- ✅ **Settings Persistence** - NVS storage for toggle states -- ✅ **Touch UI** - LVGL 8.4.0 with SquareLine Studio UI -- ✅ **FreeRTOS** - Multi-core architecture (WiFi/UART on Core 0, LVGL on Core 1) +- ✅ **CAN bus** - decodes the BMW M57N / ZF 6HP powertrain frames (gear, temperatures, rpm, ...) +- ✅ **Link to Controller B** - data + gauge config @ 5 Hz over RS485 (UART1) and ESP-NOW +- ✅ **Screens** - Driveline (boot), Settings (Wi-Fi / Updates / System), Gauge Tuning; LVGL 8.4.0, hand-coded +- ✅ **Wi-Fi** - one remembered network, joined at boot +- ✅ **OTA updates** - signed releases from Gitea, installed from the Settings screen +- ✅ **Settings persistence** - NVS +- ✅ **FreeRTOS** - Wi-Fi / UART / CAN on Core 0, LVGL on Core 1 ## Hardware @@ -64,32 +65,31 @@ pio run --target upload && pio device monitor ## Project Structure ``` -migrate-to-pio/ -├── platformio.ini # PlatformIO configuration -├── partition_table.csv # Partition table (3MB app + 1MB SPIFFS) -├── src/ # Source code (non-UI) -│ ├── main.cpp # Main application -│ ├── automotive_data.h # UART data structures -│ └── lvgl_v8_port.h/cpp # LVGL porting layer -├── ui/ # SquareLine Studio exports -│ └── ui*.h/c # UI files (auto-generated) -├── include/ -│ └── lv_conf.h # LVGL configuration -└── .pio/ # Build artifacts (gitignored) +platformio.ini # PlatformIO configuration +partition_table.csv # dual OTA slots (2 x 7.9 MB), NVS, coredump +src/ + main.cpp # setup, loop, console routing + modules/ # screens, Wi-Fi, link, OTA, tunables, ... + drivers/can_driver.cpp # CAN (TWAI) +include/ + config/ # lv_conf.h, ota_config.h, board config + display/ # LVGL port + protocol/automotive_data.h # link protocol shared with Controller B +wiki/ # project knowledge base ``` -**Important**: Configure SquareLine Studio to export UI files to the `ui/` directory. This prevents the auto-generated UI code from overwriting your custom source files in `src/`. +See `CLAUDE.md` for the architecture. ## Configuration ### Partition Scheme -Current: **Huge APP (3MB No OTA / 1MB SPIFFS)** +Dual OTA (see `partition_table.csv`): -- NVS: 20KB (settings storage) +- NVS: 20KB (settings, tunables, Wi-Fi) - never move it - OTA data: 8KB -- App: 3MB (application code) -- SPIFFS: 1MB (file system) +- app0 / app1: 7.9MB each (firmware ~1.7MB) +- Coredump: 64KB Edit `partition_table.csv` to customize partition sizes. diff --git a/include/ui/CMakeLists.txt b/include/ui/CMakeLists.txt deleted file mode 100644 index 5690e29..0000000 --- a/include/ui/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -SET(SOURCES ui_theme_manager.c - ui_themes.c - ui.c - components/ui_comp_hook.c - ui_helpers.c) - -add_library(ui ${SOURCES}) diff --git a/include/ui/components/ui_comp_hook.c b/include/ui/components/ui_comp_hook.c deleted file mode 100644 index 14c2e58..0000000 --- a/include/ui/components/ui_comp_hook.c +++ /dev/null @@ -1,5 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD - diff --git a/include/ui/filelist.txt b/include/ui/filelist.txt deleted file mode 100644 index 76453f7..0000000 --- a/include/ui/filelist.txt +++ /dev/null @@ -1,5 +0,0 @@ -ui_theme_manager.c -ui_themes.c -ui.c -components/ui_comp_hook.c -ui_helpers.c diff --git a/include/ui/project.info b/include/ui/project.info deleted file mode 100644 index b86b646..0000000 --- a/include/ui/project.info +++ /dev/null @@ -1,9 +0,0 @@ -{ - "project_name": "SquareLine_Project.spj", - "datetime": "2025-11-09T17:09:26.2274380+01:00", - "editor_version": "1.5.4", - "project_version": 60, - "user": "Goxhe Altin", - "export_datetime": "2025-11-09T17:09:28.3122290+01:00", - "export_user": "Goxhe Altin" -} diff --git a/include/ui/ui.c b/include/ui/ui.c deleted file mode 100644 index 130c058..0000000 --- a/include/ui/ui.c +++ /dev/null @@ -1,44 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD-5B - -#include "ui.h" -#include "ui_helpers.h" - -///////////////////// VARIABLES //////////////////// - -// EVENTS -lv_obj_t * ui____initial_actions0; - -// IMAGES AND IMAGE SETS - -///////////////////// TEST LVGL SETTINGS //////////////////// -#if LV_COLOR_DEPTH != 16 - #error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings" -#endif -#if LV_COLOR_16_SWAP !=0 - #error "LV_COLOR_16_SWAP should be 0 to match SquareLine Studio's settings" -#endif - -///////////////////// ANIMATIONS //////////////////// - -///////////////////// FUNCTIONS //////////////////// - -///////////////////// SCREENS //////////////////// - -void ui_init(void) -{ - lv_disp_t * dispp = lv_disp_get_default(); - lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), - true, LV_FONT_DEFAULT); - lv_disp_set_theme(dispp, theme); - // Home (2026-09-21) and Settings (2026-09-27) screens removed: every screen - // is hand-coded in src/modules; display_init.cpp shows the Driveline screen. - ui____initial_actions0 = lv_obj_create(NULL); - lv_disp_load_scr(ui____initial_actions0); -} - -void ui_destroy(void) -{ -} diff --git a/include/ui/ui.h b/include/ui/ui.h deleted file mode 100644 index 57ffbfe..0000000 --- a/include/ui/ui.h +++ /dev/null @@ -1,49 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD-5B - -#ifndef _ESP32_S3_TOUCH_LCD_5B_UI_H -#define _ESP32_S3_TOUCH_LCD_5B_UI_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined __has_include -#if __has_include("lvgl.h") -#include "lvgl.h" -#elif __has_include("lvgl/lvgl.h") -#include "lvgl/lvgl.h" -#else -#include "lvgl.h" -#endif -#else -#include "lvgl.h" -#endif - -#include "ui_helpers.h" -#include "ui_events.h" -#include "ui_theme_manager.h" -#include "ui_themes.h" - -///////////////////// SCREENS //////////////////// -// None: every screen is hand-coded in src/modules (Driveline, Settings, Gauge -// Tuning). The SquareLine Settings screen was removed on 2026-09-27. - -///////////////////// VARIABLES //////////////////// - -// EVENTS -extern lv_obj_t * ui____initial_actions0; - -// IMAGES AND IMAGE SETS - -// UI INIT -void ui_init(void); -void ui_destroy(void); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif diff --git a/include/ui/ui_events.h b/include/ui/ui_events.h deleted file mode 100644 index 38801e5..0000000 --- a/include/ui/ui_events.h +++ /dev/null @@ -1,18 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD-5B - -#ifndef _UI_EVENTS_H -#define _UI_EVENTS_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif diff --git a/include/ui/ui_helpers.c b/include/ui/ui_helpers.c deleted file mode 100644 index 0f66770..0000000 --- a/include/ui/ui_helpers.c +++ /dev/null @@ -1,262 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD-5B - -#include "ui_helpers.h" - -void _ui_bar_set_property(lv_obj_t * target, int id, int val) -{ - if(id == _UI_BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON); - if(id == _UI_BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF); -} - -void _ui_basic_set_property(lv_obj_t * target, int id, int val) -{ - if(id == _UI_BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val); - if(id == _UI_BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val); - if(id == _UI_BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val); - if(id == _UI_BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val); -} - -void _ui_dropdown_set_property(lv_obj_t * target, int id, int val) -{ - if(id == _UI_DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val); -} - -void _ui_image_set_property(lv_obj_t * target, int id, uint8_t * val) -{ - if(id == _UI_IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val); -} - -void _ui_label_set_property(lv_obj_t * target, int id, const char * val) -{ - if(id == _UI_LABEL_PROPERTY_TEXT) lv_label_set_text(target, val); -} - -void _ui_roller_set_property(lv_obj_t * target, int id, int val) -{ - if(id == _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON); - if(id == _UI_ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF); -} - -void _ui_slider_set_property(lv_obj_t * target, int id, int val) -{ - if(id == _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON); - if(id == _UI_SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF); -} - -void _ui_screen_change(lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)) -{ - if(*target == NULL) - target_init(); - lv_scr_load_anim(*target, fademode, spd, delay, false); -} - -void _ui_arc_increment(lv_obj_t * target, int val) -{ - int old = lv_arc_get_value(target); - lv_arc_set_value(target, old + val); - lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0); -} - -void _ui_bar_increment(lv_obj_t * target, int val, int anm) -{ - int old = lv_bar_get_value(target); - lv_bar_set_value(target, old + val, anm); -} - -void _ui_slider_increment(lv_obj_t * target, int val, int anm) -{ - int old = lv_slider_get_value(target); - lv_slider_set_value(target, old + val, anm); - lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0); -} - -void _ui_keyboard_set_target(lv_obj_t * keyboard, lv_obj_t * textarea) -{ - lv_keyboard_set_textarea(keyboard, textarea); -} - -void _ui_flag_modify(lv_obj_t * target, int32_t flag, int value) -{ - if(value == _UI_MODIFY_FLAG_TOGGLE) { - if(lv_obj_has_flag(target, flag)) lv_obj_clear_flag(target, flag); - else lv_obj_add_flag(target, flag); - } - else if(value == _UI_MODIFY_FLAG_ADD) lv_obj_add_flag(target, flag); - else lv_obj_clear_flag(target, flag); -} -void _ui_state_modify(lv_obj_t * target, int32_t state, int value) -{ - if(value == _UI_MODIFY_STATE_TOGGLE) { - if(lv_obj_has_state(target, state)) lv_obj_clear_state(target, state); - else lv_obj_add_state(target, state); - } - else if(value == _UI_MODIFY_STATE_ADD) lv_obj_add_state(target, state); - else lv_obj_clear_state(target, state); -} - -void _ui_textarea_move_cursor(lv_obj_t * target, int val) -{ - if(val == UI_MOVE_CURSOR_UP) lv_textarea_cursor_up(target); - if(val == UI_MOVE_CURSOR_RIGHT) lv_textarea_cursor_right(target); - if(val == UI_MOVE_CURSOR_DOWN) lv_textarea_cursor_down(target); - if(val == UI_MOVE_CURSOR_LEFT) lv_textarea_cursor_left(target); - lv_obj_add_state(target, LV_STATE_FOCUSED); -} - -typedef void (*screen_destroy_cb_t)(void); -void scr_unloaded_delete_cb(lv_event_t * e) -{ - // Get the destroy callback from user_data - screen_destroy_cb_t destroy_cb = lv_event_get_user_data(e); - if(destroy_cb) { - destroy_cb(); // call the specific screen destroy function - } -} - -void _ui_opacity_set(lv_obj_t * target, int val) -{ - lv_obj_set_style_opa(target, val, 0); -} - -void _ui_anim_callback_free_user_data(lv_anim_t * a) -{ - lv_mem_free(a->user_data); - a->user_data = NULL; -} - -void _ui_anim_callback_set_x(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_x(usr->target, v); -} - -void _ui_anim_callback_set_y(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_y(usr->target, v); -} - -void _ui_anim_callback_set_width(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_width(usr->target, v); -} - -void _ui_anim_callback_set_height(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_height(usr->target, v); -} - -void _ui_anim_callback_set_opacity(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_obj_set_style_opa(usr->target, v, 0); -} - -void _ui_anim_callback_set_image_zoom(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_img_set_zoom(usr->target, v); -} - -void _ui_anim_callback_set_image_angle(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - lv_img_set_angle(usr->target, v); -} - -void _ui_anim_callback_set_image_frame(lv_anim_t * a, int32_t v) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - usr->val = v; - if(v < 0) v = 0; - if(v >= usr->imgset_size) v = usr->imgset_size - 1; - lv_img_set_src(usr->target, usr->imgset[v]); -} - -int32_t _ui_anim_callback_get_x(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_x_aligned(usr->target); -} - -int32_t _ui_anim_callback_get_y(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_y_aligned(usr->target); -} - -int32_t _ui_anim_callback_get_width(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_width(usr->target); -} - -int32_t _ui_anim_callback_get_height(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_height(usr->target); -} - -int32_t _ui_anim_callback_get_opacity(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_obj_get_style_opa(usr->target, 0); -} - -int32_t _ui_anim_callback_get_image_zoom(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_img_get_zoom(usr->target); -} - -int32_t _ui_anim_callback_get_image_angle(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return lv_img_get_angle(usr->target); -} - -int32_t _ui_anim_callback_get_image_frame(lv_anim_t * a) -{ - ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data; - return usr->val; -} - -void _ui_arc_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix) -{ - char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; - lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_arc_get_value(src), postfix); - lv_label_set_text(trg, buf); -} - -void _ui_slider_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix) -{ - char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; - lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_slider_get_value(src), postfix); - lv_label_set_text(trg, buf); -} -void _ui_checked_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * txt_on, const char * txt_off) -{ - if(lv_obj_has_state(src, LV_STATE_CHECKED)) lv_label_set_text(trg, txt_on); - else lv_label_set_text(trg, txt_off); -} - -void _ui_spinbox_step(lv_obj_t * target, int val) -{ - if(val > 0) lv_spinbox_increment(target); - else lv_spinbox_decrement(target); - - lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0); -} - -void _ui_switch_theme(int val) -{ -#ifdef UI_THEME_ACTIVE - ui_theme_set(val); -#endif -} - diff --git a/include/ui/ui_helpers.h b/include/ui/ui_helpers.h deleted file mode 100644 index 2b02acd..0000000 --- a/include/ui/ui_helpers.h +++ /dev/null @@ -1,131 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD-5B - -#ifndef _ESP32_S3_TOUCH_LCD_5B_UI_HELPERS_H -#define _ESP32_S3_TOUCH_LCD_5B_UI_HELPERS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "ui.h" - -#define _UI_TEMPORARY_STRING_BUFFER_SIZE 32 -#define _UI_BAR_PROPERTY_VALUE 0 -#define _UI_BAR_PROPERTY_VALUE_WITH_ANIM 1 -void _ui_bar_set_property(lv_obj_t * target, int id, int val); - -#define _UI_BASIC_PROPERTY_POSITION_X 0 -#define _UI_BASIC_PROPERTY_POSITION_Y 1 -#define _UI_BASIC_PROPERTY_WIDTH 2 -#define _UI_BASIC_PROPERTY_HEIGHT 3 -void _ui_basic_set_property(lv_obj_t * target, int id, int val); - -#define _UI_DROPDOWN_PROPERTY_SELECTED 0 -void _ui_dropdown_set_property(lv_obj_t * target, int id, int val); - -#define _UI_IMAGE_PROPERTY_IMAGE 0 -void _ui_image_set_property(lv_obj_t * target, int id, uint8_t * val); - -#define _UI_LABEL_PROPERTY_TEXT 0 -void _ui_label_set_property(lv_obj_t * target, int id, const char * val); - -#define _UI_ROLLER_PROPERTY_SELECTED 0 -#define _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM 1 -void _ui_roller_set_property(lv_obj_t * target, int id, int val); - -#define _UI_SLIDER_PROPERTY_VALUE 0 -#define _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM 1 -void _ui_slider_set_property(lv_obj_t * target, int id, int val); - -void _ui_screen_change(lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)); - -void _ui_arc_increment(lv_obj_t * target, int val); - -void _ui_bar_increment(lv_obj_t * target, int val, int anm); - -void _ui_slider_increment(lv_obj_t * target, int val, int anm); - -void _ui_keyboard_set_target(lv_obj_t * keyboard, lv_obj_t * textarea); - -#define _UI_MODIFY_FLAG_ADD 0 -#define _UI_MODIFY_FLAG_REMOVE 1 -#define _UI_MODIFY_FLAG_TOGGLE 2 -void _ui_flag_modify(lv_obj_t * target, int32_t flag, int value); - -#define _UI_MODIFY_STATE_ADD 0 -#define _UI_MODIFY_STATE_REMOVE 1 -#define _UI_MODIFY_STATE_TOGGLE 2 -void _ui_state_modify(lv_obj_t * target, int32_t state, int value); - -#define UI_MOVE_CURSOR_UP 0 -#define UI_MOVE_CURSOR_RIGHT 1 -#define UI_MOVE_CURSOR_DOWN 2 -#define UI_MOVE_CURSOR_LEFT 3 -void _ui_textarea_move_cursor(lv_obj_t * target, int val) -; - -void scr_unloaded_delete_cb(lv_event_t * e); - -void _ui_opacity_set(lv_obj_t * target, int val); - -/** Describes an animation*/ -typedef struct _ui_anim_user_data_t { - lv_obj_t * target; - lv_img_dsc_t ** imgset; - int32_t imgset_size; - int32_t val; -} ui_anim_user_data_t; -void _ui_anim_callback_free_user_data(lv_anim_t * a); - -void _ui_anim_callback_set_x(lv_anim_t * a, int32_t v); - -void _ui_anim_callback_set_y(lv_anim_t * a, int32_t v); - -void _ui_anim_callback_set_width(lv_anim_t * a, int32_t v); - -void _ui_anim_callback_set_height(lv_anim_t * a, int32_t v); - -void _ui_anim_callback_set_opacity(lv_anim_t * a, int32_t v); - -void _ui_anim_callback_set_image_zoom(lv_anim_t * a, int32_t v); - -void _ui_anim_callback_set_image_angle(lv_anim_t * a, int32_t v); - -void _ui_anim_callback_set_image_frame(lv_anim_t * a, int32_t v); - -int32_t _ui_anim_callback_get_x(lv_anim_t * a); - -int32_t _ui_anim_callback_get_y(lv_anim_t * a); - -int32_t _ui_anim_callback_get_width(lv_anim_t * a); - -int32_t _ui_anim_callback_get_height(lv_anim_t * a); - -int32_t _ui_anim_callback_get_opacity(lv_anim_t * a); - -int32_t _ui_anim_callback_get_image_zoom(lv_anim_t * a); - -int32_t _ui_anim_callback_get_image_angle(lv_anim_t * a); - -int32_t _ui_anim_callback_get_image_frame(lv_anim_t * a); - -void _ui_arc_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix); - -void _ui_slider_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix); - -void _ui_checked_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * txt_on, const char * txt_off); - -void _ui_spinbox_step(lv_obj_t * target, int val) -; - -void _ui_switch_theme(int val) -; - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif diff --git a/include/ui/ui_theme_manager.c b/include/ui/ui_theme_manager.c deleted file mode 100644 index 72c086e..0000000 --- a/include/ui/ui_theme_manager.c +++ /dev/null @@ -1,209 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.4.3+ -// LVGL version: 8.3.11 -// Project name: design - -#include "ui.h" - -_ui_local_style_t* _ui_local_styles; -uint32_t _ui_local_style_count = 0; - - -inline void ui_object_set_local_style_property -(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, ui_style_variable_t value ) { - if ( object_p!=NULL /*&& lv_obj_is_valid(object_p)*/ ) { - lv_obj_set_local_style_prop( object_p, property, _ui_style_value_convert( property, value ), selector ); - } -} - -//Atomic function to set (and register) an LVGL local style-property for a given part+state (selector) of an object (widget) - can be used in many ways due to being atomic -void ui_object_set_themeable_style_property -(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, const ui_theme_variable_t* theme_variable_p) { - static _ui_local_style_t* local_style_p; - static _ui_local_style_property_setting_t* property_setting_p; - - if (object_p==NULL /*|| !lv_obj_is_valid(object_p)*/ || theme_variable_p==NULL) return; - local_style_p = _ui_local_style_create( theme_variable_p, true ); - if (local_style_p == NULL) return; - property_setting_p = _ui_local_style_property_setting_create( local_style_p, object_p, selector, property ); - if (property_setting_p == NULL) return; - - lv_obj_set_local_style_prop( object_p, property, _ui_style_value_convert( property, ui_get_theme_value(theme_variable_p) ), selector ); //ui_object_set_local_style_property( object_p, selector, property, ui_get_theme_value(theme_variable_p) ); -} - - -//This function goes through all registered style-property settings and if theme is changed, sets all of them to the theme. (If called periodically, it can follow change of values automatically.) -void _ui_theme_set_variable_styles (uint8_t mode) { - static uint8_t ui_theme_idx_previous = -1; - static uint32_t i, j; - static _ui_local_style_property_setting_t* property_setting_p; - static ui_style_variable_t style_value; - static ui_style_variable_t* style_variable_p; - - uint8_t ui_Theme_Changed = (ui_theme_idx != ui_theme_idx_previous); ui_theme_idx_previous = ui_theme_idx; - - for (i = 0; i < _ui_local_style_count; ++i) { - - style_variable_p = _ui_local_styles[i].style_variable_p; - if (_ui_local_styles[i].is_themeable) style_value = ui_get_theme_value( style_variable_p ); - else style_value = *style_variable_p; - - if (style_variable_p != _ui_local_styles[i].previous_pointer || style_value != _ui_local_styles[i].previous_value - || mode == UI_VARIABLE_STYLES_MODE_INIT || ui_Theme_Changed) { - _ui_local_styles[i].previous_pointer = style_variable_p; _ui_local_styles[i].previous_value = style_value; - - property_setting_p = _ui_local_styles[i].style_property_settings; //first item of linked list - for (j = 0; j < _ui_local_styles[i].style_property_setting_count; ++j) { - if (property_setting_p->object_p != NULL) { - ui_object_set_local_style_property ( - property_setting_p->object_p, property_setting_p->selector, property_setting_p->property, style_value - ); - } - if (property_setting_p->next_p != NULL) property_setting_p = (_ui_local_style_property_setting_t*) property_setting_p->next_p; //get next item in linked-list for next round - else break; //this shouldn't happen, but if it does, it's assumed end of the list - } - } - } -} - - -ui_style_variable_t ui_get_theme_value(const ui_theme_variable_t* var) { - return var[ui_theme_idx]; -} - - -lv_style_value_t _ui_style_value_convert (lv_style_prop_t property, ui_style_variable_t value) { - static lv_style_value_t Style_Value; //LVGL would produce artefacts if both .num and .color were set for the local style to add: - //static lv_style_const_prop_t ValueConvert_Table [_LV_STYLE_NUM_BUILT_IN_PROPS] = { [LV_STYLE_BG_COLOR] = LV_STYLE_CONST_BG_COLOR(1), [LV_STYLE_BG_OPA] = LV_STYLE_CONST_BG_OPA(1) }; - if (property==LV_STYLE_BG_COLOR || property==LV_STYLE_BG_GRAD_COLOR || property==LV_STYLE_BG_IMG_RECOLOR || property==LV_STYLE_BORDER_COLOR - || property==LV_STYLE_OUTLINE_COLOR || property==LV_STYLE_SHADOW_COLOR || property==LV_STYLE_IMG_RECOLOR || property==LV_STYLE_LINE_COLOR - || property==LV_STYLE_ARC_COLOR || property==LV_STYLE_TEXT_COLOR) { - Style_Value.color = lv_color_hex(value); - } - else if (property==LV_STYLE_BG_GRAD || property==LV_STYLE_BG_IMG_SRC || property==LV_STYLE_ARC_IMG_SRC || property==LV_STYLE_TEXT_FONT - || property==LV_STYLE_COLOR_FILTER_DSC || property==LV_STYLE_ANIM || property==LV_STYLE_TRANSITION) { - Style_Value.ptr = (void*)(uintptr_t) value; - } - else Style_Value.num = value; - return Style_Value; -} - - -//auto-update dynamic local style array with existing/new style-variable (1st dimension) -_ui_local_style_t* _ui_local_style_create (const ui_style_variable_t* style_variable_p, bool is_themeable) { - static uint32_t i; - static _ui_local_style_t* local_style_p; - - for (i = 0; i < _ui_local_style_count; ++i) { //Find existing local style - if (_ui_local_styles[i].style_variable_p == style_variable_p) return &_ui_local_styles[i]; - } - //If not found, create new local style - _ui_local_styles = (_ui_local_style_t*) lv_mem_realloc( _ui_local_styles, (_ui_local_style_count + 1) * sizeof(_ui_local_style_t) ); - LV_ASSERT_MALLOC( _ui_local_styles ); - if (_ui_local_styles == NULL) return NULL; - //Reset new local style - local_style_p = &_ui_local_styles[ _ui_local_style_count ]; - local_style_p->style_variable_p = (ui_style_variable_t*) style_variable_p; - local_style_p->is_themeable = is_themeable; - local_style_p->previous_pointer = NULL; - local_style_p->previous_value = -1; - local_style_p->style_property_setting_count = 0; - local_style_p->style_property_settings = NULL; - /*#ifdef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD - local_style_p->garbage_collector_couter = 0; - #endif*/ - - ++_ui_local_style_count; - return local_style_p; -} - - -void _ui_local_style_property_setting_delete (lv_event_t* event) { * (lv_obj_t**) lv_event_get_user_data( event ) = NULL; } - -//auto-update dynamic local style-array's 2nd dimension (object part+state style-property settings for a given style-variable) -_ui_local_style_property_setting_t* _ui_local_style_property_setting_create -(_ui_local_style_t* local_style_p, lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property) { - static uint32_t i; //auto-update - static _ui_local_style_property_setting_t *style_property_setting_p, *empty_style_property_setting_p; - - /*#ifdef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD - style_property_setting_p = local_style_p->style_property_settings; //first item of linked list - if (style_property_setting_p != NULL) { //checking might be unnecessary if count is properly initialized to 0 - if (local_style_p->garbage_collector_couter > 0) --local_style_p->garbage_collector_couter; //avoid calling garbage collector every time - else if (LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD > 0) { - local_style_p->garbage_collector_couter = LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD - 1; - for (i = 0; i < local_style_p->style_property_setting_count; ++i) { - if (style_property_setting_p->object_p != NULL) { //check only valid object entry (skip already emptied positions{ - #if ( defined(LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE) && LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE ) //Not recommended inside explicit garbage collector. - if ( style_property_setting_p->validcheck_counter > 0 ) --style_property_setting_p->validcheck_counter; //avoids calling complex lv_obj_is_valid() many times - else { //check objects with expired positive vaidity check - if ( lv_obj_is_valid( style_property_setting_p->object_p ) ) style_property_setting_p->validcheck_counter = LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE; - else style_property_setting_p->object_p = NULL; //free up an entry of a deleted widget - } - #else //this is the recommended variant inside explicit garbage collector: - if ( !lv_obj_is_valid( style_property_setting_p->object_p ) ) style_property_setting_p->object_p = NULL; //free up an entry of a deleted widget - #endif - } - if (style_property_setting_p->next_p != NULL) style_property_setting_p = (_ui_local_style_property_setting_t*) style_property_setting_p->next_p; //get next item in linked-list for next round - else break; //this shouldn't happen - } - } - } - #endif*/ - style_property_setting_p = local_style_p->style_property_settings; //first item of linked list - empty_style_property_setting_p = NULL; - if (style_property_setting_p != NULL) { //checking might be unnecessary if count is properly initialized to 0 - for (i = 0; i < local_style_p->style_property_setting_count; ++i) { - if (empty_style_property_setting_p == NULL) { //search and register one empty position that might be needed for a newly created entry - if (style_property_setting_p->object_p == NULL) empty_style_property_setting_p = style_property_setting_p; //if found empty position, register it - /*#ifdef LV_SQUARELINE_THEME__IMPLICIT_GARBAGE_COLLECTOR - else { //if not, check for possible empty positions of deleted objects (garbage-collection) - #if ( defined(LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE) && LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE ) //for slow hardware, adding this and setting to 5..10 in lv_conf.h might make it faster - if ( style_property_setting_p->validcheck_counter > 0 ) --style_property_setting_p->validcheck_counter; //avoids calling complex lv_obj_is_valid() many times - else { //check objects with expired positive vaidity check - if ( lv_obj_is_valid( style_property_setting_p->object_p ) ) style_property_setting_p->validcheck_counter = LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE; - else { //free up an entry of a deleted widget - style_property_setting_p->object_p = NULL; - empty_style_property_setting_p = style_property_setting_p; - } - } - #else - if ( !lv_obj_is_valid( style_property_setting_p->object_p ) ) { //free up an entry of a deleted widget - style_property_setting_p->object_p = NULL; - empty_style_property_setting_p = style_property_setting_p; - } - #endif - } - #endif*/ - } - if (style_property_setting_p->object_p == object_p && style_property_setting_p->selector == selector - && style_property_setting_p->property == property) { //setting found in the list (created already), so returning it - return style_property_setting_p; - } - if (style_property_setting_p->next_p != NULL) style_property_setting_p = (_ui_local_style_property_setting_t*) style_property_setting_p->next_p; //get next item in linked-list for next round - else break; //this shouldn't happen, but if it does, create a new element - } - } - //If not found, create new local style-property (can be inside the array at freed-up places of deleted objects too) - if (empty_style_property_setting_p == NULL) { //allocate new - empty_style_property_setting_p = (_ui_local_style_property_setting_t*) lv_mem_alloc( sizeof(_ui_local_style_property_setting_t) ); - LV_ASSERT_MALLOC( empty_style_property_setting_p ); - if (empty_style_property_setting_p == NULL) return NULL; - if (style_property_setting_p != NULL) style_property_setting_p->next_p = (void*) empty_style_property_setting_p; //create link from last item to the new - else local_style_p->style_property_settings = empty_style_property_setting_p; //(except if creating first item) - style_property_setting_p = empty_style_property_setting_p; //take the new item pointer for initialization - style_property_setting_p->next_p = NULL; //signify the end of the linked list, just in case - ++local_style_p->style_property_setting_count; - } - else { //reuse empty - style_property_setting_p = empty_style_property_setting_p; - } - style_property_setting_p->object_p = object_p; lv_obj_add_event_cb( object_p, _ui_local_style_property_setting_delete, LV_EVENT_DELETE, &style_property_setting_p->object_p ); - style_property_setting_p->selector = selector; - style_property_setting_p->property = property; - /*#ifdef LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE - style_property_setting_p->validcheck_counter = LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE; //0 - #endif*/ - return style_property_setting_p; -} - diff --git a/include/ui/ui_theme_manager.h b/include/ui/ui_theme_manager.h deleted file mode 100644 index 7840da4..0000000 --- a/include/ui/ui_theme_manager.h +++ /dev/null @@ -1,75 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.4.3+ - -#ifndef _UI_THEME_MANAGER_H -#define _UI_THEME_MANAGER_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define UI_THEME_ACTIVE 1 - -/*#ifndef LV_SQUARELINE_THEME__IMPLICIT_GARBAGE_COLLECTOR - #ifndef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD //for slow hardware, tells how frequently the style-properties inside this style should be garbage-collected (recommended value: 10..100, 0:never) - #define LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD 100 //a sensible default value that already gives good results on slow hardware, can be overridden from outside - #endif -#endif*/ - - -enum { UI_VARIABLE_STYLES_MODE_INIT = 1, UI_VARIABLE_STYLES_MODE_FOLLOW = 0 }; - - -typedef int64_t ui_style_variable_t; -typedef ui_style_variable_t ui_theme_variable_t; //A 'theme' variable array is an array of 'style' variables for corresponding themes. - -typedef struct { - lv_obj_t * object_p; - lv_style_selector_t selector; - lv_style_prop_t property; - /*#ifdef LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE //for slow hardware, adding this and setting to 5..10 in lv_conf.h might make it faster (less lv_obj_is_valid calls) - uint16_t validcheck_counter; //used for garbage collection (finding empty slots) not to call lv_obj_is_valid() every time - #endif*/ - void * next_p; -} _ui_local_style_property_setting_t; - -typedef struct { - bool is_themeable; //scalar or vector? - ui_style_variable_t * style_variable_p; - ui_style_variable_t * previous_pointer; - ui_style_variable_t previous_value; - uint32_t style_property_setting_count; - _ui_local_style_property_setting_t * style_property_settings; - /*#ifdef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD - uint16_t garbage_collector_couter; - #endif*/ -} _ui_local_style_t; - - -extern _ui_local_style_t * _ui_local_styles; -extern uint32_t _ui_local_style_count; - - -void ui_object_set_local_style_property -(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, ui_style_variable_t value ); - -void ui_object_set_themeable_style_property -(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, const ui_theme_variable_t* theme_variable_p); - -void _ui_theme_set_variable_styles (uint8_t mode); - -lv_style_value_t _ui_style_value_convert (lv_style_prop_t property, ui_style_variable_t value); -ui_style_variable_t ui_get_theme_value (const ui_theme_variable_t *var); - -_ui_local_style_t * _ui_local_style_create (const ui_style_variable_t * style_variable_p, bool is_themeable); - -_ui_local_style_property_setting_t * _ui_local_style_property_setting_create -(_ui_local_style_t * local_style, lv_obj_t * object_p, lv_style_selector_t selector, lv_style_prop_t property); - - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif - diff --git a/include/ui/ui_themes.c b/include/ui/ui_themes.c deleted file mode 100644 index 6f9177f..0000000 --- a/include/ui/ui_themes.c +++ /dev/null @@ -1,17 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD-5B - -#include "ui.h" - -const ui_theme_variable_t _ui_theme_color_panel_backgroung[1] = {0x7F7A9C}; -const ui_theme_variable_t _ui_theme_alpha_panel_backgroung[1] = {255}; -uint8_t ui_theme_idx = UI_THEME_DEFAULT; - -void ui_theme_set(uint8_t theme_idx) -{ - ui_theme_idx = theme_idx; - _ui_theme_set_variable_styles(UI_VARIABLE_STYLES_MODE_FOLLOW); -} - diff --git a/include/ui/ui_themes.h b/include/ui/ui_themes.h deleted file mode 100644 index ec90408..0000000 --- a/include/ui/ui_themes.h +++ /dev/null @@ -1,30 +0,0 @@ -// This file was generated by SquareLine Studio -// SquareLine Studio version: SquareLine Studio 1.5.4 -// LVGL version: 8.3.6 -// Project name: ESP32-S3-Touch-LCD-5B - -#ifndef _UI_THEMES_H -#define _UI_THEMES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define UI_THEME_COLOR_PANEL_BACKGROUNG 0 - -#define UI_THEME_DEFAULT 0 - -extern const ui_theme_variable_t _ui_theme_color_panel_backgroung[1]; -extern const ui_theme_variable_t _ui_theme_alpha_panel_backgroung[1]; - -extern const uint32_t * ui_theme_colors[1]; -extern const uint8_t * ui_theme_alphas[1]; -extern uint8_t ui_theme_idx; - -void ui_theme_set(uint8_t theme_idx); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif diff --git a/platformio.ini b/platformio.ini index 78f10f1..10a649c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -49,8 +49,8 @@ lib_deps = ; ---------------------------------------------------------------------------- ; Build Flags & Source Directories ; ---------------------------------------------------------------------------- -; Include UI, display, and modules directories as source directories -build_src_filter = +<*> + +<../include/ui/*> +<../include/display/*> +; Also compile the LVGL port that lives under include/display +build_src_filter = +<*> + +<../include/display/*> build_flags = ; C++ standard (required for ESP32_Display_Panel) @@ -91,7 +91,6 @@ build_flags = -I include/config -I include/display -I include/protocol - -I include/ui -I src ; ---------------------------------------------------------------------------- diff --git a/src/modules/display_init.cpp b/src/modules/display_init.cpp index 114dfde..171ffa8 100644 --- a/src/modules/display_init.cpp +++ b/src/modules/display_init.cpp @@ -4,7 +4,6 @@ #include "display_init.h" #include "display/lvgl_v8_port.h" -#include "ui/ui.h" #include "driveline_screen.h" #include "config/ota_config.h" // FW_VERSION @@ -90,17 +89,20 @@ DisplayObjects init() { Serial.println("[DisplayInit] Step 11: LVGL initialized successfully!"); Serial.flush(); - // Step 12-13: Load SquareLine Studio UI - Serial.println("[DisplayInit] Step 12: Loading SquareLine Studio UI..."); + // Step 12-13: Theme + boot screen + Serial.println("[DisplayInit] Step 12: Loading UI..."); lvgl_port_lock(-1); - ui_init(); // Initialize the SquareLine Studio generated UI - // Boot screen: the hand-coded Driveline screen. ui_init() only loads an - // empty placeholder now (the SquareLine Home screen was removed 2026-09-21); - // swap while the backlight is still off so there's no flash. + // Dark default theme, blue primary. The hand-coded screens override most + // styles, but the keyboard, dialogs, text areas, switches and sliders take + // their base look from it. + lv_disp_t* disp = lv_disp_get_default(); + lv_disp_set_theme(disp, lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE), + lv_palette_main(LV_PALETTE_RED), true, LV_FONT_DEFAULT)); + // Boot screen, loaded while the backlight is still off so there's no flash. DrivelineScreen::show(); createVersionLabel(); lvgl_port_unlock(); - Serial.println("[DisplayInit] Step 13: SquareLine UI loaded successfully!"); + Serial.println("[DisplayInit] Step 13: UI loaded"); // Small delay to ensure UI is rendered delay(100); diff --git a/src/modules/display_init.h b/src/modules/display_init.h index c5741bd..0aab1c1 100644 --- a/src/modules/display_init.h +++ b/src/modules/display_init.h @@ -4,7 +4,7 @@ * Handles hardware-specific initialization for the Waveshare ESP32-S3-Touch-LCD-5B: * - Board initialization (LCD panel, touch controller) * - LVGL initialization and configuration - * - SquareLine Studio UI loading + * - LVGL theme and the boot (Driveline) screen * - Backlight control to prevent white flash during startup */ @@ -35,7 +35,7 @@ struct DisplayObjects { * 3. Initialize backlight (off initially to prevent white flash) * 4. Start the board * 5. Initialize LVGL porting layer - * 6. Load SquareLine Studio UI + * 6. Set the LVGL theme and show the Driveline screen * 7. Turn on backlight after UI is ready * * @return DisplayObjects containing board and backlight pointers diff --git a/src/modules/driveline_screen.h b/src/modules/driveline_screen.h index 5fc228b..6c7e21a 100644 --- a/src/modules/driveline_screen.h +++ b/src/modules/driveline_screen.h @@ -5,16 +5,8 @@ * the swap's bus: gear (hero), coolant, gearbox oil temp, engine RPM, turbine * speed and output shaft, plus ignition / engine / clutch / mismatch status. * - * WHY THIS IS NOT A SQUARELINE SCREEN - * SquareLine Studio owns include/ui/ and overwrites it on every export. Editing - * generated files loses the edit — that is exactly how the CAN toggle's event - * handler went missing. This screen lives entirely in src/, which SquareLine - * never touches, so it cannot be clobbered. Since 2026-09-21 it IS the boot - * screen: the SquareLine Home screen was removed, and the generated Settings - * screen's back gesture calls app_show_driveline() (defined at the bottom of - * driveline_screen.cpp) to return here. - * - * Navigation: swipe LEFT -> Settings (SquareLine), swipe RIGHT -> Gauge Tuning. + * The boot screen. Navigation: swipe LEFT -> Settings, swipe RIGHT -> Gauge + * Tuning (both hand-coded, like this one). * * Signals deliberately NOT shown: engine oil temp (no sensor on this M57N — * 0x1D0 byte 1 is permanently 0xFF) and battery voltage (0x3B4 publishes the diff --git a/src/modules/settings_screen.h b/src/modules/settings_screen.h index e6d5384..1dd32ac 100644 --- a/src/modules/settings_screen.h +++ b/src/modules/settings_screen.h @@ -1,8 +1,7 @@ /* * Settings Screen Module * - * Hand-coded (replaces the SquareLine Settings screen, 2026-09-27). Sidebar - * with three sections: + * Sidebar with three sections: * Wi-Fi - switch, connection status, networks nearby, full-screen password * entry; the joined network is remembered (WiFiManager) * Updates - installed vs latest release, Check, Install behind a confirm diff --git a/src/modules/ui_state_manager.h b/src/modules/ui_state_manager.h index 8c64325..236a4f0 100644 --- a/src/modules/ui_state_manager.h +++ b/src/modules/ui_state_manager.h @@ -2,8 +2,6 @@ * UI State Manager Module * * Holds the debug flag (sent to Controller B, shows LVGL's performance overlay). - * The screen-sync logic for the SquareLine Settings screen went with that - * screen (2026-09-27): the hand-coded Settings screen reads live state itself. */ #pragma once