From 7bb17f7539b3f9be95b064017af91d6e81eff73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=B9=8F?= <52451470+txp666@users.noreply.github.com> Date: Fri, 13 Jun 2025 13:46:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(ota):=20=E4=BF=AE=E5=A4=8D=20ottoRobot?= =?UTF-8?q?=E5=92=8CelectronBot=20OTA=20=E5=8D=87=E7=BA=A7=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=E9=97=AE=E9=A2=98=20bug=20(#812)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * otto v1.4.0 MCP 1.使用MCP协议控制机器人 2.gif继承lcdDisplay,避免修改lcdDisplay * otto v1.4.1 gif as components gif as components * electronBot v1.1.0 mcp 1.增加electronBot支持 2.mcp协议 3.gif 作为组件 4.display子类 * 规范代码 1.规范代码 2.修复切换主题死机bug * fix(ota): 修复 ottoRobot和electronBot OTA 升级崩溃问题 bug --- main/boards/electron-bot/config.h | 2 +- .../electron-bot/electron_emoji_display.cc | 26 +++++++++++++++++++ .../electron-bot/electron_emoji_display.h | 3 +++ main/boards/otto-robot/config.h | 2 +- main/boards/otto-robot/otto_emoji_display.cc | 26 +++++++++++++++++++ main/boards/otto-robot/otto_emoji_display.h | 3 +++ 6 files changed, 60 insertions(+), 2 deletions(-) diff --git a/main/boards/electron-bot/config.h b/main/boards/electron-bot/config.h index ba68c39f..64c49831 100644 --- a/main/boards/electron-bot/config.h +++ b/main/boards/electron-bot/config.h @@ -47,5 +47,5 @@ #define BOOT_BUTTON_GPIO GPIO_NUM_0 -#define ELECTRON_BOT_VERSION "1.1.1" +#define ELECTRON_BOT_VERSION "1.1.2" #endif // _BOARD_CONFIG_H_ diff --git a/main/boards/electron-bot/electron_emoji_display.cc b/main/boards/electron-bot/electron_emoji_display.cc index 95edb317..b43fa481 100644 --- a/main/boards/electron-bot/electron_emoji_display.cc +++ b/main/boards/electron-bot/electron_emoji_display.cc @@ -4,6 +4,9 @@ #include #include +#include + +#include "font_awesome_symbols.h" #define TAG "ElectronEmojiDisplay" @@ -141,4 +144,27 @@ void ElectronEmojiDisplay::SetChatMessage(const char* role, const char* content) lv_obj_clear_flag(chat_message_label_, LV_OBJ_FLAG_HIDDEN); ESP_LOGI(TAG, "设置聊天消息 [%s]: %s", role, content); +} + +void ElectronEmojiDisplay::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_clear_flag(chat_message_label_, LV_OBJ_FLAG_HIDDEN); + + ESP_LOGI(TAG, "设置图标: %s", icon); + } } \ No newline at end of file diff --git a/main/boards/electron-bot/electron_emoji_display.h b/main/boards/electron-bot/electron_emoji_display.h index 9d8c5e20..b88d5ed8 100644 --- a/main/boards/electron-bot/electron_emoji_display.h +++ b/main/boards/electron-bot/electron_emoji_display.h @@ -33,6 +33,9 @@ public: // 重写聊天消息设置方法 virtual void SetChatMessage(const char* role, const char* content) override; + // 重写图标设置方法 + virtual void SetIcon(const char* icon) override; + private: void SetupGifContainer(); diff --git a/main/boards/otto-robot/config.h b/main/boards/otto-robot/config.h index 6f910638..e7663b3a 100644 --- a/main/boards/otto-robot/config.h +++ b/main/boards/otto-robot/config.h @@ -47,6 +47,6 @@ #define BOOT_BUTTON_GPIO GPIO_NUM_0 -#define OTTO_ROBOT_VERSION "1.4.2" +#define OTTO_ROBOT_VERSION "1.4.3" #endif // _BOARD_CONFIG_H_ diff --git a/main/boards/otto-robot/otto_emoji_display.cc b/main/boards/otto-robot/otto_emoji_display.cc index 7f7eb8c3..06215d90 100644 --- a/main/boards/otto-robot/otto_emoji_display.cc +++ b/main/boards/otto-robot/otto_emoji_display.cc @@ -4,8 +4,11 @@ #include #include +#include #include "display/lcd_display.h" +#include "font_awesome_symbols.h" + #define TAG "OttoEmojiDisplay" // 表情映射表 - 将原版21种表情映射到现有6个GIF @@ -143,3 +146,26 @@ 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_clear_flag(chat_message_label_, LV_OBJ_FLAG_HIDDEN); + + ESP_LOGI(TAG, "设置图标: %s", icon); + } +} diff --git a/main/boards/otto-robot/otto_emoji_display.h b/main/boards/otto-robot/otto_emoji_display.h index 5b137019..d3e47bdc 100644 --- a/main/boards/otto-robot/otto_emoji_display.h +++ b/main/boards/otto-robot/otto_emoji_display.h @@ -26,6 +26,9 @@ public: // 重写聊天消息设置方法 virtual void SetChatMessage(const char* role, const char* content) override; + // 添加SetIcon方法声明 + virtual void SetIcon(const char* icon) override; + private: void SetupGifContainer();