33 lines
865 B
C++
33 lines
865 B
C++
#pragma once
|
|
|
|
#include "Widget.hpp"
|
|
#include <ctime>
|
|
|
|
class ClockWidget : public Widget {
|
|
public:
|
|
explicit ClockWidget(const WidgetConfig& config);
|
|
|
|
lv_obj_t* create(lv_obj_t* parent) override;
|
|
void applyStyle() override;
|
|
void onKnxTime(const struct tm& value, TextSource source) override;
|
|
|
|
private:
|
|
void drawFace();
|
|
void updateHands(const struct tm& time);
|
|
|
|
lv_obj_t* hourHand_ = nullptr;
|
|
lv_obj_t* minuteHand_ = nullptr;
|
|
lv_obj_t* secondHand_ = nullptr;
|
|
lv_obj_t* centerDot_ = nullptr;
|
|
|
|
// Persistent point arrays for lines (LVGL does not copy them)
|
|
lv_point_precise_t hourPoints_[2];
|
|
lv_point_precise_t minutePoints_[2];
|
|
lv_point_precise_t secondPoints_[2];
|
|
|
|
// Cache current time to avoid redrawing if not changed
|
|
int lastHour_ = -1;
|
|
int lastMinute_ = -1;
|
|
int lastSecond_ = -1;
|
|
};
|