update firmware v1.2.4 (#16)

This commit is contained in:
Forairaaaaa
2026-04-20 16:27:36 +08:00
committed by GitHub
parent 605b575fcc
commit dd34f9e0ec
94 changed files with 3615 additions and 41513 deletions
@@ -177,6 +177,8 @@ void CoreS3AudioCodec::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk, gp
ESP_ERROR_CHECK(i2s_channel_init_std_mode(tx_handle_, &std_cfg));
ESP_ERROR_CHECK(i2s_channel_init_tdm_mode(rx_handle_, &tdm_cfg));
ESP_ERROR_CHECK(i2s_channel_enable(tx_handle_));
ESP_ERROR_CHECK(i2s_channel_enable(rx_handle_));
ESP_LOGI(TAG, "Duplex channels created");
}
-8
View File
@@ -92,12 +92,6 @@ void disply_lvgl_unlock()
display->LvglUnlock();
}
void display_setup_xiaozhi_ui()
{
auto display = static_cast<DISPLAY_TYPE*>(Board::GetInstance().GetDisplay());
display->SetupXiaoZhiUI();
}
/* -------------------------------------------------------------------------- */
/* Application */
/* -------------------------------------------------------------------------- */
@@ -110,8 +104,6 @@ void xiaozhi_board_init()
void start_xiaozhi_app()
{
display_setup_xiaozhi_ui();
set_xiaozhi_mode(true);
// Initialize and run the application
+2 -1
View File
@@ -37,7 +37,6 @@ void toggle_xiaozhi_chat_state();
void disply_lvgl_lock();
void disply_lvgl_unlock();
lv_disp_t* display_get_lvgl_display();
void display_setup_xiaozhi_ui();
void xiaozhi_board_init();
void start_xiaozhi_app();
@@ -49,6 +48,8 @@ int board_get_battery_level();
bool board_is_battery_charging();
void board_set_backlight_brightness(uint8_t brightness, bool permanent = false);
uint8_t board_get_backlight_brightness();
void board_set_speaker_volume(uint8_t volume, bool permanent = false);
uint8_t board_get_speaker_volume();
void app_play_sound(const std::string_view& sound);
+23 -1
View File
@@ -16,7 +16,6 @@
#include <esp_lcd_panel_ops.h>
#include <esp_lcd_ili9341.h>
#include <esp_timer.h>
// #include "esp32_camera.h"
#include "stackchan_camera.h"
#include "hal_bridge.h"
@@ -59,6 +58,7 @@ public:
WriteReg(0x90, 0xBF);
WriteReg(0x94, 33 - 5);
WriteReg(0x95, 33 - 5);
WriteReg(0x27, 0x00);
auto ret = setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_700MA);
if (!ret) {
@@ -541,6 +541,28 @@ uint8_t hal_bridge::board_get_backlight_brightness()
}
}
void hal_bridge::board_set_speaker_volume(uint8_t volume, bool permanent)
{
auto& board = Board::GetInstance();
auto audio_codec = board.GetAudioCodec();
if (audio_codec) {
if (permanent) {
audio_codec->SetOutputVolume(volume);
}
}
}
uint8_t hal_bridge::board_get_speaker_volume()
{
int volume = 70;
Settings settings("audio", false);
volume = settings.GetInt("output_volume", volume);
if (volume <= 0) {
volume = 10;
}
return volume;
}
void hal_bridge::toggle_xiaozhi_chat_state()
{
auto& app = Application::GetInstance();
+44 -7
View File
@@ -10,6 +10,7 @@
#include <esp_psram.h>
#include <vector>
#include <cstring>
#include <src/misc/cache/lv_cache.h>
#include <settings.h>
#include <lvgl.h>
#include <lvgl_theme.h>
@@ -228,8 +229,16 @@ lv_disp_t* StackChanAvatarDisplay::GetLvglDisplay()
#include <hal/board/hal_bridge.h>
void StackChanAvatarDisplay::SetupXiaoZhiUI()
void StackChanAvatarDisplay::SetupUI()
{
// Prevent duplicate calls - if already called, return early
if (setup_ui_called_) {
ESP_LOGW(TAG, "SetupUI() called multiple times, skipping duplicate call");
return;
}
Display::SetupUI(); // Mark SetupUI as called
auto& stackchan = GetStackChan();
if (stackchan.hasAvatar()) {
@@ -243,7 +252,11 @@ void StackChanAvatarDisplay::SetupXiaoZhiUI()
auto avatar = std::make_unique<DefaultAvatar>();
avatar->init(lv_screen_active());
avatar->getPanel()->onClick().connect([]() { hal_bridge::toggle_xiaozhi_chat_state(); });
avatar->getPanel()->onClick().connect([]() {
if (hal_bridge::is_xiaozhi_ready()) {
hal_bridge::toggle_xiaozhi_chat_state();
}
});
stackchan.attachAvatar(std::move(avatar));
stackchan.addModifier(std::make_unique<BreathModifier>());
@@ -283,7 +296,7 @@ void StackChanAvatarDisplay::SetEmotion(const char* emotion)
DisplayLockGuard lock(this);
ESP_LOGE(TAG, "SetEmotion: %s", emotion);
// ESP_LOGE(TAG, "SetEmotion: %s", emotion);
auto& avatar = stackchan.avatar();
@@ -335,12 +348,16 @@ void StackChanAvatarDisplay::SetEmotion(const char* emotion)
void StackChanAvatarDisplay::SetChatMessage(const char* role, const char* content)
{
if (!setup_ui_called_) {
ESP_LOGW(TAG, "SetChatMessage('%s', '%s') called before SetupUI() - message will be lost!", role, content);
}
auto& stackchan = GetStackChan();
if (!stackchan.hasAvatar()) {
return;
}
ESP_LOGE(TAG, "SetChatMessage: role=%s, content=%s", role ? role : "null", content ? content : "null");
// ESP_LOGE(TAG, "SetChatMessage: role=%s, content=%s", role ? role : "null", content ? content : "null");
DisplayLockGuard lock(this);
@@ -351,6 +368,20 @@ void StackChanAvatarDisplay::SetChatMessage(const char* role, const char* conten
}
}
void StackChanAvatarDisplay::ClearChatMessages()
{
auto& stackchan = GetStackChan();
if (!stackchan.hasAvatar()) {
return;
}
DisplayLockGuard lock(this);
stackchan.avatar().clearSpeech();
ESP_LOGI(TAG, "Chat messages cleared");
}
void StackChanAvatarDisplay::SetPreviewImage(std::unique_ptr<LvglImage> image)
{
DisplayLockGuard lock(this);
@@ -380,6 +411,10 @@ void StackChanAvatarDisplay::SetPreviewImage(std::unique_ptr<LvglImage> image)
ESP_ERROR_CHECK(esp_timer_start_once(preview_timer_, 6000 * 1000));
}
void StackChanAvatarDisplay::UpdateStatusBar(bool update_all)
{
}
void StackChanAvatarDisplay::SetTheme(Theme* theme)
{
ESP_LOGI(TAG, "SetTheme: %s", theme->name().c_str());
@@ -407,9 +442,7 @@ bool hal_bridge::is_xiaozhi_ready()
void StackChanAvatarDisplay::SetStatus(const char* status)
{
ESP_LOGE(TAG, "SetStatus: %s", status);
LvglDisplay::SetStatus(status);
// ESP_LOGE(TAG, "SetStatus: %s", status);
auto& stackchan = GetStackChan();
if (!stackchan.hasAvatar()) {
@@ -491,3 +524,7 @@ void StackChanAvatarDisplay::SetStatus(const char* status)
avatar.setSpeech("");
}
}
void StackChanAvatarDisplay::ShowNotification(const char* notification, int duration_ms)
{
}
+4 -1
View File
@@ -38,11 +38,14 @@ public:
// Override Display methods to control Robot
virtual void SetEmotion(const char* emotion) override;
virtual void SetChatMessage(const char* role, const char* content) override;
virtual void ClearChatMessages() override;
virtual void SetPreviewImage(std::unique_ptr<LvglImage> image) override;
virtual void UpdateStatusBar(bool update_all = false) override;
virtual void SetupUI() override;
virtual void SetTheme(Theme* theme) override;
virtual void SetStatus(const char* status) override;
virtual void ShowNotification(const char* notification, int duration_ms = 3000) override;
void SetupXiaoZhiUI();
void LvglLock();
void LvglUnlock();
lv_disp_t* GetLvglDisplay();