Add 3-pin whistle sound sensor digital H/L detect on GPIO22.

Touch+LVGL UI shows QUIET/SOUND, pin level, hit count; no dB (digital only).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-23 13:47:52 +08:00
commit b2052a7771
23 changed files with 1875 additions and 0 deletions

1127
include/lv_conf.h Normal file

File diff suppressed because it is too large Load Diff

21
include/pins.h Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
// CYD ESP32-2432S028R — 触控/屏脚与 tftest 一致
#define TFT_BL_PIN 21
#define CYD_TOUCH_IRQ 36
#define CYD_TOUCH_MOSI 32
#define CYD_TOUCH_MISO 39
#define CYD_TOUCH_CLK 25
#define CYD_TOUCH_CS 33
// 三针口哨/声音传感器:OUT 高低电平(常见:有声=HIGH)
#define SOUND_PIN 22
// 1 = 高电平表示检测到声音;若模块相反改成 0
#define SOUND_ACTIVE_HIGH 1
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define UI_HOR_RES 320
#define UI_VER_RES 240

20
include/sound.h Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <stdint.h>
void sound_init();
void sound_poll();
/** 当前是否检测到声音(已按 SOUND_ACTIVE_HIGH 解释) */
bool sound_detected();
/** 原始引脚电平:true=HIGH */
bool sound_raw_high();
/** 累计触发次数(边沿,带消抖) */
uint32_t sound_event_count();
/** 最近一次触发后经过的 ms;未触发过为 UINT32_MAX */
uint32_t sound_ms_since_last();
void sound_reset_count();

12
include/touch.h Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
#include <lvgl.h>
#include <stdint.h>
void touch_init();
void touch_read_cb(lv_indev_t *indev, lv_indev_data_t *data);
// 调试:最近一次触点(物理 / LVGL 旋转后逻辑)
extern int16_t g_dbg_phys_x, g_dbg_phys_y;
extern int16_t g_dbg_logic_x, g_dbg_logic_y;
extern bool g_dbg_touch_down;

4
include/ui.h Normal file
View File

@@ -0,0 +1,4 @@
#pragma once
void ui_create();
void ui_tick();