Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/build_t5ai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build T5AI Firmware with Xiaozhi UI

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git wget build-essential cmake ninja-build
pip install -r TuyaOpen/requirements.txt

- name: Setup T5AI Platform
run: |
cd TuyaOpen
python tos.py build -v || true

- name: Build Firmware
run: |
cd TuyaOpen
export TUYA_PROJECT_DIR=$PWD/..
export TUYA_APP_NAME=DuckyClaw
export TUYA_APP_PATH=$PWD/../
platform/T5AI/t5_os/build.sh DuckyClaw 1.0.0 bk7258 $PWD/../ build

- name: Upload Firmware
uses: actions/upload-artifact@v4
with:
name: DuckyClaw_Xiaozhi_Firmware
path: |
output/*.bin
TuyaOpen/platform/T5AI/t5_os/build/bk7258/tuya_app/package/*.bin
retention-days: 30
119 changes: 119 additions & 0 deletions .github/workflows/build_t5ai_xiaozhi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build T5AI Firmware with Xiaozhi UI

on:
push:
branches: [ master, main ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo apt-get clean
df -h

- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Cache TuyaOpen
uses: actions/cache@v4
with:
path: TuyaOpen
key: tuyaopen-${{ hashFiles('.gitmodules') }}
restore-keys: |
tuyaopen-

- name: Init TuyaOpen submodules
run: |
git submodule update --init --recursive

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git wget build-essential
pip install -r TuyaOpen/requirements.txt

- name: Setup T5AI Platform
run: |
cd TuyaOpen
# Set up git safe directories
git config --global --add safe.directory "$(pwd)/platform/T5AI"
# Install ARM toolchain
if [ ! -d "platform/tools/gcc-arm-none-eabi-10.3-2021.10" ]; then
echo "Downloading ARM toolchain..."
wget -q https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
tar -xjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 -C platform/tools/
rm gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
fi
echo "ARM toolchain ready"

- name: Copy config file
run: |
cp -f .build/cache/using.config TuyaOpen/

- name: Build Firmware
run: |
cd TuyaOpen/platform/T5AI/t5_os
export TUYA_PROJECT_DIR="$(cd ../../../.. && pwd)"
export TUYA_APP_NAME="DuckyClaw"
export TUYA_APP_PATH="$TUYA_PROJECT_DIR"
export TUYA_TOOLCHAIN_PATH="$TUYA_PROJECT_DIR/TuyaOpen/platform/tools/gcc-arm-none-eabi-10.3-2021.10"
export PATH="$TUYA_TOOLCHAIN_PATH/bin:$PATH"

# Create tuya_iot_config.h
mkdir -p include/base/include
cp "$TUYA_PROJECT_DIR/include/tuya_app_config.h" include/base/include/tuya_iot_config.h

echo "Starting build..."
bash build.sh DuckyClaw 1.0.0 bk7258 "$TUYA_PROJECT_DIR" build 2>&1 | tee build.log

- name: Package Firmware
run: |
cd TuyaOpen/platform/T5AI/t5_os
if [ -f "build/bk7258/tuya_app/package/ua_file.bin" ]; then
cp build/bk7258/tuya_app/package/ua_file.bin "$GITHUB_WORKSPACE/DuckyClaw_Xiaozhi_UA.bin"
cp build/bk7258/tuya_app/package/all-app.bin "$GITHUB_WORKSPACE/DuckyClaw_Xiaozhi_QIO.bin"
echo "Firmware packaged successfully"
ls -lh "$GITHUB_WORKSPACE/"*.bin
else
echo "Build artifacts not found"
exit 1
fi

- name: Upload Firmware
uses: actions/upload-artifact@v4
with:
name: DuckyClaw_Xiaozhi_Firmware
path: |
DuckyClaw_Xiaozhi_UA.bin
DuckyClaw_Xiaozhi_QIO.bin
TuyaOpen/platform/T5AI/t5_os/build/bk7258/tuya_app/*/app.bin
TuyaOpen/platform/T5AI/t5_os/build.log
retention-days: 30
if-no-files-found: error

