From cec4828a1371957d5f80c3a1bd5e12a00898dc5c Mon Sep 17 00:00:00 2001 From: mikep1998 <44448320+mikep1998@users.noreply.github.com> Date: Mon, 10 May 2021 13:26:59 -0700 Subject: [PATCH 1/3] Adding support for ILI9488/XPT2046 display --- lib/lib_display/UDisplay/uDisplay.cpp | 14 ++++++++ lib/lib_display/UDisplay/uDisplay.h | 4 +++ .../displaydesc/ILI9488_XPT2046_display.ini | 32 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 tasmota/displaydesc/ILI9488_XPT2046_display.ini diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index c54628266..9bffc5558 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -69,6 +69,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { fg_col = 1; bg_col = 0; splash_font = -1; + rotmap_xmin = -1; allcmd_mode = 0; startline = 0xA1; uint8_t section = 0; @@ -290,6 +291,12 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { lvgl_param.fluslines = next_val(&lp1); lvgl_param.use_dma = next_val(&lp1); break; + case 'M': + rotmap_xmin = next_val(&lp1); + rotmap_xmax = next_val(&lp1); + rotmap_ymin = next_val(&lp1); + rotmap_ymax = next_val(&lp1); + break; } } } @@ -1372,9 +1379,16 @@ void uDisplay::dim(uint8_t dim) { } +// the cases are PSEUDO_OPCODES from MODULE_DESCRIPTOR +// and may be exapnded with more opcodes void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) { int16_t temp; + if (rotmap_xmin >= 0) { + *y = map(*y, rotmap_ymin, rotmap_ymax, 0, height()); + *x = map(*x, rotmap_xmin, rotmap_xmax, 0, width()); + } + switch (rot_t[cur_rot]) { case 0: break; diff --git a/lib/lib_display/UDisplay/uDisplay.h b/lib/lib_display/UDisplay/uDisplay.h index 0d448d546..b0193f7d8 100755 --- a/lib/lib_display/UDisplay/uDisplay.h +++ b/lib/lib_display/UDisplay/uDisplay.h @@ -214,6 +214,10 @@ class uDisplay : public Renderer { uint16_t seta_xp2; uint16_t seta_yp1; uint16_t seta_yp2; + int16_t rotmap_xmin; + int16_t rotmap_xmax; + int16_t rotmap_ymin; + int16_t rotmap_ymax; void pushColorsMono(uint16_t *data, uint16_t len); #ifdef ESP32 // dma section diff --git a/tasmota/displaydesc/ILI9488_XPT2046_display.ini b/tasmota/displaydesc/ILI9488_XPT2046_display.ini new file mode 100644 index 000000000..f1bbf892d --- /dev/null +++ b/tasmota/displaydesc/ILI9488_XPT2046_display.ini @@ -0,0 +1,32 @@ +:H,ILI9488,480,320,16,SPI,1,*,*,*,*,*,*,*,10 +:S,2,1,1,0,40,20 +:I +E0,0F,00,03,09,08,16,0A,3F,78,4C,09,0A,08,16,1A,0F +E1,0F,00,16,19,03,0F,05,32,45,46,04,0E,0D,35,37,0F +C0,2,17,15 +C1,1,41 +C5,3,00,12,80 +36,1,48 +3A,1,66 +B0,1,80 +B1,1,A0 +B4,1,02 +B6,2,02,02 +E9,1,00 +F7,4,A9,51,2C,82 +11,80 +29,0 +:o,28 +:O,29 +:A,2A,2B,2C,16 +:R,36 +:0,28,00,00,06 +:1,48,00,00,05 +:2,E8,00,00,04 +:3,88,00,00,07 +:P,18 +:i,20,21 +:TS,16 +:B,20,0 +:M,340,3900,300,3800 +# From de506edd8e8863026cf9b306c3fdd491b22423a8 Mon Sep 17 00:00:00 2001 From: mikep1998 <44448320+mikep1998@users.noreply.github.com> Date: Mon, 10 May 2021 13:40:27 -0700 Subject: [PATCH 2/3] uDisplay support for new opcodes. --- lib/lib_display/UDisplay/uDisplay.cpp | 48 ++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index 9bffc5558..fb0a8177f 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -1384,10 +1384,7 @@ void uDisplay::dim(uint8_t dim) { void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) { int16_t temp; - if (rotmap_xmin >= 0) { - *y = map(*y, rotmap_ymin, rotmap_ymax, 0, height()); - *x = map(*x, rotmap_xmin, rotmap_xmax, 0, width()); - } + // Serial.printf("RAW X: %d, Y: %d, width: %d, height: %d\n", *x, *y, width(), height()); switch (rot_t[cur_rot]) { case 0: @@ -1406,7 +1403,50 @@ void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) { *y = *x; *x = width() - temp; break; + case 4: + break; + case 5: + // Serial.printf("Case 1 before, X: %d, Y: %d\n", *x, *y); + temp = *y; + *y = rotmap_xmax - *x; + *x = temp; + // Serial.printf("Case 1 after, X: %d, Y: %d\n", *x, *y); + break; + case 6: + // Serial.printf("Case 2 before, X: %d, Y: %d\n", *x, *y); + *x = rotmap_xmax - *x; + *y = rotmap_ymax - *y; + // Serial.printf("Case 2 after, X: %d, Y: %d\n", *x, *y); + break; + case 7: + // Serial.printf("Case 3 before, X: %d, Y: %d\n", *x, *y); + temp = *y; + *y = *x; + *x = rotmap_xmax - temp; + // Serial.printf("Case 3 after, X: %d, Y: %d\n", *x, *y); + break; } + + // Serial.printf("MAP rot: %d, case: %d, X: %d, Y: %d\n",cur_rot , rot_t[cur_rot], *x, *y); + + if (rotmap_xmin >= 0) { + *y = map(*y, rotmap_ymin, rotmap_ymax, 0, height()); + *x = map(*x, rotmap_xmin, rotmap_xmax, 0, width()); + } + + if (*x < 0) { + *x = 0; + } else if (*x > width()) { + *x = width(); + } + if (*y < 0) { + *y = 0; + } else if (*y > height()) { + *y = height(); + } + + // Serial.printf("ROT X: %d, Y: %d\n", *x, *y); + } uint8_t uDisplay::strlen_ln(char *str) { From 1c1495d52d426bcac0055406c65629866eb3062b Mon Sep 17 00:00:00 2001 From: mikep1998 <44448320+mikep1998@users.noreply.github.com> Date: Tue, 11 May 2021 00:26:14 -0700 Subject: [PATCH 3/3] rework of mapping --- lib/lib_display/UDisplay/uDisplay.cpp | 49 +++---------------- .../displaydesc/ILI9488_XPT2046_display.ini | 8 +-- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index fb0a8177f..e298ec8d1 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -1384,7 +1384,12 @@ void uDisplay::dim(uint8_t dim) { void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) { int16_t temp; - // Serial.printf("RAW X: %d, Y: %d, width: %d, height: %d\n", *x, *y, width(), height()); + if (rotmap_xmin >= 0) { + *y = map(*y, rotmap_ymin, rotmap_ymax, 0, gys); + *x = map(*x, rotmap_xmin, rotmap_xmax, 0, gxs); + } + *x = constrain(*x, 0, gxs); + *y = constrain(*y, 0, gys); switch (rot_t[cur_rot]) { case 0: @@ -1403,50 +1408,8 @@ void uDisplay::TS_RotConvert(int16_t *x, int16_t *y) { *y = *x; *x = width() - temp; break; - case 4: - break; - case 5: - // Serial.printf("Case 1 before, X: %d, Y: %d\n", *x, *y); - temp = *y; - *y = rotmap_xmax - *x; - *x = temp; - // Serial.printf("Case 1 after, X: %d, Y: %d\n", *x, *y); - break; - case 6: - // Serial.printf("Case 2 before, X: %d, Y: %d\n", *x, *y); - *x = rotmap_xmax - *x; - *y = rotmap_ymax - *y; - // Serial.printf("Case 2 after, X: %d, Y: %d\n", *x, *y); - break; - case 7: - // Serial.printf("Case 3 before, X: %d, Y: %d\n", *x, *y); - temp = *y; - *y = *x; - *x = rotmap_xmax - temp; - // Serial.printf("Case 3 after, X: %d, Y: %d\n", *x, *y); - break; } - // Serial.printf("MAP rot: %d, case: %d, X: %d, Y: %d\n",cur_rot , rot_t[cur_rot], *x, *y); - - if (rotmap_xmin >= 0) { - *y = map(*y, rotmap_ymin, rotmap_ymax, 0, height()); - *x = map(*x, rotmap_xmin, rotmap_xmax, 0, width()); - } - - if (*x < 0) { - *x = 0; - } else if (*x > width()) { - *x = width(); - } - if (*y < 0) { - *y = 0; - } else if (*y > height()) { - *y = height(); - } - - // Serial.printf("ROT X: %d, Y: %d\n", *x, *y); - } uint8_t uDisplay::strlen_ln(char *str) { diff --git a/tasmota/displaydesc/ILI9488_XPT2046_display.ini b/tasmota/displaydesc/ILI9488_XPT2046_display.ini index f1bbf892d..5d7fbbd5e 100644 --- a/tasmota/displaydesc/ILI9488_XPT2046_display.ini +++ b/tasmota/displaydesc/ILI9488_XPT2046_display.ini @@ -20,10 +20,10 @@ F7,4,A9,51,2C,82 :O,29 :A,2A,2B,2C,16 :R,36 -:0,28,00,00,06 -:1,48,00,00,05 -:2,E8,00,00,04 -:3,88,00,00,07 +:0,28,00,00,02 +:1,48,00,00,01 +:2,E8,00,00,00 +:3,88,00,00,03 :P,18 :i,20,21 :TS,16