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);
if (actualRefreshRate > 100) // HACK Hard Coded: Minimum frame rate of 150
if (actualRefreshRate > min_refresh_rate) // HACK Hard Coded: 100
break;

View file

@ -180,6 +180,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
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
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
// 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
flipDMABuffer(); // flip to backbuffer 1
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.
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!
inline void flipDMABuffer()
{
// Step 1. Bring backbuffer to the foreground (i.e. show it)
//showDMABuffer();
{
// Step 1. Bring backbuffer to the foreground (i.e. show it)
//showDMABuffer();
// Step 2. Copy foreground to backbuffer
//matrixUpdateFrames[backbuf_id ^ 1] = matrixUpdateFrames[backbuf_id]; // copy currently being displayed buffer to backbuffer
// Step 2. Copy foreground 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
backbuf_id ^=1; // set this now to the back_buffer to update (not displayed yet though)
// 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)
#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
}
inline void showDMABuffer()
{
i2s_parallel_flip_to_buffer(&I2S1, backbuf_id);
}
inline void showDMABuffer()
{
i2s_parallel_flip_to_buffer(&I2S1, backbuf_id);
}
inline void setPanelBrightness(int b)
{
// Change to set the brightness of the display, range of 1 to matrixWidth (i.e. 1 - 64)
brightness = b;
}
inline void setPanelBrightness(int b)
{
// Change to set the brightness of the display, range of 1 to matrixWidth (i.e. 1 - 64)
brightness = b;
}
inline void setMinRefreshRate(int rr)
{
min_refresh_rate = rr;
}
// ------- 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)
frameStruct *matrixUpdateFrames;
// Setup
bool dma_configuration_success;
// Setup
bool dma_configuration_success;
// Internal variables
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?
// Internal variables
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 lsbMsbTransitionBit;
int refreshRate;
int brightness;
int brightness;
int min_refresh_rate;
}; // end Class header