diff --git a/firmware/cyd_28r/VERSION.txt b/firmware/cyd_28r/VERSION.txt index 10037e9..c4c6408 100644 --- a/firmware/cyd_28r/VERSION.txt +++ b/firmware/cyd_28r/VERSION.txt @@ -1,5 +1,5 @@ name: CYD inmp441recondtest (cyd_28r) -git: 994d21c +git: 024fcd8 date: 2026-10-27 board: ESP32-2432S028R (ILI9341) inmp441: WS=GPIO22 SCK=GPIO27 SD=GPIO35 @@ -14,5 +14,5 @@ offsets: sha256: bootloader.bin 3D234A7471F67B013686DABD4DEE7C1FA915C9928463616A94BC9297ACF1ABF8 boot_app0.bin F94C5D786A7A8FAB06AC5D10E33BF37711A6697636DC037559EA19CC410A17F0 - firmware.bin 98431C01560E890DBE3F2BDE0A42AA6CFFBDF356FB8172B6FE755CB1FFC3AE99 + firmware.bin CDC0616C236CA29B7849A2CA63A49D3CB1811ED8FA20C087B5F84503D55DFDB4 partitions.bin 0A8B5720E7B77FF11F1462458C3A509DEE79224E5279898F26D6A2E3AE0517B7 diff --git a/firmware/cyd_28r/firmware.bin b/firmware/cyd_28r/firmware.bin index 1e06059..16863ff 100644 Binary files a/firmware/cyd_28r/firmware.bin and b/firmware/cyd_28r/firmware.bin differ diff --git a/src/main.cpp b/src/main.cpp index ad4b6e5..f1b8d3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -93,19 +93,6 @@ static const char *basename_of(const char *path) { return p ? p + 1 : path; } -/* Mirror LVGL 9 ROTATION_270 indev transform (create 240×320). */ -static void native_to_ui(int16_t nx, int16_t ny, int16_t *ux, int16_t *uy) { - int32_t x = nx; - int32_t y = ny; - x = SCREEN_WIDTH - x - 1; - y = SCREEN_HEIGHT - y - 1; - int32_t tmp = y; - y = x; - x = SCREEN_HEIGHT - tmp - 1; - *ux = (int16_t)x; - *uy = (int16_t)y; -} - static void touchscreen_read(lv_indev_t *indev, lv_indev_data_t *data) { static bool was_pressed = false; static uint32_t press_ms = 0; @@ -114,9 +101,15 @@ static void touchscreen_read(lv_indev_t *indev, lv_indev_data_t *data) { touch_read_cb(indev, data); + /* Touch already reports landscape UI coords (320×240). LVGL still applies + * ROTATION_270 transform on indev — undo it so widgets + hit-test match. */ if (data->state == LV_INDEV_STATE_PRESSED) { - int16_t ux = 0, uy = 0; - native_to_ui(data->point.x, data->point.y, &ux, &uy); + const int16_t ux = data->point.x; + const int16_t uy = data->point.y; + /* Inverse of LVGL ROTATION_270: UI(ux,uy) → native(nx,ny) for indev feed */ + data->point.x = uy; + data->point.y = (int16_t)(UI_HOR_RES - 1 - ux); + if (!was_pressed) { was_pressed = true; press_ms = millis(); @@ -131,20 +124,20 @@ static void touchscreen_read(lv_indev_t *indev, lv_indev_data_t *data) { was_pressed = false; uint32_t held = millis() - press_ms; if (held < 700) { - /* Direct hit-test in landscape UI — bypass flaky LVGL button hitboxes. */ + /* Hit-test only (no LV_EVENT_CLICKED) — avoids double toggle. + * Top strip = backlight; everything else is half-screen REC | PLAY + * (touch Y cal is coarse on SoftSPI CYD — don't require exact button box). */ if (press_uy < 36) { set_backlight((bright_level + 1) & 0x03); char buf[24]; lv_snprintf(buf, sizeof(buf), "brightness %u/3", (unsigned)bright_level); show_hint(buf, 900); - } else if (press_uy > 130) { - if (press_ux < (UI_HOR_RES / 2)) { - Serial.println("Hit → REC"); - do_rec_toggle(); - } else { - Serial.println("Hit → PLAY"); - do_play_toggle(); - } + } else if (press_ux < (UI_HOR_RES / 2)) { + Serial.println("Hit → REC"); + do_rec_toggle(); + } else { + Serial.println("Hit → PLAY"); + do_play_toggle(); } } } @@ -320,7 +313,7 @@ static void create_ui(void) { lv_obj_align(btn_rec, LV_ALIGN_BOTTOM_LEFT, 0, -18); style_btn(btn_rec, COL_REC); lv_obj_set_ext_click_area(btn_rec, 16); - lv_obj_add_event_cb(btn_rec, on_rec_clicked, LV_EVENT_CLICKED, nullptr); + lv_obj_clear_flag(btn_rec, LV_OBJ_FLAG_CLICKABLE); /* hit-test in touchscreen_read */ lbl_rec = lv_label_create(btn_rec); lv_label_set_text(lbl_rec, "REC"); lv_obj_set_style_text_font(lbl_rec, &lv_font_montserrat_16, 0); @@ -333,7 +326,7 @@ static void create_ui(void) { lv_obj_align(btn_play, LV_ALIGN_BOTTOM_RIGHT, 0, -18); style_btn(btn_play, COL_ACCENT); lv_obj_set_ext_click_area(btn_play, 16); - lv_obj_add_event_cb(btn_play, on_play_clicked, LV_EVENT_CLICKED, nullptr); + lv_obj_clear_flag(btn_play, LV_OBJ_FLAG_CLICKABLE); /* hit-test in touchscreen_read */ lbl_play = lv_label_create(btn_play); lv_label_set_text(lbl_play, "PLAY"); lv_obj_set_style_text_font(lbl_play, &lv_font_montserrat_16, 0); diff --git a/src/touch.cpp b/src/touch.cpp index 944fdc9..3714d86 100644 --- a/src/touch.cpp +++ b/src/touch.cpp @@ -160,15 +160,17 @@ void touch_read_cb(lv_indev_t * /*indev*/, lv_indev_data_t *data) { return; } - /* Random Nerd Tutorials LVGL9 mapping → native 240×320 feed - * (lv_display_set_rotation 270 transforms to 320×240 UI). */ - int16_t x = (int16_t)map(p.x, 200, 3700, 1, SCREEN_WIDTH); - int16_t y = (int16_t)map(p.y, 240, 3800, 1, SCREEN_HEIGHT); - x = clampi(x, 0, SCREEN_WIDTH - 1); - y = clampi(y, 0, SCREEN_HEIGHT - 1); + /* Map raw ADC → landscape UI 320×240 directly (USB-left / ROTATION_270). + * Do NOT feed portrait+let-LVGL-rotate: LVGL 9.2 90/270 indev math is + * swapped on many CYD builds (see lvgl#10052). Invert Y raw→X so left + * physical taps land on left UI half. */ + 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); + ux = clampi(ux, 0, UI_HOR_RES - 1); + uy = clampi(uy, 0, UI_VER_RES - 1); - data->point.x = x; - data->point.y = y; + data->point.x = ux; + data->point.y = uy; data->state = LV_INDEV_STATE_PRESSED; }