#include "ui.h"
#include "lvgl.h"

void ledtoggle(lv_event_t * e)
{
    static bool ledOn = false;
    ledOn = !ledOn;

    LV_LOG_USER("ledtoggle klik! ledOn=%d", ledOn);

    lv_obj_set_style_bg_opa(ui_uiLedIndicator, LV_OPA_COVER, LV_PART_MAIN);
    lv_obj_set_style_bg_color(
        ui_uiLedIndicator,
        ledOn ? lv_palette_main(LV_PALETTE_GREEN) : lv_color_hex(0x202020),
        LV_PART_MAIN
    );
    lv_obj_set_style_shadow_width(ui_uiLedIndicator, ledOn ? 16 : 0, LV_PART_MAIN);

    lv_obj_t *label = lv_obj_get_child(ui_uiButtonLED, 0);
    if (label) lv_label_set_text(label, ledOn ? "LED ON" : "LED OFF");
}
