Restore TF card UI and speaker at 20% volume.

Keep calibrated SoftSPI touch mapping unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-17 18:43:11 +08:00
parent 7b5f984731
commit a1ab088d70
12 changed files with 581 additions and 62 deletions

View File

@@ -1,7 +1,9 @@
#include <Arduino.h>
#include <lvgl.h>
#include "audio_test.h"
#include "pins.h"
#include "sd_info.h"
#include "touch.h"
#include "ui.h"
@@ -9,19 +11,38 @@ static constexpr uint32_t DRAW_BUF_SIZE =
(SCREEN_WIDTH * SCREEN_HEIGHT / 10 * (LV_COLOR_DEPTH / 8));
static uint32_t draw_buf[DRAW_BUF_SIZE / 4];
static uint32_t last_dbg_ms = 0;
static uint32_t last_refresh_ms = 0;
static uint32_t last_btn_ui_ms = 0;
static constexpr uint32_t REFRESH_MS = 3000;
static void refresh_sd_ui() {
SdCardInfo info = sd_read_info();
Serial.println("---- TF Card ----");
if (!info.mounted) {
Serial.printf("Error: %s\n", info.error.c_str());
} else {
Serial.printf("Type: %s FS: %s Cap: %s\n", info.type, info.filesystem,
format_bytes(info.card_bytes).c_str());
}
ui_update(info);
}
void setup() {
Serial.begin(115200);
delay(200);
Serial.println();
Serial.printf("LVGL %d.%d.%d | touch test only\n", lv_version_major(),
Serial.printf("LVGL %d.%d.%d | CYD TF + Speaker\n", lv_version_major(),
lv_version_minor(), lv_version_patch());
pinMode(TFT_BL_PIN, OUTPUT);
digitalWrite(TFT_BL_PIN, HIGH);
// 先触摸再 SD:触控 SoftSPI 与 SD VSPI 分脚,映射勿改 touch.cpp
touch_init();
audio_init();
lv_init();
lv_display_t *disp =
@@ -34,15 +55,30 @@ void setup() {
lv_indev_set_display(indev, disp);
ui_create();
if (!sd_init()) {
Serial.println("SD mount failed at boot");
}
refresh_sd_ui();
last_refresh_ms = millis();
last_btn_ui_ms = millis();
}
void loop() {
lv_timer_handler();
lv_tick_inc(5);
audio_tick();
const uint32_t now = millis();
if (now - last_dbg_ms >= 50) {
last_dbg_ms = now;
if (now - last_refresh_ms >= REFRESH_MS) {
last_refresh_ms = now;
refresh_sd_ui();
}
if (now - last_btn_ui_ms >= 200) {
last_btn_ui_ms = now;
ui_refresh_audio_buttons();
ui_set_touch_debug(g_dbg_logic_x, g_dbg_logic_y, g_dbg_touch_down);
}