mrcodetastic / ESP32-HUB75-MatrixPanel-DMA

An Adafruit GFX Compatible Library for the ESP32, ESP32-S2, ESP32-S3 to drive HUB75 LED matrix panels using DMA for high refresh rates. Supports panel chaining.
MIT License
977 stars 215 forks source link

flipDMABuffer - What am I doing wrong? #610

Closed mcgalactor closed 8 months ago

mcgalactor commented 8 months ago

Hi,

I'm trying to reduce flickering using flipDMABuffer. From what I understand, I can disconnect (flip#1) the buffer from the output (sending it to the back), do some heavy calculations for the new output, and then reconnect it (flip#2). I've simplified the problem in the following test sketch. Why am I seeing the "Temp Output" on the display? Wasn't it supposed to go to the back buffer?

Thanks

Jan

include

MatrixPanel_I2S_DMA *display = nullptr;

const int panelResX = 64; // Number of pixels wide of each INDIVIDUAL panel module. const int panelResY = 32; // Number of pixels tall of each INDIVIDUAL panel module. const int panel_chain = 2; // Total number of panels chained one to another void drawHeavyStuff();

define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module.

define PANEL_RES_Y 32 // Number of pixels tall of each INDIVIDUAL panel module.

void setup() { // put your setup code here, to run once: delay(1000); Serial.begin(115200); delay(200);

define R1_PIN 25

define G1_PIN 27

define B1_PIN 26

define R2_PIN 14

define G2_PIN 13

define B2_PIN 12

define A_PIN 22

define B_PIN 19

define C_PIN 18

define D_PIN 5

define E_PIN 23 // required for 1/32 scan panels, like 64x64px. Any available pin would do, i.e. IO32

define LAT_PIN 2

define OE_PIN 15

define CLK_PIN 4

HUB75_I2S_CFG::i2s_pins _pins = {R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN}; HUB75_I2S_CFG mxconfig(/ width = / panelResX, / height = / panelResY, / chain = / panel_chain, _pins);

display = new MatrixPanel_I2S_DMA(mxconfig); mxconfig.double_buff = true; // <------------- Turn on double buffer

display->begin(); display->setBrightness8(255); display->setTextSize(4); drawHeavyStuff(); }

void drawHeavyStuff() { display->flipDMABuffer(); //flip#1; disconnect output buffer (send it to the back) display->clearScreen(); //clear back buffer for (int i = 0; i < 64; i++) //simulating heavy calculations { display->setCursor(i, 0); display->print("Temp Output"); // not supposed to be seen, since it is printed to the back buffer delay(40); display->clearScreen(); //clear back buffer }

display->setCursor(0, 0); display->print("Final Output"); //print final output display->flipDMABuffer();//flip#2; flip buffer to see "Final Output" }

void loop() {

delay(1000);

}

mcgalactor commented 8 months ago

Sorry, shout have gone to "Discussions" not to issues.