Skip to content

Commit

Permalink
HUB75 trying to reduce glitches
Browse files Browse the repository at this point in the history
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
  • Loading branch information
softhack007 committed Aug 12, 2024
1 parent e90f8e7 commit a257e49
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
23 changes: 16 additions & 7 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."));
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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.");

Expand Down
1 change: 1 addition & 0 deletions wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit a257e49

Please sign in to comment.