From d7fef245050064d9a259b73b79ba593da9f3cf43 Mon Sep 17 00:00:00 2001 From: Eya Date: Tue, 28 Mar 2023 15:38:43 +0100 Subject: [PATCH] Update touch calibration to fix inverted touch panel on STM32F429I-DISC1 RevE-01. --- .../stm32f429i_discovery.h | 4 ++-- .../stm32f429i_discovery_ts.c | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery.h b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery.h index d429a3672..eabdc35af 100644 --- a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery.h +++ b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery.h @@ -18,8 +18,8 @@ */ /* IMPORTANT: One of the following flags must be defined in the preprocessor */ /* options in order to select the target board revision: !!!!!!!!!! */ -/* USE_STM32F429I_DISCO */ /* Applicable for all boards execept STM32F429I DISCOVERY REVD */ -/* USE_STM32F429I_DISCOVERY_REVD */ /* Applicable only for STM32F429I DISCOVERY REVD */ +/* USE_STM32F429I_DISCO */ /* Applicable for all boards except STM32F429I DISCOVERY REVD and above */ +/* USE_STM32F429I_DISCOVERY_REVD */ /* Applicable only for STM32F429I DISCOVERY REVD and above */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F429I_DISCOVERY_H diff --git a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.c b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.c index 2ae46b619..7fc5a95fd 100644 --- a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.c +++ b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_ts.c @@ -145,10 +145,26 @@ void BSP_TS_GetState(TS_StateTypeDef* TsState) if(TsState->TouchDetected) { TsDrv->GetXY(TS_I2C_ADDRESS, &x, &y); - + +#if defined (USE_STM32F429I_DISCOVERY_REVD) + if (y > 3700) + { + y = 3700; + } + else if (y < 180) + { + y = 180; + } + /* Y value first correction */ - y -= 360; - + y = 3700 - y; +#else + + /* Y value first correction */ + y -= 360; + +#endif + /* Y value second correction */ yr = y / 11;