Bad Apple!!
This commit is contained in:
parent
b7445338db
commit
2315fe15ff
@ -20,4 +20,5 @@ lib_deps =
|
||||
Wire
|
||||
fastled/FastLED
|
||||
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA.git
|
||||
bitbank2/AnimatedGIF
|
||||
|
||||
|
52047
src/badapple.h
Normal file
52047
src/badapple.h
Normal file
File diff suppressed because it is too large
Load Diff
106
src/main.cpp
106
src/main.cpp
@ -1,8 +1,10 @@
|
||||
#include <Arduino.h>
|
||||
#include "xtensa/core-macros.h"
|
||||
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
|
||||
#include <AnimatedGIF.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "badapple.h"
|
||||
|
||||
#define R1 25
|
||||
#define G1 27 //26
|
||||
@ -30,6 +32,8 @@
|
||||
#define NUM_LEDS PANE_WIDTH*PANE_HEIGHT
|
||||
|
||||
MatrixPanel_I2S_DMA *matrix = nullptr;
|
||||
AnimatedGIF gif;
|
||||
int frameDelay = 500;
|
||||
|
||||
void setup(){
|
||||
|
||||
@ -45,20 +49,106 @@ void setup(){
|
||||
|
||||
mxconfig.latch_blanking = 4;
|
||||
mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M;
|
||||
mxconfig.clkphase = true;
|
||||
mxconfig.clkphase = false;
|
||||
|
||||
matrix = new MatrixPanel_I2S_DMA(mxconfig);
|
||||
matrix->begin();
|
||||
matrix->setBrightness8(32);
|
||||
matrix->setBrightness8(128);
|
||||
matrix->fillScreenRGB888(0, 0, 0);
|
||||
|
||||
gif.begin(LITTLE_ENDIAN_PIXELS);
|
||||
}
|
||||
|
||||
void GIFDraw(GIFDRAW *pDraw) {
|
||||
uint8_t *s;
|
||||
uint16_t *d, *usPalette, usTemp[320];
|
||||
int x, y, iWidth;
|
||||
|
||||
usPalette = pDraw->pPalette;
|
||||
y = pDraw->iY + pDraw->y; // current line
|
||||
|
||||
s = pDraw->pPixels;
|
||||
if (pDraw->ucDisposalMethod == 2) // restore to background color
|
||||
{
|
||||
for (x = 0; x < iWidth; x++)
|
||||
{
|
||||
if (s[x] == pDraw->ucTransparent)
|
||||
s[x] = pDraw->ucBackground;
|
||||
}
|
||||
pDraw->ucHasTransparency = 0;
|
||||
}
|
||||
// Apply the new pixels to the main image
|
||||
if (pDraw->ucHasTransparency) // if transparency used
|
||||
{
|
||||
Serial.println("Transparency!");
|
||||
uint8_t *pEnd, c, ucTransparent = pDraw->ucTransparent;
|
||||
int x, iCount;
|
||||
pEnd = s + pDraw->iWidth;
|
||||
//x = 0;
|
||||
x = pDraw->iX;
|
||||
iCount = 0; // count non-transparent pixels
|
||||
while (x < pDraw->iWidth)
|
||||
{
|
||||
c = ucTransparent - 1;
|
||||
d = usTemp;
|
||||
while (c != ucTransparent && s < pEnd)
|
||||
{
|
||||
c = *s++;
|
||||
if (c == ucTransparent) // done, stop
|
||||
{
|
||||
s--; // back up to treat it like transparent
|
||||
}
|
||||
else // opaque
|
||||
{
|
||||
*d++ = usPalette[c];
|
||||
iCount++;
|
||||
}
|
||||
} // while looking for opaque pixels
|
||||
if (iCount) // any opaque pixels?
|
||||
{
|
||||
for (int xOffset = 0; xOffset < iCount; xOffset++)
|
||||
{
|
||||
matrix->drawPixel(x + xOffset, y, usTemp[xOffset]);
|
||||
}
|
||||
x += iCount;
|
||||
iCount = 0;
|
||||
}
|
||||
// no, look for a run of transparent pixels
|
||||
c = ucTransparent;
|
||||
while (c == ucTransparent && s < pEnd)
|
||||
{
|
||||
c = *s++;
|
||||
if (c == ucTransparent)
|
||||
iCount++;
|
||||
else
|
||||
s--;
|
||||
}
|
||||
if (iCount)
|
||||
{
|
||||
x += iCount; // skip these
|
||||
iCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = pDraw->pPixels;
|
||||
// Translate the 8-bit pixels through the RGB565 palette (already byte reversed)
|
||||
for (x = 0; x < pDraw->iWidth; x++)
|
||||
{
|
||||
matrix->drawPixel(x, y, usPalette[*s++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for(int y = 0; y!=PANE_HEIGHT; y++) {
|
||||
for(int x = 0; x!=PANE_WIDTH; x++) {
|
||||
matrix->drawPixelRGB888(x, y, 0, 0, 255);
|
||||
delay(10);
|
||||
if (gif.open((uint8_t *)badapple, sizeof(badapple), GIFDraw))
|
||||
{
|
||||
Serial.printf("Successfully opened GIF; Canvas size = %d x %d\n", gif.getCanvasWidth(), gif.getCanvasHeight());
|
||||
while (gif.playFrame(true, NULL))
|
||||
{
|
||||
}
|
||||
Serial.printf("Row complete: %d\n", y);
|
||||
gif.close();
|
||||
}
|
||||
matrix->fillScreenRGB888(0, 0, 0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user