From 1e230e1f2d5d4b84de3c01c5f0a4f78c2a4d32c0 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 25 Apr 2021 17:28:42 +0200 Subject: [PATCH 1/3] fix lvgl touch --- .../Xlatb_RA8876-gemu-1.0/RA8876.cpp | 3 ++ .../Xlatb_RA8876-gemu-1.0/library.properties | 12 +++--- .../Adafruit_LvGL_Glue.cpp | 2 - tasmota/xdrv_13_display.ino | 38 ++++++++++--------- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.cpp b/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.cpp index 0e36a6dde..b507912ff 100644 --- a/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.cpp +++ b/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.cpp @@ -481,6 +481,9 @@ void RA8876::DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font) { } bool RA8876::initDisplay() { + + lvgl_param = 10; + SPI.beginTransaction(m_spiSettings); // Set chip config register diff --git a/lib/lib_display/Xlatb_RA8876-gemu-1.0/library.properties b/lib/lib_display/Xlatb_RA8876-gemu-1.0/library.properties index 5eea15179..6e478adf0 100644 --- a/lib/lib_display/Xlatb_RA8876-gemu-1.0/library.properties +++ b/lib/lib_display/Xlatb_RA8876-gemu-1.0/library.properties @@ -1,9 +1,9 @@ name=RA8876 -version=1.0.0 -author=Jaret Burkett / Gerhard Mutz -maintainer=Gerhard Mutz -sentence=Tasmota Library for RA8876 displays -paragraph=Tasmota Library for RA8876 displays +version=1.0.2 +author=Jaret Burkett +maintainer=Jaret Burkett +sentence=Library for RA8876 displays +paragraph=Library for RA8876 displays category=Display -url=https://github.com/arendst/Tasmota +url=https://github.com/jaretburkett/ILI9488 architectures=* diff --git a/lib/libesp32_lvgl/Adafruit_LvGL_Glue-shadinger/Adafruit_LvGL_Glue.cpp b/lib/libesp32_lvgl/Adafruit_LvGL_Glue-shadinger/Adafruit_LvGL_Glue.cpp index dfabf2efa..8128bf3b8 100644 --- a/lib/libesp32_lvgl/Adafruit_LvGL_Glue-shadinger/Adafruit_LvGL_Glue.cpp +++ b/lib/libesp32_lvgl/Adafruit_LvGL_Glue-shadinger/Adafruit_LvGL_Glue.cpp @@ -29,11 +29,9 @@ uint32_t Touch_Status(uint32_t sel); static bool touchscreen_read(struct _lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { //lv_coord_t last_x = 0, last_y = 0; //static uint8_t release_count = 0; -#if defined(USE_FT5206) || defined(USE_XPT2046) data->point.x = Touch_Status(1); // Last-pressed coordinates data->point.y = Touch_Status(2); data->state = Touch_Status(0); -#endif return false; /*No buffering now so no more data read*/ } diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index 1736e6a2c..e90eab48a 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -2677,14 +2677,32 @@ void AddValue(uint8_t num,float fval) { * Touch panel control \*********************************************************************************************/ -#if defined(USE_FT5206) || defined(USE_XPT2046) + bool FT5206_found = false; bool XPT2046_found = false; - int16_t touch_xp; int16_t touch_yp; bool touched; +uint32_t Touch_Status(uint32_t sel) { + if (FT5206_found || XPT2046_found) { + switch (sel) { + case 0: + return touched; + case 1: + return touch_xp; + case 2: + return touch_yp; + } + return 0; + } else { + return 0; + } +} + +#if defined(USE_FT5206) || defined(USE_XPT2046) + + #ifdef USE_M5STACK_CORE2 uint8_t tbstate[3]; #endif // USE_M5STACK_CORE2 @@ -2747,21 +2765,7 @@ int16_t XPT2046_y() { } #endif // USE_XPT2046 -uint32_t Touch_Status(uint32_t sel) { - if (FT5206_found || XPT2046_found) { - switch (sel) { - case 0: - return touched; - case 1: - return touch_xp; - case 2: - return touch_yp; - } - return 0; - } else { - return 0; - } -} + void Touch_Check(void(*rotconvert)(int16_t *x, int16_t *y)) { From 45b38c9bf2db942540676efb23f8483df6faae7b Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 25 Apr 2021 19:18:55 +0200 Subject: [PATCH 2/3] faster tft spi for esp32 --- lib/lib_display/UDisplay/uDisplay.cpp | 16 ++++++++-- tasmota/xdrv_10_scripter.ino | 45 ++++++++++++--------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index d529de26d..aaa5c236d 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -1026,9 +1026,19 @@ void uDisplay::pushColors(uint16_t *data, uint16_t len, boolean first) { return; } - while (len--) { - color = *data++; - WriteColor(color); + if ( (col_mode != 18) && (spi_dc >= 0) && (spi_nr <= 2) ) { + // special version 8 bit spi I or II +#ifdef ESP8266 + while (len--) { + uspi->write(*data++); + } +#else + uspi->writePixels(data, len * 2); +#endif + } else { + while (len--) { + WriteColor(*data++); + } } } diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index ff71dd4c8..da7216ca8 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -2629,7 +2629,7 @@ chknext: len = 0; goto exit; } -#endif +#endif // USE_LVGL break; case 'm': if (!strncmp(vname, "med(", 4)) { @@ -7764,39 +7764,34 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event) { if (event == LV_EVENT_CLICKED) { AddLog_P(LOG_LEVEL_INFO,PSTR(">>> clicked")); } - AddLog_P(LOG_LEVEL_INFO,PSTR(">>> clicked")); } int32_t lvgl_test(int32_t p) { + start_lvgl(ili9342); + lv_obj_clean(lv_scr_act()); - lv_obj_t *label1 = lv_label_create(lv_scr_act(), NULL); - - /*Modify the Label's text*/ - lv_label_set_text(label1, "Hello world!"); - + if (p == 0) { + lv_obj_t *label1 = lv_label_create(lv_scr_act(), NULL); + /*Modify the Label's text*/ + lv_label_set_text(label1, "Hello world!"); /* Align the Label to the center * NULL means align on parent (which is the screen now) * 0, 0 at the end means an x, y offset after alignment*/ - lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0); - - - lvgl_setup(); - - /*Add a button*/ - lv_obj_t *btn1 = lv_btn_create(lv_scr_act(), NULL); /*Add to the active screen*/ - lv_obj_set_pos(btn1, 2, 2); /*Adjust the position*/ - lv_obj_set_size(btn1, 96, 30); /* set size of button */ - lv_obj_set_event_cb(btn1, btn_event_cb); - - /*Add text*/ - lv_obj_t *label = lv_label_create(btn1, NULL); /*Put on 'btn1'*/ - lv_label_set_text(label, "Click"); - - - + lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0); + /*Add a button*/ + lv_obj_t *btn1 = lv_btn_create(lv_scr_act(), NULL); /*Add to the active screen*/ + lv_obj_set_pos(btn1, 2, 2); /*Adjust the position*/ + lv_obj_set_size(btn1, 96, 30); /* set size of button */ + lv_obj_set_event_cb(btn1, btn_event_cb); + /*Add text*/ + lv_obj_t *label = lv_label_create(btn1, NULL); /*Put on 'btn1'*/ + lv_label_set_text(label, "Click"); + } else { + lvgl_setup(); + } return 0; } @@ -7898,7 +7893,7 @@ void lvgl_setup(void) { } -#endif +#endif // USE_LVGL /*********************************************************************************************\ * Interface From 17277413575cd1c1761a28fd8050950f1d2995af Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 25 Apr 2021 19:25:42 +0200 Subject: [PATCH 3/3] add hadinger mod space --- lib/lib_display/UDisplay/uDisplay.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index aaa5c236d..95cff99dd 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -108,7 +108,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { } if (*lp1 == ',') lp1++; } - if (*lp1 != ':' && *lp1 != '\n') { + if (*lp1 != ':' && *lp1 != '\n' && *lp1 != ' ') { // Add space char switch (section) { case 'H': // header line @@ -288,11 +288,16 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { } } } - if (*lp == '\n') { + if (*lp == '\n' || *lp == ' ') { // Add space char lp++; } else { lp = strchr(lp, '\n'); - if (!lp) break; + if (!lp) { + lp = strchr(lp, ' '); + if (!lp) { + break; + } + } lp++; } } @@ -1272,7 +1277,7 @@ void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) { uint8_t uDisplay::strlen_ln(char *str) { for (uint32_t cnt = 0; cnt < 256; cnt++) { - if (!str[cnt] || str[cnt] == '\n') return cnt; + if (!str[cnt] || str[cnt] == '\n' || str[cnt] == ' ') return cnt; } return 0; }