diff --git a/RGBShades.ino b/RGBShades.ino index dcace47..2474aa1 100644 --- a/RGBShades.ino +++ b/RGBShades.ino @@ -54,6 +54,7 @@ #include #include #include "messages.h" +#include "graphicsframe.h" #include "font.h" #include "XYmap.h" #include "utils.h" @@ -73,7 +74,8 @@ functionList effectList[] = {threeSine, slantBars, scrollTextTwo, colorFill, - sideRain + sideRain, + eyesAnim }; const byte numEffects = (sizeof(effectList)/sizeof(effectList[0])); diff --git a/effects.h b/effects.h index 78df7ae..8397fe7 100644 --- a/effects.h +++ b/effects.h @@ -315,7 +315,6 @@ void scrollText(byte message, byte style, CRGB fgColor, CRGB bgColor) { } - void scrollTextZero() { scrollText(0, NORMAL, CRGB::Red, CRGB::Black); } @@ -328,3 +327,47 @@ void scrollTextTwo() { scrollText(2, NORMAL, CRGB::Green, CRGB(0,0,8)); } +void graphicsFrame(int frame, CRGB fgColor,CRGB bgColor){ + // Buffers for graphics generation + byte GlassesBits[kMatrixWidth][kMatrixHeight] = {{0}}; // 24 column x 8 row bit arrays (on/off frame) + int currentFrameAddress = pgm_read_word(&frameArray[frame]); + + // startup tasks + if (effectInit == false) { + effectInit = true; + effectDelay = 5; + } + + + for (byte x = 0; x < kMatrixWidth; x++) { + for (byte y = 0; y < kMatrixHeight; y++) { + GlassesBits[x][y] = pgm_read_byte(currentFrameAddress+x+kMatrixWidth*y); + if (GlassesBits[x][y] == 1) leds[XY(x, y)] = fgColor; + else leds[XY(x,y)] = bgColor; + } + } +} + +void eyesAnim(){ + static byte frameSeq[] = {0,2,1,2,0,2,3,2,3,2}; + static byte frameIndex = 0; + static unsigned long lastFrame=0; + const byte frameDelay=500; + + // startup tasks + if (effectInit == false) { + effectInit = true; + effectDelay = 5; + } + + if (millis() > lastFrame+frameDelay) { + frameIndex++; + frameIndex=frameIndex%10; + lastFrame=millis(); + } + + CRGB fgColor = CHSV(cycleHue, 255, 255); + //CRGB bgColor = CHSV(cycleHue+128, 255, 255); + graphicsFrame(frameSeq[frameIndex],fgColor,CRGB::Black); +} + diff --git a/graphicsframe.h b/graphicsframe.h new file mode 100644 index 0000000..6394579 --- /dev/null +++ b/graphicsframe.h @@ -0,0 +1,54 @@ +// Full-frame bitmap graphic + +// Blinking Eyes +const byte frame0[5][16] PROGMEM = +{ + {0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0}, + {1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1}, + {1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1}, + {1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1}, + {0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0} +}; + +const byte frame1[5][16] PROGMEM = +{ + {0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0}, + {1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1}, + {1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1}, + {1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1}, + {0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0} +}; + +const byte frame2[5][16] PROGMEM = +{ + {0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0}, + {1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1}, + {1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1}, + {1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1}, + {0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0} +}; +const byte frame3[5][16] PROGMEM = +{ + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0}, + {0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +}; + +const byte * const frameArray[] PROGMEM = { + frame0[0], + frame1[0], + frame2[0], + frame3[0] +}; +/* +{ +{0b00000000, 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, +{0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, +{0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, +{0b00000000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}, +{0b00000000, 0b00000000, 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000} +}; +*/ +