Files
inmp441recondtest/README.md
DESKTOP-PUHFO60\dsx2016 8f0d1d739b Gate REC/PLAY to explicit user input only.
Add boot lockout, long-press touch confirm, BOOT debounce, and
line-based serial commands so noise cannot auto-start recording.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-27 22:24:19 +08:00

107 lines
3.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CYD INMP441 录音
ESP32 Cheap Yellow Display + INMP441(I2S)→ microSD **WAV 录音**,支持 DAC 回放。
默认 **2.8" ESP32-2432S028R**;可选 **3.5" ESP32-3248S035C**(`cyd_35r`)。
引脚约定见同目录 [CYD_PROJECT_GUIDE.md](../CYD_PROJECT_GUIDE.md);麦克风接线参考 [inmp441test](../inmp441test)。
## 硬件
| 项目 | 2.8" · 2432S028R | 3.5" C · 3248S035C |
|------|------------------|---------------------|
| 屏驱 | ILI9341 | ST7796 |
| 触控 | XPT2046 **SoftSPI**(见下) | GT911 Wire1(SDA33/SCL32/INT21/RST25) |
| 背光 TFT_BL | **GPIO21** | **GPIO27** |
| INMP441 WS | **GPIO22**(CN1/P3) | **GPIO22** |
| INMP441 SCK | **GPIO27**(CN1) | **GPIO21**(CN1;勿占 27=BL) |
| INMP441 SD | **GPIO35**(P3,仅输入) | **GPIO35** |
| microSD | CS5 / SCK18 / MISO19 / MOSI23 | 同左 |
| 喇叭 | **GPIO26**(DAC2,P4) | 同左 |
接线:
| INMP441 | CYD |
|---------|-----|
| VDD | 3.3V(CN1) |
| GND | GND |
| L/R | GND(左声道,勿悬空) |
| WS | IO22 |
| SCK | IO27(2.8)/ IO21(3.5) |
| SD | IO35(P3) |
> 不要接 5V;不要占用背光脚。I2S 需要三根信号线(22 + 27/21 + 35)。
> **3.5C**:`SCK=GPIO21` 与 GT911 INT 同脚;固件先完成触控选址,再把 21 交给 I2S,触控仅轮询。
## 功能
- 触控 **REC / STOP**:录制 16 kHz / 16-bit 单声道 PCM WAV 到 `/rec/Rxxxx.WAV`
- 最长约 **120 秒**(自动停)
- 实时电平条(近似 dB,与 inmp441test 同一换算)
- **PLAY / STOP**:用板载喇叭(GPIO26)回放最近一条录音
- 需插入 **FAT32 microSD**
- 备用:板载 **BOOT** 键切换 REC;串口整行 `r` / `rec` / `p` / `play`(不会吃 USB 杂字节)
- **绝无自动开录**:无触控按钮 / BOOT / 串口整行命令;上电 4s 内锁死
## 2.8" 触控说明(重要)
本板 XPT2046 **不在硬件 SPI 上**(CLK25 / MOSI32 / MISO39 / CS33 / IRQ36),与 microSD 的 **VSPI** 冲突。固件使用 vendored [`lib/CYD28_Touchscreen`](lib/CYD28_Touchscreen)(hexeguitar SoftSPI bit-bang),把 VSPI 留给 SD。
| 项 | 做法 |
|----|------|
| 总线 | SoftSPI,读触控前拉高 `SD_CS` |
| 坐标 | raw ADC → 横屏 UI 320×240;**X/Y 均反向** 以对齐 `LVGL ROTATION_270` 画面 |
| 点击 | 只命中画出的 REC / PLAY;按住 ≥120ms 且指头不滑出按钮才算 |
| 防抖 | z≥70 且连续 5 采样;**2 s** 冷却;上电 **4 s** 动作锁 |
| 备用 | BOOT(稳定按下)/ 串口整行命令 |
参考:[RNT CYD + SoftSPI + SD](https://randomnerdtutorials.com/esp32-cyd-display-touchscreen-microsd-card/)、[hexeguitar/CYD28_Touchscreen](https://github.com/hexeguitar/CYD28_Touchscreen)。
## 构建与烧录
依赖 [PlatformIO](https://platformio.org/)。
```bash
pio run -e cyd_28r -t upload # 2.8"
pio run -e cyd_35r -t upload # 3.5C
pio device monitor -b 115200
```
### 预编译固件
| 板型 | 目录 |
|------|------|
| 2.8" | [`firmware/cyd_28r/`](firmware/cyd_28r/) |
| 3.5" | [`firmware/cyd_35r/`](firmware/cyd_35r/) |
```powershell
cd firmware\cyd_28r # 或 cyd_35r
.\flash.ps1
```
重新打包:
```powershell
.\firmware\export_from_build.ps1
.\firmware\export_from_build.ps1 -Env cyd_35r
```
## 项目结构
```
platformio.ini
include/pins.h lv_conf.h touch.h sdcard.h recorder.h player.h
src/main.cpp touch.cpp sdcard.cpp recorder.cpp player.cpp
lib/CYD28_Touchscreen/ # 2.8 SoftSPI 触控(与 SD 隔离)
scripts/exclude_lvgl_asm.py
firmware/
README.md
```
## 变更记录
| 日期 | 说明 |
|------|------|
| 2026-10-27 | 初版:INMP441 → microSD WAV 录音 + DAC 回放;双板 `cyd_28r` / `cyd_35r` |
| 2026-10-27 | 2.8 触控:SoftSPI + XY 反向校准、按钮命中区、1.5s 冷却;消除误触反复录音 |
| 2026-10-27 | 显式操作门闩:上电锁 4s、触控长按确认、BOOT 防抖、串口整行;禁止无操作自启录音 |