Sure, here is the code, PART1/2 (too long to paste in 1 pcs)
// This #include statement was automatically added by the Spark IDE.
#include "neopixel/neopixel.h"
#include "application.h"
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D0
#define PIXEL_COUNT 512
#define PIXEL_TYPE WS2812B
unsigned char alpha[][8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //space
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x0c, 0x0c, //!
0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //"
0x14, 0x14, 0x14, 0x3f, 0x14, 0x3f, 0x14, 0x14, //#
0x0c, 0x3f, 0x2d, 0x0d, 0x3f, 0x2c, 0x2d, 0x3f, //$
0x03, 0x23, 0x10, 0x08, 0x04, 0x02, 0x31, 0x30, //%
0x0c, 0x12, 0x11, 0x0a, 0x24, 0x2a, 0x11, 0x2e, //&
0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //'
0x38, 0x1c, 0x0e, 0x06, 0x06, 0x0e, 0x1c, 0x38, //(
0x07, 0x0e, 0x1c, 0x18, 0x18, 0x1c, 0x0e, 0x07, //)
0x00, 0x00, 0x12, 0x0c, 0x0c, 0x12, 0x00, 0x00, //*
0x00, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, //+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, //,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, //-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, //.
0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, // /
0x3f, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, //0
0x1c, 0x1c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //1
0x3f, 0x3f, 0x30, 0x3f, 0x3f, 0x03, 0x3f, 0x3f, //2
0x3f, 0x3f, 0x30, 0x3c, 0x3c, 0x30, 0x3f, 0x3f, //3
0x33, 0x33, 0x33, 0x3f, 0x3f, 0x30, 0x30, 0x30, //4
0x3f, 0x3f, 0x03, 0x3f, 0x3f, 0x30, 0x3f, 0x3f, //5
0x3f, 0x3f, 0x03, 0x3f, 0x3f, 0x33, 0x3f, 0x3f, //6
0x3f, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, //7
0x3f, 0x3f, 0x33, 0x3f, 0x3f, 0x33, 0x3f, 0x3f, //8
0x3f, 0x3f, 0x33, 0x3f, 0x3f, 0x30, 0x3f, 0x3f, //9
0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, //:
0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x04, 0x00, //;
0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, //<
0x00, 0x00, 0x1e, 0x00, 0x00, 0x1e, 0x00, 0x00, //=
0x00, 0x02, 0x04, 0x08, 0x10, 0x08, 0x04, 0x02, //>
0x1e, 0x10, 0x1e, 0x02, 0x1e, 0x00, 0x0c, 0x0c, //?
0x00, 0x1e, 0x21, 0x2d, 0x15, 0x1d, 0x31, 0x3e, //@
0x1e, 0x3f, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, //A
0x1f, 0x3f, 0x33, 0x1f, 0x1f, 0x33, 0x3f, 0x1f, //B
0x3e, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3e, //C
0x0f, 0x1f, 0x33, 0x33, 0x33, 0x33, 0x1f, 0x0f, //D
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x3f, 0x3f, //E
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x03, 0x03, //F
0x1e, 0x3f, 0x03, 0x03, 0x3b, 0x33, 0x3f, 0x1e, //G
0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, //H
0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, //I
0x3f, 0x3f, 0x30, 0x30, 0x30, 0x33, 0x3f, 0x1e, //J
0x03, 0x33, 0x1b, 0x0f, 0x07, 0x0f, 0x1b, 0x33, //K
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f, //L
0x21, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, 0x33, //M
0x33, 0x37, 0x37, 0x3f, 0x3f, 0x3b, 0x3b, 0x33, //N
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, //O
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x03, 0x03, //P
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x3b, 0x1f, 0x2e, //Q
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x1b, 0x33, //R
0x3e, 0x3f, 0x03, 0x1f, 0x3e, 0x30, 0x3f, 0x1f, //S
0x3f, 0x3f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, //T
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, //U
0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, //V
0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x21, //W
0x21, 0x33, 0x1e, 0x0c, 0x0c, 0x1e, 0x33, 0x21, //X
0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, 0x0c, 0x0c, //Y
0x3f, 0x3f, 0x38, 0x1c, 0x0e, 0x07, 0x3f, 0x3f, //Z
0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, //[
0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, //\
0x00, 0x1e, 0x18, 0x18, 0x18, 0x18, 0x1e, 0x00, //]
0x0e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0e, //]
0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, //^
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, //_
0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //`
0x1e, 0x3f, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, //a
0x1f, 0x3f, 0x33, 0x1f, 0x1f, 0x33, 0x3f, 0x1f, //b
0x3e, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3e, //c
0x0f, 0x1f, 0x33, 0x33, 0x33, 0x33, 0x1f, 0x0f, //d
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x3f, 0x3f, //e
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x03, 0x03, //f
0x1e, 0x3f, 0x03, 0x03, 0x3b, 0x33, 0x3f, 0x1e, //g
0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, //h
0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, //i
0x3f, 0x3f, 0x30, 0x30, 0x30, 0x33, 0x3f, 0x1e, //j
0x03, 0x33, 0x1b, 0x0f, 0x07, 0x0f, 0x1b, 0x33, //k
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f, //l
0x21, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, 0x33, //m
0x33, 0x37, 0x37, 0x3f, 0x3f, 0x3b, 0x3b, 0x33, //n
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, //o
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x03, 0x03, //p
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x3b, 0x1f, 0x2e, //q
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x1b, 0x33, //r
0x3e, 0x3f, 0x03, 0x1f, 0x3e, 0x30, 0x3f, 0x1f, //s
0x3f, 0x3f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, //t
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, //u
0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, //v
0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x21, //w
0x21, 0x33, 0x1e, 0x0c, 0x0c, 0x1e, 0x33, 0x21, //x
0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, 0x0c, 0x0c, //y
0x3f, 0x3f, 0x38, 0x1c, 0x0e, 0x07, 0x3f, 0x3f, //z
0x38, 0x0c, 0x04, 0x03, 0x03, 0x04, 0x0c, 0x38, //{
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, //|
0x07, 0x0c, 0x08, 0x30, 0x30, 0x08, 0x0c, 0x07, //}
0x04, 0x2a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 //~
};
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
String temp = "";
int effectNumber =100;
byte brightness =50;
String message ="";
byte rotating =0;
boolean rainbow =false;
boolean pulse = false;
boolean letter = false; //true for text, false for graphics, use in rotateL()
byte rotatePixel = 0; //rotate counter used to scroll text 8 pixels per letter
byte charNumber =0;
int flip =1;
byte eff8=0; // effect 8 color counter
byte changeBrightness;
byte changeColor=0;
uint32_t color=0xffffff;
int effectAt=1;
uint32_t file[512];
byte syncDelay = 10;
byte syncExtraDelay = 0;
String masterID = "";
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
unsigned long previousMillis4 = 0;
unsigned long previousMillis5 = 0;
unsigned long previousMillis6 = 0;
uint16_t delay1=100;
uint16_t delay2=100;
uint16_t delay3=100;
uint16_t delay4=10000;
uint16_t delay5=2000;
uint16_t delay6=10000;
struct rgbcolor {
byte r;
byte g;
byte b;
};
union {
rgbcolor rgb;
uint32_t hexcolor;
} col;
struct twobytes {
byte l;
byte h;
};
union {
twobytes delaybytes_1;
uint16_t delay_1;
} del1;
union {
twobytes delaybytes_2;
uint16_t delay_2;
} del2;
union {
twobytes delaybytes_3;
uint16_t delay_3;
} del3;
union {
twobytes delaybytes_4;
uint16_t delay_4;
} del4;
union {
twobytes delaybytes_5;
uint16_t delay_5;
} del5;
//----------------------------------------CLOUD VARIABLES
char cloudconfig[] = "dupa";
char cloudIP[] ="";
char cloudTemp[] = "unknown";
char cloudSSID[] = "unknown";
char cloudRSSI[] = "unknown";
char cloudID[] = "";
/////////////////////////////////////////////////////////////////////////
//
// SETUP
//
/////////////////////////////////////////////////////////////////////////
void setup()
{
col.rgb.r=255;
col.rgb.g=0;
col.rgb.g=0;
Spark.function("effect", effect);
Spark.function("bitmap", bitmap);
Spark.function("config", config);
Spark.function("text", text);
Spark.subscribe("bollard/", setEffect);
Spark.deviceID().toCharArray(cloudID, Spark.deviceID().length()+1);
Spark.variable("cloudconfig", cloudconfig , STRING);
Spark.variable("cloudIP", cloudIP , STRING);
Spark.variable("cloudTemp", cloudTemp , STRING);
Spark.variable("cloudSSID", cloudSSID , STRING);
Spark.variable("cloudRSSI", cloudRSSI , STRING);
Spark.variable("cloudID", cloudID , STRING);
////////////////////////////////////////////////////// EEPROM configuration read
if(EEPROM.read(0)!=255) effectNumber=EEPROM.read(0);
if(EEPROM.read(1)!=255) brightness=EEPROM.read(1);
if(EEPROM.read(2)!=255) rotating=EEPROM.read(2);
if(EEPROM.read(3)!=255) rainbow=EEPROM.read(3);
if(EEPROM.read(4)!=255) pulse=EEPROM.read(4);
if(EEPROM.read(5)!=255) letter=EEPROM.read(5);
if(EEPROM.read(6)!=255) syncDelay=EEPROM.read(6);
if(EEPROM.read(7)!=255) syncExtraDelay=EEPROM.read(7);
byte r=EEPROM.read(10);
byte g=EEPROM.read(11);
byte b=EEPROM.read(12);
color=strip.Color(r,g,b);
del1.delaybytes_1.l =EEPROM.read(13);
del1.delaybytes_1.h =EEPROM.read(14);
delay1=del1.delay_1;
del2.delaybytes_2.l =EEPROM.read(15);
del2.delaybytes_2.h =EEPROM.read(16);
delay2=del2.delay_2;
del3.delaybytes_3.l =EEPROM.read(17);
del3.delaybytes_3.h =EEPROM.read(18);
delay3=del3.delay_3;
del4.delaybytes_4.l =EEPROM.read(19);
del4.delaybytes_4.h =EEPROM.read(20);
delay4=del4.delay_4;
del5.delaybytes_5.l =EEPROM.read(21);
del5.delaybytes_5.h =EEPROM.read(22);
delay5=del5.delay_5;
strip.begin();
strip.setBrightness(brightness);
strip.show(); // Initialize all pixels to 'off'
if(effectNumber ==100 && letter==false) demo();
if(letter==true)
{
effectNumber=100;
message="test message ";
}
}
/////////////////////////////////////////////////////////////////////////
//
// LOOP
//
/////////////////////////////////////////////////////////////////////////
void loop()
{
if(!pulse)
{
strip.setBrightness(brightness);
//strip.show();
}
if(Time.now()>=effectAt && effectAt >0)
{
effectAt=0;
switch (effectNumber)
{
case 100:
break;
case 0:
effect0();
break;
case 1:
effect1();
break;
case 2:
effect2();
break;
case 3:
effect3();
break;
case 4:
effect4();
break;
case 5:
effect5();
break;
case 6:
effect6();
break;
case 7:
effect7();
break;
case 8:
effect8();
break;
case 9:
effect9();
break;
}}
if(millis() - previousMillis1 >= delay1) //rotating
{
if (rotating==1) rotateL(false);
else if(rotating==2) rotateR();
else if(rotating==3) rotateU(false);
else if(rotating==4) rotateD();
if (letter) //-------------------------------- displaying text
{
if(rotatePixel==0)
{
paintFont(alpha[message.charAt(charNumber)-32], color);
charNumber++;
if (charNumber==message.length()) charNumber=0;
}
rotatePixel++;
rotateL(true); //rotating text if letter=true
if(rotatePixel==8)rotatePixel=0;
}
previousMillis1 = millis();
}
//---------------------------------------
if(millis() - previousMillis2 >= delay2) // rainbow
{
if (rainbow)
{
setRainbow(changeColor);
changeColor++;
if (changeColor>255)changeColor=0;
}
previousMillis2 = millis();
}
if(millis() - previousMillis3 >= delay3) // pulse
{
if (pulse)
{
changeBrightness+=5*flip;
if(changeBrightness==0 || changeBrightness>=brightness) flip*=-1;
if(changeBrightness==0)
{
if(color==0xffffff)color=0xff0000;
else if(color==0xff0000)color=0x00ff00;
else if(color==0x00ff00)color=0x0000ff;
else if(color==0x0000ff)color=0xffffff;
}
fill(color);
strip.setBrightness(changeBrightness);
strip.show();
}
previousMillis3 = millis();
//----------------------------------------
}
if(millis() - previousMillis5 >= delay5) // recursive effects
{
switch (effectNumber)
{
case 100:
break;
case 33:
effect3();
break;
case 44:
effect4();
break;
case 88:
effect8();
break;
}
previousMillis5 = millis();
}
if(millis() - previousMillis6 >= delay6) {
temp = "ip add:"+ String(WiFi.localIP()[0])+ "." + String(WiFi.localIP()[1]) +"." +String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]);
temp.toCharArray(cloudIP, temp.length()+1);
(String(WiFi.SSID())).toCharArray(cloudSSID, (String(WiFi.SSID())).length()+1);
(String(WiFi.RSSI())).toCharArray(cloudRSSI, (String(WiFi.RSSI())).length()+1);
previousMillis6 = millis();
}
}
/////////////////////////////////////////////////////////////////////////
//
// END LOOP
//
/////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------
//
// SPARK FUNCTIONS
//
//-----------------------------------------------------------
int effect(String data)
{
clear();
if (data.substring(0,1)=="") effectNumber = 100;
if (data.substring(0,1)=="0") effectNumber = 0;
if (data.substring(0,1)=="1") effectNumber = 1;
if (data.substring(0,1)=="2") effectNumber = 2;
if (data.substring(0,1)=="3") effectNumber = 3;
if (data.substring(0,1)=="4") effectNumber = 4;
if (data.substring(0,1)=="5") effectNumber = 5;
if (data.substring(0,1)=="6") effectNumber = 6;
if (data.substring(0,1)=="7") effectNumber = 7;
if (data.substring(0,1)=="8") effectNumber = 8;
if (data.substring(0,1)=="9") effectNumber = 9;
effectAt=Time.now()+syncDelay+syncExtraDelay;
effectAt=1;
Spark.publish("bollard/"+ Spark.deviceID(), String(effectNumber) +"+"+ String(effectAt));
saveConf();
return(1);
}
//--------------------------------------------------- config
int config(String data)
{
if (data.substring(0,11)=="rotatespeed") delay1 = data.substring(11).toInt();
if (data.substring(0,12)=="rainbowspeed") delay2 = data.substring(12).toInt();
if (data.substring(0,12)=="pulsespeed") delay3 = data.substring(10).toInt();
if (data.substring(0,10)=="brightness")
{
brightness = data.substring(10).toInt();
changeBrightness=brightness;
}
if (data.substring(0,5)=="color")
{
byte r=data.substring(5,8).toInt();
byte g=data.substring(8,11).toInt();
byte b=data.substring(11,14).toInt();
color=strip.Color(r,g,b);
setColor(color);
}
if (data.substring(0,7)=="rotatel") rotating=1;
if (data.substring(0,7)=="rotater") rotating=2;
if (data.substring(0,7)=="rotateu") rotating=3;
if (data.substring(0,7)=="rotated") rotating=4;
if (data.substring(0,7)=="rotate0") rotating=0;
if (data =="clear") clear();
if (data =="save") save();
if (data =="saveconf") saveConf();
if (data =="load") load();
if (data =="")
{
cfg();
String s=cfgGet();
s.toCharArray(cloudconfig, s.length()+1);
}
if (data =="rainbow1") rainbow =true;
if (data =="rainbow0") rainbow =false;
if (data =="pulse0") pulse =false;
if (data =="fill") fill(color);
if (data =="pulse1")
{
pulse =true;
changeBrightness=brightness;
flip=-1;
save();
}
if(data=="reset") System.reset();
if(data.substring(0,6)=="master")
{
String tmp = data.substring(6);
masterID = tmp;
}
if(data.substring(0,9)=="syncdelay") syncDelay=data.substring(0,9).toInt();
if(data.substring(0,9)=="syncextradelay") syncExtraDelay=data.substring(0,9).toInt();
saveConf();
return(1);
}
//-------------------------------------------------- BITMAP
int bitmap(String data)
{
static byte bitmapbitsNumber =0; // numbering of bitmap messages send using bitmap function. every bitmap requires 3 messages. bitmapbitsNumber can be 0,1,2,3
static String bitmapbits ="";
byte sprite[64];
char buffer[129];
byte bitmapbitsStart = data.substring(0,1).toInt();
if (bitmapbitsStart ==1 && bitmapbitsNumber==0)
{
bitmapbitsNumber=1;
bitmapbits += data.substring(1);
return(1);
}
if (bitmapbitsStart ==2 && bitmapbitsNumber==1)
{
bitmapbitsNumber=2;
bitmapbits += data.substring(1);
return(2);
}
if (bitmapbitsStart ==3 && bitmapbitsNumber==2)
{
bitmapbits += data.substring(1);
bitmapbits.toCharArray(buffer, 129);
for(int i = 0; i < 128; i+=2)
{
sprite[i/2] = getVal(buffer[i+1]) + (getVal(buffer[i]) << 4);
}
paint(sprite, color);
bitmapbits="";
bitmapbitsNumber=0;
return(3);
}
return(-1);
}
//-------------------------
byte getVal(char c)
{
if(c >= '0' && c <= '9')
return (byte)(c - '0');
else
return (byte)(c-'a'+10);
}
//--------------------------------------------------------- TEXT
int text(String line)
{
static byte part = 0; // messageTemp part number
static byte messpart = 0; // message part number - delivered in first character of message
static String messageTemp = ""; // to add message parts
clear();
if (line=="")
{
letter=false;
part=0;
messpart=0;
messageTemp="";
return(0);
}
messpart = line.substring(0,1).toInt();
if (messpart ==0) //last part received correctly
{
message=messageTemp + line.substring(1) + " ";
part=0;
messpart=0;
messageTemp="";
letter=true;
charNumber=0;
rotatePixel=0;
delay1=10;
saveConf();
}
else if(messpart==1) // resetting just in case no last part arrived previously
{
part=1;
messageTemp += line.substring(1);
}
else if(messpart == part +1) // part received in order
{
part++;
messageTemp += line.substring(1);
}
else //part out of order - resetting
{
part=0;
messpart=0;
messageTemp="";
return 0;
}
return(1);
}
//-----------------------------------------------------------
//
// END SPARK FUNCTIONS
//
//-----------------------------------------------------------
//----------------------------------------------------------------EFFECTS
void effect0()
{
}
/////////////////////////////// 1 single color
void effect1()
{
fill(color);
save();
pulse=1;
//effectNumber = 100;
}
//////////////////////////////// 2 lighthouse
void effect2(){
uint8_t bits1[64] = {
0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00,
0x00, 0x00, 0xfc, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00,
0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
0xff, 0x0f, 0x00, 0x00 };
uint8_t bits2[64] = {
0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00,
0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00,
0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
0xff, 0x07, 0x00, 0x00 };
uint8_t bits3[64] = {
0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00,
0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
0xff, 0x03, 0x00, 0x00 };
uint8_t bits4[64] = {
0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00,
0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0xff, 0x01, 0x00, 0x00 };
paint(bits1, 0x0a0a0a);
paint(bits2, 0x282828);
paint(bits3, 0x505050);
paint(bits4, 0xffffff);
rotating = 1;
//effectNumber =100;
}
///////////////////////////////// 3 random lights spinning
void effect3(){
unsigned int x=random(0,492);
byte r=random(0,162);
byte g=random(0,162);
byte b=random(0,162);
byte y=random(1,20);
//y=10;
for(byte z=0; z<y; z++)
{
strip.setPixelColor(x+z,r,g,b);
}
rotating=1;
strip.show();
effectNumber =33;
}
///////////////////////////////// 4 theatre spinning rainbow lights
void effect4()
{
static int j=0;
for (int q=0; q < 3; q++) {
for (int i=0; i < 512; i=i+3) {
strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
delay(10);
for (int i=0; i < 512; i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
j++;
if(j==256) j=0;
effectNumber =44;
}
//////////////////////////////// 5 spinning left arrows
void effect5() {
uint8_t leftarrows[] = {
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xf0, 0xf0, 0xf0, 0xf0,
0xf0, 0xf0, 0xf0, 0xf0, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xc0, 0xc0, 0xc0, 0xc0,
0xc0, 0xc0, 0xc0, 0xc0 };
paint(leftarrows, color);
rainbow=1;
rotating=1;
//effectNumber = 100;
}
//////////////////////////////// 6 UP ARROWS
void effect6()
{
unsigned char uparrows[] = {
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1c, 0x1c, 0x1c, 0x1c,
0x1c, 0x1c, 0x1c, 0x1c, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x1c, 0x1c, 0x1c, 0x1c,
0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
clear();
paint(uparrows, color);
rainbow=1;
rotating=3;
//effectNumber = 100;
}
//////////////////////////////// 7 rotating rainbow
void effect7()
{
for (int y=0; y<256; y++)
{
for (int x=y*64; x<y*64+64; x++)
{
strip.setPixelColor(x,Wheel(x*4+8));
}
}
strip.show();
rotating=1;
//effectNumber = 100;
}
//////////////////////////////// 8 up rainbow
void effect8()
{
for (int x=448; x<512; x++)
{
strip.setPixelColor(x,Wheel(eff8));
}
rotateU(true);
eff8+=5;
if(eff8==255) eff8=0;
strip.show();
effectNumber =88;
}
/////////////////////////////// 9 bitmap
void effect9()
{
unsigned char blue[] = {
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x6c, 0x00, 0x00 };
unsigned char green[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f,
0x08, 0x50, 0x01, 0x00, 0x00, 0x00, 0xc0, 0x1a, 0x08, 0x90, 0x04, 0x00,
0x00, 0x00, 0x00, 0x02 };
unsigned char magenta[] = {
0x00, 0x00, 0x20, 0x00, 0x02, 0x38, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
0x01, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
0x01, 0x00, 0x00, 0x00 };
unsigned char red[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08,
0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
unsigned char yellow[] = {
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0xff, 0x00, 0x01, 0x01, 0x00,
0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00,
0x0c, 0x01, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
paint(red, 0xff0000);
paint(green,0x00ff00);
paint(blue,0x0000ff);
paint(yellow,0xff7800);
paint(magenta,0xff00ff);
strip.show();
rotating=2;
//effectNumber = 100;
}
//-------------------------------------------------------
//
//
// TOOL FUNCTIONS
//
//
//--------------------------------------------------------FILL
void fill(uint32_t color)
{
for (int x=0; x<512; x++)
{
strip.setPixelColor(x,color);
//setcolor(x,rrr,ggg,bbb);
}
strip.show();
}
//---------------------------------------------------------PAINT
void paint(uint8_t sprite[64], uint32_t c)
{
for (byte y=0; y<8; ++y)
{
for (byte x=0; x<8; ++x)
{
byte data = sprite[x+(8*y)];
for (byte b=0; b<8; ++b)
{
if (data & (1<<b))
{
strip.setPixelColor((8*x)+(64*y)+b,c);
}
}
}
}
strip.show();
}
//------------------------------------------------------------PAINT FONT
void paintFont(uint8_t font[8], uint32_t c)
{
for (byte y=0; y<8; ++y)
{
byte data = font[y];
for (byte b=0; b<6; ++b)
{
if (data & (1<<b))
{
strip.setPixelColor(56+(64*y)+b,c);
}
}
}
strip.show();
}
TBC