mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 04:36:38 +00:00
Fix TFT_eSPI setTouch
This commit is contained in:
parent
b449186aba
commit
0b02653a31
@ -76,6 +76,7 @@ class TouchLovyanGfx : public BaseTouch {
|
|||||||
delay(500);
|
delay(500);
|
||||||
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||||
set_calibration(calData);
|
set_calibration(calData);
|
||||||
|
delay(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#ifndef HASP_TFTESPI_TOUCH_DRIVER_H
|
#ifndef HASP_TFTESPI_TOUCH_DRIVER_H
|
||||||
#define HASP_TFTESPI_TOUCH_DRIVER_H
|
#define HASP_TFTESPI_TOUCH_DRIVER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO&& defined(USER_SETUP_LOADED)
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "touch_driver.h" // base class
|
#include "touch_driver.h" // base class
|
||||||
@ -35,13 +35,15 @@ class TouchTftEspi : public BaseTouch {
|
|||||||
public:
|
public:
|
||||||
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
{
|
{
|
||||||
|
#if TOUCH_DRIVER == 0x2046 && defined(TOUCH_CS)
|
||||||
if(haspTft.tft.getTouch((uint16_t*)&data->point.x, (uint16_t*)&data->point.y, 300)) {
|
if(haspTft.tft.getTouch((uint16_t*)&data->point.x, (uint16_t*)&data->point.y, 300)) {
|
||||||
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
|
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
|
||||||
data->state = LV_INDEV_STATE_PR;
|
data->state = LV_INDEV_STATE_PR;
|
||||||
hasp_set_sleep_offset(0); // Reset the offset
|
hasp_set_sleep_offset(0); // Reset the offset
|
||||||
} else {
|
return;
|
||||||
data->state = LV_INDEV_STATE_REL;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
data->state = LV_INDEV_STATE_REL;
|
||||||
|
|
||||||
/*Return `false` because we are not buffering and no more data to read*/
|
/*Return `false` because we are not buffering and no more data to read*/
|
||||||
return false;
|
return false;
|
||||||
@ -49,11 +51,14 @@ class TouchTftEspi : public BaseTouch {
|
|||||||
|
|
||||||
void set_calibration(uint16_t* calData)
|
void set_calibration(uint16_t* calData)
|
||||||
{
|
{
|
||||||
|
#if TOUCH_DRIVER == 0x2046 && defined(TOUCH_CS)
|
||||||
haspTft.tft.setTouch(calData);
|
haspTft.tft.setTouch(calData);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void calibrate(uint16_t* calData)
|
void calibrate(uint16_t* calData)
|
||||||
{
|
{
|
||||||
|
#if TOUCH_DRIVER == 0x2046 && defined(TOUCH_CS)
|
||||||
haspTft.tft.fillScreen(TFT_BLACK);
|
haspTft.tft.fillScreen(TFT_BLACK);
|
||||||
haspTft.tft.setCursor(20, 0);
|
haspTft.tft.setCursor(20, 0);
|
||||||
haspTft.tft.setTextFont(1);
|
haspTft.tft.setTextFont(1);
|
||||||
@ -66,6 +71,8 @@ class TouchTftEspi : public BaseTouch {
|
|||||||
delay(500);
|
delay(500);
|
||||||
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||||
set_calibration(calData);
|
set_calibration(calData);
|
||||||
|
delay(500);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,17 +177,14 @@ IRAM_ATTR bool gui_touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* dat
|
|||||||
void guiCalibrate(void)
|
void guiCalibrate(void)
|
||||||
{
|
{
|
||||||
#if TOUCH_DRIVER == 0x2046 //&& defined(USER_SETUP_LOADED)
|
#if TOUCH_DRIVER == 0x2046 //&& defined(USER_SETUP_LOADED)
|
||||||
#ifdef TOUCH_CS
|
|
||||||
haspTouch.calibrate(gui_settings.cal_data);
|
haspTouch.calibrate(gui_settings.cal_data);
|
||||||
#endif
|
|
||||||
|
|
||||||
size_t len = sizeof(gui_settings.cal_data) / sizeof(gui_settings.cal_data[0]);
|
// size_t len = sizeof(gui_settings.cal_data) / sizeof(gui_settings.cal_data[0]);
|
||||||
for(int i = 0; i < len; i++) {
|
// for(int i = 0; i < len; i++) {
|
||||||
Serial.print(gui_settings.cal_data[i]);
|
// Serial.print(gui_settings.cal_data[i]);
|
||||||
if(i < len - 1) Serial.print(", ");
|
// if(i < len - 1) Serial.print(", ");
|
||||||
}
|
// }
|
||||||
|
|
||||||
delay(500);
|
|
||||||
lv_obj_invalidate(lv_disp_get_layer_sys(NULL));
|
lv_obj_invalidate(lv_disp_get_layer_sys(NULL));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -462,13 +459,12 @@ bool guiGetConfig(const JsonObject& settings)
|
|||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
#if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
|
#if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
|
||||||
// haspTft.tft.setTouch(gui_settings.cal_data);
|
// haspTft.tft.setTouch(gui_settings.cal_data);
|
||||||
haspTouch.set_calibration(gui_settings.cal_data);
|
haspTouch.set_calibration(gui_settings.cal_data);
|
||||||
#elif TOUCH_DRIVER == 0x2046 && defined(HASP_USE_LGFX_TOUCH)
|
#elif TOUCH_DRIVER == 0x2046 && defined(HASP_USE_LGFX_TOUCH)
|
||||||
// haspTft.tft.setTouchCalibrate(gui_settings.cal_data);
|
// haspTft.tft.setTouchCalibrate(gui_settings.cal_data);
|
||||||
haspTouch.set_calibration(gui_settings.cal_data);
|
haspTouch.set_calibration(gui_settings.cal_data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user