From a257e49bb4430be72560425f37ac17439b9afa07 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:20:15 +0200 Subject: [PATCH] HUB75 trying to reduce glitches the HUB75 driver seems to randomly produce glitches, especially on hight contrast edges. * roll back to HUB75 version 3.0.10 (known good) * limit max brightness to 238 (=92%) * add short delay after starting the driver --- platformio.ini | 3 ++- wled00/bus_manager.cpp | 23 ++++++++++++++++------- wled00/bus_manager.h | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index ec1a387dfc..93ca49744d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1038,7 +1038,8 @@ HUB75_build_flags = -D S3_LCD_DIV_NUM=20 ;; Attempt to fix wifi performance issue when panel active with S3 chips ;; HUB75_lib_deps = https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA.git @ 3.0.11 ;; breaks the build (2024-07-30) ;; HUB75_lib_deps = https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA.git#1e4c80a26454aca7b8129bd5a966b0af329d2703 ;; 3.0.10 - something strange is going on here ... -HUB75_lib_deps = https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA.git#c4ecdcfeeb5aa668d92ddf3c3c74bc93316f6e10 ;; 3.0.11 +HUB75_lib_deps = https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA.git#1e4c80a26454aca7b8129bd5a966b0af329d2703 ;; 3.0.10 - something strange is going on here ... +;; HUB75_lib_deps = https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA.git#c4ecdcfeeb5aa668d92ddf3c3c74bc93316f6e10 ;; 3.0.11 HUB75_lib_ignore = ESP32 HUB75 LED MATRIX PANEL DMA Display ;; to remove the HUB75 lib dependancy (saves a few bytes) NetDebug_build_flags = diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index f5ecb5d676..189b779a53 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -685,17 +685,18 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh USER_PRINTLN("MatrixPanel_I2S_DMA created"); // let's adjust default brightness display->setBrightness8(25); // range is 0-255, 0 - 0%, 255 - 100% + _bri = 25; + delay(24); // experimental // Allocate memory and start DMA display if( not display->begin() ) { USER_PRINTLN("****** MatrixPanel_I2S_DMA !KABOOM! I2S memory allocation failed ***********"); return; } else { + delay(18); // experiment - give the driver a moment (~ one full frame @ 60hz) to settle _valid = true; display->clearScreen(); // initially clear the screen buffer - display->setBrightness8(127); // range is 0-255, 0 - 0%, 255 - 100% - _bri = 127; if (_ledBuffer) free(_ledBuffer); // should not happen if (_ledsDirty) free(_ledsDirty); // should not happen @@ -736,8 +737,12 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh break; } + if (_valid) { + _panelWidth = fourScanPanel ? fourScanPanel->width() : display->width(); // cache width - it will never change + } + USER_PRINT(F("MatrixPanel_I2S_DMA ")); - USER_PRINTF("%sstarted.\n", _valid? "":"not "); + USER_PRINTF("%sstarted, width=%u, %u pixels.\n", _valid? "":"not ", _panelWidth, _len); if (mxconfig.double_buff == true) USER_PRINTLN(F("MatrixPanel_I2S_DMA driver native double-buffering enabled.")); if (_ledBuffer != nullptr) USER_PRINTLN(F("MatrixPanel_I2S_DMA LEDS buffer enabled.")); @@ -772,12 +777,12 @@ void __attribute__((hot)) BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c uint8_t b = B(c); if(fourScanPanel != nullptr) { - unsigned width = fourScanPanel->width(); + int width = _panelWidth; int x = pix % width; int y = pix / width; fourScanPanel->drawPixelRGB888(int16_t(x), int16_t(y), r, g, b); } else { - unsigned width = display->width(); + int width = _panelWidth; int x = pix % width; int y = pix / width; display->drawPixelRGB888(int16_t(x), int16_t(y), r, g, b); @@ -794,16 +799,19 @@ uint32_t BusHub75Matrix::getPixelColor(uint16_t pix) const { } void BusHub75Matrix::setBrightness(uint8_t b, bool immediate) { - this->display->setBrightness(b); _bri = b; + if (_bri > 238) _bri=238; + display->setBrightness(_bri); } void __attribute__((hot)) BusHub75Matrix::show(void) { if (!_valid) return; + display->setBrightness(_bri); + if (_ledBuffer) { // write out buffered LEDs bool isFourScan = (fourScanPanel != nullptr); - unsigned width = isFourScan ? fourScanPanel->width() : display->width(); + //if (isFourScan) fourScanPanel->setRotation(0); unsigned height = isFourScan ? fourScanPanel->height() : display->height(); //while(!previousBufferFree) delay(1); // experimental - Wait before we allow any writing to the buffer. Stop flicker. @@ -837,6 +845,7 @@ void __attribute__((hot)) BusHub75Matrix::show(void) { void BusHub75Matrix::cleanup() { if (display && _valid) display->stopDMAoutput(); // terminate DMA driver (display goes black) _valid = false; + _panelWidth = 0; deallocatePins(); USER_PRINTLN("HUB75 output ended."); diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 96aba376cf..2379f43048 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -389,6 +389,7 @@ class BusHub75Matrix : public Bus { MatrixPanel_I2S_DMA *display = nullptr; VirtualMatrixPanel *fourScanPanel = nullptr; HUB75_I2S_CFG mxconfig; + unsigned _panelWidth = 0; CRGB *_ledBuffer = nullptr; byte *_ledsDirty = nullptr; };