Add INMP441 WAV recorder for CYD 2.8/3.5.

Record 16 kHz mono PCM to microSD /rec, with level meter and DAC2 playback.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-27 21:16:13 +08:00
commit ddff48d05b
33 changed files with 1975 additions and 0 deletions

86
include/lv_conf.h Normal file
View File

@@ -0,0 +1,86 @@
#ifndef LV_CONF_H
#define LV_CONF_H
#include <stdint.h>
#define LV_COLOR_DEPTH 16
#define LV_MEM_SIZE (48 * 1024U)
#define LV_DEF_REFR_PERIOD 16
#define LV_DPI_DEF 130
/* ESP32 无 Helium,关掉以免 .S 汇编被错误预处理 */
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE
#define LV_USE_OS LV_OS_NONE
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN
#define LV_USE_LOG 0
#define LV_USE_ASSERT_NULL 1
#define LV_USE_ASSERT_MALLOC 1
#define LV_FONT_MONTSERRAT_12 1
#define LV_FONT_MONTSERRAT_14 1
#define LV_FONT_MONTSERRAT_16 1
#define LV_FONT_MONTSERRAT_20 1
#define LV_FONT_MONTSERRAT_24 1
#define LV_FONT_MONTSERRAT_28 1
#define LV_FONT_MONTSERRAT_32 1
#define LV_FONT_MONTSERRAT_40 1
#define LV_FONT_DEFAULT &lv_font_montserrat_14
#define LV_USE_FLOAT 1
#define LV_USE_MATRIX 0
#define LV_USE_LABEL 1
#define LV_LABEL_TEXT_SELECTION 0
#define LV_LABEL_LONG_TXT_HINT 1
#define LV_USE_ARC 1
#define LV_USE_BAR 1
#define LV_USE_BTN 1
#define LV_USE_BUTTON 1
#define LV_USE_IMG 1
#define LV_USE_IMAGE 1
#define LV_USE_LINE 1
#define LV_USE_SLIDER 1
#define LV_USE_SWITCH 1
#define LV_USE_TEXTAREA 0
#define LV_USE_CHECKBOX 0
#define LV_USE_DROPDOWN 0
#define LV_USE_ROLLER 0
#define LV_USE_TABLE 0
#define LV_USE_CALENDAR 0
#define LV_USE_CHART 1
#define LV_USE_KEYBOARD 0
#define LV_USE_LIST 0
#define LV_USE_MENU 0
#define LV_USE_MSGBOX 0
#define LV_USE_SPAN 0
#define LV_USE_SPINBOX 0
#define LV_USE_SPINNER 1
#define LV_USE_TABVIEW 0
#define LV_USE_TILEVIEW 0
#define LV_USE_WIN 0
#define LV_USE_LED 1
#define LV_USE_SCALE 1
#define LV_USE_THEME_DEFAULT 1
#define LV_THEME_DEFAULT_DARK 1
#define LV_THEME_DEFAULT_GROW 0
#define LV_THEME_DEFAULT_TRANSITION_TIME 80
#define LV_USE_FLEX 1
#define LV_USE_GRID 1
#define LV_USE_TFT_ESPI 1
#define LV_USE_OBSERVER 0
#define LV_USE_SYSMON 0
#define LV_USE_PROFILER 0
#define LV_USE_DEMO_WIDGETS 0
#define LV_USE_DEMO_BENCHMARK 0
#endif /* LV_CONF_H */

37
include/pins.h Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
/* CYD + INMP441 record pin truth — see ../CYD_PROJECT_GUIDE.md */
#if defined(CYD_BOARD_3248S035)
/* 3.5C ESP32-3248S035C: BL=27; free peripheral pair is 22+21 */
#define TFT_BL_PIN 27
#define I2S_WS_PIN 22
#define I2S_SCK_PIN 21
#define I2S_SD_PIN 35
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 320
#define CYD_GT911_SDA 33
#define CYD_GT911_SCL 32
#define CYD_GT911_INT 21
#define CYD_GT911_RST 25
#else
/* 2.8 ESP32-2432S028R: BL=21; free peripheral pair is 22+27; SD on P3 IO35 */
#define TFT_BL_PIN 21
#define I2S_WS_PIN 22
#define I2S_SCK_PIN 27
#define I2S_SD_PIN 35
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#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
#endif
/* On-board microSD (VSPI) + speaker amp (DAC2 only — never GPIO25) */
#define SD_MISO 19
#define SD_MOSI 23
#define SD_SCK 18
#define SD_CS 5
#define SPEAKER_PIN 26

10
include/player.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
#include <stdint.h>
void player_init(void);
bool player_play(const char *path);
void player_stop(void);
bool player_is_playing(void);
const char *player_status(void);
void player_tick(void); /* stream next chunk to DAC */

17
include/recorder.h Normal file
View File

@@ -0,0 +1,17 @@
#pragma once
#include <stdint.h>
#define REC_SAMPLE_RATE 16000
#define REC_MAX_SECONDS 120
bool recorder_mic_init(void);
bool recorder_start(void);
void recorder_stop(void);
bool recorder_is_active(void);
float recorder_level_db(void); /* smoothed approx dBFS+offset, or NAN */
uint32_t recorder_elapsed_ms(void);
uint32_t recorder_bytes_written(void);
const char *recorder_last_path(void); /* e.g. /rec/R0003.WAV */
const char *recorder_status(void);
void recorder_tick(void); /* call from loop; drains I2S → SD */

9
include/sdcard.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#include <stdint.h>
bool sd_init(void);
void sd_deinit(void);
bool sd_ready(void);
uint64_t sd_free_bytes(void);
uint64_t sd_total_bytes(void);

6
include/touch.h Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
#include <lvgl.h>
void touch_init();
void touch_read_cb(lv_indev_t *indev, lv_indev_data_t *data);