mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-01-13 16:57:17 +08:00
* fix: call flush ready on io ready * eachear: update to v2 partition table but disable class Assets currently * stop gif if previewing an image * feat: build default assets instead of downloading * version updates * fix None error * delay 1s before enter wifi config mode * fix compiling with v1 partition table --------- Co-authored-by: Xiaoxia <terrence.huang@tenclass.com>
54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "display/lcd_display.h"
|
|
#include <memory>
|
|
#include <functional>
|
|
#include <esp_lcd_panel_io.h>
|
|
#include <esp_lcd_panel_ops.h>
|
|
#include "anim_player.h"
|
|
#include "assets.h"
|
|
|
|
namespace anim {
|
|
|
|
class EmojiPlayer;
|
|
|
|
using FlushIoReadyCallback = std::function<bool(esp_lcd_panel_io_handle_t, esp_lcd_panel_io_event_data_t*, void*)>;
|
|
using FlushCallback = std::function<void(anim_player_handle_t, int, int, int, int, const void*)>;
|
|
|
|
class EmojiPlayer {
|
|
public:
|
|
EmojiPlayer(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io);
|
|
~EmojiPlayer();
|
|
|
|
void StartPlayer(const std::string& asset_name, bool repeat, int fps);
|
|
void StopPlayer();
|
|
|
|
private:
|
|
static bool OnFlushIoReady(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx);
|
|
static void OnFlush(anim_player_handle_t handle, int x_start, int y_start, int x_end, int y_end, const void *color_data);
|
|
|
|
anim_player_handle_t player_handle_;
|
|
};
|
|
|
|
class EmojiWidget : public Display {
|
|
public:
|
|
EmojiWidget(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io);
|
|
virtual ~EmojiWidget();
|
|
|
|
virtual void SetEmotion(const char* emotion) override;
|
|
virtual void SetStatus(const char* status) override;
|
|
anim::EmojiPlayer* GetPlayer()
|
|
{
|
|
return player_.get();
|
|
}
|
|
|
|
private:
|
|
void InitializePlayer(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io);
|
|
virtual bool Lock(int timeout_ms = 0) override;
|
|
virtual void Unlock() override;
|
|
|
|
std::unique_ptr<anim::EmojiPlayer> player_;
|
|
};
|
|
|
|
} // namespace anim
|