From 9f9bde76dddcb71601b2b6abdb3c61f8a3c2d82d Mon Sep 17 00:00:00 2001 From: "DESKTOP-PUHFO60\\dsx2016" Date: Tue, 27 Oct 2026 22:10:31 +0800 Subject: [PATCH] Invert CYD touch X/Y to match on-screen buttons. Physical bottom-left is REC, bottom-right is PLAY; raise press threshold and 1.5s cooldown to stop false auto-record. Co-authored-by: Cursor --- src/main.cpp | 22 +++++++++------------- src/touch.cpp | 16 ++++++++-------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6ef93c8..75c7d9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -130,9 +130,9 @@ static void touchscreen_read(lv_indev_t *indev, lv_indev_data_t *data) { was_pressed = false; const uint32_t held = millis() - press_ms; const uint32_t now = millis(); - /* Short SoftSPI taps are often <20ms; cooldown stops EMI auto-toggle. */ - if (held > 1200) return; - if (now - last_action_ms < 1000) { + /* SoftSPI taps can be <15ms; 1.5s lockout kills auto start/stop. */ + if (held > 900) return; + if (now - last_action_ms < 1500) { Serial.println("Touch ignored (cooldown)"); return; } @@ -354,20 +354,16 @@ static void create_ui(void) { lv_obj_set_style_text_color(hint2, COL_MUTED, 0); lv_obj_align(hint2, LV_ALIGN_BOTTOM_MID, 0, 0); - /* Lower-half zones with gap in the middle — forgiving but not full-screen. */ + /* Hit boxes = drawn buttons (+pad). Top strip = backlight only. */ lv_obj_update_layout(scr); - hit_rec.x1 = 0; - hit_rec.x2 = UI_HOR_RES / 2 - 12; - hit_rec.y1 = 110; - hit_rec.y2 = UI_VER_RES - 1; - hit_play.x1 = UI_HOR_RES / 2 + 12; - hit_play.x2 = UI_HOR_RES - 1; - hit_play.y1 = 110; - hit_play.y2 = UI_VER_RES - 1; + lv_obj_get_coords(btn_rec, &hit_rec); + lv_obj_get_coords(btn_play, &hit_play); + hit_rec.x1 -= 10; hit_rec.y1 -= 10; hit_rec.x2 += 10; hit_rec.y2 += 14; + hit_play.x1 -= 10; hit_play.y1 -= 10; hit_play.x2 += 10; hit_play.y2 += 14; hit_bl.x1 = 0; hit_bl.y1 = 0; hit_bl.x2 = UI_HOR_RES - 1; - hit_bl.y2 = 32; + hit_bl.y2 = 28; Serial.printf("Hit REC(%d..%d,%d..%d) PLAY(%d..%d,%d..%d)\n", (int)hit_rec.x1, (int)hit_rec.x2, (int)hit_rec.y1, (int)hit_rec.y2, (int)hit_play.x1, (int)hit_play.x2, (int)hit_play.y1, (int)hit_play.y2); diff --git a/src/touch.cpp b/src/touch.cpp index b3597eb..2d595cd 100644 --- a/src/touch.cpp +++ b/src/touch.cpp @@ -129,11 +129,10 @@ void touch_read_cb(lv_indev_t * /*indev*/, lv_indev_data_t *data) { #include -/* Library thresh for XY update; our down uses hysteresis above that. - * Real presses on this panel are often z≈45–100; idle ≈5–15. */ -static constexpr int16_t Z_DOWN = 42; /* press latch */ -static constexpr int16_t Z_UP = 22; /* release */ -static constexpr int16_t RAW_MIN = 120; +/* Hysteresis: idle z≈5–15; light taps often z≈45–80. */ +static constexpr int16_t Z_DOWN = 48; +static constexpr int16_t Z_UP = 25; +static constexpr int16_t RAW_MIN = 150; static CYD28_TouchR ts(SCREEN_WIDTH, SCREEN_HEIGHT); static bool s_down = false; @@ -183,9 +182,10 @@ void touch_read_cb(lv_indev_t * /*indev*/, lv_indev_data_t *data) { return; } - /* Landscape UI 320×240: raw X→UI X, raw Y→UI Y (matches button boxes). */ - int16_t ux = (int16_t)map(p.x, 200, 3700, 0, UI_HOR_RES - 1); - int16_t uy = (int16_t)map(p.y, 240, 3800, 0, UI_VER_RES - 1); + /* Both axes inverted on this CYD + ROTATION_270 panel: + * physical bottom → high UI Y, physical left → low UI X. */ + int16_t ux = (int16_t)map(p.x, 3700, 200, 0, UI_HOR_RES - 1); + int16_t uy = (int16_t)map(p.y, 3800, 240, 0, UI_VER_RES - 1); s_ux = clampi(ux, 0, UI_HOR_RES - 1); s_uy = clampi(uy, 0, UI_VER_RES - 1);