feat(demo): add wireless and low-power examples
This commit is contained in:
1 parent
3a6f918abd
commit
26628a4777
13 files changed
+761
-12
No files matched your search
@@ -49,16 +49,19 @@ The table below describes the application capabilities implemented by the curren
|
||||
| Input | `UP`, `DOWN`, and `OK` share an ADC resistor ladder on GPIO0 | `bsp_button_init()`, `bsp_button_read_mv()` | Callbacks run in the button component task and must not block; do not create a second ADC1 unit |
|
||||
| Audio | ES8311 with full-duplex PCM over I2S0, supporting playback and microphone capture | `bsp_audio_*` | PCM reads and writes block and belong in a worker task; format changes must retain the BSP close/open sequence |
|
||||
| Battery | CW2017 state-of-charge and voltage readings | `bsp_battery_*` | This capability is optional at runtime; accuracy depends on the cell and battery profile and is not equivalent to a calibrated result |
|
||||
| Wi-Fi | On-demand 2.4 GHz STA scan demo | `main/demo_wifi.c` | Scans only; it does not connect, store credentials, or validate antenna/RF performance |
|
||||
| Bluetooth LE | On-demand non-connectable NimBLE advertising as `FoloPassport` | `main/demo_ble.c` | ESP32-C3 does not support Bluetooth Classic; radio range, coexistence, and power draw require device measurements |
|
||||
| Low power | Two-second light sleep and five-second deep sleep, both with RTC timer wakeup | `main/demo_low_power.c` | Deep sleep restarts the application; external/button wakeup and board-level power consumption remain unverified |
|
||||
| Shared bus | ES8311 and CW2017 share I2C0 | `bsp_i2c_*` | Every device must reuse the bus owned by the BSP; do not create another bus on the same port for scanning or a new device |
|
||||
| Logging and flashing | Native ESP32-C3 USB Serial/JTAG | ESP-IDF console | GPIO18/19 are reserved for USB; the default UART0 TX on GPIO21 conflicts with the backlight |
|
||||
|
||||
All pins, addresses, panel parameters, and button voltage windows are defined only in [`components/bsp/include/bsp_pins.h`](components/bsp/include/bsp_pins.h). Application code must not duplicate these constants. See the [AI Hardware Development Guide](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md) for the complete pin map, panel initialization, ADC thresholds, I2C addressing rules, audio clocks, and memory details.
|
||||
|
||||
Applications may also use ESP-IDF timers, FreeRTOS tasks, and internal Flash/NVS; the Pomodoro branch contains an NVS example. The ESP32-C3 supports 2.4 GHz Wi-Fi and Bluetooth LE, but the current BSP does not wrap either radio and `main` does not initialize a wireless stack. `demo/claude-buddy-port` is a BLE application architecture reference, not a substitute for measuring the current board's antenna, RF performance, power consumption, and coexistence behavior. Every FoloToy AI Passport has 8 MB of Flash, and the default firmware configuration targets 8 MB.
|
||||
Applications may also use ESP-IDF timers, FreeRTOS tasks, and internal Flash/NVS; the Pomodoro branch contains an NVS example. Wi-Fi and Bluetooth LE remain ESP-IDF application services rather than BSP APIs: their menu pages initialize each stack only while open and release it on exit. `demo/claude-buddy-port` remains a fuller BLE application architecture reference, not a substitute for measuring the current board's antenna, RF performance, power consumption, and coexistence behavior. Every FoloToy AI Passport has 8 MB of Flash, and the default firmware configuration targets 8 MB with a 3 MB factory-app partition.
|
||||
|
||||
### Capabilities outside the current contract
|
||||
|
||||
The repository does not currently provide enough evidence to guarantee touch input, display readback, an IMU, external storage, charging control, USB insertion detection, controllable power-amplifier enable, deep-sleep wakeup, arbitrary “free GPIOs,” exact battery capacity, or production-grade power specifications. A capability being present in the ESP32-C3 silicon does not mean that it is connected, powered correctly, or validated on this board.
|
||||
The repository does not currently provide enough evidence to guarantee touch input, display readback, an IMU, external storage, charging control, USB insertion detection, controllable power-amplifier enable, external/button deep-sleep wakeup, arbitrary “free GPIOs,” exact battery capacity, or production-grade power specifications. A capability being present in the ESP32-C3 silicon does not mean that it is connected, powered correctly, or validated on this board.
|
||||
|
||||
Requirements involving these capabilities must begin with a schematic, board revision, component documentation, or physical measurements. Only then should the BSP and its acceptance criteria be extended.
|
||||
|
||||
@@ -176,6 +179,8 @@ Different example branches may provide their own host-test commands; follow the
|
||||
- `UP`, `DOWN`, and `OK` produce the intended events, and long `OK` returns correctly.
|
||||
- Audio sample rate, playback, non-zero recording, and page exit behavior are correct.
|
||||
- Battery readings are plausible, and the application degrades safely when the CW2017 is absent.
|
||||
- Wi-Fi rescans complete, BLE advertising is visible to a phone scanner, and both pages can be entered and exited repeatedly.
|
||||
- The Low Power page uses `UP`/`DOWN` to select light or deep sleep and `OK` to run it. Light sleep wakes by timer after approximately two seconds and restores the display backlight; deep sleep restarts after approximately five seconds and reports a retained wake count.
|
||||
- Repeated page transitions and concurrent operations do not continuously leak tasks, objects, or heap.
|
||||
|
||||
An agent's final delivery must distinguish these outcomes:
|
||||
@@ -198,5 +203,6 @@ main/ Minimal menu, LVGL UI, and independent hardware demo pa
|
||||
tests/ Lightweight logic tests that can run without hardware
|
||||
docs/ Agent hardware development guide and extension documentation
|
||||
sdkconfig.defaults ESP32-C3, USB console, Flash, and LVGL defaults
|
||||
partitions.csv NVS, PHY data, and 3 MB factory application layout
|
||||
AGENTS.md Coding, validation, and contribution rules for agents
|
||||
```
|
||||
+8
-2
@@ -49,16 +49,19 @@ FoloToy AI Passport 是一个面向 AI agent 的开放式可穿戴 AI 硬件,
|
||||
| 输入 | `UP` / `DOWN` / `OK` 三键,共用 GPIO0 的 ADC 电阻分压 | `bsp_button_init()`、`bsp_button_read_mv()` | 回调运行在 button 组件任务中,不能阻塞;不能再创建第二个 ADC1 unit |
|
||||
| 音频 | ES8311,I2S0 全双工 PCM,可播放和麦克风录音 | `bsp_audio_*` | PCM 读写为阻塞调用,应放工作任务;格式切换必须保留 BSP 内的 close/open 流程 |
|
||||
| 电池 | CW2017 的 SOC 与电压读取 | `bsp_battery_*` | 是可缺省能力;读数精度取决于电芯与 profile,不能等同于已标定结果 |
|
||||
| Wi-Fi | 按需启动的 2.4 GHz STA 扫描示例 | `main/demo_wifi.c` | 只扫描,不连接、不保存凭据,也不代表天线/射频性能已验证 |
|
||||
| Bluetooth LE | 按需启动 NimBLE,以 `FoloPassport` 做不可连接广播 | `main/demo_ble.c` | ESP32-C3 不支持经典蓝牙;距离、共存和功耗需实机测量 |
|
||||
| 低功耗 | 两秒 light sleep 和五秒 deep sleep,均由 RTC timer 唤醒 | `main/demo_low_power.c` | deep sleep 会重启应用;外部/按键唤醒和板级功耗仍未验证 |
|
||||
| 共享总线 | ES8311 与 CW2017 共用 I2C0 | `bsp_i2c_*` | 所有设备复用 BSP 持有的总线;不能为扫描或新设备再创建同端口总线 |
|
||||
| 日志与烧录 | ESP32-C3 原生 USB Serial/JTAG | ESP-IDF console | GPIO18/19 保留给 USB;UART0 默认 TX GPIO21 与背光冲突 |
|
||||
|
||||
所有引脚、地址、面板参数和按键电压窗口只在 [`components/bsp/include/bsp_pins.h`](components/bsp/include/bsp_pins.h) 定义。应用代码不得复制这些常量。完整引脚表、面板初始化、ADC 阈值、I2C 地址规则、音频时钟和内存说明见 [AI 硬件开发指南](docs/AI_HARDWARE_DEVELOPMENT_GUIDE.md)。
|
||||
|
||||
应用也可以使用 ESP-IDF 提供的定时器、FreeRTOS 任务和内部 Flash/NVS;番茄钟分支提供了 NVS 示例。ESP32-C3 芯片支持 2.4 GHz Wi-Fi 和 Bluetooth LE,但当前 BSP 没有为无线能力提供封装,`main` 也不初始化无线栈;`demo/claude-buddy-port` 只能作为 BLE 应用架构参考,不能替代对当前板卡天线、射频表现、功耗和共存行为的实测。所有 FoloToy AI Passport 均配备 8 MB Flash,默认固件配置也以 8 MB 为准。
|
||||
应用也可以使用 ESP-IDF 提供的定时器、FreeRTOS 任务和内部 Flash/NVS;番茄钟分支提供了 NVS 示例。Wi-Fi 和 Bluetooth LE 仍是 ESP-IDF 应用服务,不是 BSP API:它们的菜单页只在打开期间初始化栈,退出时释放。`demo/claude-buddy-port` 仍可作为更完整的 BLE 应用架构参考,但不能替代对当前板卡天线、射频表现、功耗和共存行为的实测。所有 FoloToy AI Passport 均配备 8 MB Flash,默认使用 3 MB factory app 分区。
|
||||
|
||||
### 不属于当前能力契约的事项
|
||||
|
||||
仓库目前没有足够证据保证以下能力:触摸、屏幕读回、IMU、外部存储、充电控制、USB 插拔检测、可控功放使能、深度睡眠唤醒、任意“空闲 GPIO”、电池精确容量或量产级电源指标。ESP32-C3 芯片具备某项功能,不代表这块板已经接出、供电正确或经过验证。
|
||||
仓库目前没有足够证据保证以下能力:触摸、屏幕读回、IMU、外部存储、充电控制、USB 插拔检测、可控功放使能、外部/按键 deep-sleep 唤醒、任意“空闲 GPIO”、电池精确容量或量产级电源指标。ESP32-C3 芯片具备某项功能,不代表这块板已经接出、供电正确或经过验证。
|
||||
|
||||
需要这些能力时,先补充原理图、板卡修订号、器件资料或实测结果,再扩展 BSP 和验收项。
|
||||
|
||||
@@ -175,6 +178,8 @@ cc -std=c11 -Wall -Wextra -Werror -Imain \
|
||||
- `UP` / `DOWN` / `OK` 的目标事件和长按返回正确;
|
||||
- 音频采样速度、播放、非零录音和页面退出正确;
|
||||
- 电池读数合理,CW2017 缺失时应用能安全降级;
|
||||
- Wi-Fi 重新扫描可完成,手机 BLE 扫描器可看到广播,两页可反复进出;
|
||||
- Low Power 页可用 `UP` / `DOWN` 选择 light 或 deep sleep,`OK` 执行;light sleep 约两秒后被 timer 唤醒并恢复背光;deep sleep 约五秒后重启,再进入页面可见 RTC 保留的唤醒计数;
|
||||
- 重复进出页面和并发操作后没有任务、对象或堆持续泄漏。
|
||||
|
||||
agent 的最终交付应明确区分:
|
||||
@@ -197,5 +202,6 @@ main/ 最小菜单、LVGL UI 与独立硬件演示页
|
||||
tests/ 可脱离硬件运行的轻量逻辑测试源
|
||||
docs/ agent 硬件开发指南与扩展文档
|
||||
sdkconfig.defaults ESP32-C3、USB console、Flash、LVGL 默认配置
|
||||
partitions.csv NVS、PHY data 和 3 MB factory app 分区布局
|
||||
AGENTS.md agent 在本仓库的编码、验证和提交规则
|
||||
```
|
||||
@@ -26,6 +26,9 @@ AI 应先完成以下检查:
|
||||
| 按键 | UP/DOWN/OK 三键电阻分压 | GPIO0 / ADC1_CH0 | 已实现 |
|
||||
| 音频 | ES8311,播放 + 麦克风录音 | I2C 控制 + I2S0 全双工 | 已实现 |
|
||||
| 电池 | CW2017 电量计 | 共享 I2C0,地址 0x63 | 已实现,可缺省 |
|
||||
| Wi-Fi | ESP32-C3 2.4 GHz STA | 应用页按需初始化 | 扫描示例已实现 |
|
||||
| Bluetooth LE | ESP32-C3 NimBLE peripheral | 应用页按需初始化 | 不可连接广播示例已实现 |
|
||||
| 低功耗 | ESP32-C3 light/deep sleep | RTC timer 唤醒 | 两秒 light sleep 和五秒 deep sleep 示例已实现 |
|
||||
| 日志 | USB Serial/JTAG | 原生 USB GPIO18/19 | 已配置 |
|
||||
|
||||
仓库没有提供原理图、PCB、BOM、电池型号、充电芯片信息、LCD TE 引脚或板卡修订号。因此不能据此声称支持充电控制、USB 检测、休眠唤醒、屏幕读回、触摸或其他未在代码中出现的能力。
|
||||
@@ -68,7 +71,10 @@ app_main
|
||||
├─ Display demo
|
||||
├─ Button demo
|
||||
├─ Audio demo
|
||||
└─ Battery demo
|
||||
├─ Battery demo
|
||||
├─ Wi-Fi scan demo
|
||||
├─ Bluetooth LE advertising demo
|
||||
└─ Light-sleep demo
|
||||
```
|
||||
|
||||
显示是 UI 的硬依赖,显示或 LVGL 初始化失败时 `app_main` 直接返回。按键、音频、电池是软依赖:初始化失败的菜单项显示 `[FAIL]`,其他页面仍可用。
|
||||
@@ -84,6 +90,8 @@ app_main
|
||||
|
||||
驱动初始化大多设计为幂等,但当前没有统一 deinit API。不要假设可以在运行时反复销毁和重建总线/驱动。
|
||||
|
||||
Wi-Fi、NimBLE 和 light/deep sleep 直接使用 ESP-IDF API,不属于板级 BSP。`demo_radio.c` 只管理 NVS、`esp_netif` 和默认 event loop 这些应用级共享前置。Wi-Fi 和 BLE 页在进入时初始化高内存占用的无线栈,退出时停止并释放;不自动抹除已有 NVS 数据来掩盖分区错误。deep sleep 会按 ESP32-C3 语义重启应用,示例用 RTC slow memory 记录唤醒次数。
|
||||
|
||||
## 5. 显示与 LVGL
|
||||
|
||||
### 5.1 面板事实
|
||||
@@ -187,7 +195,7 @@ SOC 准确度取决于电芯与 profile 的匹配程度。本驱动给出的是
|
||||
|
||||
## 10. Flash、控制台和资源预算
|
||||
|
||||
FoloToy AI Passport 的所有硬件批次均使用 8 MB Flash,`sdkconfig.defaults` 因此固定使用 8 MB Flash 镜像配置;烧录时仍允许按实际探测容量更新镜像头。若实机探测结果不是 8 MB,应视为硬件、料号或连接异常并先确认,不能为了让未知板卡启动而把项目默认值降为 4 MB。
|
||||
FoloToy AI Passport 的所有硬件批次均使用 8 MB Flash,`sdkconfig.defaults` 因此固定使用 8 MB Flash 镜像配置;`partitions.csv` 提供 24 KB NVS、4 KB PHY data 和 3 MB factory app 分区,无 OTA 槽。烧录时仍允许按实际探测容量更新镜像头。若实机探测结果不是 8 MB,应视为硬件、料号或连接异常并先确认,不能为了让未知板卡启动而把项目默认值降为 4 MB。
|
||||
|
||||
控制台固定为 USB Serial/JTAG,不使用 UART0 默认输出,因为其 TX GPIO21 与背光冲突。任何日志接口修改都必须同时检查引脚占用。
|
||||
|
||||
@@ -197,6 +205,7 @@ FoloToy AI Passport 的所有硬件批次均使用 8 MB Flash,`sdkconfig.defau
|
||||
- LCD DMA buffer 约 9.6 KB;
|
||||
- I2S DMA descriptor/frame buffer;
|
||||
- Audio demo 96 KB 录音堆;
|
||||
- Wi-Fi 驱动或 NimBLE host/controller(两个示例不同时常驻);
|
||||
- 各 FreeRTOS 任务栈和最大连续空闲块。
|
||||
|
||||
新增图片、字体、网络栈、TLS、音频缓存或双缓冲时,应记录 build 后的静态 RAM/Flash 使用,并在运行时记录 free heap 与 largest free block。总 free heap 足够不代表能成功分配大连续缓冲。
|
||||
@@ -383,6 +392,9 @@ idf.py flash monitor
|
||||
| ADC/按键 | 松开和三键实测 mV、单击/双击/长按、不同电量下的裕量 |
|
||||
| codec/I2S | 1 kHz 音调频率/速度、录音非零且回放速度正确、格式切换、退出页面 |
|
||||
| 电池 | 合理 SOC 和 mV、无电量计时正确降级、断续 I2C 的错误恢复表现 |
|
||||
| Wi-Fi | 扫描总数和 SSID/RSSI 可见、OK 重扫描、反复进出后仍可扫描 |
|
||||
| Bluetooth LE | 手机看到 `FoloPassport`、OK 重启广播、退出后广播消失、反复进出无重启 |
|
||||
| light/deep sleep | Low Power 页用 UP/DOWN 选择、OK 执行;light sleep 约 2 秒后原地恢复背光;deep sleep 约 5 秒后重启,页面显示 timer 唤醒和 RTC 保留计数 |
|
||||
| DMA/内存/UI | build 内存报告、运行时最小堆/最大块、音频与刷屏并发稳定性 |
|
||||
|
||||
## 14. 故障症状速查
|
||||
@@ -401,6 +413,9 @@ idf.py flash monitor
|
||||
| 录音全零 | `no_dac_ref` 是否为 true、DIN GPIO4、麦克风通路和输入增益 |
|
||||
| 录音缓冲分配失败 | C3 无 PSRAM;缩短录音或改流式,检查 largest free block |
|
||||
| 电量显示 `--` | 0x63 是否应答、SOC 是否读到 >100/0xFF、profile/启动等待 |
|
||||
| Wi-Fi/BLE 第二次进入失败 | 退出页时是否已停止并 deinit radio stack,NVS/event loop 是否只初始化一次 |
|
||||
| light sleep 后黑屏 | timer wake source、`esp_light_sleep_start()` 错误日志、唤醒后是否恢复背光 |
|
||||
| deep sleep 后未重启 | timer wake source、启动日志的 wake cause、页面 RTC 计数;不用未验证按键作唤醒源 |
|
||||
| 加大 UI 后 I2S NO_MEM | LCD 双缓冲/LVGL pool 与 I2S DMA 争夺内部 RAM |
|
||||
|
||||
## 15. AI 提交前自检
|
||||
@@ -421,4 +436,4 @@ idf.py flash monitor
|
||||
|
||||
要把本指南提升为可用于量产的完整硬件规范,还需补充:板卡修订号和原理图、PCB/BOM、LCD 模组完整料号及初始化来源、电池型号与容量、CW2017 profile、充电/电源路径、扬声器和麦克风参数、功放型号及使能极性、I2C 外部上拉值、各电源域与最大电流、未用 GPIO 的实际连接,以及温度/电压/EMC 验证结果。
|
||||
|
||||
在这些资料缺失时,AI 可以安全开发现有 BSP 覆盖的功能,但对新增低功耗、电源控制、充电、未用引脚复用、音频功率或电池精度需求,必须先请求硬件证据。
|
||||
在这些资料缺失时,AI 可以安全开发现有 BSP 覆盖的功能,以及当前已限定的 RTC timer light/deep-sleep 验证;但对外部唤醒、板级功耗数据、电源控制、充电、未用引脚复用、音频功率或电池精度需求,必须先请求硬件证据。
|
||||
Loaded 3 of 13 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user