Avoid divide by zero crash if touch screen not fitted or not wired up
This commit is contained in:
parent
b536af5062
commit
5e98ce5294
10
TFT_eSPI.cpp
10
TFT_eSPI.cpp
|
|
@ -4249,6 +4249,11 @@ void TFT_eSPI::calibrateTouch(uint16_t *parameters, uint32_t color_fg, uint32_t
|
||||||
touchCalibration_x1 -= touchCalibration_x0;
|
touchCalibration_x1 -= touchCalibration_x0;
|
||||||
touchCalibration_y1 -= touchCalibration_y0;
|
touchCalibration_y1 -= touchCalibration_y0;
|
||||||
|
|
||||||
|
if(touchCalibration_x0 == 0) touchCalibration_x0 = 1;
|
||||||
|
if(touchCalibration_x1 == 0) touchCalibration_x1 = 1;
|
||||||
|
if(touchCalibration_y0 == 0) touchCalibration_y0 = 1;
|
||||||
|
if(touchCalibration_y1 == 0) touchCalibration_y1 = 1;
|
||||||
|
|
||||||
// export parameters, if pointer valid
|
// export parameters, if pointer valid
|
||||||
if(parameters != NULL){
|
if(parameters != NULL){
|
||||||
parameters[0] = touchCalibration_x0;
|
parameters[0] = touchCalibration_x0;
|
||||||
|
|
@ -4270,6 +4275,11 @@ void TFT_eSPI::setTouch(uint16_t *parameters){
|
||||||
touchCalibration_y0 = parameters[2];
|
touchCalibration_y0 = parameters[2];
|
||||||
touchCalibration_y1 = parameters[3];
|
touchCalibration_y1 = parameters[3];
|
||||||
|
|
||||||
|
if(touchCalibration_x0 == 0) touchCalibration_x0 = 1;
|
||||||
|
if(touchCalibration_x1 == 0) touchCalibration_x1 = 1;
|
||||||
|
if(touchCalibration_y0 == 0) touchCalibration_y0 = 1;
|
||||||
|
if(touchCalibration_y1 == 0) touchCalibration_y1 = 1;
|
||||||
|
|
||||||
touchCalibration_rotate = parameters[4] & 0x01;
|
touchCalibration_rotate = parameters[4] & 0x01;
|
||||||
touchCalibration_invert_x = parameters[4] & 0x02;
|
touchCalibration_invert_x = parameters[4] & 0x02;
|
||||||
touchCalibration_invert_y = parameters[4] & 0x04;
|
touchCalibration_invert_y = parameters[4] & 0x04;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue