knxdisplay/main/Gui.cpp
2026-01-23 17:21:54 +01:00

39 lines
1.0 KiB
C++

#include "Gui.hpp"
#include "esp_lv_adapter.h"
#include "Gui/WifiSetting.hpp"
#include "Gui/EthSetting.hpp"
#include "WidgetManager.hpp"
KnxWorker Gui::knxWorker; // Define the static member
static void screen_long_press_handler(lv_event_t * e)
{
if (lv_event_get_code(e) == LV_EVENT_LONG_PRESSED) {
//WifiSetting::instance().show();
EthSetting::instance().show();
}
}
void Gui::create()
{
// Initialize WidgetManager (loads config from SD card)
WidgetManager::instance().init();
if (esp_lv_adapter_lock(-1) == ESP_OK) {
// Add long press handler for settings
lv_obj_add_event_cb(lv_scr_act(), screen_long_press_handler,
LV_EVENT_LONG_PRESSED, NULL);
esp_lv_adapter_unlock();
}
// Apply loaded configuration (creates widgets)
WidgetManager::instance().applyConfig();
}
void Gui::updateTemperature(float temp)
{
// Delegate to WidgetManager for KNX group address 1
WidgetManager::instance().onKnxValue(1, temp);
}