Replies: 3 comments 1 reply
-
Hi I did other tests (using the serial monitor) and I understood that the period in which the matrix remains "off" (at startup), is for the entire duration of the first gif. Thanks again everyone |
Beta Was this translation helpful? Give feedback.
-
first of all thanks for replying to me Would it be possible to put dma_display->flipDMABuffer(); directly in the gif_functions.hpp file in the FOR cycle?
do you think it could work? |
Beta Was this translation helpful? Give feedback.
-
I tried, but the animations slow down a lot. I tried to find out all the steps that the code does and I discovered a place in the main code to insert it. here: if (!gif.open(gifPath, GIFOpenFile, GIFCloseFile, GIFReadFile, GIFSeekFile, GIFDraw)) int frameDelay = 0; // store delay for the last frame while (gif.playFrame(true, &frameDelay)) //here } return then; In this case it works quite well. If there is nothing better I will settle for this solution. Thank you |
Beta Was this translation helpful? Give feedback.
-
Hi
I successfully used the AnimatedGIFPanel_SD example (Thanks for creating it), but now I need to configure "mxconfig.double_buff = true;" because I need it for other parts of code that flicker without doublebuff.
the problem is that by setting doublebuffer to true the animated gifs no longer work and I get this result:
the matrix remains off for a many seconds and then only one frame is displayed (it is the last) for each gif on SD card
this is my code:
`#include "FS.h"
#include "SD.h"
#include "SPI.h"
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include <AnimatedGIF.h>
/**** SD Card GPIO mappings ****/
#define SS_PIN 3 // SD pin config
#define R1_PIN 27
#define G1_PIN 26
#define B1_PIN 14
#define R2_PIN 12
#define G2_PIN 25
#define B2_PIN 15
#define A_PIN 32
#define B_PIN 17
#define C_PIN 33
#define D_PIN 16
#define E_PIN 5
#define LAT_PIN 2
#define OE_PIN 4
#define CLK_PIN 0
/***************************************************************
**************************************************************/
#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.
#define PANEL_CHAIN 1 // Total number of panels chained one to another
/**************************************************************/
AnimatedGIF gif;
MatrixPanel_I2S_DMA *dma_display = nullptr;
static int totalFiles = 0; // GIF files count
static File FSGifFile; // temp gif file holder
static File GifRootFolder; // directory listing
std::vectorstd::string GifFiles; // GIF files path
const int maxGifDuration = 20000; // ms, max GIF duration
#include "gif_functions.hpp"
#include "sdcard_functions.hpp"
/**************************************************************/
int gifPlay(const char *gifPath)
{ // 0=infinite
if (!gif.open(gifPath, GIFOpenFile, GIFCloseFile, GIFReadFile, GIFSeekFile, GIFDraw))
{
log_n("Could not open gif %s", gifPath);
}
int frameDelay = 0; // store delay for the last frame
int then = 0; // store overall delay
while (gif.playFrame(true, &frameDelay))
{
then += frameDelay;
if (then > maxGifDuration)
{ // avoid being trapped in infinite GIF's
//log_w("Broke the GIF loop, max duration exceeded");
break;
}
}
gif.close();
return then;
}
/**************************************************************/
void setup()
{
// **************************** Setup SD Card access via SPI ****************************
if (!SD.begin(SS_PIN))
{
// bool begin(uint8_t ssPin=SS, SPIClass &spi=SPI, uint32_t frequency=4000000, const char * mountpoint="/sd", uint8_t max_files=5, bool format_if_empty=false);
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE)
{
return;
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
// **************************** Setup DMA Matrix ****************************
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(
PANEL_RES_X, PANEL_RES_Y, // Module width and height
PANEL_CHAIN, // Chain length
_pins // Pin configuration
);
//******** Display Setup********************
//mxconfig.i2sspeed = mxconfig.HZ_20M;
//mxconfig.min_refresh_rate = 10;
mxconfig.double_buff = true;
dma_display = new MatrixPanel_I2S_DMA(mxconfig);
// Allocate memory and start DMA display
if (not dma_display->begin())
dma_display->clearScreen();
dma_display->setBrightness(40);
// **************************** Setup Sketch ****************************
// SD CARD STOPS WORKING WITH DMA DISPLAY ENABLED>...
File root = SD.open("/gifs");
if (!root)
{
return;
}
File file = root.openNextFile();
while (file)
{
if (!file.isDirectory())
{
std::string filename = "/gifs/" + std::string(file.name());
GifFiles.push_back(filename);
totalFiles++;
}
file = root.openNextFile();
}
file.close();
// This is important - Set the right endianness.
gif.begin(LITTLE_ENDIAN_PIXELS);
}
/**************************************************************/
void loop()
{
// Riproduzione di GIF
for (auto &elem : GifFiles)
{
// clear screen
dma_display->clearScreen();
delay(10);
}
}
`
I also tried to insert:
mxconfig.i2sspeed = mxconfig.HZ_20M;
mxconfig.min_refresh_rate = 10;
but nothing changes so I comment them into the code
is there any solution?
Could you please help me?
thanks
best regards
Beta Was this translation helpful? Give feedback.
All reactions