mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2025-05-17 15:20:29 +08:00
支持 ESP32 系列开发板 (#116)
* 1. 支持 ESP32系列开发板: DevKitC / NodeMcu-32S / GoouuuESP32 / ESP32 DoIt / ESP-32S 2. 注意:非ESP32-C3 / 非ESP32-S3 * 补图片: M5Stack Atom Matrix + ES8311 + NS4150B * 修订 ESP32 系列开发板 面包板 成品图 * 修订: ESP32系列开发板 README.md * 修订: 移除对首页修改的这部分内容,跳转链接添加至《百科全书》的目录里。
This commit is contained in:
@ -51,6 +51,7 @@
|
|||||||
- <a href="https://github.com/espressif/esp-box" target="_blank" title="乐鑫 ESP32-S3-BOX3">乐鑫 ESP32-S3-BOX3</a>
|
- <a href="https://github.com/espressif/esp-box" target="_blank" title="乐鑫 ESP32-S3-BOX3">乐鑫 ESP32-S3-BOX3</a>
|
||||||
- <a href="https://docs.m5stack.com/zh_CN/core/CoreS3" target="_blank" title="M5Stack CoreS3">M5Stack CoreS3</a>
|
- <a href="https://docs.m5stack.com/zh_CN/core/CoreS3" target="_blank" title="M5Stack CoreS3">M5Stack CoreS3</a>
|
||||||
- <a href="https://docs.m5stack.com/en/atom/Atomic%20Echo%20Base" target="_blank" title="AtomS3R + Echo Base">AtomS3R + Echo Base</a>
|
- <a href="https://docs.m5stack.com/en/atom/Atomic%20Echo%20Base" target="_blank" title="AtomS3R + Echo Base">AtomS3R + Echo Base</a>
|
||||||
|
- <a href="https://docs.m5stack.com/en/core/ATOM%20Matrix" target="_blank" title="AtomMatrix + Echo Base">AtomMatrix + Echo Base</a>
|
||||||
- <a href="https://gf.bilibili.com/item/detail/1108782064" target="_blank" title="神奇按钮 2.4">神奇按钮 2.4</a>
|
- <a href="https://gf.bilibili.com/item/detail/1108782064" target="_blank" title="神奇按钮 2.4">神奇按钮 2.4</a>
|
||||||
- <a href="https://www.waveshare.net/shop/ESP32-S3-Touch-AMOLED-1.8.htm" target="_blank" title="微雪电子 ESP32-S3-Touch-AMOLED-1.8">微雪电子 ESP32-S3-Touch-AMOLED-1.8</a>
|
- <a href="https://www.waveshare.net/shop/ESP32-S3-Touch-AMOLED-1.8.htm" target="_blank" title="微雪电子 ESP32-S3-Touch-AMOLED-1.8">微雪电子 ESP32-S3-Touch-AMOLED-1.8</a>
|
||||||
- <a href="https://github.com/Xinyuan-LilyGO/T-Circle-S3" target="_blank" title="LILYGO T-Circle-S3">LILYGO T-Circle-S3</a>
|
- <a href="https://github.com/Xinyuan-LilyGO/T-Circle-S3" target="_blank" title="LILYGO T-Circle-S3">LILYGO T-Circle-S3</a>
|
||||||
@ -70,6 +71,9 @@
|
|||||||
<a href="docs/v1/atoms3r.jpg" target="_blank" title="AtomS3R + Echo Base">
|
<a href="docs/v1/atoms3r.jpg" target="_blank" title="AtomS3R + Echo Base">
|
||||||
<img src="docs/v1/atoms3r.jpg" width="240" />
|
<img src="docs/v1/atoms3r.jpg" width="240" />
|
||||||
</a>
|
</a>
|
||||||
|
<a href="docs/AtomMatrix-echo-base.jpg" target="_blank" title="AtomMatrix-echo-base + Echo Base">
|
||||||
|
<img src="docs/AtomMatrix-echo-base.jpg" width="240" />
|
||||||
|
</a>
|
||||||
<a href="docs/v1/magiclick.jpg" target="_blank" title="神奇按钮 2.4">
|
<a href="docs/v1/magiclick.jpg" target="_blank" title="神奇按钮 2.4">
|
||||||
<img src="docs/v1/magiclick.jpg" width="240" />
|
<img src="docs/v1/magiclick.jpg" width="240" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -51,6 +51,7 @@ Breadboard setup shown below:
|
|||||||
- <a href="https://github.com/espressif/esp-box" target="_blank" title="Espressif ESP32-S3-BOX3">Espressif ESP32-S3-BOX3</a>
|
- <a href="https://github.com/espressif/esp-box" target="_blank" title="Espressif ESP32-S3-BOX3">Espressif ESP32-S3-BOX3</a>
|
||||||
- <a href="https://docs.m5stack.com/zh_CN/core/CoreS3" target="_blank" title="M5Stack CoreS3">M5Stack CoreS3</a>
|
- <a href="https://docs.m5stack.com/zh_CN/core/CoreS3" target="_blank" title="M5Stack CoreS3">M5Stack CoreS3</a>
|
||||||
- <a href="https://docs.m5stack.com/en/atom/Atomic%20Echo%20Base" target="_blank" title="AtomS3R + Echo Base">AtomS3R + Echo Base</a>
|
- <a href="https://docs.m5stack.com/en/atom/Atomic%20Echo%20Base" target="_blank" title="AtomS3R + Echo Base">AtomS3R + Echo Base</a>
|
||||||
|
- <a href="https://docs.m5stack.com/en/core/ATOM%20Matrix" target="_blank" title="AtomMatrix + Echo Base">AtomMatrix + Echo Base</a>
|
||||||
- <a href="https://gf.bilibili.com/item/detail/1108782064" target="_blank" title="MagiClick 2.4">MagiClick 2.4</a>
|
- <a href="https://gf.bilibili.com/item/detail/1108782064" target="_blank" title="MagiClick 2.4">MagiClick 2.4</a>
|
||||||
- <a href="https://www.waveshare.net/shop/ESP32-S3-Touch-AMOLED-1.8.htm" target="_blank" title="Waveshare ESP32-S3-Touch-AMOLED-1.8">Waveshare ESP32-S3-Touch-AMOLED-1.8</a>
|
- <a href="https://www.waveshare.net/shop/ESP32-S3-Touch-AMOLED-1.8.htm" target="_blank" title="Waveshare ESP32-S3-Touch-AMOLED-1.8">Waveshare ESP32-S3-Touch-AMOLED-1.8</a>
|
||||||
- <a href="https://github.com/Xinyuan-LilyGO/T-Circle-S3" target="_blank" title="LILYGO T-Circle-S3">LILYGO T-Circle-S3</a>
|
- <a href="https://github.com/Xinyuan-LilyGO/T-Circle-S3" target="_blank" title="LILYGO T-Circle-S3">LILYGO T-Circle-S3</a>
|
||||||
@ -70,6 +71,9 @@ Breadboard setup shown below:
|
|||||||
<a href="docs/v1/atoms3r.jpg" target="_blank" title="AtomS3R + Echo Base">
|
<a href="docs/v1/atoms3r.jpg" target="_blank" title="AtomS3R + Echo Base">
|
||||||
<img src="docs/v1/atoms3r.jpg" width="240" />
|
<img src="docs/v1/atoms3r.jpg" width="240" />
|
||||||
</a>
|
</a>
|
||||||
|
<a href="docs/AtomMatrix-echo-base.jpg" target="_blank" title="AtomMatrix-echo-base + Echo Base">
|
||||||
|
<img src="docs/AtomMatrix-echo-base.jpg" width="240" />
|
||||||
|
</a>
|
||||||
<a href="docs/v1/magiclick.jpg" target="_blank" title="MagiClick 2.4">
|
<a href="docs/v1/magiclick.jpg" target="_blank" title="MagiClick 2.4">
|
||||||
<img src="docs/v1/magiclick.jpg" width="240" />
|
<img src="docs/v1/magiclick.jpg" width="240" />
|
||||||
</a>
|
</a>
|
||||||
|
BIN
docs/AtomMatrix-echo-base.jpg
Normal file
BIN
docs/AtomMatrix-echo-base.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
docs/ESP32-BreadBoard.jpg
Normal file
BIN
docs/ESP32-BreadBoard.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 94 KiB |
@ -41,6 +41,8 @@ if(CONFIG_BOARD_TYPE_BREAD_COMPACT_WIFI)
|
|||||||
set(BOARD_TYPE "bread-compact-wifi")
|
set(BOARD_TYPE "bread-compact-wifi")
|
||||||
elseif(CONFIG_BOARD_TYPE_BREAD_COMPACT_ML307)
|
elseif(CONFIG_BOARD_TYPE_BREAD_COMPACT_ML307)
|
||||||
set(BOARD_TYPE "bread-compact-ml307")
|
set(BOARD_TYPE "bread-compact-ml307")
|
||||||
|
elseif(CONFIG_BOARD_TYPE_BREAD_COMPACT_ESP32)
|
||||||
|
set(BOARD_TYPE "bread-compact-esp32")
|
||||||
elseif(CONFIG_BOARD_TYPE_ESP_BOX_3)
|
elseif(CONFIG_BOARD_TYPE_ESP_BOX_3)
|
||||||
set(BOARD_TYPE "esp-box-3")
|
set(BOARD_TYPE "esp-box-3")
|
||||||
elseif(CONFIG_BOARD_TYPE_KEVIN_BOX_1)
|
elseif(CONFIG_BOARD_TYPE_KEVIN_BOX_1)
|
||||||
@ -95,7 +97,8 @@ endif()
|
|||||||
if(CONFIG_IDF_TARGET_ESP32)
|
if(CONFIG_IDF_TARGET_ESP32)
|
||||||
# 排除 "audio_codecs/box_audio_codec.cc" 和 "audio_codecs/cores3_audio_codec.cc"
|
# 排除 "audio_codecs/box_audio_codec.cc" 和 "audio_codecs/cores3_audio_codec.cc"
|
||||||
list(REMOVE_ITEM SOURCES "audio_codecs/box_audio_codec.cc"
|
list(REMOVE_ITEM SOURCES "audio_codecs/box_audio_codec.cc"
|
||||||
"audio_codecs/cores3_audio_codec.cc")
|
"audio_codecs/cores3_audio_codec.cc"
|
||||||
|
"audio_codecs/es8388_audio_codec.cc")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_component_register(SRCS ${SOURCES}
|
idf_component_register(SRCS ${SOURCES}
|
||||||
|
@ -42,6 +42,8 @@ choice BOARD_TYPE
|
|||||||
bool "面包板新版接线(WiFi)+ LCD"
|
bool "面包板新版接线(WiFi)+ LCD"
|
||||||
config BOARD_TYPE_BREAD_COMPACT_ML307
|
config BOARD_TYPE_BREAD_COMPACT_ML307
|
||||||
bool "面包板新版接线(ML307 AT)"
|
bool "面包板新版接线(ML307 AT)"
|
||||||
|
config BOARD_TYPE_BREAD_COMPACT_ESP32
|
||||||
|
bool "面包板 ESP32 DevKit"
|
||||||
config BOARD_TYPE_ESP_BOX_3
|
config BOARD_TYPE_ESP_BOX_3
|
||||||
bool "ESP BOX 3"
|
bool "ESP BOX 3"
|
||||||
config BOARD_TYPE_KEVIN_BOX_1
|
config BOARD_TYPE_KEVIN_BOX_1
|
||||||
|
@ -94,8 +94,10 @@ ATK_NoAudioCodecDuplex::ATK_NoAudioCodecDuplex(int input_sample_rate, int output
|
|||||||
.clk_cfg = {
|
.clk_cfg = {
|
||||||
.sample_rate_hz = (uint32_t)output_sample_rate_,
|
.sample_rate_hz = (uint32_t)output_sample_rate_,
|
||||||
.clk_src = I2S_CLK_SRC_DEFAULT,
|
.clk_src = I2S_CLK_SRC_DEFAULT,
|
||||||
.ext_clk_freq_hz = 0,
|
.mclk_multiple = I2S_MCLK_MULTIPLE_256,
|
||||||
.mclk_multiple = I2S_MCLK_MULTIPLE_256
|
#ifdef I2S_HW_VERSION_2
|
||||||
|
.ext_clk_freq_hz = 0,
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
.slot_cfg = {
|
.slot_cfg = {
|
||||||
.data_bit_width = I2S_DATA_BIT_WIDTH_16BIT,
|
.data_bit_width = I2S_DATA_BIT_WIDTH_16BIT,
|
||||||
@ -105,9 +107,11 @@ ATK_NoAudioCodecDuplex::ATK_NoAudioCodecDuplex(int input_sample_rate, int output
|
|||||||
.ws_width = I2S_DATA_BIT_WIDTH_16BIT,
|
.ws_width = I2S_DATA_BIT_WIDTH_16BIT,
|
||||||
.ws_pol = false,
|
.ws_pol = false,
|
||||||
.bit_shift = true,
|
.bit_shift = true,
|
||||||
.left_align = true,
|
#ifdef I2S_HW_VERSION_2
|
||||||
.big_endian = false,
|
.left_align = true,
|
||||||
.bit_order_lsb = false
|
.big_endian = false,
|
||||||
|
.bit_order_lsb = false
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
.gpio_cfg = {
|
.gpio_cfg = {
|
||||||
.mclk = I2S_GPIO_UNUSED,
|
.mclk = I2S_GPIO_UNUSED,
|
||||||
|
37
main/boards/bread-compact-esp32/README.md
Normal file
37
main/boards/bread-compact-esp32/README.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# 编译配置命令
|
||||||
|
|
||||||
|
**配置编译目标为 ESP32:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py set-target esp32
|
||||||
|
```
|
||||||
|
|
||||||
|
**打开 menuconfig:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py menuconfig
|
||||||
|
```
|
||||||
|
|
||||||
|
**选择板子:**
|
||||||
|
|
||||||
|
```
|
||||||
|
Xiaozhi Assistant -> Board Type -> 面包板 ESP32 DevKit
|
||||||
|
```
|
||||||
|
|
||||||
|
**修改 flash 大小:**
|
||||||
|
|
||||||
|
```
|
||||||
|
Serial flasher config -> Flash size -> 4 MB
|
||||||
|
```
|
||||||
|
|
||||||
|
**修改分区表:**
|
||||||
|
|
||||||
|
```
|
||||||
|
Partition Table -> Custom partition CSV file -> partitions_4M.csv
|
||||||
|
```
|
||||||
|
|
||||||
|
**编译:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
idf.py build
|
||||||
|
```
|
36
main/boards/bread-compact-esp32/config.h
Normal file
36
main/boards/bread-compact-esp32/config.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef _BOARD_CONFIG_H_
|
||||||
|
#define _BOARD_CONFIG_H_
|
||||||
|
|
||||||
|
#include <driver/gpio.h>
|
||||||
|
|
||||||
|
#define AUDIO_INPUT_SAMPLE_RATE 16000
|
||||||
|
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
||||||
|
|
||||||
|
// 如果使用 Duplex I2S 模式,请注释下面一行
|
||||||
|
#define AUDIO_I2S_METHOD_SIMPLEX
|
||||||
|
|
||||||
|
#ifdef AUDIO_I2S_METHOD_SIMPLEX
|
||||||
|
|
||||||
|
#define AUDIO_I2S_MIC_GPIO_WS GPIO_NUM_25
|
||||||
|
#define AUDIO_I2S_MIC_GPIO_SCK GPIO_NUM_26
|
||||||
|
#define AUDIO_I2S_MIC_GPIO_DIN GPIO_NUM_32
|
||||||
|
|
||||||
|
#define AUDIO_I2S_SPK_GPIO_DOUT GPIO_NUM_33
|
||||||
|
#define AUDIO_I2S_SPK_GPIO_BCLK GPIO_NUM_14
|
||||||
|
#define AUDIO_I2S_SPK_GPIO_LRCK GPIO_NUM_27
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define AUDIO_I2S_GPIO_WS GPIO_NUM_4
|
||||||
|
#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_5
|
||||||
|
#define AUDIO_I2S_GPIO_DIN GPIO_NUM_6
|
||||||
|
#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_7
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
||||||
|
#define TOUCH_BUTTON_GPIO GPIO_NUM_5
|
||||||
|
#define BUILTIN_LED_GPIO GPIO_NUM_2
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _BOARD_CONFIG_H_
|
80
main/boards/bread-compact-esp32/esp32_bread_board.cc
Normal file
80
main/boards/bread-compact-esp32/esp32_bread_board.cc
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#include "wifi_board.h"
|
||||||
|
#include "audio_codecs/no_audio_codec.h"
|
||||||
|
#include "system_reset.h"
|
||||||
|
#include "application.h"
|
||||||
|
#include "button.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "iot/thing_manager.h"
|
||||||
|
#include "led/single_led.h"
|
||||||
|
|
||||||
|
#include <wifi_station.h>
|
||||||
|
#include <esp_log.h>
|
||||||
|
#include <driver/i2c_master.h>
|
||||||
|
|
||||||
|
#define TAG "ESP32-MarsbearSupport"
|
||||||
|
|
||||||
|
|
||||||
|
class CompactWifiBoard : public WifiBoard {
|
||||||
|
private:
|
||||||
|
Button boot_button_;
|
||||||
|
Button touch_button_;
|
||||||
|
|
||||||
|
void InitializeButtons() {
|
||||||
|
|
||||||
|
// 配置 GPIO
|
||||||
|
gpio_config_t io_conf = {
|
||||||
|
.pin_bit_mask = 1ULL << BUILTIN_LED_GPIO, // 设置需要配置的 GPIO 引脚
|
||||||
|
.mode = GPIO_MODE_OUTPUT, // 设置为输出模式
|
||||||
|
.pull_up_en = GPIO_PULLUP_DISABLE, // 禁用上拉
|
||||||
|
.pull_down_en = GPIO_PULLDOWN_DISABLE, // 禁用下拉
|
||||||
|
.intr_type = GPIO_INTR_DISABLE // 禁用中断
|
||||||
|
};
|
||||||
|
gpio_config(&io_conf); // 应用配置
|
||||||
|
|
||||||
|
boot_button_.OnClick([this]() {
|
||||||
|
auto& app = Application::GetInstance();
|
||||||
|
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
||||||
|
ResetWifiConfiguration();
|
||||||
|
}
|
||||||
|
gpio_set_level(BUILTIN_LED_GPIO, 1);
|
||||||
|
app.ToggleChatState();
|
||||||
|
});
|
||||||
|
touch_button_.OnPressDown([this]() {
|
||||||
|
gpio_set_level(BUILTIN_LED_GPIO, 1);
|
||||||
|
Application::GetInstance().StartListening();
|
||||||
|
});
|
||||||
|
touch_button_.OnPressUp([this]() {
|
||||||
|
gpio_set_level(BUILTIN_LED_GPIO, 0);
|
||||||
|
Application::GetInstance().StopListening();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 物联网初始化,添加对 AI 可见设备
|
||||||
|
void InitializeIot() {
|
||||||
|
auto& thing_manager = iot::ThingManager::GetInstance();
|
||||||
|
thing_manager.AddThing(iot::CreateThing("Speaker"));
|
||||||
|
thing_manager.AddThing(iot::CreateThing("Lamp"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
CompactWifiBoard() : boot_button_(BOOT_BUTTON_GPIO), touch_button_(TOUCH_BUTTON_GPIO)
|
||||||
|
{
|
||||||
|
InitializeButtons();
|
||||||
|
InitializeIot();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual AudioCodec* GetAudioCodec() override
|
||||||
|
{
|
||||||
|
#ifdef AUDIO_I2S_METHOD_SIMPLEX
|
||||||
|
static NoAudioCodecSimplex audio_codec(AUDIO_INPUT_SAMPLE_RATE, AUDIO_OUTPUT_SAMPLE_RATE,
|
||||||
|
AUDIO_I2S_SPK_GPIO_BCLK, AUDIO_I2S_SPK_GPIO_LRCK, AUDIO_I2S_SPK_GPIO_DOUT, AUDIO_I2S_MIC_GPIO_SCK, AUDIO_I2S_MIC_GPIO_WS, AUDIO_I2S_MIC_GPIO_DIN);
|
||||||
|
#else
|
||||||
|
static NoAudioCodecDuplex audio_codec(AUDIO_INPUT_SAMPLE_RATE, AUDIO_OUTPUT_SAMPLE_RATE,
|
||||||
|
AUDIO_I2S_GPIO_BCLK, AUDIO_I2S_GPIO_WS, AUDIO_I2S_GPIO_DOUT, AUDIO_I2S_GPIO_DIN);
|
||||||
|
#endif
|
||||||
|
return &audio_codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_BOARD(CompactWifiBoard);
|
Reference in New Issue
Block a user