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
153 changes: 153 additions & 0 deletions GIT_UPLOAD_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Git 上传代码指南

## 当前状态
- 您有新的项目:`apps/tuya.ai/your_chat_bot_led_ctl/`
- 原 `your_chat_bot` 目录下的文件被删除(可能已移动到新目录)

## 上传步骤

### 1. 检查当前更改
```bash
git status
```

### 2. 添加新文件到暂存区

#### 添加新项目目录(推荐)
```bash
# 只添加新项目目录
git add apps/tuya.ai/your_chat_bot_led_ctl/
```

#### 或者添加所有更改
```bash
# 添加所有更改(包括删除的文件)
git add -A
```

#### 或者分别添加不同类型
```bash
# 只添加新文件和修改的文件(不包括删除)
git add apps/tuya.ai/your_chat_bot_led_ctl/

# 如果需要提交删除的文件
git add -u
```

### 3. 检查即将提交的内容
```bash
git status
git diff --cached # 查看已暂存的更改
```

### 4. 提交更改
```bash
git commit -m "添加LED PWM控制功能到your_chat_bot_led_ctl项目"
```

或者更详细的提交信息:
```bash
git commit -m "feat: 添加LED PWM控制功能

- 新增LED开关控制(DP ID: 20)
- 新增LED亮度控制(DP ID: 22)
- 支持本地触摸按键控制(GPIO29)
- 更新README文档(中英文)
- 使用PWM5通道控制LED
"

### 5. 推送到远程仓库

#### 如果您有推送权限(原始仓库)
```bash
# 推送到master分支(不推荐直接推送到master)
git push origin master

# 推荐:创建并推送到新分支
git checkout -b feature/led-pwm-control
git push origin feature/led-pwm-control
```

#### 如果您需要Fork仓库
```bash
# 1. 首先fork仓库到您的GitHub账户(在GitHub网站上操作)

# 2. 添加您的fork作为远程仓库
git remote add myfork https://github.com/您的用户名/TuyaOpen.git

# 3. 推送到您的fork
git push myfork master

# 或推送到新分支
git checkout -b feature/led-pwm-control
git push myfork feature/led-pwm-control
```

### 6. 创建Pull Request(如果使用Fork)
- 访问 https://github.com/tuya/TuyaOpen
- 点击 "New Pull Request"
- 选择您的fork和分支
- 填写PR描述
- 提交PR等待审核

## 常用Git命令

### 查看更改
```bash
git status # 查看工作区状态
git diff # 查看未暂存的更改
git diff --cached # 查看已暂存的更改
git log --oneline # 查看提交历史
```

### 撤销更改(谨慎使用)
```bash
# 撤销未暂存的更改(危险!)
git restore <文件>

# 撤销已暂存但未提交的更改
git restore --staged <文件>

