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

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();