58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#include "Gui.hpp"
|
|
#include "esp_lv_adapter.h"
|
|
#include "Gui/WifiSetting.hpp"
|
|
|
|
lv_obj_t * Gui::label2 = nullptr;
|
|
lv_obj_t * label = nullptr;
|
|
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();
|
|
}
|
|
}
|
|
|
|
static void event_handler(lv_event_t * e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
|
|
if(code == LV_EVENT_CLICKED) {
|
|
lv_label_set_text(label, "clicked");
|
|
}
|
|
else if(code == LV_EVENT_VALUE_CHANGED) {
|
|
LV_LOG_USER("Toggled");
|
|
Gui::knxWorker.toggleProgMode(); // Call toggleProgMode
|
|
}
|
|
}
|
|
|
|
void Gui::create()
|
|
{
|
|
if (esp_lv_adapter_lock(-1) == ESP_OK) {
|
|
|
|
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
|
|
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
|
|
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);
|
|
|
|
label = lv_label_create(btn1);
|
|
lv_label_set_text(label, "Button");
|
|
lv_obj_center(label);
|
|
|
|
lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
|
|
lv_obj_add_event_cb(btn2, event_handler, LV_EVENT_ALL, NULL);
|
|
lv_obj_align(btn2, LV_ALIGN_CENTER, 0, 40);
|
|
lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
|
|
lv_obj_set_height(btn2, LV_SIZE_CONTENT);
|
|
|
|
label = lv_label_create(btn2);
|
|
lv_label_set_text(label, "Toggle");
|
|
lv_obj_center(label);
|
|
|
|
// Add long press handler for WiFi settings
|
|
lv_obj_add_event_cb(lv_scr_act(), screen_long_press_handler,
|
|
LV_EVENT_LONG_PRESSED, NULL);
|
|
|
|
esp_lv_adapter_unlock();
|
|
}
|
|
}
|