From 1fa0b42480a56022a8ba1359863838b47ed18f2f Mon Sep 17 00:00:00 2001 From: mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:18:36 +0100 Subject: [PATCH] Fix #163 Array out of bounds DMA change. --- ESP32-HUB75-MatrixPanel-I2S-DMA.cpp | 8 ++++++-- ESP32-HUB75-MatrixPanel-I2S-DMA.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp b/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp index e32fb26..c32dc13 100644 --- a/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp +++ b/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp @@ -754,6 +754,7 @@ void MatrixPanel_I2S_DMA::brtCtrlOE(int brt, const bool _buff_id){ /* * overload for compatibility */ + /* bool MatrixPanel_I2S_DMA::begin(int r1, int g1, int b1, int r2, int g2, int b2, int a, int b, int c, int d, int e, int lat, int oe, int clk) { // RGB @@ -769,6 +770,7 @@ bool MatrixPanel_I2S_DMA::begin(int r1, int g1, int b1, int r2, int g2, int b2, return begin(); } +*/ /** * @brief - Sets how many clock cycles to blank OE before/after LAT signal change @@ -879,8 +881,10 @@ void MatrixPanel_I2S_DMA::vlineDMA(int16_t x_coord, int16_t y_coord, int16_t l, if ( x_coord < 0 || y_coord < 0 || l < 1 || x_coord >= PIXELS_PER_ROW || y_coord >= m_cfg.mx_height) return; - if (y_coord + l > m_cfg.mx_height) - l = m_cfg.mx_height - y_coord + 1; // reset width to end of col + // check for a length that goes beyond the height of the screen! Array out of bounds dma memory changes = screwed output #163 + l = ( (y_coord + l) >= m_cfg.mx_height ) ? (m_cfg.mx_height - y_coord):l; + //if (y_coord + l > m_cfg.mx_height) + /// l = m_cfg.mx_height - y_coord + 1; // reset width to end of col /* LED Brightness Compensation */ #ifndef NO_CIE1931 diff --git a/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/ESP32-HUB75-MatrixPanel-I2S-DMA.h index 113bffe..c1561b9 100644 --- a/ESP32-HUB75-MatrixPanel-I2S-DMA.h +++ b/ESP32-HUB75-MatrixPanel-I2S-DMA.h @@ -351,7 +351,7 @@ class MatrixPanel_I2S_DMA { /* Propagate the DMA pin configuration, allocate DMA buffs and start data ouput, initialy blank */ bool begin(){ - if (initialized) return; // we don't do this twice or more! + if (initialized) return true; // we don't do this twice or more! // Change 'if' to '1' to enable, 0 to not include this Serial output in compiled program #if SERIAL_DEBUG @@ -402,7 +402,9 @@ class MatrixPanel_I2S_DMA { /* * overload for compatibility */ + /* bool begin(int r1, int g1 = G1_PIN_DEFAULT, int b1 = B1_PIN_DEFAULT, int r2 = R2_PIN_DEFAULT, int g2 = G2_PIN_DEFAULT, int b2 = B2_PIN_DEFAULT, int a = A_PIN_DEFAULT, int b = B_PIN_DEFAULT, int c = C_PIN_DEFAULT, int d = D_PIN_DEFAULT, int e = E_PIN_DEFAULT, int lat = LAT_PIN_DEFAULT, int oe = OE_PIN_DEFAULT, int clk = CLK_PIN_DEFAULT); + */ // TODO: Disable/Enable auto buffer flipping (useful for lots of drawPixel usage)...