Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new effect to the demo firmware #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion RGBShades.ino
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <FastLED.h>
#include <EEPROM.h>
#include "messages.h"
#include "graphicsframe.h"
#include "font.h"
#include "XYmap.h"
#include "utils.h"
Expand All @@ -73,7 +74,8 @@ functionList effectList[] = {threeSine,
slantBars,
scrollTextTwo,
colorFill,
sideRain
sideRain,
eyesAnim
};

const byte numEffects = (sizeof(effectList)/sizeof(effectList[0]));
Expand Down
45 changes: 44 additions & 1 deletion effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ void scrollText(byte message, byte style, CRGB fgColor, CRGB bgColor) {

}


void scrollTextZero() {
scrollText(0, NORMAL, CRGB::Red, CRGB::Black);
}
Expand All @@ -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);
}

54 changes: 54 additions & 0 deletions graphicsframe.h
Original file line number Diff line number Diff line change
@@ -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}
};
*/