diff --git a/src/drv/old/hasp_drv_ft5206.cpp b/src/drv/old/hasp_drv_ft5206.cpp index be9bb94b..bbcdfde4 100644 --- a/src/drv/old/hasp_drv_ft5206.cpp +++ b/src/drv/old/hasp_drv_ft5206.cpp @@ -67,10 +67,10 @@ void FT5206_init() { LOG_INFO(TAG_DRVR, F("Touch SDA : %d"), TOUCH_SDA); LOG_INFO(TAG_DRVR, F("Touch SCL : %d"), TOUCH_SCL); - LOG_INFO(TAG_DRVR, F("Touch freq. : %d"), TOUCH_FREQUENCY); + LOG_INFO(TAG_DRVR, F("Touch freq. : %d"), I2C_TOUCH_FREQUENCY); LOG_INFO(TAG_DRVR, F("Touch address : %02x"), FT5206_address); - Wire1.begin(TOUCH_SDA, TOUCH_SCL, TOUCH_FREQUENCY); + Wire1.begin(TOUCH_SDA, TOUCH_SCL, I2C_TOUCH_FREQUENCY); scan(Wire1); touchpanel = new FocalTech_Class(); diff --git a/src/drv/old/hasp_drv_ft6336u.cpp b/src/drv/old/hasp_drv_ft6336u.cpp index 7eb4534b..5abf7ef2 100644 --- a/src/drv/old/hasp_drv_ft6336u.cpp +++ b/src/drv/old/hasp_drv_ft6336u.cpp @@ -62,7 +62,7 @@ void FT6336U_init() LOG_INFO(TAG_DRVR, F("Touch SDA : %d"), TOUCH_SDA); LOG_INFO(TAG_DRVR, F("Touch SCL : %d"), TOUCH_SCL); - LOG_INFO(TAG_DRVR, F("Touch freq. : %d"), TOUCH_FREQUENCY); + LOG_INFO(TAG_DRVR, F("Touch freq. : %d"), I2C_TOUCH_FREQUENCY); LOG_INFO(TAG_DRVR, F("Touch address : %x"), I2C_ADDR_FT6336U); touchpanel = new FT6336U(TOUCH_SDA, TOUCH_SCL, TOUCH_RST, TOUCH_IRQ); diff --git a/src/drv/tft/tft_driver_lovyangfx.cpp b/src/drv/tft/tft_driver_lovyangfx.cpp index 42bb21e4..ddc3d4c2 100644 --- a/src/drv/tft/tft_driver_lovyangfx.cpp +++ b/src/drv/tft/tft_driver_lovyangfx.cpp @@ -40,7 +40,7 @@ void LovyanGfx::init(int w, int h) #ifdef USE_DMA_TO_TFT int dma_channel = 1; // Set the DMA channel (1 or 2. 0=disable) #else - int dma_channel = 1; // Set the DMA channel (1 or 2. 0=disable) + int dma_channel = 0; // Set the DMA channel (1 or 2. 0=disable) #endif uint32_t tft_driver = 0; @@ -73,7 +73,7 @@ else if (tft_driver == 0x7796) { // バス制御の設定を行います。 auto bus = (lgfx::v1::Bus_SPI*)tft._bus_instance; auto cfg = bus->config(); // バス設定用の構造体を取得します。 - cfg.spi_host = VSPI_HOST; // 使用するSPIを選択 (VSPI_HOST or HSPI_HOST) + cfg.spi_host = HSPI_HOST; // 使用するSPIを選択 (VSPI_HOST or HSPI_HOST) cfg.spi_mode = 0; // SPI通信モードを設定 (0 ~ 3) cfg.freq_write = SPI_FREQUENCY; // 送信時のSPIクロック (最大80MHz, 80MHzを整数で割った値に丸められます) cfg.freq_read = SPI_READ_FREQUENCY; // 受信時のSPIクロック @@ -137,7 +137,7 @@ else if (tft_driver == 0x7796) cfg.pin_int = -1; // INTが接続されているピン番号 cfg.bus_shared = true; // 画面と共通のバスを使用している場合 trueを設定 cfg.offset_rotation = 0; // 表示とタッチの向きのが一致しない場合の調整 0~7の値で設定 - cfg.spi_host = VSPI_HOST; // 使用するSPIを選択 (HSPI_HOST or VSPI_HOST) + cfg.spi_host = HSPI_HOST; // 使用するSPIを選択 (HSPI_HOST or VSPI_HOST) cfg.pin_sclk = TFT_SCLK; // SCLKが接続されているピン番号 cfg.pin_mosi = TFT_MOSI; // MOSIが接続されているピン番号 cfg.pin_miso = TFT_MISO; // MISOが接続されているピン番号 diff --git a/src/drv/touch/touch_driver_analog.h b/src/drv/touch/touch_driver_analog.h index 27361c21..db6d7d0d 100644 --- a/src/drv/touch/touch_driver_analog.h +++ b/src/drv/touch/touch_driver_analog.h @@ -18,29 +18,26 @@ extern uint8_t hasp_sleep_state; #define MINPRESSURE 200 #define MAXPRESSURE 2400 -const int XP=TFT_D6,XM=TFT_DC,YP=TFT_WR,YM=TFT_D7; //ID=0x9341 -const int TS_LEFT=560,TS_RT=3670,TS_TOP=3850,TS_BOT=580; -int max_x = 4095,max_y=4095; +const int XP = TFT_D6, XM = TFT_DC, YP = TFT_WR, YM = TFT_D7; // ID=0x9341 +const int TS_LEFT = 560, TS_RT = 3670, TS_TOP = 3850, TS_BOT = 580; +int max_x = 4095, max_y = 4095; static TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); -IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) -{ - static TSPoint tp; - tp = ts.getPoint(); - if (tp.z < MINPRESSURE){ - data->state = LV_INDEV_STATE_REL; - }else{ - data->point.x = map(tp.x,TS_LEFT,TS_RT,0,max_x); - data->point.y = map(tp.y,TS_BOT,TS_TOP,max_y,0); - data->state = LV_INDEV_STATE_PR; - } +// IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) +// { +// static TSPoint tp; +// tp = ts.getPoint(); +// if(tp.z < MINPRESSURE) { +// data->state = LV_INDEV_STATE_REL; +// } else { +// data->point.x = map(tp.x, TS_LEFT, TS_RT, 0, max_x); +// data->point.y = map(tp.y, TS_BOT, TS_TOP, max_y, 0); +// data->state = LV_INDEV_STATE_PR; +// } - return false; - - /*Return `false` because we are not buffering and no more data to read*/ - // return false; -} +// return false; +// } namespace dev { @@ -52,10 +49,20 @@ class AnalogTouch : public BaseTouch { max_x = w; max_y = h; } - + IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) { - return touch_read(indev_driver, data); + static TSPoint tp; + tp = ts.getPoint(); + if(tp.z < MINPRESSURE) { + data->state = LV_INDEV_STATE_REL; + } else { + data->point.x = map(tp.x, TS_LEFT, TS_RT, 0, max_x); + data->point.y = map(tp.y, TS_BOT, TS_TOP, max_y, 0); + data->state = LV_INDEV_STATE_PR; + } + + return false; } }; diff --git a/src/drv/touch/touch_driver_ft6336u.h b/src/drv/touch/touch_driver_ft6336u.h index 5f3fb81d..701ee07e 100644 --- a/src/drv/touch/touch_driver_ft6336u.h +++ b/src/drv/touch/touch_driver_ft6336u.h @@ -22,65 +22,34 @@ extern uint8_t hasp_sleep_state; FT6336U* ft6336u_touch; // Read touch points -HASP_ATTRIBUTE_FAST_MEM bool FT6336U_getXY(int16_t* touchX, int16_t* touchY) -{ - if(ft6336u_touch->read_touch_number() == 1) { - *touchX = ft6336u_touch->read_touch1_x(); - *touchY = ft6336u_touch->read_touch1_y(); - return true; - } else { - return false; - } -} +// HASP_ATTRIBUTE_FAST_MEM bool FT6336U_getXY(int16_t* touchX, int16_t* touchY) +// { +// if(ft6336u_touch->read_touch_number() == 1) { +// *touchX = ft6336u_touch->read_touch1_x(); +// *touchY = ft6336u_touch->read_touch1_y(); +// return true; +// } else { +// return false; +// } +// } -IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) -{ +// IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) +// { - if(ft6336u_touch->read_touch_number() == 1) { - if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle +// if(ft6336u_touch->read_touch_number() == 1) { +// if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle - data->point.x = ft6336u_touch->read_touch1_x(); - data->point.y = ft6336u_touch->read_touch1_y(); - data->state = LV_INDEV_STATE_PR; +// data->point.x = ft6336u_touch->read_touch1_x(); +// data->point.y = ft6336u_touch->read_touch1_y(); +// data->state = LV_INDEV_STATE_PR; - } else { - data->state = LV_INDEV_STATE_REL; - } +// } else { +// data->state = LV_INDEV_STATE_REL; +// } - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} - -static inline void FT6336U_drv_init() -{ - LOG_INFO(TAG_DRVR, F("Touch SDA : %d"), TOUCH_SDA); - LOG_INFO(TAG_DRVR, F("Touch SCL : %d"), TOUCH_SCL); - LOG_INFO(TAG_DRVR, F("Touch freq. : %d"), TOUCH_FREQUENCY); - LOG_INFO(TAG_DRVR, F("Touch address : %x"), I2C_ADDR_FT6336U); - - ft6336u_touch = new FT6336U(TOUCH_SDA, TOUCH_SCL, TOUCH_RST, TOUCH_IRQ); - ft6336u_touch->begin(); - - // From: M5Core2/src/M5Touch.cpp - // By default, the FT6336 will pulse the INT line for every touch - // event. But because it shares the Wire1 TwoWire/I2C with other - // devices, we cannot easily create an interrupt service routine to - // handle these events. So instead, we set the INT wire to polled mode, - // so it simply goes low as long as there is at least one valid touch. - // ft6336u_touch->writeByte(0xA4, 0x00); - Wire1.beginTransmission(I2C_ADDR_FT6336U); - Wire1.write(0xA4); // address - Wire1.write(0x00); // data - Wire1.endTransmission(); - - touch_scan(Wire1); - - if(ft6336u_touch->read_chip_id() != 0) { - LOG_INFO(TAG_DRVR, F("FT6336U touch driver started chipid: %d"), ft6336u_touch->read_chip_id()); - } else { - LOG_ERROR(TAG_DRVR, F("FT6336U touch driver failed to start")); - } -} +// /*Return `false` because we are not buffering and no more data to read*/ +// return false; +// } namespace dev { @@ -89,18 +58,42 @@ class TouchFt6336u : public BaseTouch { public: void init(int w, int h) { - FT6336U_drv_init(); + LOG_INFO(TAG_DRVR, F("Touch SDA : %d"), TOUCH_SDA); + LOG_INFO(TAG_DRVR, F("Touch SCL : %d"), TOUCH_SCL); + LOG_INFO(TAG_DRVR, F("Touch freq. : %d"), I2C_TOUCH_FREQUENCY); + LOG_INFO(TAG_DRVR, F("Touch address : %x"), I2C_ADDR_FT6336U); + + ft6336u_touch = new FT6336U(TOUCH_SDA, TOUCH_SCL, TOUCH_RST, TOUCH_IRQ); + ft6336u_touch->begin(); + + // From: M5Core2/src/M5Touch.cpp + // By default, the FT6336 will pulse the INT line for every touch + // event. But because it shares the Wire1 TwoWire/I2C with other + // devices, we cannot easily create an interrupt service routine to + // handle these events. So instead, we set the INT wire to polled mode, + // so it simply goes low as long as there is at least one valid touch. + // ft6336u_touch->writeByte(0xA4, 0x00); + Wire1.beginTransmission(I2C_ADDR_FT6336U); + Wire1.write(0xA4); // address + Wire1.write(0x00); // data + Wire1.endTransmission(); + + touch_scan(Wire1); + + if(ft6336u_touch->read_chip_id() != 0) { + LOG_INFO(TAG_DRVR, F("FT6336U touch driver started chipid: %d"), ft6336u_touch->read_chip_id()); + } else { + LOG_ERROR(TAG_DRVR, F("FT6336U touch driver failed to start")); + } } IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) { - int16_t touchX; - int16_t touchY; - if(FT6336U_getXY(&touchX, &touchY)) { + if(ft6336u_touch->read_touch_number() == 1) { if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle - data->point.x = touchX; - data->point.y = touchY; + data->point.x = ft6336u_touch->read_touch1_x(); + data->point.y = ft6336u_touch->read_touch1_y(); data->state = LV_INDEV_STATE_PR; } else { diff --git a/src/drv/touch/touch_driver_gt911.h b/src/drv/touch/touch_driver_gt911.h index 53dfca6a..02dd90f5 100644 --- a/src/drv/touch/touch_driver_gt911.h +++ b/src/drv/touch/touch_driver_gt911.h @@ -38,28 +38,28 @@ IRAM_ATTR void GT911_setXY(int8_t contacts, GTPoint* points) // } } -IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) -{ - // LOG_VERBOSE(TAG_GUI, F("Contacts: %d"), GT911_num_touches); - static GTPoint points[5]; +// IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) +// { +// // LOG_VERBOSE(TAG_GUI, F("Contacts: %d"), GT911_num_touches); +// static GTPoint points[5]; - if(touch.readInput((uint8_t*)&points) > 0) { +// if(touch.readInput((uint8_t*)&points) > 0) { - 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->point.x = points[0].x; - data->point.y = points[0].y; - data->state = LV_INDEV_STATE_PR; +// data->point.x = points[0].x; +// data->point.y = points[0].y; +// data->state = LV_INDEV_STATE_PR; - } else { - data->state = LV_INDEV_STATE_REL; - } +// } else { +// data->state = LV_INDEV_STATE_REL; +// } - touch.loop(); // reset IRQ +// touch.loop(); // reset IRQ - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} +// /*Return `false` because we are not buffering and no more data to read*/ +// return false; +// } namespace dev { @@ -68,7 +68,25 @@ class TouchGt911 : public BaseTouch { public: IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) { - return touch_read(indev_driver, data); + // LOG_VERBOSE(TAG_GUI, F("Contacts: %d"), GT911_num_touches); + static GTPoint points[5]; + + if(touch.readInput((uint8_t*)&points) > 0) { + + if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle + + data->point.x = points[0].x; + data->point.y = points[0].y; + data->state = LV_INDEV_STATE_PR; + + } else { + data->state = LV_INDEV_STATE_REL; + } + + touch.loop(); // reset IRQ + + /*Return `false` because we are not buffering and no more data to read*/ + return false; } void init(int w, int h) diff --git a/src/drv/touch/touch_driver_lovyangfx.h b/src/drv/touch/touch_driver_lovyangfx.h new file mode 100644 index 00000000..06f2da9b --- /dev/null +++ b/src/drv/touch/touch_driver_lovyangfx.h @@ -0,0 +1,80 @@ +/* MIT License - Copyright (c) 2019-2021 Francis Van Roie + For full license information read the LICENSE file in the project folder */ + +#ifndef HASP_LOVYANGFX_TOUCH_DRIVER_H +#define HASP_LOVYANGFX_TOUCH_DRIVER_H + +#ifdef ARDUINO +#include "Arduino.h" + +#include "touch_driver.h" // base class +#include "dev/device.h" // for haspTft +#include "drv/tft/tft_driver.h" + +#include "../../hasp/hasp.h" // for hasp_sleep_state +extern uint8_t hasp_sleep_state; + +// IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) +// { +// 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; + +// } else { +// data->state = LV_INDEV_STATE_REL; +// } + +// /*Return `false` because we are not buffering and no more data to read*/ +// return false; +// } + +namespace dev { + +class TouchLovyanGfx : public BaseTouch { + + public: + static IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) + { + int16_t touchX = 0; + int16_t touchY = 0; + + if(haspTft.tft.getTouch((uint16_t*)&touchX, (uint16_t*)&touchY, 300)) { + if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle + + data->point.x = touchX; + data->point.y = touchY; + data->state = LV_INDEV_STATE_PR; + + } else { + data->state = LV_INDEV_STATE_REL; + } + + /*Return `false` because we are not buffering and no more data to read*/ + return false; + } + + void calibrate(uint16_t* calData) + { + haspTft.tft.fillScreen(TFT_BLACK); + haspTft.tft.setCursor(20, 0); + haspTft.tft.setTextFont(1); + haspTft.tft.setTextSize(1); + haspTft.tft.setTextColor(TFT_WHITE, TFT_BLACK); + + // tft.println(PSTR("Touch corners as indicated")); + + haspTft.tft.setTextFont(1); + delay(500); + haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15); + haspTft.tft.setTouch(calData); + } +}; + +} // namespace dev + +using dev::TouchLovyanGfx; +extern dev::TouchLovyanGfx haspTouch; + +#endif // ARDUINO + +#endif // HASP_LOVYANGFX_TOUCH_DRIVER_H \ No newline at end of file diff --git a/src/drv/touch/touch_driver_stmpe610.h b/src/drv/touch/touch_driver_stmpe610.h index e6e150cf..ce73e3eb 100644 --- a/src/drv/touch/touch_driver_stmpe610.h +++ b/src/drv/touch/touch_driver_stmpe610.h @@ -25,33 +25,33 @@ extern uint8_t hasp_sleep_state; static Adafruit_STMPE610 stmpe610_touchpanel = Adafruit_STMPE610(TOUCH_CS); -bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) -{ - data->state = LV_INDEV_STATE_REL; +// bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) +// { +// data->state = LV_INDEV_STATE_REL; - // while touched, but the state is released => read next point - while(data->state == LV_INDEV_STATE_REL && stmpe610_touchpanel.touched()) { +// // while touched, but the state is released => read next point +// while(data->state == LV_INDEV_STATE_REL && stmpe610_touchpanel.touched()) { - TS_Point point = stmpe610_touchpanel.getPoint(); - Log.trace(TAG_DRVR, F("STMPE610: x=%i y=%i z=%i"), point.x, point.y, point.z); +// TS_Point point = stmpe610_touchpanel.getPoint(); +// Log.trace(TAG_DRVR, F("STMPE610: x=%i y=%i z=%i"), point.x, point.y, point.z); - if(point.z && point.x < 4096 && point.y < 4096) { // valid reading - if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle - data->state = LV_INDEV_STATE_PR; +// if(point.z && point.x < 4096 && point.y < 4096) { // valid reading +// if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle +// data->state = LV_INDEV_STATE_PR; -#if HX8357D_DRIVER == 1 - data->point.x = map(point.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0); - data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); -#else - data->point.x = map(point.x, TS_MINX, TS_MAXX, 0, TFT_WIDTH); - data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); -#endif - } - } +// #if HX8357D_DRIVER == 1 +// data->point.x = map(point.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0); +// data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); +// #else +// data->point.x = map(point.x, TS_MINX, TS_MAXX, 0, TFT_WIDTH); +// data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); +// #endif +// } +// } - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} +// /*Return `false` because we are not buffering and no more data to read*/ +// return false; +// } namespace dev { @@ -60,7 +60,30 @@ class TouchStmpe610 : public BaseTouch { public: IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) { - return touch_read(indev_driver, data); + data->state = LV_INDEV_STATE_REL; + + // while touched, but the state is released => read next point + while(data->state == LV_INDEV_STATE_REL && stmpe610_touchpanel.touched()) { + + TS_Point point = stmpe610_touchpanel.getPoint(); + Log.trace(TAG_DRVR, F("STMPE610: x=%i y=%i z=%i"), point.x, point.y, point.z); + + if(point.z && point.x < 4096 && point.y < 4096) { // valid reading + if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle + data->state = LV_INDEV_STATE_PR; + +#if HX8357D_DRIVER == 1 + data->point.x = map(point.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0); + data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); +#else + data->point.x = map(point.x, TS_MINX, TS_MAXX, 0, TFT_WIDTH); + data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); +#endif + } + } + + /*Return `false` because we are not buffering and no more data to read*/ + return false; } void init(int w, int h) diff --git a/src/drv/touch/touch_driver_tftespi.h b/src/drv/touch/touch_driver_tftespi.h index 82ed45ff..5446ce21 100644 --- a/src/drv/touch/touch_driver_tftespi.h +++ b/src/drv/touch/touch_driver_tftespi.h @@ -14,19 +14,19 @@ #include "../../hasp/hasp.h" // for hasp_sleep_state extern uint8_t hasp_sleep_state; -IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) -{ - 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; +// IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) +// { +// 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; - } else { - data->state = LV_INDEV_STATE_REL; - } +// } else { +// data->state = LV_INDEV_STATE_REL; +// } - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} +// /*Return `false` because we are not buffering and no more data to read*/ +// return false; +// } namespace dev { @@ -35,16 +35,9 @@ class TouchTftEspi : public BaseTouch { public: IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) { - int16_t touchX = 0; - int16_t touchY = 0; - - if(haspTft.tft.getTouch((uint16_t*)&touchX, (uint16_t*)&touchY, 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 - - data->point.x = touchX; - data->point.y = touchY; - data->state = LV_INDEV_STATE_PR; - + data->state = LV_INDEV_STATE_PR; } else { data->state = LV_INDEV_STATE_REL; } diff --git a/user_setups/esp32/esp32-touchdown.ini b/user_setups/esp32/esp32-touchdown.ini index a18ab7de..f08669ae 100644 --- a/user_setups/esp32/esp32-touchdown.ini +++ b/user_setups/esp32/esp32-touchdown.ini @@ -30,7 +30,7 @@ build_flags = -D TOUCH_SCL=22 -D TOUCH_IRQ=27 -D TOUCH_RST=-1 ; not used - -D TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_FREQUENCY=400000 -D SPI_FREQUENCY=40000000 -D SPI_READ_FREQUENCY=20000000 ;endregion diff --git a/user_setups/esp32/lanbon_l8.ini b/user_setups/esp32/lanbon_l8.ini index f6fd9e85..7a664867 100644 --- a/user_setups/esp32/lanbon_l8.ini +++ b/user_setups/esp32/lanbon_l8.ini @@ -33,7 +33,7 @@ build_flags = -D TOUCH_SCL=0 -D TOUCH_IRQ=-1 ; not connected -D TOUCH_RST=-1 ; not used, connected to 3.3V on FCP pin10 - -D TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_FREQUENCY=400000 -D LED_RED=26 -D LED_GREEN=32 -D LED_BLUE=33 diff --git a/user_setups/esp32/m5stack_core2.ini b/user_setups/esp32/m5stack_core2.ini index bf336aec..0c8041af 100644 --- a/user_setups/esp32/m5stack_core2.ini +++ b/user_setups/esp32/m5stack_core2.ini @@ -31,7 +31,7 @@ build_flags = -D TOUCH_SCL=22 -D TOUCH_IRQ=39 -D TOUCH_RST=-1 ; Managed by AXP_IO4 - -D TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_FREQUENCY=400000 ;endregion ;region -- Library options ------------------------------- diff --git a/user_setups/esp32/makerfabs-tft35-cap.ini b/user_setups/esp32/makerfabs-tft35-cap.ini index 8c52ddf7..3124765a 100644 --- a/user_setups/esp32/makerfabs-tft35-cap.ini +++ b/user_setups/esp32/makerfabs-tft35-cap.ini @@ -35,7 +35,7 @@ build_flags = -D TOUCH_SCL=27 -D TOUCH_IRQ=0 -D TOUCH_RST=-1 - -D TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_FREQUENCY=400000 ;endregion ;region -- Library options ------------------------------- diff --git a/user_setups/esp32/ttgo-lilygo-pi_st7796.ini b/user_setups/esp32/ttgo-lilygo-pi_st7796.ini index 229911a1..e33b572f 100644 --- a/user_setups/esp32/ttgo-lilygo-pi_st7796.ini +++ b/user_setups/esp32/ttgo-lilygo-pi_st7796.ini @@ -39,7 +39,6 @@ build_flags = -D TOUCH_SDA=21 -D TOUCH_SCL=22 -D I2C_TOUCH_FREQUENCY=400000 - -D TOUCH_FREQUENCY=400000 ;endregion ;region -- Hasp build options ---------------------------- diff --git a/user_setups/esp32/wt32-sc01.ini b/user_setups/esp32/wt32-sc01.ini index f65819c3..7fab4c6b 100644 --- a/user_setups/esp32/wt32-sc01.ini +++ b/user_setups/esp32/wt32-sc01.ini @@ -32,7 +32,7 @@ build_flags = -D TOUCH_SCL=19 -D TOUCH_IRQ=-1 ; not connected -D TOUCH_RST=-1 ; not used, connected to 3.3V - -D TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_FREQUENCY=400000 ;endregion ;region -- Library options ------------------------------- diff --git a/user_setups/esp32/yeacreate-nscreen32.ini b/user_setups/esp32/yeacreate-nscreen32.ini index e92dfeb3..96b6f999 100644 --- a/user_setups/esp32/yeacreate-nscreen32.ini +++ b/user_setups/esp32/yeacreate-nscreen32.ini @@ -46,7 +46,6 @@ build_flags = -D TOUCH_SCL=22 -D TOUCH_IRQ=5 -D TOUCH_RST=23 - ;-D TOUCH_FREQUENCY=400000 -D I2C_TOUCH_FREQUENCY=400000 -D SPI_FREQUENCY=40000000 -D SPI_READ_FREQUENCY=20000000