123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- int frameCount = 0;
- char previousAnicode = 'a';
- void delayWithEarlyBreakout(int delayDuration) {
- delayDuration = delayDuration / 100;
- for (int i = 0; i < delayDuration; i++) {
- delay(100);
- if (getAnimationCode() != previousAnicode) {
- break;
- }
- }
- }
- void handleAnimationRendering(char anicode) {
- if (previousAnicode != anicode) {
- previousAnicode = anicode;
- frameCount = 0;
- }
-
- String targetFrame = "/" + String(anicode) + ".bin";
- if (SD.exists(targetFrame)) {
-
- loadFrameAndRender(targetFrame);
- int delayDuration = getFrameDuration(anicode, 0);
- delayWithEarlyBreakout(delayDuration);
- return;
- }
-
- targetFrame = "/" + String(anicode) + String(frameCount) + ".bin";
- if (SD.exists(targetFrame)) {
- loadFrameAndRender(targetFrame);
- frameCount++;
- int delayDuration = getFrameDuration(anicode, frameCount);
- delayWithEarlyBreakout(delayDuration);
- return;
- } else {
-
- if (frameCount != 0) {
- loadFrameAndRender("/" + String(anicode) + "0.bin");
- int delayDuration = getFrameDuration(anicode, 0);
- delayWithEarlyBreakout(delayDuration);
- frameCount = 1;
- return;
- } else {
-
- Serial.println("Target frame buffer not found: " + String(anicode) + ".bin");
- setAnimationCode('a');
- return;
- }
- }
- }
- int getFrameDuration(char anicode, int framecount) {
- if ((anicode == 'a' || anicode == 'b' || anicode == 'g')) {
-
- if (framecount == 0) {
- return 3000;
- }
- return 300;
- }
- return 500;
- }
|