From 9beb6146e402c4b8e9879af2260899c5da3a1102 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 2 Oct 2018 19:03:06 +0200 Subject: [PATCH] trezorhal: minor cleanup in touch for T1 --- embed/trezorhal/touch.c | 2 ++ embed/trezorhal/touch_1.h | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/embed/trezorhal/touch.c b/embed/trezorhal/touch.c index 7b5bd1b597..c1ff33e99a 100644 --- a/embed/trezorhal/touch.c +++ b/embed/trezorhal/touch.c @@ -24,6 +24,8 @@ #include "touch_t.h" #elif TREZOR_MODEL == 1 #include "touch_1.h" +#else +#error Unknown TREZOR Model #endif uint32_t touch_click(void) diff --git a/embed/trezorhal/touch_1.h b/embed/trezorhal/touch_1.h index ce111ab3ba..9f1aea28e2 100644 --- a/embed/trezorhal/touch_1.h +++ b/embed/trezorhal/touch_1.h @@ -1,6 +1,11 @@ #define BTN_PIN_LEFT GPIO_PIN_5 #define BTN_PIN_RIGHT GPIO_PIN_2 +#define DISPLAY_RESX 128 +#define DISPLAY_RESY 64 +#define BTN_LEFT_COORDS touch_pack_xy(0, DISPLAY_RESY - 1) +#define BTN_RIGHT_COORDS touch_pack_xy(DISPLAY_RESX - 1, DISPLAY_RESY - 1) + void touch_init(void) { __HAL_RCC_GPIOC_CLK_ENABLE(); @@ -26,17 +31,17 @@ uint32_t touch_read(void) if (last_left != left) { last_left = left; if (left) { - return TOUCH_START | touch_pack_xy(0, 63); + return TOUCH_START | BTN_LEFT_COORDS; } else { - return TOUCH_END | touch_pack_xy(0, 63); + return TOUCH_END | BTN_LEFT_COORDS; } } if (last_right != right) { last_right = right; if (right) { - return TOUCH_START | touch_pack_xy(127, 63); + return TOUCH_START | BTN_RIGHT_COORDS; } else { - return TOUCH_END | touch_pack_xy(127, 63); + return TOUCH_END | BTN_RIGHT_COORDS; } } return 0;