Update to 2.0.0
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
{
|
||||
"name": "otto-robot",
|
||||
"sdkconfig_append": [
|
||||
"CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v1/16m.csv\"",
|
||||
"CONFIG_LVGL_USE_GIF=y"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "otto_emoji_display.h"
|
||||
#include "lvgl_theme.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <font_awesome.h>
|
||||
@@ -51,9 +52,8 @@ const OttoEmojiDisplay::EmotionMap OttoEmojiDisplay::emotion_maps_[] = {
|
||||
|
||||
OttoEmojiDisplay::OttoEmojiDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
|
||||
int width, int height, int offset_x, int offset_y, bool mirror_x,
|
||||
bool mirror_y, bool swap_xy, DisplayFonts fonts)
|
||||
: SpiLcdDisplay(panel_io, panel, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy,
|
||||
fonts),
|
||||
bool mirror_y, bool swap_xy)
|
||||
: SpiLcdDisplay(panel_io, panel, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy),
|
||||
emotion_gif_(nullptr) {
|
||||
SetupGifContainer();
|
||||
};
|
||||
@@ -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;
|
||||
@@ -108,7 +108,11 @@ void OttoEmojiDisplay::SetupGifContainer() {
|
||||
|
||||
lv_obj_align(chat_message_label_, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
|
||||
LcdDisplay::SetTheme("dark");
|
||||
auto& theme_manager = LvglThemeManager::GetInstance();
|
||||
auto theme = theme_manager.GetTheme("dark");
|
||||
if (theme != nullptr) {
|
||||
LcdDisplay::SetTheme(theme);
|
||||
}
|
||||
}
|
||||
|
||||
void OttoEmojiDisplay::SetEmotion(const char* emotion) {
|
||||
@@ -146,26 +150,3 @@ void OttoEmojiDisplay::SetChatMessage(const char* role, const char* content) {
|
||||
|
||||
ESP_LOGI(TAG, "设置聊天消息 [%s]: %s", role, content);
|
||||
}
|
||||
|
||||
void OttoEmojiDisplay::SetIcon(const char* icon) {
|
||||
if (!icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayLockGuard lock(this);
|
||||
|
||||
if (chat_message_label_ != nullptr) {
|
||||
std::string icon_message = std::string(icon) + " ";
|
||||
|
||||
if (strcmp(icon, FONT_AWESOME_DOWNLOAD) == 0) {
|
||||
icon_message += "正在升级...";
|
||||
} else {
|
||||
icon_message += "系统状态";
|
||||
}
|
||||
|
||||
lv_label_set_text(chat_message_label_, icon_message.c_str());
|
||||
lv_obj_remove_flag(chat_message_label_, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
ESP_LOGI(TAG, "设置图标: %s", icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
*/
|
||||
OttoEmojiDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, int width,
|
||||
int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y,
|
||||
bool swap_xy, DisplayFonts fonts);
|
||||
bool swap_xy);
|
||||
|
||||
virtual ~OttoEmojiDisplay() = default;
|
||||
|
||||
@@ -26,9 +26,6 @@ public:
|
||||
// 重写聊天消息设置方法
|
||||
virtual void SetChatMessage(const char* role, const char* content) override;
|
||||
|
||||
// 添加SetIcon方法声明
|
||||
virtual void SetIcon(const char* icon) override;
|
||||
|
||||
private:
|
||||
void SetupGifContainer();
|
||||
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
|
||||
#define TAG "OttoRobot"
|
||||
|
||||
LV_FONT_DECLARE(font_puhui_16_4);
|
||||
LV_FONT_DECLARE(font_awesome_16_4);
|
||||
|
||||
extern void InitializeOttoController();
|
||||
|
||||
class OttoRobot : public WifiBoard {
|
||||
@@ -78,12 +75,7 @@ private:
|
||||
|
||||
display_ = new OttoEmojiDisplay(
|
||||
panel_io, panel, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y,
|
||||
DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
|
||||
{
|
||||
.text_font = &font_puhui_16_4,
|
||||
.icon_font = &font_awesome_16_4,
|
||||
.emoji_font = DISPLAY_HEIGHT >= 240 ? font_emoji_64_init() : font_emoji_32_init(),
|
||||
});
|
||||
DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
|
||||
}
|
||||
|
||||
void InitializeButtons() {
|
||||
|
||||
Reference in New Issue
Block a user