Correct rotated touch coordinates bug

This commit is contained in:
Bodmer 2018-02-24 18:28:31 +00:00
parent 3c9ab80ee6
commit 99b8568a48
3 changed files with 8 additions and 8 deletions

View File

@ -203,7 +203,7 @@ void TFT_eSPI::calibrateTouch(uint16_t *parameters, uint32_t color_fg, uint32_t
for(uint8_t j= 0; j<8; j++){ for(uint8_t j= 0; j<8; j++){
// Use a lower detect threshold as corners tend to be less sensitive // Use a lower detect threshold as corners tend to be less sensitive
while(!validTouch(&x_tmp, &y_tmp, Z_THRESHOLD/2)) delay(10); while(!validTouch(&x_tmp, &y_tmp, Z_THRESHOLD/4));
values[i*2 ] += x_tmp; values[i*2 ] += x_tmp;
values[i*2+1] += y_tmp; values[i*2+1] += y_tmp;
} }
@ -215,14 +215,14 @@ void TFT_eSPI::calibrateTouch(uint16_t *parameters, uint32_t color_fg, uint32_t
// check orientation // check orientation
// from case 0 to case 1, the y value changed. // from case 0 to case 1, the y value changed.
// If the meassured delta of the touch x axis is bigger than the delta of the y axis, the touch and TFT axes are switched. // If the measured delta of the touch x axis is bigger than the delta of the y axis, the touch and TFT axes are switched.
touchCalibration_rotate = false; touchCalibration_rotate = false;
if(abs(values[0]-values[2]) > abs(values[1]-values[3])){ if(abs(values[0]-values[2]) > abs(values[1]-values[3])){
touchCalibration_rotate = true; touchCalibration_rotate = true;
touchCalibration_x1 = (values[0] + values[4])/2; // calc min x touchCalibration_x0 = (values[0] + values[4])/2; // calc min x
touchCalibration_x0 = (values[2] + values[6])/2; // calc max x touchCalibration_x1 = (values[2] + values[6])/2; // calc max x
touchCalibration_y1 = (values[1] + values[3])/2; // calc min y touchCalibration_y0 = (values[1] + values[3])/2; // calc min y
touchCalibration_y0 = (values[5] + values[7])/2; // calc max y touchCalibration_y1 = (values[5] + values[7])/2; // calc max y
} else { } else {
touchCalibration_x0 = (values[0] + values[2])/2; // calc min x touchCalibration_x0 = (values[0] + values[2])/2; // calc min x
touchCalibration_x1 = (values[4] + values[6])/2; // calc max x touchCalibration_x1 = (values[4] + values[6])/2; // calc max x

View File

@ -1,6 +1,6 @@
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "0.18.20", "version": "0.18.21",
"keywords": "tft, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486", "keywords": "tft, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486",
"description": "A TFT SPI graphics library for ESP8266 and ESP32", "description": "A TFT SPI graphics library for ESP8266 and ESP32",
"repository": "repository":

View File

@ -1,5 +1,5 @@
name=TFT_eSPI name=TFT_eSPI
version=0.18.20 version=0.18.21
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=A fast TFT library for ESP8266 processors and the Arduino IDE sentence=A fast TFT library for ESP8266 processors and the Arduino IDE