From 1278682182b7b0bdf82acb8f168231d8166fe71f Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 16 Nov 2021 08:03:15 +0100 Subject: [PATCH 1/3] epaper area calls --- .../Display_Renderer-gemu-1.0/src/renderer.cpp | 18 ++++++++++++++++++ .../Display_Renderer-gemu-1.0/src/renderer.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.cpp b/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.cpp index fb223680b..e09ab71a8 100644 --- a/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.cpp +++ b/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.cpp @@ -633,6 +633,12 @@ LVGL_PARAMS *Renderer::lvgl_pars(void) { return &lvgl_param; } +void Renderer::ep_update_mode(uint8_t mode) { +} + +void Renderer::ep_update_area(uint16_t xp, uint16_t yp, uint16_t width, uint16_t height, uint8_t mode) { +} + // #ifndef USE_DISPLAY_LVGL_ONLY @@ -642,6 +648,18 @@ void VButton::xdrawButton(bool inverted) { wr_redir=0; } +void VButton::xinitButtonUL(Renderer *renderer, int16_t gxp, int16_t gyp, uint16_t gxs, uint16_t gys, uint16_t outline,\ + uint16_t fill, uint16_t textcolor , char *label, uint8_t textsize) { + + initButtonUL(renderer, gxp, gyp, gxs, gys, outline, fill, textcolor, label, textsize); + + spars.xp = gxp; + spars.yp = gyp; + spars.xs = gxs; + spars.ys = gys; + +} + boolean VButton::didhit(int16_t x, int16_t y) { return ((x >= spars.xp) && (x < (int16_t) (spars.xp + spars.xs)) && (y >= spars.yp) && (y < (int16_t) (spars.yp + spars.ys))); diff --git a/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h b/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h index 49f4d7b5e..3e3304fbb 100644 --- a/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h +++ b/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h @@ -88,6 +88,8 @@ public: virtual void Splash(void); virtual char *devname(void); virtual LVGL_PARAMS *lvgl_pars(void); + virtual void ep_update_mode(uint8_t mode); + virtual void ep_update_area(uint16_t xp, uint16_t yp, uint16_t width, uint16_t height, uint8_t mode); void setDrawMode(uint8_t mode); uint8_t drawmode; @@ -144,6 +146,8 @@ class VButton : public Adafruit_GFX_Button { boolean didhit(int16_t x, int16_t y); uint16_t UpdateSlider(int16_t x, int16_t y); void SliderInit(Renderer *rend, uint16_t xp, uint16_t yp, uint16_t xs, uint16_t ys, uint16_t nelem, uint16_t bgcol, uint16_t frcol, uint16_t barcol); + void xinitButtonUL(Renderer *renderer, int16_t gxp, int16_t gyp, uint16_t gxs, uint16_t gys, uint16_t outline,\ + uint16_t fill, uint16_t textcolor , char *label, uint8_t textsize); }; // #endif // USE_DISPLAY_LVGL_ONLY From 3885a19b57990f787580f6da687d88eb4eedf90c Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 16 Nov 2021 08:09:04 +0100 Subject: [PATCH 2/3] enable all pins for cs and dc --- lib/lib_display/UDisplay/uDisplay.cpp | 1 + lib/lib_display/UDisplay/uDisplay.h | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index aa2dae903..6f48d5796 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -343,6 +343,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { Serial.printf("SPED: %d\n", spi_speed*1000000); Serial.printf("Pixels: %d\n", col_mode); Serial.printf("SaMode: %d\n", sa_mode); + Serial.printf("DMA-Mode: %d\n", lvgl_param.use_dma); Serial.printf("opts: %02x,%02x,%02x\n", saw_3, dim_op, startline); diff --git a/lib/lib_display/UDisplay/uDisplay.h b/lib/lib_display/UDisplay/uDisplay.h index 8ce012bf5..3dbc5aed7 100755 --- a/lib/lib_display/UDisplay/uDisplay.h +++ b/lib/lib_display/UDisplay/uDisplay.h @@ -68,10 +68,12 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR }; #define SPI_BEGIN_TRANSACTION if (spi_nr <= 2) beginTransaction(spiSettings); #define SPI_END_TRANSACTION if (spi_nr <= 2) endTransaction(); -#define SPI_CS_LOW if (spi_cs >= 0) GPIO_CLR(spi_cs); -#define SPI_CS_HIGH if (spi_cs >= 0) GPIO_SET(spi_cs); -#define SPI_DC_LOW if (spi_dc >= 0) GPIO_CLR(spi_dc); -#define SPI_DC_HIGH if (spi_dc >= 0) GPIO_SET(spi_dc); + +#define SPI_CS_LOW if (spi_cs >= 0) GPIO_CLR_SLOW(spi_cs); +#define SPI_CS_HIGH if (spi_cs >= 0) GPIO_SET_SLOW(spi_cs); +#define SPI_DC_LOW if (spi_dc >= 0) GPIO_CLR_SLOW(spi_dc); +#define SPI_DC_HIGH if (spi_dc >= 0) GPIO_SET_SLOW(spi_dc); + #define ESP32_PWM_CHANNEL 1 From a35846769d9dba87002a618e4a3bfd296af34b19 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 16 Nov 2021 08:12:23 +0100 Subject: [PATCH 3/3] epaper area update, fix graph overflow --- tasmota/xdrv_13_display.ino | 41 ++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index bcf545bc5..636d0e1ce 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -701,6 +701,12 @@ void DisplayText(void) if (renderer) renderer->fillCircle(disp_xpos, disp_ypos, temp, fg_color); //else DisplayDrawFilledCircle(disp_xpos, disp_ypos, temp, fg_color); break; + case 'm': + // epaper draw mode currently only for 4,7 inch displays + var = atoiv(cp, &temp); + cp += var; + if (renderer) renderer->ep_update_mode(temp); + break; case 'r': // rectangle var = atoiv(cp, &temp); @@ -723,7 +729,27 @@ void DisplayText(void) break; case 'u': // rounded rectangle - { int16_t rad; + { int16_t rad, xp, yp, width, height; + if (*cp == 'p') { + // update epaper display + cp++; + var = atoiv(cp, &xp); + cp += var; + cp++; + var = atoiv(cp, &yp); + cp += var; + cp++; + var = atoiv(cp, &width); + cp += var; + cp++; + var = atoiv(cp, &height); + cp += var; + cp++; + var = atoiv(cp, &temp); + cp += var; + if (renderer) renderer->ep_update_area(xp, yp, width, height, temp); + break; + } var = atoiv(cp, &temp); cp += var; cp++; @@ -1100,7 +1126,7 @@ extern FS *ffsp; if (buttons[num]) { if (!sbt) { buttons[num]->vpower.slider = 0; - buttons[num]->initButtonUL(renderer, gxp, gyp, gxs, gys, GetColorFromIndex(outline),\ + buttons[num]->xinitButtonUL(renderer, gxp, gyp, gxs, gys, GetColorFromIndex(outline),\ GetColorFromIndex(fill), GetColorFromIndex(textcolor), bbuff, textsize); if (!bflags) { // power button @@ -1969,6 +1995,7 @@ void ApplyDisplayDimmer(void) { // still call Berry virtual display in case it is not managed entirely by renderer Xdsp18(FUNC_DISPLAY_DIM); #endif // USE_BERRY + } else { XdspCall(FUNC_DISPLAY_DIM); } @@ -2631,7 +2658,11 @@ void Restore_graph(uint8_t num, char *path) { if (count<=4) { if (count==0) gp->xcnt=atoi(vbuff); } else { - gp->values[count-5]=atoi(vbuff); + uint8_t yval = atoi(vbuff); + if (yval >= gp->ys) { + yval = gp->ys - 1; + } + gp->values[count-5] = yval; } } fp.close(); @@ -2735,9 +2766,9 @@ void AddValue(uint8_t num,float fval) { // decimation option if (gp->decimation<0) { if (gp->dcnt>=-gp->decimation) { - gp->dcnt=0; // calc average - val=gp->summ/-gp->decimation; + val=gp->summ/gp->dcnt; + gp->dcnt=0; gp->summ=0; // add to graph AddGraph(num,val);