mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 21:26:43 +00:00
Add haspTouch.set_calibration()
This commit is contained in:
parent
ec0000039e
commit
b449186aba
@ -32,6 +32,8 @@ class BaseTouch {
|
||||
}
|
||||
void calibrate(uint16_t* calData)
|
||||
{}
|
||||
void set_calibration(uint16_t* calData)
|
||||
{}
|
||||
bool is_driver_pin(uint8_t)
|
||||
{
|
||||
return false;
|
||||
|
@ -53,8 +53,16 @@ class TouchLovyanGfx : public BaseTouch {
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_calibration(uint16_t* calData)
|
||||
{
|
||||
if(haspTft.tft.panel() && haspTft.tft.width() && haspTft.tft.height()) {
|
||||
haspTft.tft.setTouchCalibrate(calData);
|
||||
}
|
||||
}
|
||||
|
||||
void calibrate(uint16_t* calData)
|
||||
{
|
||||
if(haspTft.tft.panel() && haspTft.tft.width() && haspTft.tft.height()) {
|
||||
|
||||
haspTft.tft.fillScreen(TFT_BLACK);
|
||||
// haspTft.tft.setCursor(20, 0);
|
||||
@ -67,8 +75,8 @@ class TouchLovyanGfx : public BaseTouch {
|
||||
// haspTft.tft.setTextFont(1);
|
||||
delay(500);
|
||||
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||
// haspTft.tft.setTouch(calData);
|
||||
|
||||
set_calibration(calData);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -38,8 +38,8 @@ class TouchTftEspi : public BaseTouch {
|
||||
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
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
hasp_set_sleep_offset(0); // Reset the offset
|
||||
} else {
|
||||
hasp_set_sleep_offset(0); // Reset the offset
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
@ -47,6 +47,11 @@ class TouchTftEspi : public BaseTouch {
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_calibration(uint16_t* calData)
|
||||
{
|
||||
haspTft.tft.setTouch(calData);
|
||||
}
|
||||
|
||||
void calibrate(uint16_t* calData)
|
||||
{
|
||||
haspTft.tft.fillScreen(TFT_BLACK);
|
||||
@ -60,7 +65,7 @@ class TouchTftEspi : public BaseTouch {
|
||||
haspTft.tft.setTextFont(1);
|
||||
delay(500);
|
||||
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||
haspTft.tft.setTouch(calData);
|
||||
set_calibration(calData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -374,6 +374,7 @@ void guiSetup()
|
||||
#if !(defined(WINDOWS) || defined(POSIX))
|
||||
// drv_touch_init(gui_settings.rotation); // Touch driver
|
||||
haspTouch.init(tft_width, tft_height);
|
||||
haspTouch.set_calibration(gui_settings.cal_data);
|
||||
haspTouch.set_rotation(gui_settings.rotation);
|
||||
#endif
|
||||
|
||||
@ -461,9 +462,13 @@ bool guiGetConfig(const JsonObject& settings)
|
||||
changed = true;
|
||||
|
||||
#if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
|
||||
// tft_espi_set_touch(gui_settings.cal_data);
|
||||
haspTft.tft.setTouch(gui_settings.cal_data);
|
||||
// haspTft.tft.setTouch(gui_settings.cal_data);
|
||||
haspTouch.set_calibration(gui_settings.cal_data);
|
||||
#elif TOUCH_DRIVER == 0x2046 && defined(HASP_USE_LGFX_TOUCH)
|
||||
// haspTft.tft.setTouchCalibrate(gui_settings.cal_data);
|
||||
haspTouch.set_calibration(gui_settings.cal_data);
|
||||
#endif
|
||||
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -477,10 +482,11 @@ bool guiGetConfig(const JsonObject& settings)
|
||||
changed = true;
|
||||
|
||||
#if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
|
||||
// tft_espi_set_touch(gui_settings.cal_data);
|
||||
haspTft.tft.setTouch(gui_settings.cal_data);
|
||||
// haspTft.tft.setTouch(gui_settings.cal_data);
|
||||
haspTouch.set_calibration(gui_settings.cal_data);
|
||||
#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);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -553,9 +559,13 @@ bool guiSetConfig(const JsonObject& settings)
|
||||
}
|
||||
|
||||
#if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
|
||||
if(status) // tft_espi_set_touch(gui_settings.cal_data);
|
||||
haspTft.tft.setTouch(gui_settings.cal_data);
|
||||
// haspTft.tft.setTouch(gui_settings.cal_data);
|
||||
if(status) haspTouch.set_calibration(gui_settings.cal_data);
|
||||
#elif TOUCH_DRIVER == 0x2046 && defined(HASP_USE_LGFX_TOUCH)
|
||||
// haspTft.tft.setTouchCalibrate(gui_settings.cal_data);
|
||||
if(status) haspTouch.set_calibration(gui_settings.cal_data);
|
||||
#endif
|
||||
|
||||
changed |= status;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user