From 58a0b5fd115d9687a1292e5e82e6b9fa8454b930 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 May 2026 01:44:11 +0530 Subject: Dynamic layout for WiFi setup: landscape rotation, responsive render, highlight feedback - Render functions use axs15231b_get_width/height() instead of hardcoded coords - render_wifi_setup_list: dynamic item widths, screen-relative cancel button - render_wifi_setup_password: dynamic field/eye/keyboard from kb_get_layout() - render_wifi_setup_result: centered on screen, dynamic button placement - handle_wifi_setup_touch: matching dynamic hit areas, highlight_rect() feedback - Rotation lifecycle: enter_wifi_setup_rotation/exit wired into all entry/exit paths - display_enter_wifi_setup + READY/ERROR touch + SUCCESS auto-return + LIST cancel - Added kb_result_t typedef to keyboard.h (was only in .c) - Fixed test_keyboard.c: use computed offsets from kb_layout_t defaults - All 101 unit tests pass (touch:19, keyboard:46, wifi_setup:36) --- main/touch.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'main/touch.c') diff --git a/main/touch.c b/main/touch.c index 5a1eec9..a28d13e 100644 --- a/main/touch.c +++ b/main/touch.c @@ -11,6 +11,7 @@ static const char *TAG = "touch"; static i2c_master_bus_handle_t s_bus = NULL; static i2c_master_dev_handle_t s_dev = NULL; static bool s_initialized = false; +static int s_rotation = 0; static const uint8_t s_read_cmd[11] = { 0xb5, 0xab, 0xa5, 0x5a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 @@ -115,9 +116,33 @@ bool touch_read(touch_point_t *pt) { } touch_parse_raw(data, pt); + + if (pt->touched && s_rotation != 0) { + uint16_t raw_x = pt->x; + uint16_t raw_y = pt->y; + switch (s_rotation) { + case 1: + pt->x = raw_y; + pt->y = TOUCH_MAX_X - raw_x; + break; + case 2: + pt->x = TOUCH_MAX_X - raw_x; + pt->y = TOUCH_MAX_Y - raw_y; + break; + case 3: + pt->x = TOUCH_MAX_Y - raw_y; + pt->y = raw_x; + break; + } + } + return pt->touched; } +void touch_set_rotation(int rotation) { + s_rotation = rotation; +} + void touch_deinit(void) { if (s_dev) { i2c_master_bus_rm_device(s_dev); -- cgit v1.2.3