forked from xiaozhi/xiaozhi-esp32
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#ifndef DISPLAY_H
|
|
#define DISPLAY_H
|
|
|
|
#include <lvgl.h>
|
|
#include <esp_timer.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
class Display {
|
|
public:
|
|
Display();
|
|
virtual ~Display();
|
|
|
|
virtual void SetStatus(const std::string &status);
|
|
virtual void ShowNotification(const std::string ¬ification, int duration_ms = 3000);
|
|
virtual void SetEmotion(const std::string &emotion);
|
|
virtual void SetChatMessage(const std::string &role, const std::string &content);
|
|
virtual void SetIcon(const char* icon);
|
|
|
|
int width() const { return width_; }
|
|
int height() const { return height_; }
|
|
|
|
protected:
|
|
int width_ = 0;
|
|
int height_ = 0;
|
|
int offset_x_ = 0;
|
|
int offset_y_ = 0;
|
|
|
|
lv_disp_t *disp_ = nullptr;
|
|
|
|
lv_obj_t *emotion_label_ = nullptr;
|
|
lv_obj_t *network_label_ = nullptr;
|
|
lv_obj_t *status_label_ = nullptr;
|
|
lv_obj_t *notification_label_ = nullptr;
|
|
lv_obj_t *mute_label_ = nullptr;
|
|
lv_obj_t *battery_label_ = nullptr;
|
|
const char* battery_icon_ = nullptr;
|
|
const char* network_icon_ = nullptr;
|
|
bool muted_ = false;
|
|
|
|
esp_timer_handle_t notification_timer_ = nullptr;
|
|
esp_timer_handle_t update_timer_ = nullptr;
|
|
|
|
friend class DisplayLockGuard;
|
|
virtual void Lock() = 0;
|
|
virtual void Unlock() = 0;
|
|
|
|
virtual void Update();
|
|
};
|
|
|
|
|
|
class DisplayLockGuard {
|
|
public:
|
|
DisplayLockGuard(Display *display) : display_(display) {
|
|
display_->Lock();
|
|
}
|
|
~DisplayLockGuard() {
|
|
display_->Unlock();
|
|
}
|
|
|
|
private:
|
|
Display *display_;
|
|
};
|
|
|
|
#endif
|