From 368283f0e4b33c1d56541de2d2567060510571e0 Mon Sep 17 00:00:00 2001 From: Calvin Hass Date: Mon, 4 Jan 2021 20:21:27 -0800 Subject: [PATCH 1/2] Add support for capacitive display calibration --- .../diag_ard_touch_calib.ino | 59 +++++++++---------- .../diag_ard_touch_test.ino | 8 +-- src/GUIslice.h | 8 +-- src/GUIslice_drv_adagfx.cpp | 12 ++-- src/GUIslice_drv_adagfx.h | 8 +++ src/GUIslice_drv_tft_espi.cpp | 20 +++---- src/GUIslice_drv_tft_espi.h | 8 +++ src/GUIslice_drv_utft.cpp | 12 ++-- src/GUIslice_drv_utft.h | 7 +++ 9 files changed, 81 insertions(+), 61 deletions(-) diff --git a/examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino b/examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino index f61495bc1..c8259e745 100644 --- a/examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino +++ b/examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino @@ -29,16 +29,9 @@ // ------------------------------------------------------------ // CALIB: Check configuration settings // ------------------------------------------------------------ -#if defined(DRV_TOUCH_ADA_STMPE610) -#elif defined(DRV_TOUCH_ADA_SIMPLE) -#elif defined(DRV_TOUCH_ADA_RA8875) -#elif defined(DRV_TOUCH_ADA_RA8875_SUMO) -#elif defined(DRV_TOUCH_XPT2046_STM) -#elif defined(DRV_TOUCH_XPT2046_PS) -#elif defined(DRV_TOUCH_TFT_ESPI) -#else - #error "Calibration only supported for resistive touch displays" -#endif // DRV_TOUCH_* +#if !defined(DRV_TOUCH_CALIB) + #warning "Calibration not expected for this display" +#endif // DRV_TOUCH_CALIB #define DO_CALIB // ------------------------------------------------------------ @@ -196,23 +189,27 @@ uint16_t m_nPointBufCnt = 0; // displays, a typical range might be 200...3700, implying // a full-scale range of 3500. One would expect to obtain // calibration ranges in excess of 10% of the full-scale range. -#define DET_RAW_RANGE_MIN 350 +// For resistive displays, a default of 350 is reasonable +// For capacitive displays, a default of 50 is reasonable +#define DET_RAW_RANGE_MIN 50 // Define the maximum variance between readings that are // expected to be on the same side of the display (eg. X:TL/BL) // Exceeding this value will cause the sketch to report // that the calibration has failed, likely due to a pin // wiring issue. +// For resistive displays, a default of 350 is reasonable +// For capacitive displays, a default of 50 is reasonable #define DET_RAW_VAR_MAX 350 int16_t m_nPointFinalX = -1; int16_t m_nPointFinalY = -1; // Corner readings before adjusting for offsets -uint16_t m_nTouchCalXMinRaw; -uint16_t m_nTouchCalXMaxRaw; -uint16_t m_nTouchCalYMinRaw; -uint16_t m_nTouchCalYMaxRaw; +int16_t m_nTouchCalXMinRaw; +int16_t m_nTouchCalXMaxRaw; +int16_t m_nTouchCalYMinRaw; +int16_t m_nTouchCalYMaxRaw; // Preserve reading ranges int16_t m_nTouchCalXRngRaw; int16_t m_nTouchCalYRngRaw; @@ -236,10 +233,10 @@ int16_t m_nTouchYMax; int16_t m_nTouchZMin; int16_t m_nTouchZMax; -uint16_t m_nTouchCalXMin; -uint16_t m_nTouchCalXMax; -uint16_t m_nTouchCalYMin; -uint16_t m_nTouchCalYMax; +int16_t m_nTouchCalXMin; +int16_t m_nTouchCalXMax; +int16_t m_nTouchCalYMin; +int16_t m_nTouchCalYMax; bool m_bRemapYX = false; @@ -766,10 +763,10 @@ void ReportCalibResult() return; } - GSLC_DEBUG_PRINT(" #define ADATOUCH_X_MIN %u\n", m_nTouchCalXMin); - GSLC_DEBUG_PRINT(" #define ADATOUCH_X_MAX %u\n", m_nTouchCalXMax); - GSLC_DEBUG_PRINT(" #define ADATOUCH_Y_MIN %u\n", m_nTouchCalYMin); - GSLC_DEBUG_PRINT(" #define ADATOUCH_Y_MAX %u\n", m_nTouchCalYMax); + GSLC_DEBUG_PRINT(" #define ADATOUCH_X_MIN %d\n", m_nTouchCalXMin); + GSLC_DEBUG_PRINT(" #define ADATOUCH_X_MAX %d\n", m_nTouchCalXMax); + GSLC_DEBUG_PRINT(" #define ADATOUCH_Y_MIN %d\n", m_nTouchCalYMin); + GSLC_DEBUG_PRINT(" #define ADATOUCH_Y_MAX %d\n", m_nTouchCalYMax); GSLC_DEBUG_PRINT(" #define ADATOUCH_REMAP_YX %u\n", m_bRemapYX); @@ -805,13 +802,13 @@ void ReportCalibResult() void DrawCalibResult() { - snprintf(m_acTxt, MAX_STR, "ADATOUCH_X_MIN: %u", m_nTouchCalXMin); + snprintf(m_acTxt, MAX_STR, "ADATOUCH_X_MIN: %d", m_nTouchCalXMin); gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y + 00, m_pFont, m_acTxt, GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK); - snprintf(m_acTxt, MAX_STR, "ADATOUCH_Y_MIN: %u", m_nTouchCalYMin); + snprintf(m_acTxt, MAX_STR, "ADATOUCH_Y_MIN: %d", m_nTouchCalYMin); gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y + 20, m_pFont, m_acTxt, GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK); - snprintf(m_acTxt, MAX_STR, "ADATOUCH_X_MAX: %u", m_nTouchCalXMax); + snprintf(m_acTxt, MAX_STR, "ADATOUCH_X_MAX: %d", m_nTouchCalXMax); gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y + 40, m_pFont, m_acTxt, GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK); - snprintf(m_acTxt, MAX_STR, "ADATOUCH_Y_MAX: %u", m_nTouchCalYMax); + snprintf(m_acTxt, MAX_STR, "ADATOUCH_Y_MAX: %d", m_nTouchCalYMax); gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y + 60, m_pFont, m_acTxt, GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK); if (m_bTouchCalFail) { @@ -1252,7 +1249,7 @@ void setup() GSLC_DEBUG_PRINT("\n=== Touch Testing ===\n\n", ""); #endif - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) // Reset to calibration defaults from configuration m_nTouchCalXMin = ADATOUCH_X_MIN; m_nTouchCalXMax = ADATOUCH_X_MAX; @@ -1263,7 +1260,7 @@ void setup() #else m_bRemapYX = false; #endif - GSLC_DEBUG_PRINT("CALIB: Config defaults: XMin=%u XMax=%u YMin=%u YMax=%u RemapYX=%u\n", + GSLC_DEBUG_PRINT("CALIB: Config defaults: XMin=%d XMax=%d YMin=%d YMax=%d RemapYX=%u\n", ADATOUCH_X_MIN, ADATOUCH_X_MAX, ADATOUCH_Y_MIN, ADATOUCH_Y_MAX,m_bRemapYX); #if defined(DRV_DISP_ADAGFX_MCUFRIEND) @@ -1272,7 +1269,7 @@ void setup() GSLC_DEBUG_PRINT("%s ", m_acTxt); #endif - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB GSLC_DEBUG_PRINT("\n", ""); } @@ -1318,4 +1315,4 @@ void loop() gslc_Quit(&m_gui); while (1) {} } -} \ No newline at end of file +} diff --git a/examples/arduino/diag_ard_touch_test/diag_ard_touch_test.ino b/examples/arduino/diag_ard_touch_test/diag_ard_touch_test.ino index 2505577fd..78454bb4d 100644 --- a/examples/arduino/diag_ard_touch_test/diag_ard_touch_test.ino +++ b/examples/arduino/diag_ard_touch_test/diag_ard_touch_test.ino @@ -396,7 +396,7 @@ void setup() GSLC_DEBUG_PRINT("\n=== Touch Testing ===\n\n", ""); #endif - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) // Reset to calibration defaults from configuration m_nTouchCalXMin = ADATOUCH_X_MIN; m_nTouchCalXMax = ADATOUCH_X_MAX; @@ -407,7 +407,7 @@ void setup() #else m_bRemapYX = false; #endif - GSLC_DEBUG_PRINT("CALIB: Config defaults: XMin=%u XMax=%u YMin=%u YMax=%u RemapYX=%u\n", + GSLC_DEBUG_PRINT("CALIB: Config defaults: XMin=%d XMax=%d YMin=%d YMax=%d RemapYX=%u\n", ADATOUCH_X_MIN, ADATOUCH_X_MAX, ADATOUCH_Y_MIN, ADATOUCH_Y_MAX,m_bRemapYX); #if defined(DRV_DISP_ADAGFX_MCUFRIEND) @@ -416,7 +416,7 @@ void setup() GSLC_DEBUG_PRINT("%s ", m_acTxt); #endif - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB GSLC_DEBUG_PRINT("\n", ""); } @@ -462,4 +462,4 @@ void loop() gslc_Quit(&m_gui); while (1) {} } -} \ No newline at end of file +} diff --git a/src/GUIslice.h b/src/GUIslice.h index cb39018b7..cdeb07291 100755 --- a/src/GUIslice.h +++ b/src/GUIslice.h @@ -729,10 +729,10 @@ typedef struct { uint8_t nFlipX; ///< Adafruit GFX Touch Flip x axis uint8_t nFlipY; ///< Adafruit GFX Touch Flip x axis // Calibration for resistive touch displays - uint16_t nTouchCalXMin; ///< Calibration X minimum reading - uint16_t nTouchCalXMax; ///< Calibration X maximum reading - uint16_t nTouchCalYMin; ///< Calibration Y minimum reading - uint16_t nTouchCalYMax; ///< Calibration Y maximum reading + int16_t nTouchCalXMin; ///< Calibration X minimum reading + int16_t nTouchCalXMax; ///< Calibration X maximum reading + int16_t nTouchCalYMin; ///< Calibration Y minimum reading + int16_t nTouchCalYMax; ///< Calibration Y maximum reading #endif gslc_tsFont* asFont; ///< Collection of loaded fonts diff --git a/src/GUIslice_drv_adagfx.cpp b/src/GUIslice_drv_adagfx.cpp index a7e3e49e6..52c645368 100755 --- a/src/GUIslice_drv_adagfx.cpp +++ b/src/GUIslice_drv_adagfx.cpp @@ -2277,12 +2277,12 @@ bool gslc_TDrvInitTouch(gslc_tsGui* pGui,const char* acDev) { (void)acDev; // Unused // Capture default calibration settings for resistive displays - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) pGui->nTouchCalXMin = ADATOUCH_X_MIN; pGui->nTouchCalXMax = ADATOUCH_X_MAX; pGui->nTouchCalYMin = ADATOUCH_Y_MIN; pGui->nTouchCalYMax = ADATOUCH_Y_MAX; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB // Support touch controllers with swapped X & Y #if defined(ADATOUCH_REMAP_YX) @@ -2925,7 +2925,7 @@ bool gslc_TDrvGetTouch(gslc_tsGui* pGui,int16_t* pnX,int16_t* pnY,uint16_t* pnPr nInputY = nRawY; // For resistive displays, perform constraint and scaling - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) if (pGui->bTouchRemapEn) { // Perform scaling from input to output // - Calibration done in native orientation (GSLC_ROTATE=0) @@ -2953,14 +2953,14 @@ bool gslc_TDrvGetTouch(gslc_tsGui* pGui,int16_t* pnX,int16_t* pnY,uint16_t* pnPr // No scaling from input to output nOutputX = nInputX; nOutputY = nInputY; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB #ifdef DBG_TOUCH GSLC_DEBUG_PRINT("DBG: PreRotate: x=%u y=%u\n", nOutputX, nOutputY); - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) GSLC_DEBUG_PRINT("DBG: RotateCfg: remap=%u nSwapXY=%u nFlipX=%u nFlipY=%u\n", pGui->bTouchRemapEn,pGui->nSwapXY,pGui->nFlipX,pGui->nFlipY); - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB #endif // DBG_TOUCH // Perform remapping due to current orientation diff --git a/src/GUIslice_drv_adagfx.h b/src/GUIslice_drv_adagfx.h index 95c503013..8d69247c0 100755 --- a/src/GUIslice_drv_adagfx.h +++ b/src/GUIslice_drv_adagfx.h @@ -89,6 +89,14 @@ extern "C" { #elif defined(DRV_TOUCH_NONE) #endif // DRV_TOUCH_* +// Determine if calibration required +// - Enable for resistive displays +// - User config can also enable for capacitive displays by adding: +// #define DRV_TOUCH_CALIB +#if defined(DRV_TOUCH_TYPE_RES) + #define DRV_TOUCH_CALIB +#endif + // ======================================================================= // API support definitions diff --git a/src/GUIslice_drv_tft_espi.cpp b/src/GUIslice_drv_tft_espi.cpp index 376b780f1..df1d70d21 100755 --- a/src/GUIslice_drv_tft_espi.cpp +++ b/src/GUIslice_drv_tft_espi.cpp @@ -1204,12 +1204,12 @@ bool gslc_DrvInitTouch(gslc_tsGui* pGui, const char* acDev) { #endif // Load calibration settings for resistive displays from config - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) pGui->nTouchCalXMin = ADATOUCH_X_MIN; pGui->nTouchCalXMax = ADATOUCH_X_MAX; pGui->nTouchCalYMin = ADATOUCH_Y_MIN; pGui->nTouchCalYMax = ADATOUCH_Y_MAX; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB // Support touch controllers with swapped X & Y #if defined(ADATOUCH_REMAP_YX) @@ -1339,7 +1339,7 @@ bool gslc_DrvGetTouch(gslc_tsGui* pGui, int16_t* pnX, int16_t* pnY, uint16_t* pn nInputY = nRawY; // For resistive displays, perform constraint and scaling - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) if (pGui->bTouchRemapEn) { // Perform scaling from input to output // - Calibration done in native orientation (GSLC_ROTATE=0) @@ -1378,7 +1378,7 @@ bool gslc_DrvGetTouch(gslc_tsGui* pGui, int16_t* pnX, int16_t* pnY, uint16_t* pn // No scaling from input to output nOutputX = nInputX; nOutputY = nInputY; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB #ifdef DBG_TOUCH GSLC_DEBUG_PRINT("DBG: PreRotate: x=%u y=%u\n", nOutputX, nOutputY); @@ -1571,12 +1571,12 @@ bool gslc_DrvGetTouch(gslc_tsGui* pGui, int16_t* pnX, int16_t* pnY, uint16_t* pn bool gslc_TDrvInitTouch(gslc_tsGui* pGui,const char* acDev) { // Capture default calibration settings for resistive displays - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) pGui->nTouchCalXMin = ADATOUCH_X_MIN; pGui->nTouchCalXMax = ADATOUCH_X_MAX; pGui->nTouchCalYMin = ADATOUCH_Y_MIN; pGui->nTouchCalYMax = ADATOUCH_Y_MAX; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB // Support touch controllers with swapped X & Y #if defined(ADATOUCH_REMAP_YX) @@ -2017,7 +2017,7 @@ bool gslc_TDrvGetTouch(gslc_tsGui* pGui,int16_t* pnX,int16_t* pnY,uint16_t* pnPr nInputY = nRawY; // For resistive displays, perform constraint and scaling - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) if (pGui->bTouchRemapEn) { // Perform scaling from input to output // - Calibration done in native orientation (GSLC_ROTATE=0) @@ -2045,14 +2045,14 @@ bool gslc_TDrvGetTouch(gslc_tsGui* pGui,int16_t* pnX,int16_t* pnY,uint16_t* pnPr // No scaling from input to output nOutputX = nInputX; nOutputY = nInputY; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB #ifdef DBG_TOUCH GSLC_DEBUG_PRINT("DBG: PreRotate: x=%u y=%u\n", nOutputX, nOutputY); - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) GSLC_DEBUG_PRINT("DBG: RotateCfg: remap=%u nSwapXY=%u nFlipX=%u nFlipY=%u\n", pGui->bTouchRemapEn,pGui->nSwapXY,pGui->nFlipX,pGui->nFlipY); - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB #endif // DBG_TOUCH // Perform remapping due to current orientation diff --git a/src/GUIslice_drv_tft_espi.h b/src/GUIslice_drv_tft_espi.h index a09966a39..9877c493f 100755 --- a/src/GUIslice_drv_tft_espi.h +++ b/src/GUIslice_drv_tft_espi.h @@ -79,6 +79,14 @@ extern "C" { #elif defined(DRV_TOUCH_NONE) #endif // DRV_TOUCH_* +// Determine if calibration required +// - Enable for resistive displays +// - User config can also enable for capacitive displays by adding: +// #define DRV_TOUCH_CALIB +#if defined(DRV_TOUCH_TYPE_RES) + #define DRV_TOUCH_CALIB +#endif + // Additional defines // - Provide default if not in config file #if !defined(GSLC_SPIFFS_EN) diff --git a/src/GUIslice_drv_utft.cpp b/src/GUIslice_drv_utft.cpp index 0ddba7f3d..8cb66eac7 100644 --- a/src/GUIslice_drv_utft.cpp +++ b/src/GUIslice_drv_utft.cpp @@ -978,12 +978,12 @@ bool gslc_DrvGetTouch(gslc_tsGui* pGui,int16_t* pnX,int16_t* pnY,uint16_t* pnPre bool gslc_TDrvInitTouch(gslc_tsGui* pGui,const char* acDev) { // Capture default calibration settings for resistive displays - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) pGui->nTouchCalXMin = ADATOUCH_X_MIN; pGui->nTouchCalXMax = ADATOUCH_X_MAX; pGui->nTouchCalYMin = ADATOUCH_Y_MIN; pGui->nTouchCalYMax = ADATOUCH_Y_MAX; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB // Support touch controllers with swapped X & Y #if defined(ADATOUCH_REMAP_YX) @@ -1157,7 +1157,7 @@ bool gslc_TDrvGetTouch(gslc_tsGui* pGui,int16_t* pnX,int16_t* pnY,uint16_t* pnPr nInputY = nRawY; // For resistive displays, perform constraint and scaling - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) if (pGui->bTouchRemapEn) { // Perform scaling from input to output // - Calibration done in native orientation (GSLC_ROTATE=0) @@ -1185,14 +1185,14 @@ bool gslc_TDrvGetTouch(gslc_tsGui* pGui,int16_t* pnX,int16_t* pnY,uint16_t* pnPr // No scaling from input to output nOutputX = nInputX; nOutputY = nInputY; - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB #ifdef DBG_TOUCH GSLC_DEBUG_PRINT("DBG: PreRotate: x=%u y=%u\n", nOutputX, nOutputY); - #if defined(DRV_TOUCH_TYPE_RES) + #if defined(DRV_TOUCH_CALIB) GSLC_DEBUG_PRINT("DBG: RotateCfg: remap=%u nSwapXY=%u nFlipX=%u nFlipY=%u\n", pGui->bTouchRemapEn,pGui->nSwapXY,pGui->nFlipX,pGui->nFlipY); - #endif // DRV_TOUCH_TYPE_RES + #endif // DRV_TOUCH_CALIB #endif // DBG_TOUCH // Perform remapping due to current orientation diff --git a/src/GUIslice_drv_utft.h b/src/GUIslice_drv_utft.h index 3f7abd7fb..6e87377fb 100644 --- a/src/GUIslice_drv_utft.h +++ b/src/GUIslice_drv_utft.h @@ -62,6 +62,13 @@ extern "C" { #elif defined(DRV_TOUCH_NONE) #endif // DRV_TOUCH_* +// Determine if calibration required +// - Enable for resistive displays +// - User config can also enable for capacitive displays by adding: +// #define DRV_TOUCH_CALIB +#if defined(DRV_TOUCH_TYPE_RES) + #define DRV_TOUCH_CALIB +#endif // ======================================================================= // API support definitions From 3f993bfb69d460a7436fcfc817d6863145ac34b8 Mon Sep 17 00:00:00 2001 From: Calvin Hass Date: Sat, 6 Mar 2021 14:26:36 -0800 Subject: [PATCH 2/2] Provide defaults for forced calibration mode --- src/GUIslice_drv_adagfx.h | 16 ++++++++++++++++ src/GUIslice_drv_tft_espi.h | 17 +++++++++++++++++ src/GUIslice_drv_utft.h | 17 +++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/src/GUIslice_drv_adagfx.h b/src/GUIslice_drv_adagfx.h index 8d69247c0..f88b8d617 100755 --- a/src/GUIslice_drv_adagfx.h +++ b/src/GUIslice_drv_adagfx.h @@ -97,6 +97,22 @@ extern "C" { #define DRV_TOUCH_CALIB #endif +#if defined(DRV_TOUCH_CALIB) + // Ensure calibration settings are present in the config file + #if !defined(ADATOUCH_X_MIN) + // We didn't locate the calibration settings, so provide some + // temporary defaults. This typically only occurs if user has + // decided to force calibration on a capacitive display by + // adding DRV_TOUCH_CALIB, but hasn't yet added the calibration + // settings (ADATOUCH_X/Y_MIN/MAX) from the calibration sketch yet. + #warning Calibration settings (ADATOUCH_X/Y_MIN/MAX) need to be added to config. Using defaults. + #define ADATOUCH_X_MIN 0 + #define ADATOUCH_X_MAX 4000 + #define ADATOUCH_Y_MIN 0 + #define ADATOUCH_Y_MAX 4000 + #define ADATOUCH_REMAP_YX 0 + #endif // ADATOUCH_X_MIN +#endif // DRV_TOUCH_CALIB // ======================================================================= // API support definitions diff --git a/src/GUIslice_drv_tft_espi.h b/src/GUIslice_drv_tft_espi.h index 9877c493f..18591127f 100755 --- a/src/GUIslice_drv_tft_espi.h +++ b/src/GUIslice_drv_tft_espi.h @@ -87,6 +87,23 @@ extern "C" { #define DRV_TOUCH_CALIB #endif +#if defined(DRV_TOUCH_CALIB) + // Ensure calibration settings are present in the config file + #if !defined(ADATOUCH_X_MIN) + // We didn't locate the calibration settings, so provide some + // temporary defaults. This typically only occurs if user has + // decided to force calibration on a capacitive display by + // adding DRV_TOUCH_CALIB, but hasn't yet added the calibration + // settings (ADATOUCH_X/Y_MIN/MAX) from the calibration sketch yet. + #warning Calibration settings (ADATOUCH_X/Y_MIN/MAX) need to be added to config. Using defaults. + #define ADATOUCH_X_MIN 0 + #define ADATOUCH_X_MAX 4000 + #define ADATOUCH_Y_MIN 0 + #define ADATOUCH_Y_MAX 4000 + #define ADATOUCH_REMAP_YX 0 + #endif // ADATOUCH_X_MIN +#endif // DRV_TOUCH_CALIB + // Additional defines // - Provide default if not in config file #if !defined(GSLC_SPIFFS_EN) diff --git a/src/GUIslice_drv_utft.h b/src/GUIslice_drv_utft.h index 6e87377fb..af80a6591 100644 --- a/src/GUIslice_drv_utft.h +++ b/src/GUIslice_drv_utft.h @@ -70,6 +70,23 @@ extern "C" { #define DRV_TOUCH_CALIB #endif +#if defined(DRV_TOUCH_CALIB) + // Ensure calibration settings are present in the config file + #if !defined(ADATOUCH_X_MIN) + // We didn't locate the calibration settings, so provide some + // temporary defaults. This typically only occurs if user has + // decided to force calibration on a capacitive display by + // adding DRV_TOUCH_CALIB, but hasn't yet added the calibration + // settings (ADATOUCH_X/Y_MIN/MAX) from the calibration sketch yet. + #warning Calibration settings (ADATOUCH_X/Y_MIN/MAX) need to be added to config. Using defaults. + #define ADATOUCH_X_MIN 0 + #define ADATOUCH_X_MAX 4000 + #define ADATOUCH_Y_MIN 0 + #define ADATOUCH_Y_MAX 4000 + #define ADATOUCH_REMAP_YX 0 + #endif // ADATOUCH_X_MIN +#endif // DRV_TOUCH_CALIB + // ======================================================================= // API support definitions // - These defines indicate whether the driver includes optimized