forked from xiaozhi/xiaozhi-esp32
feat: Add gif support (#1183)
* feat: Add gif support * fix: compiling errors * fix remove bg image
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "display.h"
|
||||
#include "board.h"
|
||||
#include "system_info.h"
|
||||
#include "lvgl_display.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <esp_heap_caps.h>
|
||||
@@ -60,7 +61,7 @@ bool Esp32Camera::Capture() {
|
||||
ESP_LOGI(TAG, "Camera captured %d frames in %d ms", frames_to_get, int((end_time - start_time) / 1000));
|
||||
|
||||
// 显示预览图片
|
||||
auto display = Board::GetInstance().GetDisplay();
|
||||
auto display = dynamic_cast<LvglDisplay*>(Board::GetInstance().GetDisplay());
|
||||
if (display != nullptr) {
|
||||
// Create a new preview image
|
||||
auto img_dsc = (lv_img_dsc_t*)heap_caps_calloc(1, sizeof(lv_img_dsc_t), MALLOC_CAP_8BIT);
|
||||
|
||||
@@ -60,8 +60,8 @@ ElectronEmojiDisplay::ElectronEmojiDisplay(esp_lcd_panel_io_handle_t panel_io,
|
||||
void ElectronEmojiDisplay::SetupGifContainer() {
|
||||
DisplayLockGuard lock(this);
|
||||
|
||||
if (emotion_label_) {
|
||||
lv_obj_del(emotion_label_);
|
||||
if (emoji_label_) {
|
||||
lv_obj_del(emoji_label_);
|
||||
}
|
||||
if (chat_message_label_) {
|
||||
lv_obj_del(chat_message_label_);
|
||||
@@ -78,11 +78,11 @@ void ElectronEmojiDisplay::SetupGifContainer() {
|
||||
lv_obj_set_flex_grow(content_, 1);
|
||||
lv_obj_center(content_);
|
||||
|
||||
emotion_label_ = lv_label_create(content_);
|
||||
lv_label_set_text(emotion_label_, "");
|
||||
lv_obj_set_width(emotion_label_, 0);
|
||||
lv_obj_set_style_border_width(emotion_label_, 0, 0);
|
||||
lv_obj_add_flag(emotion_label_, LV_OBJ_FLAG_HIDDEN);
|
||||
emoji_label_ = lv_label_create(content_);
|
||||
lv_label_set_text(emoji_label_, "");
|
||||
lv_obj_set_width(emoji_label_, 0);
|
||||
lv_obj_set_style_border_width(emoji_label_, 0, 0);
|
||||
lv_obj_add_flag(emoji_label_, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
emotion_gif_ = lv_gif_create(content_);
|
||||
int gif_size = LV_HOR_RES;
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
// 设置内容区背景色和文本颜色
|
||||
lv_obj_set_style_bg_color(content_, lv_color_black(), 0);
|
||||
lv_obj_set_style_border_width(content_, 0, 0);
|
||||
lv_obj_set_style_text_color(emotion_label_, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_color(emoji_label_, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_color(chat_message_label_, lv_color_white(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
// 设置内容区背景色和文本颜色
|
||||
lv_obj_set_style_bg_color(content_, lv_color_black(), 0);
|
||||
lv_obj_set_style_border_width(content_, 0, 0);
|
||||
lv_obj_set_style_text_color(emotion_label_, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_color(emoji_label_, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_color(chat_message_label_, lv_color_white(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
// 设置内容区背景色和文本颜色
|
||||
lv_obj_set_style_bg_color(content_, lv_color_black(), 0);
|
||||
lv_obj_set_style_border_width(content_, 0, 0);
|
||||
lv_obj_set_style_text_color(emotion_label_, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_color(emoji_label_, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_color(chat_message_label_, lv_color_white(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
{
|
||||
"name": "otto-robot",
|
||||
"sdkconfig_append": [
|
||||
"CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v1/16m.csv\""
|
||||
"CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v1/16m.csv\"",
|
||||
"CONFIG_LVGL_USE_GIF=y"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -61,8 +61,8 @@ OttoEmojiDisplay::OttoEmojiDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_p
|
||||
void OttoEmojiDisplay::SetupGifContainer() {
|
||||
DisplayLockGuard lock(this);
|
||||
|
||||
if (emotion_label_) {
|
||||
lv_obj_del(emotion_label_);
|
||||
if (emoji_label_) {
|
||||
lv_obj_del(emoji_label_);
|
||||
}
|
||||
|
||||
if (chat_message_label_) {
|
||||
@@ -80,11 +80,11 @@ void OttoEmojiDisplay::SetupGifContainer() {
|
||||
lv_obj_set_flex_grow(content_, 1);
|
||||
lv_obj_center(content_);
|
||||
|
||||
emotion_label_ = lv_label_create(content_);
|
||||
lv_label_set_text(emotion_label_, "");
|
||||
lv_obj_set_width(emotion_label_, 0);
|
||||
lv_obj_set_style_border_width(emotion_label_, 0, 0);
|
||||
lv_obj_add_flag(emotion_label_, LV_OBJ_FLAG_HIDDEN);
|
||||
emoji_label_ = lv_label_create(content_);
|
||||
lv_label_set_text(emoji_label_, "");
|
||||
lv_obj_set_width(emoji_label_, 0);
|
||||
lv_obj_set_style_border_width(emoji_label_, 0, 0);
|
||||
lv_obj_add_flag(emoji_label_, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
emotion_gif_ = lv_gif_create(content_);
|
||||
int gif_size = LV_HOR_RES;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "led/single_led.h"
|
||||
#include "power_save_timer.h"
|
||||
#include "sscma_camera.h"
|
||||
#include "lvgl_theme.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
#include "esp_check.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "sscma_camera.h"
|
||||
#include "mcp_server.h"
|
||||
#include "display.h"
|
||||
#include "lvgl_display.h"
|
||||
#include "board.h"
|
||||
#include "system_info.h"
|
||||
#include "config.h"
|
||||
@@ -243,7 +243,7 @@ bool SscmaCamera::Capture() {
|
||||
}
|
||||
|
||||
// 显示预览图片
|
||||
auto display = Board::GetInstance().GetDisplay();
|
||||
auto display = dynamic_cast<LvglDisplay*>(Board::GetInstance().GetDisplay());
|
||||
if (display != nullptr) {
|
||||
display->SetPreviewImage(&preview_image_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user