mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Workinig
This commit is contained in:
parent
414f27f6d7
commit
96f8389408
@ -238,6 +238,11 @@ const uint32_t LOOP_SLEEP_DELAY = 50; // Lowest number of milliseconds to
|
|||||||
#define KNX_MAX_device_param 31
|
#define KNX_MAX_device_param 31
|
||||||
#define MAX_KNXTX_CMNDS 5
|
#define MAX_KNXTX_CMNDS 5
|
||||||
|
|
||||||
|
// XPT2046 resistive touch driver min/max raw values
|
||||||
|
#define XPT2046_MINX 192
|
||||||
|
#define XPT2046_MAXX 3895
|
||||||
|
#define XPT2046_MINY 346
|
||||||
|
#define XPT2046_MAXY 3870
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Enumeration
|
* Enumeration
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -2621,6 +2621,9 @@ bool XPT2046_found;
|
|||||||
bool Touch_Init(uint16_t CS) {
|
bool Touch_Init(uint16_t CS) {
|
||||||
touchp = new XPT2046_Touchscreen(CS);
|
touchp = new XPT2046_Touchscreen(CS);
|
||||||
XPT2046_found = touchp->begin();
|
XPT2046_found = touchp->begin();
|
||||||
|
if (XPT2046_found) {
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("TS: XPT2046"));
|
||||||
|
}
|
||||||
return XPT2046_found;
|
return XPT2046_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2644,7 +2647,11 @@ uint32_t Touch_Status(uint32_t sel) {
|
|||||||
|
|
||||||
#ifdef USE_TOUCH_BUTTONS
|
#ifdef USE_TOUCH_BUTTONS
|
||||||
void Touch_MQTT(uint8_t index, const char *cp, uint32_t val) {
|
void Touch_MQTT(uint8_t index, const char *cp, uint32_t val) {
|
||||||
|
#if defined(USE_FT5206)
|
||||||
ResponseTime_P(PSTR(",\"FT5206\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
|
ResponseTime_P(PSTR(",\"FT5206\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
|
||||||
|
#elif defined(USE_XPT2046)
|
||||||
|
ResponseTime_P(PSTR(",\"XPT2046\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
|
||||||
|
#endif
|
||||||
MqttPublishTeleSensor();
|
MqttPublishTeleSensor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2696,7 +2703,7 @@ uint8_t vbutt=0;
|
|||||||
|
|
||||||
rotconvert(&pLoc.x, &pLoc.y);
|
rotconvert(&pLoc.x, &pLoc.y);
|
||||||
|
|
||||||
//AddLog(LOG_LEVEL_INFO, PSTR("touch %d - %d"), pLoc.x, pLoc.y);
|
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("touch after convert %d - %d"), pLoc.x, pLoc.y);
|
||||||
// now must compare with defined buttons
|
// now must compare with defined buttons
|
||||||
for (uint8_t count = 0; count < MAX_TOUCH_BUTTONS; count++) {
|
for (uint8_t count = 0; count < MAX_TOUCH_BUTTONS; count++) {
|
||||||
if (buttons[count]) {
|
if (buttons[count]) {
|
||||||
|
@ -171,7 +171,8 @@ void ili9342_dimm(uint8_t dim) {
|
|||||||
#if defined(USE_FT5206) || defined(USE_XPT2046)
|
#if defined(USE_FT5206) || defined(USE_XPT2046)
|
||||||
#ifdef USE_TOUCH_BUTTONS
|
#ifdef USE_TOUCH_BUTTONS
|
||||||
|
|
||||||
void ili9342_RotConvert(int16_t *x, int16_t *y) {
|
#if defined(USE_FT5206)
|
||||||
|
void TS_RotConvert(int16_t *x, int16_t *y) {
|
||||||
|
|
||||||
int16_t temp;
|
int16_t temp;
|
||||||
if (renderer) {
|
if (renderer) {
|
||||||
@ -196,6 +197,38 @@ int16_t temp;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(USE_XPT2046)
|
||||||
|
void TS_RotConvert(int16_t *x, int16_t *y) {
|
||||||
|
|
||||||
|
int16_t temp;
|
||||||
|
if (renderer) {
|
||||||
|
uint8_t rot = renderer->getRotation();
|
||||||
|
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(" TS: before convert x:%d / y:%d screen r:%d / w:%d / h:%d"), *x, *y,rot,renderer->width(),renderer->height());
|
||||||
|
temp = map(*x,XPT2046_MINX,XPT2046_MAXX, renderer->height(), 0);
|
||||||
|
*x = map(*y,XPT2046_MINY,XPT2046_MAXY, renderer->width(), 0);
|
||||||
|
*y = temp;
|
||||||
|
switch (rot) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
temp = *y;
|
||||||
|
*y = renderer->width() - *x;
|
||||||
|
*x = temp;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
*x = renderer->width() - *x;
|
||||||
|
*y = renderer->height() - *y;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
temp = *y;
|
||||||
|
*y = *x;
|
||||||
|
*x = renderer->height() - temp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(" TS: after convert x:%d / y:%d screen r:%d / w:%d / h:%d"), *x, *y,rot,renderer->width(),renderer->height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// check digitizer hit
|
// check digitizer hit
|
||||||
void ili9342_CheckTouch() {
|
void ili9342_CheckTouch() {
|
||||||
@ -203,7 +236,8 @@ ili9342_ctouch_counter++;
|
|||||||
if (2 == ili9342_ctouch_counter) {
|
if (2 == ili9342_ctouch_counter) {
|
||||||
// every 100 ms should be enough
|
// every 100 ms should be enough
|
||||||
ili9342_ctouch_counter = 0;
|
ili9342_ctouch_counter = 0;
|
||||||
Touch_Check(ili9342_RotConvert);
|
|
||||||
|
Touch_Check(TS_RotConvert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_TOUCH_BUTTONS
|
#endif // USE_TOUCH_BUTTONS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user