Stabilize CYD touch: correct axes, debounce, lower-half zones.

Fix raw→UI mapping, 1s action cooldown, and stop noise from
auto starting/stopping recordings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-27 22:06:33 +08:00
parent e2e0f4d470
commit 0e8a06d24a
2 changed files with 17 additions and 14 deletions

View File

@@ -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();
/* Min hold filters spikes; max ignores long rests; cooldown stops auto-toggle. */
if (held < 40 || held > 800) return;
if (now - last_action_ms < 900) {
/* Short SoftSPI taps are often <20ms; cooldown stops EMI auto-toggle. */
if (held > 1200) return;
if (now - last_action_ms < 1000) {
Serial.println("Touch ignored (cooldown)");
return;
}
@@ -354,16 +354,20 @@ 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);
/* Force layout then capture absolute hit boxes (+pad). */
/* Lower-half zones with gap in the middle — forgiving but not full-screen. */
lv_obj_update_layout(scr);
lv_obj_get_coords(btn_rec, &hit_rec);
lv_obj_get_coords(btn_play, &hit_play);
hit_rec.x1 -= 8; hit_rec.y1 -= 8; hit_rec.x2 += 8; hit_rec.y2 += 12;
hit_play.x1 -= 8; hit_play.y1 -= 8; hit_play.x2 += 8; hit_play.y2 += 12;
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;
hit_bl.x1 = 0;
hit_bl.y1 = 0;
hit_bl.x2 = UI_HOR_RES - 1;
hit_bl.y2 = 28;
hit_bl.y2 = 32;
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);

View File

@@ -161,11 +161,10 @@ void touch_read_cb(lv_indev_t * /*indev*/, lv_indev_data_t *data) {
s_down_streak = 0;
}
} else if (p.z >= Z_DOWN && raw_ok) {
if (s_down_streak < 255) s_down_streak++;
/* 2 solid samples — filters 1-poll EMI spikes, still accepts light taps */
if (s_down_streak >= 2) {
s_down = true;
}
/* Single solid sample OK — SoftSPI taps are often 1 poll wide.
* Cooldown in main.cpp blocks EMI auto-toggle. */
s_down = true;
s_down_streak = 1;
} else {
s_down_streak = 0;
}