From 7e38e7511664bd66f135508dc4d51c9134adffa7 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Thu, 30 Sep 2021 19:09:38 +0200 Subject: [PATCH] fix multi display issues --- lib/lib_display/UDisplay/uDisplay.cpp | 1 + tasmota/xdrv_13_display.ino | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index 7bca0f723..44b19d6e9 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -70,6 +70,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { bg_col = 0; splash_font = -1; rotmap_xmin = -1; + bpanel = -1; allcmd_mode = 0; startline = 0xA1; uint8_t section = 0; diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index dd3567822..b55ab7359 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -63,6 +63,8 @@ struct MULTI_DISP { int16_t disp_ypos; uint8_t color_type; uint8_t auto_draw; + uint8_t model; + uint8_t used; } displays[MAX_MULTI_DISPLAYS]; uint8_t cur_display; Renderer *Init_uDisplay(const char *desc, int8_t cs); @@ -75,6 +77,8 @@ void Set_display(uint8_t index) { displays[index].auto_draw = auto_draw; displays[index].disp_xpos = disp_xpos; displays[index].disp_ypos = disp_ypos; + displays[index].model = Settings->display_model; + displays[index].used = 1; cur_display = index; } @@ -87,6 +91,7 @@ void Get_display(uint8_t index) { disp_xpos = displays[index].disp_xpos; disp_ypos = displays[index].disp_ypos; if (renderer) renderer->setDrawMode(auto_draw >> 1); + //Settings->display_model = displays[index].model; cur_display = index; } #endif // USE_MULTI_DISPLAY @@ -587,16 +592,21 @@ void DisplayText(void) break; #ifdef USE_MULTI_DISPLAY case 'S': - { + { int16_t rot = -1, srot, model; var = atoiv(cp, &temp); cp += var; if (temp < 1 || temp > MAX_MULTI_DISPLAYS) { temp = 1; } temp--; + if (*cp == 'r') { + cp++; + var = atoiv(cp, &rot); + cp += var; + } if (*cp == ':') { cp++; - if (displays[temp].display) { + if (displays[temp].used) { Set_display(cur_display); Get_display(temp); } @@ -613,13 +623,22 @@ void DisplayText(void) uint32_t size = fp.size(); char *fdesc = (char *)calloc(size + 4, 1); if (fdesc) { + model = Settings->display_model; fp.read((uint8_t*)fdesc, size); fp.close(); Get_display(temp); + if (rot >= 0) { + srot = Settings->display_rotate; + Settings->display_rotate = rot; + } renderer = Init_uDisplay(fdesc, -1); + if (rot >= 0) { + Settings->display_rotate = srot; + } Set_display(temp); AddLog(LOG_LEVEL_INFO, PSTR("DSP: File descriptor loaded %x"),renderer); free(fdesc); + Settings->display_model = model; } } }