GIFs work again in principle
This commit is contained in:
committed by
Will Tatam
parent
e8c09104e1
commit
b8a29bcbf8
@@ -374,6 +374,7 @@ lib_deps =
|
||||
https://github.com/softhack007/LITTLEFS-threadsafe.git#master
|
||||
makuna/NeoPixelBus @ 2.7.5
|
||||
;; makuna/NeoPixelBus @ 2.7.9 ;; experimental
|
||||
https://github.com/Aircoookie/GifDecoder#e76f58f
|
||||
${env.lib_deps}
|
||||
|
||||
;; Compatibility with upstream --> you should prefer using ${common_mm.build_flags_S} and ${common_mm.lib_deps_S}
|
||||
|
||||
@@ -4650,6 +4650,21 @@ uint16_t mode_washing_machine(void) {
|
||||
static const char _data_FX_MODE_WASHING_MACHINE[] PROGMEM = "Washing Machine@!,!;;!";
|
||||
|
||||
|
||||
/*
|
||||
Image effect
|
||||
Draws a .gif image from filesystem on the matrix/strip
|
||||
*/
|
||||
uint16_t mode_image(void) {
|
||||
//Serial.println(renderImageToSegment(SEGMENT));
|
||||
int status = renderImageToSegment(SEGMENT);
|
||||
if (status != 0 && status != 254 && status != 255) {
|
||||
Serial.print("GIF renderer return: ");
|
||||
Serial.println(status);
|
||||
}
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_IMAGE[] PROGMEM = "Image@!,;;;12;sx=128";
|
||||
|
||||
/*
|
||||
Blends random colors across palette
|
||||
Modified, originally by Mark Kriegsman https://gist.github.com/kriegsman/1f7ccbbfa492a73c015e
|
||||
@@ -9071,7 +9086,7 @@ void WS2812FX::setupEffectData() {
|
||||
addEffect(FX_MODE_TWO_DOTS, &mode_two_dots, _data_FX_MODE_TWO_DOTS);
|
||||
addEffect(FX_MODE_FAIRYTWINKLE, &mode_fairytwinkle, _data_FX_MODE_FAIRYTWINKLE);
|
||||
addEffect(FX_MODE_RUNNING_DUAL, &mode_running_dual, _data_FX_MODE_RUNNING_DUAL);
|
||||
|
||||
addEffect(FX_MODE_IMAGE, &mode_image, _data_FX_MODE_IMAGE);
|
||||
addEffect(FX_MODE_TRICOLOR_CHASE, &mode_tricolor_chase, _data_FX_MODE_TRICOLOR_CHASE);
|
||||
addEffect(FX_MODE_TRICOLOR_WIPE, &mode_tricolor_wipe, _data_FX_MODE_TRICOLOR_WIPE);
|
||||
addEffect(FX_MODE_TRICOLOR_FADE, &mode_tricolor_fade, _data_FX_MODE_TRICOLOR_FADE);
|
||||
|
||||
@@ -287,6 +287,7 @@ void Segment::resetIfRequired() {
|
||||
needsBlank = false;
|
||||
}
|
||||
}
|
||||
endImagePlayback(this);
|
||||
}
|
||||
|
||||
void Segment::setUpLeds() {
|
||||
|
||||
@@ -119,6 +119,7 @@ int fileReadCallback(void);
|
||||
int fileReadBlockCallback(void * buffer, int numberOfBytes);
|
||||
int fileSizeCallback(void);
|
||||
byte renderImageToSegment(Segment &seg);
|
||||
void endImagePlayback(Segment* seg);
|
||||
#endif
|
||||
|
||||
//improv.cpp
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
File file;
|
||||
char lastFilename[34] = "/";
|
||||
GifDecoder<32,32,12> decoder;
|
||||
GifDecoder<32,32,12,true> decoder;
|
||||
bool gifDecodeFailed = false;
|
||||
long lastFrameDisplayTime = 0, currentFrameDelay = 0;
|
||||
|
||||
@@ -85,7 +85,7 @@ byte renderImageToSegment(Segment &seg) {
|
||||
if (file) file.close();
|
||||
openGif(lastFilename);
|
||||
if (!file) { gifDecodeFailed = true; return IMAGE_ERROR_FILE_MISSING; }
|
||||
//if (!decoder) decoder = new GifDecoder<32,32,12>();
|
||||
//if (!decoder) decoder = new GifDecoder<32,32,12,true>();
|
||||
//if (!decoder) { gifDecodeFailed = true; return IMAGE_ERROR_DECODER_ALLOC; }
|
||||
decoder.setScreenClearCallback(screenClearCallback);
|
||||
decoder.setUpdateScreenCallback(updateScreenCallback);
|
||||
@@ -95,6 +95,7 @@ byte renderImageToSegment(Segment &seg) {
|
||||
decoder.setFileReadCallback(fileReadCallback);
|
||||
decoder.setFileReadBlockCallback(fileReadBlockCallback);
|
||||
decoder.setFileSizeCallback(fileSizeCallback);
|
||||
decoder.alloc(); // TODO only if not already allocated
|
||||
Serial.println("Starting decoding");
|
||||
if(decoder.startDecoding() < 0) { gifDecodeFailed = true; return IMAGE_ERROR_GIF_DECODE; }
|
||||
Serial.println("Decoding started");
|
||||
@@ -124,12 +125,16 @@ byte renderImageToSegment(Segment &seg) {
|
||||
return IMAGE_ERROR_NONE;
|
||||
}
|
||||
|
||||
void endImagePlayback() {
|
||||
void endImagePlayback(Segment *seg) {
|
||||
Serial.println("Image playback end called");
|
||||
if (!activeSeg || activeSeg != seg) return;
|
||||
if (file) file.close();
|
||||
//delete decoder;
|
||||
decoder.dealloc();
|
||||
gifDecodeFailed = false;
|
||||
activeSeg = nullptr;
|
||||
lastFilename[0] = '\0';
|
||||
lastFilename[1] = '\0';
|
||||
Serial.println("Image playback ended");
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user