# 修改最后一次提交
git commit --amend
```

### 分支操作
```bash
git branch # 查看本地分支
git branch -a # 查看所有分支
git checkout -b <分支名> # 创建并切换到新分支
git checkout <分支名> # 切换到分支
```

## 注意事项

1. **不要直接推送到master分支**:建议创建新分支或使用fork
2. **提交前检查**:使用 `git status` 和 `git diff` 确认更改
3. **提交信息清晰**:使用有意义的提交信息
4. **忽略文件**:确保 `.DS_Store` 等文件在 `.gitignore` 中

## 如果遇到问题

### 撤销所有本地更改
```bash
git restore .
git clean -fd # 删除未跟踪的文件
```

### 拉取最新代码
```bash
git fetch origin
git pull origin master
```

### 解决冲突
如果推送时出现冲突,需要先拉取最新代码并解决冲突:
```bash
git pull origin master
# 解决冲突后
git add .
git commit -m "解决合并冲突"
git push origin master
```

Binary file added apps/.DS_Store
Binary file not shown.
Binary file added apps/tuya.ai/.DS_Store
Binary file not shown.
Empty file modified apps/tuya.ai/your_chat_bot/app_default.config
100755 → 100644
Empty file.
141 changes: 141 additions & 0 deletions apps/tuya.ai/your_chat_bot/config/Ubuntu.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#
# Ubuntu x86_64 Configuration for AI Chat Bot with Keyboard Control
# This configuration is for running natively on Ubuntu/Linux x86_64 systems
# with ALSA audio support and keyboard input (no physical buttons/LEDs)
#

#
# Project Configuration
#
CONFIG_PROJECT_VERSION="1.0.1"
CONFIG_TUYA_PRODUCT_ID="p320pepzvmm1ghse"

#
# Chat Mode Configuration
# Using KEY_PRESS_HOLD_SINGLE mode with keyboard input (Press 'S' to start, 'X' to stop)
# In this mode, pressing 'S' starts listening, 'X' stops and uploads
#
CONFIG_ENABLE_CHAT_MODE_KEY_PRESS_HOLD_SINGEL=y
# CONFIG_ENABLE_CHAT_MODE_KEY_TRIG_VAD_FREE is not set
# CONFIG_ENABLE_CHAT_MODE_ASR_WAKEUP_SINGEL is not set
# CONFIG_ENABLE_CHAT_MODE_ASR_WAKEUP_FREE is not set

#
# Wakeup Keyword Configuration (not used with keyboard mode)
#
# CONFIG_ENABLE_WAKEUP_KEYWORD_NIHAO_TUYA=y

#
# Display Configuration
# Disable display for headless Ubuntu (no LCD/GUI)
#
CONFIG_ENABLE_CHAT_DISPLAY=n

#
# Audio Configuration
# Enable audio chat with ALSA support
#
CONFIG_ENABLE_AUDIO_CHAT=y

#
# Audio Codec Configuration - ALSA Support
#
CONFIG_ENABLE_AUDIO_CODECS=y
CONFIG_AUDIO_CODECS_NUM=1
CONFIG_AUDIO_CODEC_NAME="alsa_audio"
CONFIG_ENABLE_AUDIO_AEC=n

#
# ALSA Configuration
#
CONFIG_ENABLE_AUDIO_ALSA=y
CONFIG_ALSA_DEVICE_CAPTURE="default"
CONFIG_ALSA_DEVICE_PLAYBACK="default"
CONFIG_ALSA_BUFFER_FRAMES=1024
CONFIG_ALSA_PERIOD_FRAMES=256

#
# Platform Configuration
#
CONFIG_PLATFORM_CHOICE="Ubuntu"
CONFIG_PLATFORM_UBUNTU=y

#
# Keyboard Input Configuration (Ubuntu-specific)
#
CONFIG_ENABLE_KEYBOARD_INPUT=y

#
# Button and LED Configuration
# Button is replaced by keyboard input, LED is not used
#
CONFIG_BUTTON_NAME="button"
CONFIG_LED_NAME="led"
CONFIG_ENABLE_BUTTON=n
CONFIG_ENABLE_LED=n

#
# Network Configuration
# Enable WiFi by default for Ubuntu platform
#
CONFIG_ENABLE_WIRED=y
CONFIG_ENABLE_WIFI=n
CONFIG_ENABLE_BLUETOOTH=n

#
# System Configuration
#
CONFIG_OPERATING_SYSTEM=100
CONFIG_LITTLE_END=1
CONFIG_FLASH_FILE_PATH="./tuyadb"

#
# TLS Configuration
#
CONFIG_MBEDTLS_CONFIG_FILE="tuya_tls_config.h"

#
# QR Code Configuration
# Enable QR code display for device pairing
#
CONFIG_ENABLE_QRCODE=y

#
# Required Libraries
# Note: lwIP is NOT used on Ubuntu (native Linux networking)
#
# CONFIG_ENABLE_LIBLWIP is not set
CONFIG_ENABLE_LIBHTTP=y
CONFIG_ENABLE_LIBMQTT=y
CONFIG_ENABLE_LIBTLS=y
CONFIG_ENABLE_LIBCJSON=y
CONFIG_ENABLE_LIBLVGL=n

#
# Usage Instructions:
# 1. Install ALSA development library:
# sudo apt-get install libasound2-dev
#
# 2. Ensure your user is in the audio group:
# sudo usermod -a -G audio $USER
# (Log out and log back in)
#
# 3. Build:
# tos config Ubuntu apps/tuya.ai/your_chat_bot/config/Ubuntu.config
# tos build
#
# 4. Run:
# ./output/your_chat_bot
#
# The application will display a QR code in the terminal for device pairing.
# Scan the QR code with the Tuya Smart app to complete the pairing process.
#
# 5. Keyboard Controls:
# [S] - Start/Stop conversation (triggers voice capture)
# [V] - Volume up
# [D] - Volume down
# [Q] - Quit application
#
# Note: No physical buttons or LEDs are used. Everything is controlled via keyboard.
#

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_PROJECT_VERSION="1.0.1"
CONFIG_TUYA_PRODUCT_ID="lased5audtah8wcp"
CONFIG_ENABLE_WAKEUP_KEYWORD_NIHAO_XIAOZHI=y
CONFIG_ENABLE_CHAT_DISPLAY=y
CONFIG_BOARD_CHOICE_ESP32=y
CONFIG_BOARD_CHOICE_XIAOZHI_ESP32S3_MOON_1_28=y
CONFIG_ENABLE_LIBLVGL=y
15 changes: 15 additions & 0 deletions apps/tuya.ai/your_chat_bot/include/app_chat_bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ uint8_t app_chat_bot_get_enable(void);
*/
OPERATE_RET ai_audio_player_play_alert(AI_AUDIO_ALERT_TYPE_E type);

#if defined(ENABLE_KEYBOARD_INPUT) && (ENABLE_KEYBOARD_INPUT == 1)
// Include keyboard input header to get KEYBOARD_EVENT_E type
#include "keyboard_input.h"

/**
* @brief Handles keyboard events from board layer
*
* This function is called from the board layer when keyboard
* events are detected. All business logic is handled here.
*
* @param event - The keyboard event type
*/
void app_chat_bot_keyboard_event_handler(KEYBOARD_EVENT_E event);
#endif

#ifdef __cplusplus
}
#endif
Expand Down
Loading