mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-07-21 02:05:52 +00:00
* feat: migrate firmware to xiaozhi-fonts 2.0.0 * fix: restart scrolling subtitles on text change * docs: add AGENTS.md for project overview, architecture, rules, and commands - Introduced AGENTS.md to document the XiaoZhi voice-assistant firmware architecture, required rules for development, board configuration process, and validation steps. - Included detailed sections on project structure, commands for building and testing, and authoritative documentation references. * feat: finalize glyph push protocol * fix: remove stale emoji font include * build: use xiaozhi-fonts 2.0.0 * fix: decouple custom fonts from glyph push * refactor: improve wake word invocation handling - Introduced BeginWakeWordInvoke method to streamline the wake word processing flow. - Updated HandleWakeWordDetectedEvent to utilize the new method, ensuring proper state transitions and scheduling. - Enhanced error handling to prevent the device from getting stuck in the connecting state. - Refactored audio channel management to improve responsiveness during wake word detection. --------- Co-authored-by: Xiaoxia <terrence.huang@tenclass.com>
88 lines
2.3 KiB
C++
88 lines
2.3 KiB
C++
#ifndef DISPLAY_H
|
|
#define DISPLAY_H
|
|
|
|
#include "emoji_collection.h"
|
|
#include "text_glyph.h"
|
|
|
|
#ifndef CONFIG_USE_EMOTE_MESSAGE_STYLE
|
|
#define HAVE_LVGL 1
|
|
#include <lvgl.h>
|
|
#endif
|
|
|
|
#include <esp_log.h>
|
|
#include <esp_pm.h>
|
|
#include <esp_timer.h>
|
|
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class Theme {
|
|
public:
|
|
Theme(const std::string& name) : name_(name) {}
|
|
virtual ~Theme() = default;
|
|
|
|
inline std::string name() const { return name_; }
|
|
|
|
private:
|
|
std::string name_;
|
|
};
|
|
|
|
class Display {
|
|
public:
|
|
Display();
|
|
virtual ~Display();
|
|
|
|
virtual void SetStatus(const char* status);
|
|
virtual void ShowNotification(const char* notification, int duration_ms = 3000);
|
|
virtual void ShowNotification(const std::string& notification, int duration_ms = 3000);
|
|
virtual void SetEmotion(const char* emotion);
|
|
virtual void SetChatMessage(const char* role, const char* content);
|
|
virtual void ClearChatMessages();
|
|
virtual void SetTheme(Theme* theme);
|
|
virtual Theme* GetTheme() { return current_theme_; }
|
|
virtual void UpdateStatusBar(bool update_all = false);
|
|
virtual void SetPowerSaveMode(bool on);
|
|
virtual bool AddTextGlyphs(const std::vector<TextGlyph>& glyphs, uint8_t bpp) { return false; }
|
|
virtual void ClearTextGlyphs() {}
|
|
virtual void SetEmojiCollection(std::shared_ptr<EmojiCollection>) {}
|
|
virtual void SetupUI() { setup_ui_called_ = true; }
|
|
|
|
inline int width() const { return width_; }
|
|
inline int height() const { return height_; }
|
|
inline bool IsSetupUICalled() const { return setup_ui_called_; }
|
|
|
|
protected:
|
|
int width_ = 0;
|
|
int height_ = 0;
|
|
bool setup_ui_called_ = false; // Track if SetupUI() has been called
|
|
|
|
Theme* current_theme_ = nullptr;
|
|
|
|
friend class DisplayLockGuard;
|
|
virtual bool Lock(int timeout_ms = 0) = 0;
|
|
virtual void Unlock() = 0;
|
|
};
|
|
|
|
class DisplayLockGuard {
|
|
public:
|
|
DisplayLockGuard(Display* display) : display_(display) {
|
|
if (!display_->Lock(30000)) {
|
|
ESP_LOGE("Display", "Failed to lock display");
|
|
}
|
|
}
|
|
~DisplayLockGuard() { display_->Unlock(); }
|
|
|
|
private:
|
|
Display* display_;
|
|
};
|
|
|
|
class NoDisplay : public Display {
|
|
private:
|
|
virtual bool Lock(int timeout_ms = 0) override { return true; }
|
|
virtual void Unlock() override {}
|
|
};
|
|
|
|
#endif
|