Fix touch axis map and soften press threshold.

Map raw X/Y straight to landscape UI, keep debounce/cooldown so REC
no longer auto-toggles from noise.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-27 22:04:16 +08:00
parent 4b99c229a5
commit e2e0f4d470

View File

@@ -131,9 +131,9 @@ void touch_read_cb(lv_indev_t * /*indev*/, lv_indev_data_t *data) {
/* 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 = 55; /* press latch */
static constexpr int16_t Z_UP = 28; /* release */
static constexpr int16_t RAW_MIN = 150;
static constexpr int16_t Z_DOWN = 42; /* press latch */
static constexpr int16_t Z_UP = 22; /* release */
static constexpr int16_t RAW_MIN = 120;
static CYD28_TouchR ts(SCREEN_WIDTH, SCREEN_HEIGHT);
static bool s_down = false;
@@ -162,8 +162,8 @@ void touch_read_cb(lv_indev_t * /*indev*/, lv_indev_data_t *data) {
}
} else if (p.z >= Z_DOWN && raw_ok) {
if (s_down_streak < 255) s_down_streak++;
/* Need 3 solid samples — kills SD/EMI spikes that auto-toggle REC */
if (s_down_streak >= 3) {
/* 2 solid samples — filters 1-poll EMI spikes, still accepts light taps */
if (s_down_streak >= 2) {
s_down = true;
}
} else {
@@ -184,9 +184,9 @@ void touch_read_cb(lv_indev_t * /*indev*/, lv_indev_data_t *data) {
return;
}
/* Landscape UI 320×240 (USB on left). Y-raw→X inverted for this panel. */
int16_t ux = (int16_t)map(p.y, 3800, 240, 0, UI_HOR_RES - 1);
int16_t uy = (int16_t)map(p.x, 200, 3700, 0, UI_VER_RES - 1);
/* 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);
s_ux = clampi(ux, 0, UI_HOR_RES - 1);
s_uy = clampi(uy, 0, UI_VER_RES - 1);