Files
touchbtntest/README.md
DESKTOP-PUHFO60\dsx2016 7f0f391705 Add capacitive touch-button test optimized from btntest.
TTP223-style debounce (majority, min touch, rearm), SoftSPI+LVGL shell, flashable firmware/cyd.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 13:15:39 +08:00

63 lines
1.5 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)
复用 [btntest](../btntest) 的 CYD + SoftSPI 触控 + LVGL 壳,针对 **电容触控感应模块**(如 TTP223)单独优化:抖沿确认、最短触摸、松手再武装。
GPIO22 读模块 OUT:每次有效触摸,屏幕计数 +1。
## 硬件
| 项目 | 说明 |
|------|------|
| 板子 | CYD ESP32-2432S028R |
| 模块 | 三脚触控感应(VCC / GND / OUT),典型 TTP223 |
| 输出 | **GPIO22** |
### 接线
| 模块 | CYD |
|------|-----|
| VCC / 3.3V | **3.3V** |
| GND | **GND** |
| OUT / S / DO | **GPIO22** |
开机自动采空闲电平,反相视为触摸(兼容「触摸变高」或「触摸变低」)。引脚用浮空 `INPUT`(推挽输出,不上/下拉)。
屏上 `OUT HIGH/LOW` 与 `act=`:触摸时 OUT 应变到 `act` 那一侧并 +1;`hold` / 进度条显示持续触摸。
## 相对机械轻触的优化
| 点 | 说明 |
|----|------|
| 多数表决 | 5 次采样,压接近阈值时的抖沿 |
| 积分迟滞 | 更宽进入/离开门限 |
| 最短确认 | 稳定触摸 ≥ 35ms 才计 1 次 |
| 松手再武装 | 松开后再冷却 120ms,防悬停连计 |
| UI | 显示 TOUCHING / hold ms / 触摸条 |
上电时请勿按住感应区。
## 操作
- 轻触感应面一次:计数 +1
- 屏上触控 **Reset**:清零
## 构建 / 烧录
```bash
pio run -e cyd -t upload
```
预编译包:
```powershell
cd firmware\cyd
.\flash.ps1
# 或 .\flash.ps1 -Port COMx
```
导出固件:
```powershell
.\firmware\export_from_build.ps1
```