This commit is contained in:
mrfaptastic 2019-07-29 13:45:06 +01:00
parent e22a1173ef
commit 194a5f0f31
2 changed files with 51 additions and 44 deletions

View file

@ -61,7 +61,7 @@ void RGB64x32MatrixPanel_I2S_DMA::configureDMA(int r1_pin, int g1_pin, int b1_
Serial.printf("lsbMsbTransitionBit of %d gives %d Hz refresh: \r\n", lsbMsbTransitionBit, actualRefreshRate); Serial.printf("lsbMsbTransitionBit of %d gives %d Hz refresh: \r\n", lsbMsbTransitionBit, actualRefreshRate);
if (actualRefreshRate > 100) // HACK Hard Coded: Minimum frame rate of 150 if (actualRefreshRate > min_refresh_rate) // HACK Hard Coded: 100
break; break;

View file

@ -180,6 +180,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
backbuf_id = 0; backbuf_id = 0;
brightness = 60; // If you get ghosting... reduce brightness level. 60 seems to be the limit before ghosting on a 64 pixel wide physical panel for some panels brightness = 60; // If you get ghosting... reduce brightness level. 60 seems to be the limit before ghosting on a 64 pixel wide physical panel for some panels
min_refresh_rate = 100; // Probably best to leave as is unless you want to experiment. Framerate has an impact on brightness.
} }
@ -212,7 +213,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
#endif #endif
// Flush the DMA buffers prior to configuring DMA - Avoid visual artefacts on boot. // Flush the DMA buffers prior to configuring DMA - Avoid visual artefacts on boot.
clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage
flipDMABuffer(); // flip to backbuffer 1 flipDMABuffer(); // flip to backbuffer 1
clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage
@ -221,7 +222,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
// Setup the ESP32 DMA Engine. Sprite_TM built this stuff. // Setup the ESP32 DMA Engine. Sprite_TM built this stuff.
configureDMA(dma_r1_pin, dma_g1_pin, dma_b1_pin, dma_r2_pin, dma_g2_pin, dma_b2_pin, dma_a_pin, dma_b_pin, dma_c_pin, dma_d_pin, dma_e_pin, dma_lat_pin, dma_oe_pin, dma_clk_pin ); //DMA and I2S configuration and setup configureDMA(dma_r1_pin, dma_g1_pin, dma_b1_pin, dma_r2_pin, dma_g2_pin, dma_b2_pin, dma_a_pin, dma_b_pin, dma_c_pin, dma_d_pin, dma_e_pin, dma_lat_pin, dma_oe_pin, dma_clk_pin ); //DMA and I2S configuration and setup
showDMABuffer(); // show 0 showDMABuffer(); // show 0
} }
@ -242,32 +243,37 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
uint16_t color565(uint8_t r, uint8_t g, uint8_t b); // This is what is used by Adafruit GFX! uint16_t color565(uint8_t r, uint8_t g, uint8_t b); // This is what is used by Adafruit GFX!
inline void flipDMABuffer() inline void flipDMABuffer()
{ {
// Step 1. Bring backbuffer to the foreground (i.e. show it) // Step 1. Bring backbuffer to the foreground (i.e. show it)
//showDMABuffer(); //showDMABuffer();
// Step 2. Copy foreground to backbuffer // Step 2. Copy foreground to backbuffer
//matrixUpdateFrames[backbuf_id ^ 1] = matrixUpdateFrames[backbuf_id]; // copy currently being displayed buffer to backbuffer //matrixUpdateFrames[backbuf_id ^ 1] = matrixUpdateFrames[backbuf_id]; // copy currently being displayed buffer to backbuffer
// Step 3. Change to this new buffer as the backbuffer // Step 3. Change to this new buffer as the backbuffer
backbuf_id ^=1; // set this now to the back_buffer to update (not displayed yet though) backbuf_id ^=1; // set this now to the back_buffer to update (not displayed yet though)
#if SERIAL_DEBUG_OUTPUT #if SERIAL_DEBUG_OUTPUT
Serial.printf("Set back buffer to: %d\n", backbuf_id); Serial.printf("Set back buffer to: %d\n", backbuf_id);
#endif #endif
} }
inline void showDMABuffer() inline void showDMABuffer()
{ {
i2s_parallel_flip_to_buffer(&I2S1, backbuf_id); i2s_parallel_flip_to_buffer(&I2S1, backbuf_id);
} }
inline void setPanelBrightness(int b) inline void setPanelBrightness(int b)
{ {
// Change to set the brightness of the display, range of 1 to matrixWidth (i.e. 1 - 64) // Change to set the brightness of the display, range of 1 to matrixWidth (i.e. 1 - 64)
brightness = b; brightness = b;
} }
inline void setMinRefreshRate(int rr)
{
min_refresh_rate = rr;
}
// ------- PRIVATE ------- // ------- PRIVATE -------
@ -292,16 +298,17 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
// Pixel data is organized from LSB to MSB sequentially by row, from row 0 to row matrixHeight/matrixRowsInParallel (two rows of pixels are refreshed in parallel) // Pixel data is organized from LSB to MSB sequentially by row, from row 0 to row matrixHeight/matrixRowsInParallel (two rows of pixels are refreshed in parallel)
frameStruct *matrixUpdateFrames; frameStruct *matrixUpdateFrames;
// Setup // Setup
bool dma_configuration_success; bool dma_configuration_success;
// Internal variables // Internal variables
bool doubleBuffer; // Do we use double buffer mode? Your project code will have to manually flip between both. bool doubleBuffer; // Do we use double buffer mode? Your project code will have to manually flip between both.
int backbuf_id; // If using double buffer, which one is NOT active (ie. being displayed) to write too? int backbuf_id; // If using double buffer, which one is NOT active (ie. being displayed) to write too?
int lsbMsbTransitionBit; int lsbMsbTransitionBit;
int refreshRate; int refreshRate;
int brightness; int brightness;
int min_refresh_rate;
}; // end Class header }; // end Class header