Files
inmp441recondtest/README.md
DESKTOP-PUHFO60\dsx2016 b8527e9fb8 Document working SoftSPI touch calibration and ship firmware.
Record XY invert, button hit-test, and 1.5s cooldown in README;
refresh cyd_28r prebuilt binaries.

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

105 lines
3.6 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;串口 `115200` 发 `r` / `p` 切换录音 / 播放
## 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 区域(带边距);松手触发 |
| 防抖 | 压力滞回 + **1.5 s** 动作冷却,避免误触反复开停录音 |
| 备用 | BOOT / 串口 `r`·`p`(触控异常时仍可用) |
参考:[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 冷却;消除误触反复录音 |