From cf8cb970e95a08a4b44a7b917775d158f6e2501d Mon Sep 17 00:00:00 2001 From: mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> Date: Tue, 16 Feb 2021 20:20:09 +0000 Subject: [PATCH] Minor changes --- ESP32-HUB75-MatrixPanel-I2S-DMA.cpp | 3 +- ESP32-HUB75-MatrixPanel-I2S-DMA.h | 5 +- .../DoubleBufferSwap/DoubleBufferSwap.ino | 55 +++++++++++-------- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp b/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp index 89f24ae..b7dc8b0 100644 --- a/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp +++ b/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp @@ -100,10 +100,11 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory() Serial.println(F("DMA memory blocks available before any malloc's: ")); heap_caps_print_heap_info(MALLOC_CAP_DMA); - + Serial.println(F("******************************************************************")); Serial.printf_P(PSTR("We're going to need %d bytes of SRAM just for the frame buffer(s).\r\n"), _frame_buffer_memory_required); Serial.printf_P(PSTR("The total amount of DMA capable SRAM memory is %d bytes.\r\n"), heap_caps_get_free_size(MALLOC_CAP_DMA)); Serial.printf_P(PSTR("Largest DMA capable SRAM memory block is %d bytes.\r\n"), heap_caps_get_largest_free_block(MALLOC_CAP_DMA)); + Serial.println(F("******************************************************************")); #endif diff --git a/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/ESP32-HUB75-MatrixPanel-I2S-DMA.h index e1c1067..83c43dd 100644 --- a/ESP32-HUB75-MatrixPanel-I2S-DMA.h +++ b/ESP32-HUB75-MatrixPanel-I2S-DMA.h @@ -67,9 +67,6 @@ /***************************************************************************************/ /* Do not change definitions below unless you pretty sure you know what you are doing! */ -#ifndef ESP32_I2S_CLOCK_SPEED - #define ESP32_I2S_CLOCK_SPEED (10000000UL) // @ 10Mhz -#endif // RGB Panel Constants / Calculated Values #ifndef MATRIX_ROWS_IN_PARALLEL @@ -233,7 +230,7 @@ struct HUB75_I2S_CFG { /** * I2S clock speed selector */ - enum clk_speed {HZ_10M=10000000, HZ_13340K=13340000, HZ_16M=16000000, HZ_20M=20000000, HZ_26670K=26670000}; + enum clk_speed {HZ_10M=10000000, HZ_20M=20000000}; // Structure Variables diff --git a/examples/DoubleBufferSwap/DoubleBufferSwap.ino b/examples/DoubleBufferSwap/DoubleBufferSwap.ino index 81e116d..76e2ea2 100644 --- a/examples/DoubleBufferSwap/DoubleBufferSwap.ino +++ b/examples/DoubleBufferSwap/DoubleBufferSwap.ino @@ -10,8 +10,8 @@ * for different resolutions / panel chain lengths within the sketch 'setup()'. * */ -MatrixPanel_I2S_DMA display(true); // Note the TRUE -> Turns of secondary buffer - "double buffering"! - // Double buffering is not enabled by default with the library. + +MatrixPanel_I2S_DMA *display = nullptr; const byte row0 = 2+0*10; const byte row1 = 2+1*10; @@ -26,30 +26,37 @@ void setup() Serial.println("...Starting Display"); - display.begin(); // setup display with pins as per defined in the library - display.setTextColor(display.color565(128, 128, 128)); + HUB75_I2S_CFG mxconfig; + mxconfig.double_buff = true; // Turn of double buffer + + // OK, now we can create our matrix object + display = new MatrixPanel_I2S_DMA(mxconfig); + + + display->begin(); // setup display with pins as per defined in the library + display->setTextColor(display->color565(255, 255, 255)); // Buffer 0 test - display.fillScreen(display.color565(128, 0, 0)); - display.setCursor(3, row0); - display.print(F("Buffer 0")); - display.setCursor(3, row1); - display.print(F(" Buffer 0")); + display->fillScreen(display->color565(128, 0, 0)); + display->setCursor(3, row0); + display->print(F("Buffer 0")); + display->setCursor(3, row1); + display->print(F(" Buffer 0")); Serial.println("Wrote to to Buffer 0"); - display.showDMABuffer(); + display->showDMABuffer(); delay(1500); // Buffer 1 test - display.flipDMABuffer(); - display.fillScreen(display.color565(0, 128, 0)); // shouldn't see this - display.setCursor(3, row0); - display.print(F("Buffer 1")); - display.setCursor(3, row2); - display.print(F(" Buffer 1")); + display->flipDMABuffer(); + display->fillScreen(display->color565(0, 128, 0)); // shouldn't see this + display->setCursor(3, row0); + display->print(F("Buffer 1")); + display->setCursor(3, row2); + display->print(F(" Buffer 1")); Serial.println("Wrote to to Buffer 1"); - display.showDMABuffer(); + display->showDMABuffer(); delay(1500); } @@ -57,31 +64,31 @@ void setup() void loop() { // Flip the back buffer - display.flipDMABuffer(); + display->flipDMABuffer(); // Write: Set bottow row to black for (int y=20;ydrawPixelRGB888( x, y, 0, 0, 0); } // Write: Set bottom row to blue (this is what should show) for (int y=20;ydrawPixelRGB888( x, y, 0, 0, 64); } // Now show this back buffer - display.showDMABuffer(); + display->showDMABuffer(); delay(1000); // Flip back buffer - display.flipDMABuffer(); + display->flipDMABuffer(); // Show this buffer - display.showDMABuffer(); + display->showDMABuffer(); delay(1000); -} +} \ No newline at end of file