From 055ff08fe51da232c28d0fffeda6a4808eb141c1 Mon Sep 17 00:00:00 2001 From: mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> Date: Thu, 19 Aug 2021 19:34:40 +0100 Subject: [PATCH] Double buffer function reduction Can't get rid of the wait while statement though... --- ESP32-HUB75-MatrixPanel-I2S-DMA.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/ESP32-HUB75-MatrixPanel-I2S-DMA.h index f8648a1..93b5227 100644 --- a/ESP32-HUB75-MatrixPanel-I2S-DMA.h +++ b/ESP32-HUB75-MatrixPanel-I2S-DMA.h @@ -388,7 +388,7 @@ class MatrixPanel_I2S_DMA { // Setup the ESP32 DMA Engine. Sprite_TM built this stuff. configureDMA(m_cfg); //DMA and I2S configuration and setup - showDMABuffer(); // show backbuf_id of 0 + //showDMABuffer(); // show backbuf_id of 0 #if SERIAL_DEBUG if (!initialized) @@ -492,7 +492,7 @@ class MatrixPanel_I2S_DMA { static void color565to888(const uint16_t color, uint8_t &r, uint8_t &g, uint8_t &b); - inline void flipDMABuffer() + inline void IRAM_ATTR flipDMABuffer() { if ( !m_cfg.double_buff) return; @@ -503,25 +503,12 @@ class MatrixPanel_I2S_DMA { Serial.printf_P(PSTR("Set back buffer to: %d\n"), back_buffer_id); #endif - // Wait before we allow any writing to the buffer. Stop flicker. - while(!i2s_parallel_is_previous_buffer_free()) { delay(1); } - } - - inline void showDMABuffer() - { - - if (!m_cfg.double_buff) return; - - #if SERIAL_DEBUG - Serial.printf_P(PSTR("Showtime for buffer: %d\n"), back_buffer_id); - #endif - i2s_parallel_flip_to_buffer(I2S_NUM_0, back_buffer_id); // Wait before we allow any writing to the buffer. Stop flicker. - while(!i2s_parallel_is_previous_buffer_free()) { delay(1); } + while(i2s_parallel_is_previous_buffer_free() == false) { } } - + inline void setPanelBrightness(int b) { // Change to set the brightness of the display, range of 1 to matrixWidth (i.e. 1 - 64)