diff --git a/CMakeLists.txt b/CMakeLists.txt index b0622170..7343f639 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) -set(PROJECT_VER "1.0.0") +set(PROJECT_VER "1.0.1") # Add this line to disable the specific warning add_compile_options(-Wno-missing-field-initializers) diff --git a/main/boards/atoms3r-echo-base/atoms3r_echo_base.cc b/main/boards/atoms3r-echo-base/atoms3r_echo_base.cc index 8b3eb8b0..c84cbe77 100644 --- a/main/boards/atoms3r-echo-base/atoms3r_echo_base.cc +++ b/main/boards/atoms3r-echo-base/atoms3r_echo_base.cc @@ -197,7 +197,11 @@ private: display_ = new LcdDisplay(io_handle, panel_handle, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_16_4, &font_awesome_16_4); + { + .text_font = &font_puhui_16_4, + .icon_font = &font_awesome_16_4, + .emoji_font = emoji_font_init(), + }); } void InitializeButtons() { diff --git a/main/boards/esp-box-3/esp_box3_board.cc b/main/boards/esp-box-3/esp_box3_board.cc index ddec7501..20751557 100644 --- a/main/boards/esp-box-3/esp_box3_board.cc +++ b/main/boards/esp-box-3/esp_box3_board.cc @@ -123,7 +123,11 @@ private: esp_lcd_panel_disp_on_off(panel, true); display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_20_4, &font_awesome_20_4); + { + .text_font = &font_puhui_20_4, + .icon_font = &font_awesome_20_4, + .emoji_font = emoji_font_64_lite_init(), + }); } // 物联网初始化,添加对 AI 可见设备 diff --git a/main/boards/esp-sparkbot/esp_sparkbot_board.cc b/main/boards/esp-sparkbot/esp_sparkbot_board.cc index 29e119bf..ee4a68a7 100644 --- a/main/boards/esp-sparkbot/esp_sparkbot_board.cc +++ b/main/boards/esp-sparkbot/esp_sparkbot_board.cc @@ -15,8 +15,8 @@ #define TAG "esp_sparkbot" -LV_FONT_DECLARE(font_puhui_16_4); -LV_FONT_DECLARE(font_awesome_16_4); +LV_FONT_DECLARE(font_puhui_20_4); +LV_FONT_DECLARE(font_awesome_20_4); class SparkBotEs8311AudioCodec : public Es8311AudioCodec { private: @@ -115,7 +115,11 @@ private: esp_lcd_panel_disp_on_off(panel, true); display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_16_4, &font_awesome_16_4); + { + .text_font = &font_puhui_20_4, + .icon_font = &font_awesome_20_4, + .emoji_font = emoji_font_64_lite_init(), + }); } // 物联网初始化,添加对 AI 可见设备 diff --git a/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc b/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc index 5b2ba13f..7e086ebe 100644 --- a/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc +++ b/main/boards/esp32-s3-touch-amoled-1.8/esp32-s3-touch-amoled-1.8.cc @@ -49,7 +49,11 @@ public: bool swap_xy) : LcdDisplay(io_handle, panel_handle, backlight_pin, backlight_output_invert, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy, - &font_puhui_30_4, &font_awesome_30_4) { + { + .text_font = &font_puhui_30_4, + .icon_font = &font_awesome_30_4, + .emoji_font = emoji_font_64_lite_init(), + }) { DisplayLockGuard lock(this); // 由于屏幕是带圆角的,所以状态栏需要增加左右内边距 diff --git a/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc b/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc index 2999a279..bd5ffd8a 100644 --- a/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc +++ b/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc @@ -99,7 +99,11 @@ private: display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_20_4, &font_awesome_20_4); + { + .text_font = &font_puhui_20_4, + .icon_font = &font_awesome_20_4, + .emoji_font = emoji_font_64_lite_init(), + }); } // 物联网初始化,添加对 AI 可见设备 diff --git a/main/boards/lichuang-c3-dev/lichuang_c3_dev_board.cc b/main/boards/lichuang-c3-dev/lichuang_c3_dev_board.cc index 924ca641..f3e81928 100644 --- a/main/boards/lichuang-c3-dev/lichuang_c3_dev_board.cc +++ b/main/boards/lichuang-c3-dev/lichuang_c3_dev_board.cc @@ -99,7 +99,11 @@ private: esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y); display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_16_4, &font_awesome_16_4); + { + .text_font = &font_puhui_16_4, + .icon_font = &font_awesome_16_4, + .emoji_font = emoji_font_64_lite_init(), + }); } // 物联网初始化,添加对 AI 可见设备 diff --git a/main/boards/lichuang-dev/lichuang_dev_board.cc b/main/boards/lichuang-dev/lichuang_dev_board.cc index 293f387d..6dde42e0 100644 --- a/main/boards/lichuang-dev/lichuang_dev_board.cc +++ b/main/boards/lichuang-dev/lichuang_dev_board.cc @@ -120,7 +120,11 @@ private: esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y); display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_20_4, &font_awesome_20_4); + { + .text_font = &font_puhui_20_4, + .icon_font = &font_awesome_20_4, + .emoji_font = emoji_font_64_lite_init(), + }); } // 物联网初始化,添加对 AI 可见设备 diff --git a/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc b/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc index b45b7610..356ecec6 100644 --- a/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc +++ b/main/boards/lilygo-t-circle-s3/lilygo-t-circle-s3.cc @@ -172,7 +172,11 @@ private: display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_16_4, &font_awesome_16_4); + { + .text_font = &font_puhui_16_4, + .icon_font = &font_awesome_16_4, + .emoji_font = emoji_font_init(), + }); gpio_config_t config; config.pin_bit_mask = BIT64(DISPLAY_BL); diff --git a/main/boards/m5stack-core-s3/m5stack_core_s3.cc b/main/boards/m5stack-core-s3/m5stack_core_s3.cc index 89a7837b..b1e28709 100644 --- a/main/boards/m5stack-core-s3/m5stack_core_s3.cc +++ b/main/boards/m5stack-core-s3/m5stack_core_s3.cc @@ -181,7 +181,11 @@ private: // On press if (!was_touched) { was_touched = true; - Application::GetInstance().ToggleChatState(); + auto& app = Application::GetInstance(); + if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) { + board.ResetWifiConfiguration(); + } + app.ToggleChatState(); } } // On release @@ -244,7 +248,11 @@ private: display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_20_4, &font_awesome_20_4); + { + .text_font = &font_puhui_20_4, + .icon_font = &font_awesome_20_4, + .emoji_font = emoji_font_64_lite_init(), + }); } void InitializeButtons() { diff --git a/main/boards/magiclick-2p4/magiclick_2p4_board.cc b/main/boards/magiclick-2p4/magiclick_2p4_board.cc index 31c55c75..5acd51af 100644 --- a/main/boards/magiclick-2p4/magiclick_2p4_board.cc +++ b/main/boards/magiclick-2p4/magiclick_2p4_board.cc @@ -26,7 +26,11 @@ public: int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy) : LcdDisplay(panel_io, panel, backlight_pin, backlight_output_invert, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy, - &font_puhui_16_4, &font_awesome_16_4) { + { + .text_font = &font_puhui_16_4, + .icon_font = &font_awesome_16_4, + .emoji_font = emoji_font_init(), + }) { DisplayLockGuard lock(this); // 只需要覆盖颜色相关的样式 diff --git a/main/boards/magiclick-c3/magiclick_c3_board.cc b/main/boards/magiclick-c3/magiclick_c3_board.cc index 43a4efea..0f632d34 100644 --- a/main/boards/magiclick-c3/magiclick_c3_board.cc +++ b/main/boards/magiclick-c3/magiclick_c3_board.cc @@ -27,7 +27,11 @@ public: int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy) : LcdDisplay(panel_io, panel, backlight_pin, backlight_output_invert, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy, - &font_puhui_16_4, &font_awesome_16_4) { + { + .text_font = &font_puhui_16_4, + .icon_font = &font_awesome_16_4, + .emoji_font = emoji_font_init(), + }) { DisplayLockGuard lock(this); // 只需要覆盖颜色相关的样式 diff --git a/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc b/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc index 6b578e88..47936d5f 100644 --- a/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc +++ b/main/boards/movecall-moji-esp32s3/movecall_moji_esp32s3.cc @@ -22,8 +22,8 @@ #define TAG "MovecallMojiESP32S3" -LV_FONT_DECLARE(font_puhui_16_4); -LV_FONT_DECLARE(font_awesome_16_4); +LV_FONT_DECLARE(font_puhui_20_4); +LV_FONT_DECLARE(font_awesome_20_4); static const gc9a01_lcd_init_cmd_t gc9107_lcd_init_cmds[] = { // {cmd, { data }, data_size, delay_ms} @@ -79,6 +79,34 @@ static const gc9a01_lcd_init_cmd_t gc9107_lcd_init_cmds[] = { {0x21, (uint8_t[]){0x00}, 0, 20}, }; +class CustomLcdDisplay : public LcdDisplay { +public: + CustomLcdDisplay(esp_lcd_panel_io_handle_t io_handle, + esp_lcd_panel_handle_t panel_handle, + gpio_num_t backlight_pin, + bool backlight_output_invert, + int width, + int height, + int offset_x, + int offset_y, + bool mirror_x, + bool mirror_y, + bool swap_xy) + : LcdDisplay(io_handle, panel_handle, backlight_pin, backlight_output_invert, + width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy, + { + .text_font = &font_puhui_20_4, + .icon_font = &font_awesome_20_4, + .emoji_font = emoji_font_64_lite_init(), + }) { + + DisplayLockGuard lock(this); + // 由于屏幕是圆的,所以状态栏需要增加左右内边距 + lv_obj_set_style_pad_left(status_bar_, LV_HOR_RES * 0.33, 0); + lv_obj_set_style_pad_right(status_bar_, LV_HOR_RES * 0.33, 0); + } +}; + class MovecallMojiESP32S3 : public WifiBoard { private: i2c_master_bus_handle_t codec_i2c_bus_; @@ -150,7 +178,11 @@ private: display_ = new LcdDisplay(io_handle, panel_handle, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY, - &font_puhui_16_4, &font_awesome_16_4); + { + .text_font = &font_puhui_20_4, + .icon_font = &font_awesome_20_4, + .emoji_font = emoji_font_64_lite_init(), + }); } void InitializeButtons() { diff --git a/main/display/display.h b/main/display/display.h index 7158aa49..815cbd88 100644 --- a/main/display/display.h +++ b/main/display/display.h @@ -6,6 +6,11 @@ #include +struct DisplayFonts { + const lv_font_t* text_font = nullptr; + const lv_font_t* icon_font = nullptr; + const lv_font_t* emoji_font = nullptr; +}; class Display { public: diff --git a/main/display/lcd_display.cc b/main/display/lcd_display.cc index 9a3e872b..5da58227 100644 --- a/main/display/lcd_display.cc +++ b/main/display/lcd_display.cc @@ -5,7 +5,6 @@ #include #include #include -#include #include "board.h" #define TAG "LcdDisplay" @@ -90,17 +89,15 @@ void LcdDisplay::LvglTask() { LcdDisplay::LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, gpio_num_t backlight_pin, bool backlight_output_invert, int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy, - const lv_font_t* text_font, const lv_font_t* icon_font) + DisplayFonts fonts) : panel_io_(panel_io), panel_(panel), backlight_pin_(backlight_pin), backlight_output_invert_(backlight_output_invert), mirror_x_(mirror_x), mirror_y_(mirror_y), swap_xy_(swap_xy), - text_font_(text_font), icon_font_(icon_font) { + fonts_(fonts) { width_ = width; height_ = height; offset_x_ = offset_x; offset_y_ = offset_y; - - emoji_font_init(); InitializeBacklight(backlight_pin); // draw white @@ -253,7 +250,7 @@ void LcdDisplay::SetupUI() { DisplayLockGuard lock(this); auto screen = lv_disp_get_scr_act(lv_disp_get_default()); - lv_obj_set_style_text_font(screen, text_font_, 0); + lv_obj_set_style_text_font(screen, fonts_.text_font, 0); lv_obj_set_style_text_color(screen, lv_color_black(), 0); /* Container */ @@ -266,7 +263,7 @@ void LcdDisplay::SetupUI() { /* Status bar */ status_bar_ = lv_obj_create(container_); - lv_obj_set_size(status_bar_, LV_HOR_RES, text_font_->line_height); + lv_obj_set_size(status_bar_, LV_HOR_RES, fonts_.text_font->line_height); lv_obj_set_style_radius(status_bar_, 0, 0); /* Content */ @@ -282,7 +279,6 @@ void LcdDisplay::SetupUI() { emotion_label_ = lv_label_create(content_); lv_obj_set_style_text_font(emotion_label_, &font_awesome_30_4, 0); lv_label_set_text(emotion_label_, FONT_AWESOME_AI_CHIP); - // lv_obj_center(emotion_label_); chat_message_label_ = lv_label_create(content_); lv_label_set_text(chat_message_label_, ""); @@ -300,7 +296,7 @@ void LcdDisplay::SetupUI() { network_label_ = lv_label_create(status_bar_); lv_label_set_text(network_label_, ""); - lv_obj_set_style_text_font(network_label_, icon_font_, 0); + lv_obj_set_style_text_font(network_label_, fonts_.icon_font, 0); notification_label_ = lv_label_create(status_bar_); lv_obj_set_flex_grow(notification_label_, 1); @@ -316,17 +312,19 @@ void LcdDisplay::SetupUI() { mute_label_ = lv_label_create(status_bar_); lv_label_set_text(mute_label_, ""); - lv_obj_set_style_text_font(mute_label_, icon_font_, 0); + lv_obj_set_style_text_font(mute_label_, fonts_.icon_font, 0); battery_label_ = lv_label_create(status_bar_); lv_label_set_text(battery_label_, ""); - lv_obj_set_style_text_font(battery_label_, icon_font_, 0); + lv_obj_set_style_text_font(battery_label_, fonts_.icon_font, 0); } void LcdDisplay::SetChatMessage(const std::string &role, const std::string &content) { if (chat_message_label_ == nullptr) { return; } + + DisplayLockGuard lock(this); lv_label_set_text(chat_message_label_, content.c_str()); } @@ -371,7 +369,7 @@ void LcdDisplay::SetEmotion(const std::string &emotion) { [&emotion](const Emotion& e) { return e.text == emotion; }); // 如果找到匹配的表情就显示对应图标,否则显示默认的neutral表情 - lv_obj_set_style_text_font(emotion_label_, emoji_font, 0); + lv_obj_set_style_text_font(emotion_label_, fonts_.emoji_font, 0); if (it != emotions.end()) { lv_label_set_text(emotion_label_, it->icon); } else { diff --git a/main/display/lcd_display.h b/main/display/lcd_display.h index 1422bd64..76faf70d 100644 --- a/main/display/lcd_display.h +++ b/main/display/lcd_display.h @@ -9,6 +9,7 @@ #include #include #include +#include class LcdDisplay : public Display { protected: @@ -29,8 +30,8 @@ protected: lv_obj_t* container_ = nullptr; lv_obj_t* side_bar_ = nullptr; lv_obj_t* chat_message_label_ = nullptr; - const lv_font_t* text_font_ = nullptr; - const lv_font_t* icon_font_ = nullptr; + + DisplayFonts fonts_; void InitializeBacklight(gpio_num_t backlight_pin); void SetBacklight(uint8_t brightness); @@ -44,7 +45,7 @@ public: LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, gpio_num_t backlight_pin, bool backlight_output_invert, int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy, - const lv_font_t* text_font, const lv_font_t* icon_font); + DisplayFonts fonts); ~LcdDisplay(); void SetChatMessage(const std::string &role, const std::string &content) override; diff --git a/main/idf_component.yml b/main/idf_component.yml index 5881a32a..ce6cd6d8 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -10,13 +10,13 @@ dependencies: 78/esp-opus-encoder: "~2.1.0" 78/esp-ml307: "~1.7.1" 78/xiaozhi-fonts: "~1.2.0" + 78/emoji_font: "~1.1.0" espressif/led_strip: "^2.4.1" espressif/esp_codec_dev: "~1.3.2" espressif/esp-sr: "^1.9.0" espressif/button: "^3.3.1" lvgl/lvgl: "~8.4.0" esp_lvgl_port: "~2.4.1" - zhoukes/emoji_font: "~1.0.0" ## Required IDF version idf: version: ">=5.3"