diff options
| author | Your Name <you@example.com> | 2026-05-19 01:44:11 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 01:44:11 +0530 |
| commit | 58a0b5fd115d9687a1292e5e82e6b9fa8454b930 (patch) | |
| tree | dd9f18903d0237edcf5844c58fcb88bcf737b22c /main/touch.c | |
| parent | 699fc6c03899c3b1ff853d8c7c6cf32173436354 (diff) | |
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)
Diffstat (limited to 'main/touch.c')
| -rw-r--r-- | main/touch.c | 25 |
1 files changed, 25 insertions, 0 deletions
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"; | |||
| 11 | static i2c_master_bus_handle_t s_bus = NULL; | 11 | static i2c_master_bus_handle_t s_bus = NULL; |
| 12 | static i2c_master_dev_handle_t s_dev = NULL; | 12 | static i2c_master_dev_handle_t s_dev = NULL; |
| 13 | static bool s_initialized = false; | 13 | static bool s_initialized = false; |
| 14 | static int s_rotation = 0; | ||
| 14 | 15 | ||
| 15 | static const uint8_t s_read_cmd[11] = { | 16 | static const uint8_t s_read_cmd[11] = { |
| 16 | 0xb5, 0xab, 0xa5, 0x5a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 | 17 | 0xb5, 0xab, 0xa5, 0x5a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 |
| @@ -115,9 +116,33 @@ bool touch_read(touch_point_t *pt) { | |||
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | touch_parse_raw(data, pt); | 118 | touch_parse_raw(data, pt); |
| 119 | |||
| 120 | if (pt->touched && s_rotation != 0) { | ||
| 121 | uint16_t raw_x = pt->x; | ||
| 122 | uint16_t raw_y = pt->y; | ||
| 123 | switch (s_rotation) { | ||
| 124 | case 1: | ||
| 125 | pt->x = raw_y; | ||
| 126 | pt->y = TOUCH_MAX_X - raw_x; | ||
| 127 | break; | ||
| 128 | case 2: | ||
| 129 | pt->x = TOUCH_MAX_X - raw_x; | ||
| 130 | pt->y = TOUCH_MAX_Y - raw_y; | ||
| 131 | break; | ||
| 132 | case 3: | ||
| 133 | pt->x = TOUCH_MAX_Y - raw_y; | ||
| 134 | pt->y = raw_x; | ||
| 135 | break; | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 118 | return pt->touched; | 139 | return pt->touched; |
| 119 | } | 140 | } |
| 120 | 141 | ||
| 142 | void touch_set_rotation(int rotation) { | ||
| 143 | s_rotation = rotation; | ||
| 144 | } | ||
| 145 | |||
| 121 | void touch_deinit(void) { | 146 | void touch_deinit(void) { |
| 122 | if (s_dev) { | 147 | if (s_dev) { |
| 123 | i2c_master_bus_rm_device(s_dev); | 148 | i2c_master_bus_rm_device(s_dev); |