Files
touchbtntest/README.md
DESKTOP-PUHFO60\dsx2016 e70fbd1d7f Fix 3.5C board support per CYD_PROJECT_GUIDE: BL=27, GT911 INT separate.
Correct ST7796/cyd_35r backlight, leave INT as input after reset, export firmware/cyd_35r.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-25 11:51:07 +08:00

77 lines
1.9 KiB
Markdown
Raw Permalink 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 + LVGL 壳,针对 **电容触控感应模块**(如 TTP223)单独优化:抖沿确认、最短触摸、松手再武装。
GPIO22 读模块 OUT:每次有效触摸,屏幕计数 +1。
板型约定见 [`../CYD_PROJECT_GUIDE.md`](../CYD_PROJECT_GUIDE.md) §A。
## 硬件
| 项目 | 2.8" · 2432S028R | 3.5" · 3248S035C |
|------|------------------|------------------|
| 屏 | ILI9341 240×320 | ST7796 320×480 |
| UI | 320×240 | 480×320 |
| 屏触控 | XPT2046 SoftSPI | GT911 I2C |
| 背光 | **GPIO21** | **GPIO27** |
| PlatformIO | `-e cyd` | `-e cyd_35r` |
| 感应按钮 OUT | **GPIO22**(两板相同) | **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
# 2.8"
pio run -e cyd -t upload
# 3.5" C(ST7796 + GT911,BL=27)
pio run -e cyd_35r -t upload
```
预编译包:
```powershell
# 2.8"
cd firmware\cyd
.\flash.ps1
# 3.5"
cd firmware\cyd_35r
.\flash.ps1
```
导出固件:
```powershell
.\firmware\export_from_build.ps1
.\firmware\export_from_build.ps1 -Env cyd_35r
```