full code:
#include "Charliplexing.h" //initializes the LoL Sheild library
#include "planet.h"
//#define colour "orange"
#define cons 23// how many constellations there are
//orange = 23
//pink = 20
int GLOBALDELAY = 100;
int scrollSpeed = 50; //delay between frames
int xPosition = 0; //x position 0-13
int yPosition = 0; //y position 0-8
int frameCounter = 0; //used to find when the frame has filled up (126 leds)
int greyscale = 1; //greyscale color 0-7
bool set = true;
stargroup con[23];
void setup() // run once, when the sketch starts
{
LedSign::Init(GRAYSCALE); //initializes a grayscale frame buffer
// if (colour == "orange")
// {
//declaring the constella
int xL[] = {2, 2 ,3, 3, 3, 3};
int yL[] = {1, 0, 8, 7, 6, 5};
stargroup L(6, xL, yL);
con[0] = L; //Set(L);
int xM[] = {3,3,3,3};
int yM[] = {4,3,2,1};
stargroup M(4, xM, yM);
con[1] = M; //Set(M);
int xN[] = {4,4,4,4};
int yN[] = {8,7,6,5};
stargroup N(4, xN, yN);
con[2] = N;
int xO[] = {4,4,4,4};
int yO[] = {4,3,2,1};
stargroup O(4, xO, yO);
con[3] = O;
int xq[] = {5,5,5,5,5};
int yq[] = {7,6,5,4,3};
stargroup q(5, xq, yq);
con[4] = q; //Set(M);
int xe[] = {13, 13};
int ye[] = {8,7};
stargroup e(2, xe, ye);
con[5] = e; //Set(M);
int xf[] = {0,0,0,0,0}; //06 05 04 03 02
int yf[] = {6,5,4,3,2};
stargroup f(5, xf, yf);
con[6] = f; //Set(M);
int xg[] = {0,0,1,1}; //01 00 18 17
int yg[] = {1,0,8,7};
stargroup g(4, xg, yg);
con[7] = g; //Set(M);
int xh[] = {1,1,1,1,1};
int yh[] = {6,5,4,3,2};
stargroup h(5, xh, yh);
con[8] = h; //Set(M);
int xi[] = {1,4}; //10 48
int yi[] = {0,8};
stargroup i(2, xi, yi);
con[9] = i; //Set(M);
int xj[] = {2,2}; //27 26
int yj[] = {7,6};
stargroup j(2, xj, yj);
con[10] = j; //Set(M);
int xk[] = {2,2,2,2};
int yk[] = {5,4,3,2};
stargroup k(4, xk, yk);
con[11] = k; //Set(M);
int xa[] = {5,5,5,6,6,6}; //52 51 50 68 67 66
int ya[] = {2,1,0,8,7,6};
stargroup a(6, xa, ya);
con[12] = a; //Set(M);
int xb[] = {6,6,6,6};
int yb[] = {5,4,3,2};
stargroup b(4, xb, yb);
con[13] = b; //Set(M);
int xc[] = {6,6,7,7,7,7,7,7,7,7}; //61 60 78 77 76 75 74 73 72 71
int yc[] = {1,0,8,7,6,5,4,3,2,1};
stargroup c(10, xc, yc);
con[14] = c; //Set(M);
int xd[] = {7,8,8,8,8,8}; //06 05 04 03 02
int yd[] = {0,8,7,6,5,4};
stargroup d(6, xd, yd);
con[15] = d; //Set(M);
int xs[] = {8,8};
int ys[] = {3,2};
stargroup s(2, xs, ys);
con[16] = s; //Set(M);
int xt[] = {8,8,9,9};
int yt[] = {1,0,8,7};
stargroup t(4, xt, yt);
con[17] = t; //Set(M);
int xv[] = {9,9,9,9};
int yv[] = {6,5,4,3};
stargroup v(4, xv, yv);
con[18] = v; //Set(M);
int xw[] = {9,9,9,10,10,10};
int yw[] = {2,1,0,8,7,6};
stargroup w(6, xw, yw);
con[19] = w; //Set(M);
int xx[] = {10,10,10,10,10};
int yx[] = {5,4,3,2,1};
stargroup x(5, xx, yx);
con[20] = x; //Set(M);
int xy[] = {10, 11};
int yy[] = {0,8};
stargroup y(2, xy, yy);
con[21] = y; //Set(M);
int xz[] = {11,11,11};
int yz[] = {7,6,5};
stargroup z(3, xz, yz);
con[22] = z; //Set(M);
int xzz[] = {11,11};
int yzz[] = {4,3};
stargroup zz(2, xzz, yzz);
con[23] = zz;
}
void loop() // run over and over again
{
// int count = 0; //used for timing
bool up = true; //up is used for twinkle direction.
int lightup = 0; //used for which constellation is to be chosen.
// stargroup con[20]; // array of constellations
// for (int k = 0; k < 10000; k++)
// {
//If the frame counter is full, then it delays for scrollSpeed.
if(frameCounter == 126)
{
delay(scrollSpeed);
frameCounter=0;
// LedSign::Set(random(13), random(8), random(7));
// count++;
}
//at the end of the row, it advances Y to the next one
if(xPosition == 13)yPosition++;
//at the end of the row, it starts from the first LED in the next one
if(xPosition > 13)xPosition=0;
//at the end of the frame, it starts from the begining again
if(yPosition > 8)yPosition=0;
//twinkle the lights between 2 and 6 so they dont turn off completly
if(greyscale > 6) up = false;
if(greyscale < 2) up = true;
if (up) greyscale++;
if (!up) greyscale--;
// here are some variations for twinkles, but they are commented out
// greyscale = random(7); //random (comment out increment above)
// if(greyscale > 7)greyscale= 0; // original
// if(greyscale > 7)greyscale= 4; //light twinkle
//sends the current x, y, and color to the frame, one LED at a time
LedSign::Set(xPosition, yPosition, greyscale); //set normal light to twinkle
LedSign::Set(random(13), random(8), random(2,6)); //set random light to random value.
//the counters are at the end of the loop, which will advance everything
//for the next frame
xPosition++;
frameCounter++;
// }
for (int i = 0; i < cons; i++)
{
con[i].fadeOffAll();
}
delay(1000);
for (int i = 0; i < 5; i++)
{
lightup = random(cons);
con[lightup].fadeOn();
delay(500);
con[lightup].fadeOff();
delay(500);
}
// count = 0;
}
/////////////////////////////////////////