#pragma once #include "Widget.hpp" class RoomCardWidget : public Widget { public: explicit RoomCardWidget(const WidgetConfig& config); lv_obj_t* create(lv_obj_t* parent) override; void applyStyle() override; void onKnxValue(float value) override; // Temperature update void onKnxSwitch(bool value) override; // Not used directly // Sub-button specific handling void onSubButtonStatus(uint8_t index, bool value); void sendSubButtonToggle(uint8_t index); private: // Central bubble elements lv_obj_t* bubble_ = nullptr; lv_obj_t* roomIcon_ = nullptr; lv_obj_t* roomLabel_ = nullptr; lv_obj_t* tempLabel_ = nullptr; // Sub-button elements lv_obj_t* subButtonObjs_[MAX_SUBBUTTONS] = {}; lv_obj_t* subButtonIcons_[MAX_SUBBUTTONS] = {}; bool subButtonStates_[MAX_SUBBUTTONS] = {}; // Cached config values char roomName_[MAX_TEXT_LEN] = {0}; char tempFormat_[MAX_TEXT_LEN] = {0}; // Layout helpers void parseText(); void createCentralBubble(); void createSubButtons(); void updateSubButtonColor(uint8_t index); void updateTemperature(float value); // Geometry calculations void calculateSubButtonPosition(SubButtonPosition pos, int16_t& x, int16_t& y); // Event handlers static void bubbleClickCallback(lv_event_t* e); static void subButtonClickCallback(lv_event_t* e); // UTF-8 encoding helper static int encodeUtf8(uint32_t codepoint, char* buf); };