Init new era, with wiki integrated.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Display Initialization Module Implementation
|
||||
*/
|
||||
|
||||
#include "display_init.h"
|
||||
#include "display/lvgl_v8_port.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
namespace DisplayInit {
|
||||
|
||||
// ============================================================================
|
||||
// PUBLIC API IMPLEMENTATION
|
||||
// ============================================================================
|
||||
|
||||
DisplayObjects init() {
|
||||
Serial.println("[DisplayInit] Starting display initialization...");
|
||||
|
||||
// Step 1-3: Create and initialize board
|
||||
Serial.println("[DisplayInit] Step 1: Creating Board object...");
|
||||
Board *board = new Board();
|
||||
|
||||
Serial.println("[DisplayInit] Step 2: Calling board->init()...");
|
||||
board->init();
|
||||
Serial.println("[DisplayInit] Step 3: Board init completed");
|
||||
|
||||
// Step 4-5: Configure framebuffers (if avoid-tearing mode is enabled)
|
||||
#if LVGL_PORT_AVOID_TEARING_MODE
|
||||
Serial.println("[DisplayInit] Step 4: Configuring LCD frame buffers...");
|
||||
auto lcd = board->getLCD();
|
||||
lcd->configFrameBufferNumber(LVGL_PORT_DISP_BUFFER_NUM);
|
||||
|
||||
#if ESP_PANEL_DRIVERS_BUS_ENABLE_RGB && CONFIG_IDF_TARGET_ESP32S3
|
||||
auto lcd_bus = lcd->getBus();
|
||||
if (lcd_bus->getBasicAttributes().type == ESP_PANEL_BUS_TYPE_RGB) {
|
||||
Serial.println("[DisplayInit] Step 5: Configuring bounce buffer...");
|
||||
static_cast<BusRGB *>(lcd_bus)->configRGB_BounceBufferSize(lcd->getFrameWidth() * 10);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Step 6: Get backlight object (before board->begin() to control it manually)
|
||||
Serial.println("[DisplayInit] Step 6: Getting backlight control...");
|
||||
auto backlight = board->getBacklight();
|
||||
|
||||
// Step 7-8: Start the board
|
||||
Serial.println("[DisplayInit] Step 7: Calling board->begin()...");
|
||||
if (!board->begin()) {
|
||||
Serial.println("[DisplayInit] ERROR: board->begin() failed!");
|
||||
Serial.println("[DisplayInit] System halted.");
|
||||
while (1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
Serial.println("[DisplayInit] Step 8: Board initialized successfully!");
|
||||
|
||||
// Step 9: Turn OFF backlight to prevent white flash
|
||||
Serial.println("[DisplayInit] Step 9: Turning off backlight to prevent white flash...");
|
||||
if (backlight != nullptr) {
|
||||
backlight->off();
|
||||
}
|
||||
|
||||
// Step 10-11: Initialize LVGL
|
||||
Serial.println("[DisplayInit] Step 10: Initializing LVGL...");
|
||||
Serial.flush();
|
||||
lvgl_port_init(board->getLCD(), board->getTouch());
|
||||
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...");
|
||||
lvgl_port_lock(-1);
|
||||
ui_init(); // Initialize the SquareLine Studio generated UI
|
||||
// Note: onSelectSSID event handler is registered in ui_Settings_Screen.c
|
||||
lvgl_port_unlock();
|
||||
Serial.println("[DisplayInit] Step 13: SquareLine UI loaded successfully!");
|
||||
|
||||
// Small delay to ensure UI is rendered
|
||||
delay(100);
|
||||
|
||||
// Step 14: NOW turn on backlight - UI is ready!
|
||||
Serial.println("[DisplayInit] Step 14: Turning on backlight...");
|
||||
if (backlight != nullptr) {
|
||||
backlight->on();
|
||||
}
|
||||
Serial.println("[DisplayInit] Backlight on - no white flash!");
|
||||
Serial.println("[DisplayInit] Display initialization complete!");
|
||||
|
||||
// Return board and backlight objects for later use
|
||||
return {board, backlight};
|
||||
}
|
||||
|
||||
} // namespace DisplayInit
|
||||
Reference in New Issue
Block a user