68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "Widget.hpp"
|
|
|
|
class RoomCardWidget : public Widget {
|
|
public:
|
|
explicit RoomCardWidget(const WidgetConfig& config);
|
|
~RoomCardWidget() override;
|
|
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);
|
|
|
|
// Override to also clear sub-buttons
|
|
void clearLvglObject();
|
|
|
|
private:
|
|
// Parent (screen) for sub-buttons to avoid clipping
|
|
lv_obj_t* screenParent_ = nullptr;
|
|
|
|
// Bubble style elements (cardStyle=0)
|
|
lv_obj_t* bubble_ = nullptr;
|
|
lv_obj_t* roomIcon_ = nullptr;
|
|
lv_obj_t* roomLabel_ = nullptr;
|
|
lv_obj_t* tempLabel_ = nullptr;
|
|
|
|
// Tile style elements (cardStyle=1)
|
|
lv_obj_t* subtitleLabel_ = nullptr;
|
|
lv_obj_t* humidityLabel_ = nullptr;
|
|
lv_obj_t* decorIcon_ = nullptr; // Large decorative icon bottom-left
|
|
|
|
// 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};
|
|
char subtitle_[MAX_TEXT_LEN] = {0};
|
|
char humidityFormat_[MAX_FORMAT_LEN] = {0};
|
|
|
|
// Layout helpers
|
|
void parseText();
|
|
void createBubbleLayout(); // Bubble style (round)
|
|
void createTileLayout(); // Tile style (rectangular)
|
|
void createSubButtons();
|
|
void createSubButtonsTile(); // SubButtons for tile (right side)
|
|
void updateSubButtonColor(uint8_t index);
|
|
void updateTemperature(float value);
|
|
void updateHumidity(float value);
|
|
|
|
// Geometry calculations
|
|
void calculateSubButtonPosition(SubButtonPosition pos, int16_t& x, int16_t& y);
|
|
void calculateSubButtonPositionTile(uint8_t index, 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);
|
|
};
|