diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2b75f6da..de463b31 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -44,7 +44,7 @@ jobs: run: | cat platformio_override.ini - name: Run PlatformIO - run: pio run -e d1-mini-esp32_ili9341 -e esp32-touchdown -e freetouchdeck -e huzzah32-featherwing-24 -e huzzah32-featherwing-35 -e lanbon_l8 -e m5stack-core2 -e wt32-sc01 -e d1-mini-esp8266_ili9341 -e linux_sdl_64bits + run: pio run -e yeacreate-nscreen32 -e d1-mini-esp32_ili9341 -e esp32-touchdown -e freetouchdeck -e huzzah32-featherwing-24 -e huzzah32-featherwing-35 -e lanbon_l8 -e m5stack-core2 -e wt32-sc01 -e d1-mini-esp8266_ili9341 -e linux_sdl_64bits - name: Upload output file uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71f23e39..7c308c15 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,7 @@ jobs: run: | cat platformio_override.ini - name: Run PlatformIO - run: pio run -e d1-mini-esp32_ili9341 -e esp32-touchdown -e freetouchdeck -e huzzah32-featherwing-24 -e huzzah32-featherwing-35 -e lanbon_l8 -e m5stack-core2 -e wt32-sc01 -e d1-mini-esp8266_ili9341 -e linux_sdl_64bits + run: pio run -e yeacreate-nscreen32 -e d1-mini-esp32_ili9341 -e esp32-touchdown -e freetouchdeck -e huzzah32-featherwing-24 -e huzzah32-featherwing-35 -e lanbon_l8 -e m5stack-core2 -e wt32-sc01 -e d1-mini-esp8266_ili9341 -e linux_sdl_64bits - name: Upload output file uses: actions/upload-artifact@v2 with: diff --git a/src/drv/old/hasp_drv_gt911.cpp b/src/drv/old/hasp_drv_gt911.cpp index eebba5b1..e44931ba 100644 --- a/src/drv/old/hasp_drv_gt911.cpp +++ b/src/drv/old/hasp_drv_gt911.cpp @@ -1,4 +1,5 @@ -#if TOUCH_DRIVER == 911 +/* +#if TOUCH_DRIVER == 91100 #include #include "Goodix.h" @@ -105,4 +106,5 @@ void GT911_loop() { touch.loop(); } -#endif \ No newline at end of file +#endif +*/ \ No newline at end of file diff --git a/src/drv/old/hasp_drv_gt911.h b/src/drv/old/hasp_drv_gt911.h index 727a84e7..b1ae26f1 100644 --- a/src/drv/old/hasp_drv_gt911.h +++ b/src/drv/old/hasp_drv_gt911.h @@ -1,10 +1,11 @@ /* MIT License - Copyright (c) 2019-2021 Francis Van Roie For full license information read the LICENSE file in the project folder */ +/* #ifndef HASP_DRV_911_H #define HASP_DRV_911_H -#if TOUCH_DRIVER == 911 +#if TOUCH_DRIVER == 91100 #include "hasp_debug.h" // for TAG_DRVR @@ -13,4 +14,5 @@ void GT911_init(); void GT911_loop(); #endif -#endif \ No newline at end of file +#endif +*/ \ No newline at end of file diff --git a/src/drv/old/hasp_drv_touch.cpp b/src/drv/old/hasp_drv_touch.cpp index 6d159601..540c4e6e 100644 --- a/src/drv/old/hasp_drv_touch.cpp +++ b/src/drv/old/hasp_drv_touch.cpp @@ -63,7 +63,7 @@ void drv_touch_init(uint8_t rotation) #endif #elif TOUCH_DRIVER == 911 - GT911_init(); + // GT911_init(); #elif TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller // Touch_init(); @@ -96,7 +96,7 @@ static inline bool drv_touchpad_getXY(int16_t* touchX, int16_t* touchY) touched = XPT2046_getXY(&normal_x, &normal_y, true); #elif TOUCH_DRIVER == 911 - touched = GT911_getXY(&normal_x, &normal_y, true); + // touched = GT911_getXY(&normal_x, &normal_y, true); #elif TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller touched = Touch_getXY(&normal_x, &normal_y, false); @@ -221,6 +221,6 @@ IRAM_ATTR bool drv_touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* dat IRAM_ATTR void drv_touch_loop() { #if TOUCH_DRIVER == 911 - GT911_loop(); + // GT911_loop(); #endif } \ No newline at end of file diff --git a/src/drv/touch/touch_driver.h b/src/drv/touch/touch_driver.h index f1cf24e6..b9081504 100644 --- a/src/drv/touch/touch_driver.h +++ b/src/drv/touch/touch_driver.h @@ -51,15 +51,18 @@ class BaseTouch { #warning Building for XPT2046 //#include "touch_driver_xpt2046.h" #include "touch_driver_tftespi.h" +#elif TOUCH_DRIVER == 5206 +#warning Building for FT5206 +#include "touch_driver_ft5206.h" #elif TOUCH_DRIVER == 6336 #warning Building for FT6336 #include "touch_driver_ft6336u.h" #elif TOUCH_DRIVER == 610 #warning Building for STMPE610 #include "touch_driver_stmpe610.h" -#elif TOUCH_DRIVER == 5206 -#warning Building for FT5206 -#include "touch_driver_ft5206.h" +#elif TOUCH_DRIVER == 911 +#warning Building for GT911 +#include "touch_driver_gt911.h" #else #warning Building for Generic Touch using dev::BaseTouch; diff --git a/src/drv/touch/touch_driver_gt911.h b/src/drv/touch/touch_driver_gt911.h new file mode 100644 index 00000000..53766060 --- /dev/null +++ b/src/drv/touch/touch_driver_gt911.h @@ -0,0 +1,110 @@ +/* MIT License - Copyright (c) 2019-2021 Francis Van Roie + For full license information read the LICENSE file in the project folder */ + +#ifndef HASP_GT911_TOUCH_DRIVER_H +#define HASP_GT911_TOUCH_DRIVER_H + +#ifdef ARDUINO +#include "hasp_conf.h" + +#include "Arduino.h" +#include +#include "Goodix.h" +#include "ArduinoLog.h" + +#include "touch_driver.h" // base class + +#include "../../hasp/hasp.h" // for hasp_sleep_state +extern uint8_t hasp_sleep_state; + +#define INT_PIN (TOUCH_IRQ) +#define RST_PIN (TOUCH_RST) // -1 if pin is connected to VCC else set pin number + +static Goodix touch = Goodix(); +// static int8_t GT911_num_touches; +// static GTPoint* GT911_points; + +// Store touch points into global variable +IRAM_ATTR void GT911_setXY(int8_t contacts, GTPoint* points) +{ + // GT911_num_touches = contacts; + // GT911_points = points; + + // LOG_VERBOSE(TAG_GUI, F("Contacts: %d"), contacts); + // for(int i = 0; i < contacts; i++) { + // LOG_VERBOSE(TAG_GUI, F("C%d: #%d %d,%d s:%d"), i, points[i].trackId, points[i].x, points[i].y, + // points[i].area); yield(); + // } +} + +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(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; +} + +namespace dev { + +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); + } + + void init(int w, int h) + { + Wire.begin(TOUCH_SDA, TOUCH_SCL, I2C_TOUCH_FREQUENCY); + delay(300); + + touch.setHandler(GT911_setXY); + + if(touch.begin(INT_PIN, RST_PIN)) { + LOG_VERBOSE(TAG_DRVR, F("Goodix GT911 reset OK")); + } else { + LOG_WARNING(TAG_DRVR, F("Goodix GT911 reset failed")); + } + + Serial.print("Check ACK on addr request on 0x"); + // Serial.print(touch.i2cAddr, HEX); + + // Wire.beginTransmission(touch.i2cAddr); + int error; + // = Wire.endTransmission(); + if(error == 0) { + // Serial.println(": SUCCESS"); + } else { + // Serial.print(": ERROR #"); + // Serial.println(error); + } + + LOG_INFO(TAG_DRVR, F("Goodix GT911 touch driver started")); + } +}; + +} // namespace dev + +using dev::TouchGt911; +extern dev::TouchGt911 haspTouch; + +#endif // ARDUINO + +#endif // HASP_GT911_TOUCH_DRIVER_H diff --git a/user_setups/esp32/nscreen32.ini b/user_setups/esp32/nscreen32.ini index b61085bb..d67437ae 100644 --- a/user_setups/esp32/nscreen32.ini +++ b/user_setups/esp32/nscreen32.ini @@ -43,7 +43,8 @@ build_flags = -D TOUCH_SCL=22 -D TOUCH_IRQ=5 -D TOUCH_RST=23 - -D TOUCH_FREQUENCY=400000 + ;-D TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_FREQUENCY=400000 -D SPI_FREQUENCY=40000000 -D SPI_READ_FREQUENCY=20000000 ;endregion @@ -55,7 +56,7 @@ build_flags = lib_deps = ${env.lib_deps} ${esp32.lib_deps} - git+https://github.com/aselectroworks/Arduino-FT6336U.git + git+https://github.com/netwizeBE/arduino-goodix.git lib_ignore = ${env.lib_ignore}