mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +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 calibrate(uint16_t* calData)
|
||||||
{}
|
{}
|
||||||
|
void set_calibration(uint16_t* calData)
|
||||||
|
{}
|
||||||
bool is_driver_pin(uint8_t)
|
bool is_driver_pin(uint8_t)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -53,8 +53,16 @@ class TouchLovyanGfx : public BaseTouch {
|
|||||||
#endif
|
#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)
|
void calibrate(uint16_t* calData)
|
||||||
{
|
{
|
||||||
|
if(haspTft.tft.panel() && haspTft.tft.width() && haspTft.tft.height()) {
|
||||||
|
|
||||||
haspTft.tft.fillScreen(TFT_BLACK);
|
haspTft.tft.fillScreen(TFT_BLACK);
|
||||||
// haspTft.tft.setCursor(20, 0);
|
// haspTft.tft.setCursor(20, 0);
|
||||||
@ -67,8 +75,8 @@ class TouchLovyanGfx : public BaseTouch {
|
|||||||
// haspTft.tft.setTextFont(1);
|
// haspTft.tft.setTextFont(1);
|
||||||
delay(500);
|
delay(500);
|
||||||
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
||||||
// haspTft.tft.setTouch(calData);
|
set_calibration(calData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,6 +47,11 @@ class TouchTftEspi : public BaseTouch {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_calibration(uint16_t* calData)
|
||||||
|
{
|
||||||
|
haspTft.tft.setTouch(calData);
|
||||||
|
}
|
||||||
|
|
||||||
void calibrate(uint16_t* calData)
|
void calibrate(uint16_t* calData)
|
||||||
{
|
{
|
||||||
haspTft.tft.fillScreen(TFT_BLACK);
|
haspTft.tft.fillScreen(TFT_BLACK);
|
||||||
@ -60,7 +65,7 @@ class TouchTftEspi : public BaseTouch {
|
|||||||
haspTft.tft.setTextFont(1);
|
haspTft.tft.setTextFont(1);
|
||||||
delay(500);
|
delay(500);
|
||||||
haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15);
|
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))
|
#if !(defined(WINDOWS) || defined(POSIX))
|
||||||
// drv_touch_init(gui_settings.rotation); // Touch driver
|
// drv_touch_init(gui_settings.rotation); // Touch driver
|
||||||
haspTouch.init(tft_width, tft_height);
|
haspTouch.init(tft_width, tft_height);
|
||||||
|
haspTouch.set_calibration(gui_settings.cal_data);
|
||||||
haspTouch.set_rotation(gui_settings.rotation);
|
haspTouch.set_rotation(gui_settings.rotation);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -461,9 +462,13 @@ 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)
|
||||||
// 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
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -477,10 +482,11 @@ 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)
|
||||||
// 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)
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,9 +559,13 @@ bool guiSetConfig(const JsonObject& settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
|
#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
|
#endif
|
||||||
|
|
||||||
changed |= status;
|
changed |= status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user