From 7cb30b07da23c5355970c595ddca39f87ab957fc Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Mon, 26 Apr 2021 14:33:20 +0200 Subject: [PATCH] LVGL fix byte order for DMA and non-DMA (#11897) Co-authored-by: Stephan Hadinger --- lib/lib_display/UDisplay/uDisplay.cpp | 7 ++----- tasmota/lvgl_berry/tasmota_lv_conf.h | 2 +- tasmota/xdrv_54_lvgl.ino | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index b8830636a..6d2d62368 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -1064,6 +1064,8 @@ void uDisplay::pushColors(uint16_t *data, uint16_t len, boolean first) { if (lvgl_param.use_dma) { pushPixelsDMA(data, len ); } else { + // reversed order for DMA, so non-DMA needs to get back to normal order + for (uint32_t i = 0; i < len; i++) (data[i] = data[i] << 8 | data[i] >> 8); uspi->writePixels(data, len * 2); } #endif @@ -1923,11 +1925,6 @@ void uDisplay::pushPixelsDMA(uint16_t* image, uint32_t len) { dmaWait(); -/* - if(_swapBytes) { - for (uint32_t i = 0; i < len; i++) (image[i] = image[i] << 8 | image[i] >> 8); - }*/ - esp_err_t ret; memset(&trans, 0, sizeof(spi_transaction_t)); diff --git a/tasmota/lvgl_berry/tasmota_lv_conf.h b/tasmota/lvgl_berry/tasmota_lv_conf.h index ccc4146dc..9a501462b 100644 --- a/tasmota/lvgl_berry/tasmota_lv_conf.h +++ b/tasmota/lvgl_berry/tasmota_lv_conf.h @@ -37,7 +37,7 @@ * Useful if the display has a 8 bit interface (e.g. SPI)*/ // #define LV_COLOR_16_SWAP 1 // #if defined(ADAFRUIT_PYPORTAL) -// #define LV_COLOR_16_SWAP 1 +#define LV_COLOR_16_SWAP 1 // needed for DMA transfer // #else // #define LV_COLOR_16_SWAP 0 // #endif diff --git a/tasmota/xdrv_54_lvgl.ino b/tasmota/xdrv_54_lvgl.ino index daddaf109..98ff42bd4 100644 --- a/tasmota/xdrv_54_lvgl.ino +++ b/tasmota/xdrv_54_lvgl.ino @@ -168,7 +168,7 @@ void lv_flush_callback(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *c lv_disp_flush_ready(disp); - if (pixels_len >= 10000) { + if (pixels_len >= 10000 && (!display->lvgl_param.use_dma)) { AddLog(LOG_LEVEL_DEBUG, D_LOG_LVGL "Refreshed %d pixels in %d ms (%i pix/ms)", pixels_len, chrono_time, chrono_time > 0 ? pixels_len / chrono_time : -1); }