- name: Upload Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: |
DuckyClaw_Xiaozhi_UA.bin
DuckyClaw_Xiaozhi_QIO.bin
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ aux_source_directory(${APP_PATH}/agent APP_SRCS)
set(APP_INC
${APP_PATH}
${APP_PATH}/include
${APP_PATH}/src
${APP_PATH}/tools
${APP_PATH}/cron_service
${APP_PATH}/heartbeat
Expand Down
94 changes: 94 additions & 0 deletions GITHUB_ACTIONS_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# GitHub Actions 自动编译指南

## 快速开始

### 步骤 1:Fork 仓库
1. 访问 https://github.com/tuya/DuckyClaw
2. 点击右上角的 "Fork" 按钮
3. 选择您的 GitHub 账户

### 步骤 2:克隆 Fork 的仓库到本地
```bash
git clone https://github.com/YOUR_USERNAME/DuckyClaw.git
cd DuckyClaw
```

### 步骤 3:添加 XIAOZHI UI 代码
我已为您创建了所有必要的 XIAOZHI UI 文件。确保这些文件已提交:
- `ai_components/ai_ui/src/ai_ui_chat_xiaozhi.c`
- `ai_components/ai_ui/src/ai_ui_standby_face.c`
- `ai_components/ai_ui/include/ai_ui_chat_xiaozhi.h`
- `ai_components/ai_ui/include/ai_ui_standby_face.h`
- `.github/workflows/build_t5ai_xiaozhi.yml`

### 步骤 4:推送代码到您的 Fork
```bash
git add .
git commit -m "Add XIAOZHI UI with animated standby face"
git push origin master
```

### 步骤 5:查看 GitHub Actions 构建
1. 访问您的 Fork 仓库:https://github.com/YOUR_USERNAME/DuckyClaw
2. 点击 "Actions" 标签
3. 等待 "Build T5AI Firmware with Xiaozhi UI" 工作流完成(约 10-15 分钟)
4. 构建完成后,点击最新的运行记录
5. 在 "Artifacts" 部分下载 `DuckyClaw_Xiaozhi_Firmware`

### 步骤 6:烧录固件
1. 解压下载的固件包
2. 使用 Tuya Uart Tool 烧录 `DuckyClaw_Xiaozhi_UA.bin`

---

## 手动触发构建

如果需要重新构建:
1. 访问您的 Fork 仓库 Actions 页面
2. 选择 "Build T5AI Firmware with Xiaozhi UI"
3. 点击 "Run workflow" 按钮
4. 选择分支(master)并点击 "Run workflow"

---

## 故障排除

### 构建失败
- 检查 GitHub Actions 日志获取详细错误信息
- 确保所有子模块已正确初始化
- 检查 TuyaOpen 平台代码是否完整

### 固件无法启动
- 确认烧录的是 UA 文件(不是 QIO)
- 使用 Tuya Uart Tool 查看串口日志(波特率 460800)
- 检查是否有权限问题

---

## 本地构建(高级用户)

如果您有 Linux 环境:

```bash
# 安装依赖
sudo apt-get install git wget build-essential cmake ninja-build

# 进入 T5AI 平台目录
cd TuyaOpen/platform/T5AI/t5_os

# 设置环境变量
export TUYA_PROJECT_DIR=$(cd ../../.. && pwd)
export TUYA_APP_NAME="DuckyClaw"
export TUYA_TOOLCHAIN_PATH="$TUYA_PROJECT_DIR/platform/tools/gcc-arm-none-eabi-10.3-2021.10"
export PATH="$TUYA_TOOLCHAIN_PATH/bin:$PATH"

# 创建配置文件
mkdir -p include/base/include
cp "$TUYA_PROJECT_DIR/include/tuya_app_config.h" include/base/include/tuya_iot_config.h

# 构建
bash build.sh DuckyClaw 1.0.0 bk7258 "$TUYA_PROJECT_DIR" build

# 输出位置
# build/bk7258/tuya_app/package/ua_file.bin
```
9 changes: 9 additions & 0 deletions ai_components/ai_main/src/ai_chat_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "ai_ui_chat_chatbot.h"
#elif defined(ENABLE_AI_CHAT_GUI_OLED) && (ENABLE_AI_CHAT_GUI_OLED == 1)
#include "ai_ui_chat_oled.h"
#elif defined(ENABLE_AI_CHAT_GUI_XIAOZHI) && (ENABLE_AI_CHAT_GUI_XIAOZHI == 1)
#include "ai_ui_chat_xiaozhi.h"
#endif

#include "ai_chat_main.h"
Expand All @@ -40,8 +42,13 @@ static void __ai_chat_disp_mode_state(AI_MODE_STATE_E state)
switch (state) {
case AI_MODE_STATE_INIT:
case AI_MODE_STATE_IDLE:
#if defined(ENABLE_AI_CHAT_GUI_XIAOZHI) && (ENABLE_AI_CHAT_GUI_XIAOZHI == 1)
/* Xiaozhi UI handles standby mode internally */
ai_ui_disp_msg(AI_UI_DISP_STATUS, (uint8_t *)STANDBY, strlen(STANDBY));
#else
ai_ui_disp_msg(AI_UI_DISP_EMOTION, (uint8_t *)EMOJI_NEUTRAL, strlen(EMOJI_NEUTRAL));
ai_ui_disp_msg(AI_UI_DISP_STATUS, (uint8_t *)STANDBY, strlen(STANDBY));
#endif
break;
case AI_MODE_STATE_LISTEN:
ai_ui_disp_msg(AI_UI_DISP_STATUS, (uint8_t *)LISTENING, strlen(LISTENING));
Expand Down Expand Up @@ -148,6 +155,8 @@ OPERATE_RET ai_chat_ui_init(void)
TUYA_CALL_ERR_RETURN(ai_ui_chat_chatbot_register());
#elif defined(ENABLE_AI_CHAT_GUI_OLED) && (ENABLE_AI_CHAT_GUI_OLED == 1)
TUYA_CALL_ERR_RETURN(ai_ui_chat_oled_register());
#elif defined(ENABLE_AI_CHAT_GUI_XIAOZHI) && (ENABLE_AI_CHAT_GUI_XIAOZHI == 1)
TUYA_CALL_ERR_RETURN(ai_ui_chat_xiaozhi_register());
#else
#error "please select ai chat present ui"
#endif
Expand Down
5 changes: 5 additions & 0 deletions ai_components/ai_ui/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ if(!ENABLE_AI_CHAT_CUSTOM_UI)
config ENABLE_AI_CHAT_GUI_OLED
select ENABLE_LIBLVGL
bool "Use OLED ui"

config ENABLE_AI_CHAT_GUI_XIAOZHI
select ENABLE_LIBLVGL
select FONT_EMOJI_SIZE_64
bool "Use Xiaozhi-style standby face ui"
endchoice

config ENABLE_CIRCLE_UI_STYLE
Expand Down
50 changes: 50 additions & 0 deletions ai_components/ai_ui/include/ai_ui_chat_xiaozhi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @file ai_ui_chat_xiaozhi.h
* @brief Xiaozhi-style chat UI with standby face animation interface.
*
* @copyright Copyright (c) 2021-2025 Tuya Inc. All Rights Reserved.
*/

#ifndef __AI_UI_CHAT_XIAOZHI_H__
#define __AI_UI_CHAT_XIAOZHI_H__

#include "tuya_cloud_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/***********************************************************
************************macro define************************
***********************************************************/

/* Emotion types for standby face */
typedef enum {
XIAOZHI_EMO_HAPPY,
XIAOZHI_EMO_RELAXED,
XIAOZHI_EMO_CURIOUS,
XIAOZHI_EMO_SLEEPY,
XIAOZHI_EMO_EXCITED,
XIAOZHI_EMO_MAX,
} XIAOZHI_EMO_TYPE_E;

/***********************************************************
********************function declaration********************/

/**
* @brief Register Xiaozhi-style chat UI.
*
* This UI provides:
* - Animated standby face with blinking eyes
* - Automatic switching between standby and chat modes
* - Smooth LVGL-based animations
*
* @return OPERATE_RET Operation result code.
*/
OPERATE_RET ai_ui_chat_xiaozhi_register(void);

#ifdef __cplusplus
}
#endif

#endif /* __AI_UI_CHAT_XIAOZHI_H__ */
Loading