From 77ab354a5a957ea75c2d433fc17ccdec6bddaddb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 13 Aug 2020 21:17:48 -0500 Subject: [PATCH] Fix touch test --- Marlin/src/lcd/touch/xpt2046.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/touch/xpt2046.cpp b/Marlin/src/lcd/touch/xpt2046.cpp index 1fed5b78f0..4407d945d3 100644 --- a/Marlin/src/lcd/touch/xpt2046.cpp +++ b/Marlin/src/lcd/touch/xpt2046.cpp @@ -133,12 +133,14 @@ uint8_t XPT2046::read_buttons() { // Touch within the button area simulates an encoder button if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT) return WITHIN(x, 14, 77) ? EN_D - : WITHIN(x, 90, 153) ? EN_A - : WITHIN(x, 166, 229) ? EN_B - : WITHIN(x, 242, 305) ? EN_C - : 0; + : WITHIN(x, 90, 153) ? EN_A + : WITHIN(x, 166, 229) ? EN_B + : WITHIN(x, 242, 305) ? EN_C + : 0; - if (x > TOUCH_SENSOR_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0; + if ( !WITHIN(x, SCREEN_START_LEFT, SCREEN_START_LEFT + SCREEN_WIDTH) + || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT) + ) return 0; // Column and row above BUTTON_AREA_TOP int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH), @@ -161,6 +163,7 @@ bool XPT2046::isTouched() { } #if ENABLED(TOUCH_BUTTONS_HW_SPI) + #include static void touch_spi_init(uint8_t spiRate) {