Skip to content

Commit

Permalink
PSRAM buffer fixes as per SoftHack007
Browse files Browse the repository at this point in the history
  • Loading branch information
troyhacks committed Sep 10, 2024
1 parent 08e2e18 commit 3ee05a7
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,12 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh

#endif

mxconfig.clkphase = false;
// mxconfig.double_buff = true; // <------------- Turn on double buffer
// mxconfig.driver = HUB75_I2S_CFG::ICN2038S; // experimental - use specific shift register driver
// mxconfig.latch_blanking = 3;
// mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M; // experimental - 5MHZ should be enugh, but colours looks slightly better at 10MHz
// mxconfig.min_refresh_rate = 90;
mxconfig.clkphase = false; // can help in case that the leftmost column is invisible, or pixels on the right side "bleeds out" to the left.
mxconfig.chain_length = max((u_int8_t) 1, min(bc.pins[0], (u_int8_t) 4)); // prevent bad data preventing boot due to low memory

USER_PRINTF("MatrixPanel_I2S_DMA config - %ux%u length: %u\n", mxconfig.mx_width, mxconfig.mx_height, mxconfig.chain_length);
Expand Down Expand Up @@ -769,15 +774,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
if (_ledBuffer) free(_ledBuffer); // should not happen
if (_ledsDirty) free(_ledsDirty); // should not happen

#if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM)
if (psramFound()){
_ledsDirty = (byte*) ps_malloc(getBitArrayBytes(_len)); // create LEDs dirty bits
} else {
_ledsDirty = (byte*) malloc(getBitArrayBytes(_len)); // create LEDs dirty bits
}
#else
_ledsDirty = (byte*) malloc(getBitArrayBytes(_len)); // create LEDs dirty bits
#endif

if (_ledsDirty == nullptr) {
display->stopDMAoutput();
Expand All @@ -789,7 +786,7 @@ BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWh
setBitArray(_ledsDirty, _len, false); // reset dirty bits

if (mxconfig.double_buff == false) {
#if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM)
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM) && defined(CONFIG_SPIRAM_MODE_OCT)
if (psramFound()){
_ledBuffer = (CRGB*) ps_calloc(_len, sizeof(CRGB)); // create LEDs buffer (initialized to BLACK)
} else {
Expand Down

0 comments on commit 3ee05a7

Please sign in to comment.