Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LCD.h>
- #include <EEPROM.h>
- #include <Switch.h>
- #include <TimerOne.h>
- #include <LiquidCrystal.h>
- #include <MENWIZ.h>
- #include <buttons.h>
- #include <math.h>
- #include <Adafruit_PWMServoDriver.h>
- #include <Encoder.h>
- #include <FastLED.h>
- //LCD outputs
- #define LED_PIN 51
- #define COLOR_ORDER GRB
- #define CHIPSET LPD8806
- #define NUM_LEDS 120
- Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x42);
- //encoders
- Encoder speedsE(18, 47);
- Encoder redE(19, 49);
- Encoder greenE(2, 51);
- Encoder blueE(3, A3);
- unsigned int SpeedRead = 0;
- //zone colors and speed
- byte newGreenPos = 0;
- byte newRedPos = 0;
- byte newBluePos = 0;
- byte newSpeedPos = 0;
- unsigned int z1Speed = 0;
- byte z1Red = 0;
- byte z1Blue = 0;
- byte z1Green = 0;
- unsigned int z2Speed = 0;
- byte z2Red = 0;
- byte z2Blue = 0;
- byte z2Green = 0;
- unsigned int z3Speed = 0;
- byte z3Red = 0;
- byte z3Blue = 0;
- byte z3Green = 0;
- unsigned int z4Speed = 0;
- byte z4Red = 0;
- byte z4Blue = 0;
- byte z4Green = 0;
- byte zRed = 0;
- byte zBlue = 0;
- byte zGreen = 0;
- unsigned int zSpeed = 0;
- byte zonePattern = 0;
- byte DisplaySpeed = 0;
- boolean colorF = 0;
- boolean SpeedF = 0;
- CRGB leds[NUM_LEDS];
- byte rs = 12;
- byte e = 11;
- byte d4 = 10;
- byte d5 = 9;
- byte d6 = 8;
- byte d7 = 7;
- //LED Information
- struct fade {
- unsigned char r, g, b, f;
- };
- struct fade *lights;
- //zone pattern arras
- byte zone1pattern[24];
- byte zone2pattern[24];
- byte zone3pattern[24];
- byte zone4pattern[24];
- //xxxxxxxxxxxxxxxxxx
- //Chasing Programs
- //xxxxxxxxxxxxxxxxxx
- //Rainbow
- byte rainbowpattern[24] = {
- 250, 0, 0, 32, 32, 32, 64, 64, 64, 96, 96, 96, 128, 128, 128, 160, 160, 160, 192, 192, 192, 224, 224, 250};
- byte rainbowfadepattern[24] = {
- 0, 11, 22, 32, 42, 52, 64, 74, 84, 96, 106, 116, 128, 138, 148, 160, 170, 180, 192, 202, 212, 224, 234, 244};
- byte lazer[24] = {
- 10, 10, 10, 10, 10, 10, 10, 255, 255, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
- byte longstreakspattern[24] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 7, 15, 30, 50, 100, 150, 200, 255, 255, 0, 0};
- byte shortstreakspattern[24] = {
- 1, 7, 50, 150, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- byte diamondfadepattern[24] = {
- 0, 1, 1, 3, 7, 15, 30, 50, 100, 150, 200, 255, 200, 200, 150, 100, 50, 30, 15, 7, 3, 1, 1, 0};
- byte copspattern[24] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160};
- // faders
- int fader[] = {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
- int faderoff[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- const char faderLength = 31;
- //xxxxxxxxxxxxxxxxxx
- //Patriotic Programs
- //xxxxxxxxxxxxxxxxxx
- //Patriotic One
- int patriotic1Red[] = {
- 255, 255, 255, 255, 255, 255, 0, 0, 0};
- int patriotic1Blue[] = {
- 244, 244, 244, 0, 0, 0, 255, 255, 255};
- int patriotic1Green[] = {
- 255, 255, 255, 0, 0, 0, 0, 0, 0};
- const char patriotic1Length = 9;
- void patternShift(int colorr[], int colorb[], int colorg[], int arraySize);
- #define LastZone1Pixel 30 //Zone1 is ten pixels in length
- #define LastZone2Pixel 59 //Zone2 is ten pixels in length (10 zone 1 pixels + 10 zone 2 pixels = 20)
- #define LastZone3Pixel 90 //Zone2 is ten pixels in length (10 zone 1 pixels + 10 zone 2 pixels + 10 zone 3 pixels = 20)
- #define LastZone4Pixel 120 //Zone2 is twenty pixels in length (10 zone 1 pixels + 10 zone 2 pixels + 10 Zone 3 pixels + 20 Zone 4 pixels = 50)
- //LASTzone4Pixel should always be equal to NUM_LEDS
- //Relay Controllers
- const int out1 = 39;
- const int out2 = 38;
- const int out3 = 41;
- const int out4 = 40;
- const int out5 = 43;
- const int out6 = 42;
- //Navigation
- #define UP_BUTTON_PIN 22
- #define DOWN_BUTTON_PIN 24
- #define ESCAPE_BUTTON_PIN 26
- #define CONFIRM_BUTTON_PIN 28
- //debounce
- Switch speedSelect = Switch(A9, INPUT, HIGH, 5);
- Switch colorSelect = Switch(A8, INPUT, HIGH, 5);
- Switch zone1 = Switch(30, INPUT_PULLUP, LOW, 5);
- Switch zone2 = Switch(32, INPUT_PULLUP, LOW, 5);
- Switch zone3 = Switch(46, INPUT_PULLUP, LOW, 5);
- Switch zone4 = Switch(50, INPUT_PULLUP, LOW, 5);
- //zone select funtions
- byte Function1 = 127;
- byte Function2 = 127;
- byte Function3 = 127;
- byte Function4 = 127;
- byte zone1Function = 128;
- byte zone2Function = 128;
- byte zone3Function = 128;
- byte zone4Function = 128;
- typedef void (*LEDfunctions) ();
- LEDfunctions functionsArray [22] =
- {
- spacing,
- off,
- custom,
- white,
- green,
- red,
- blue,
- yellow,
- orange,
- pink,
- purple,
- marine,
- grassgreen,
- rainbow,
- rainbowfade,
- longstreaks,
- shortstreaks,
- diamondfade,
- customlazer,
- cops,
- cops1,
- patriotic1,
- };
- LiquidCrystal lcd(rs, e, d4, d5, d6, d7);
- //state machine timers
- byte btnInterval = 50;
- long int btnCheck = 0;
- //int ledInterval = 100;
- long int ledWrite = 0;
- byte setpInterval = 150;
- long int blinkDo;
- unsigned long z1start = millis();
- unsigned long z2start = millis();
- unsigned long z3start = millis();
- unsigned long z4start = millis();
- unsigned long flasherstart = millis();
- unsigned long flasherstart1 = millis();
- int flasherinterval = 135;
- //variables
- //ledAction : An array for the "states" of four LED lights that are integrated with buttons.
- //Each value of the array represents a button's light.
- //0 is off, 1 is on, 2 is "was off, now blinking" and 3 is "was on, now blinking"
- byte ledAction[] = {
- 0, 0, 0, 0};
- byte led1Action = 0;
- byte led2Action = 1;
- byte led3Action = 2;
- byte led4Action = 3;
- //the actual pin locations for the LED lights
- byte pinForLedAtSwitch[] = {
- 31, 33, 35, 37};
- //turn off the LED lights initially
- byte buttonLEDstate[] = {
- LOW, LOW, LOW, LOW};
- //timers for the blinking of the lights when ledAction values are 2 or 3
- unsigned long ledPrevMillis = 0;
- const int ledinterval = 600;
- boolean on = 0;
- unsigned long SpeedPrevTime = 0;
- //keep track of what zone we are setting up
- byte zoneSetup = 0;
- //Menu Variables
- menwiz menu;
- const int time = 6500;
- void setup() {
- Serial.begin(115200); //Start Serial for Debug
- lcd.begin(20, 4); //init lcd screen
- //LED STRIP SETUP
- FastLED.addLeds<LPD8806, BRG>(leds, NUM_LEDS);
- //Small LED Controller
- pwm.begin();
- pwm.setPWMFreq(1600);
- uint8_t twbrbackup = TWBR;
- // must be changed after calling Wire.begin() (inside pwm.begin())
- TWBR = 12;
- //big button red
- pwm.setPWM(0, 4096, 0);
- //big button green
- pwm.setPWM(1, 4096, 0);
- //big button blue
- pwm.setPWM(2, 4096, 0);
- //speed button blue
- pwm.setPWM(8, 40, 0);
- //speed button green
- pwm.setPWM(9, 40, 0);
- //speed button red
- pwm.setPWM(10, 30, 0);
- //red rotary encoder
- pwm.setPWM(4, 25, 0);
- //green rotary encoder
- pwm.setPWM(5, 25, 0);
- //blue rotary encoder
- pwm.setPWM(6, 25, 0);
- //these control RELAYs, innitially set too OFF
- pinMode(out1, OUTPUT);
- pinMode(out2, OUTPUT);
- pinMode(out3, OUTPUT);
- pinMode(out4, OUTPUT);
- pinMode(out5, OUTPUT);
- pinMode(out6, OUTPUT);
- digitalWrite(out1, HIGH);
- digitalWrite(out2, HIGH);
- digitalWrite(out3, HIGH);
- digitalWrite(out4, HIGH);
- digitalWrite(out5, HIGH);
- digitalWrite(out6, HIGH);
- //set the pinForLedAtSwitchs variables to a output
- pinMode(pinForLedAtSwitch[0], OUTPUT);
- pinMode(pinForLedAtSwitch[1], OUTPUT);
- pinMode(pinForLedAtSwitch[2], OUTPUT);
- pinMode(pinForLedAtSwitch[3], OUTPUT);
- //menus
- _menu *r,*s1,*s2;
- menu.begin(&lcd,20,4);
- //menu.addUsrNav(navcheck, 4);
- r=menu.addMenu(MW_ROOT,NULL,F("Make Selection"));
- s1=menu.addMenu(MW_VAR,r,F("Stop Selected Zone"));
- s1->addVar(MW_ACTION,zoneOff);
- s1=menu.addMenu(MW_SUBMENU,r,F("Solid Colors"));
- s2=menu.addMenu(MW_VAR,s1,F("Custom Color")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,customZone);
- s2=menu.addMenu(MW_VAR,s1,F("White")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,whiteZone);
- s2=menu.addMenu(MW_VAR,s1,F("Red")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,redZone);
- s2=menu.addMenu(MW_VAR,s1,F("Green")); //will1 call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,greenZone);
- s2=menu.addMenu(MW_VAR,s1,F("Blue")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,blueZone);
- s2=menu.addMenu(MW_VAR,s1,F("Yellow")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,yellowZone);
- s2=menu.addMenu(MW_VAR,s1,F("Orange")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,orangeZone);
- s2=menu.addMenu(MW_VAR,s1,F("Pink")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,pinkZone);
- s2=menu.addMenu(MW_VAR,s1,F("Purple")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,purpleZone);
- s2=menu.addMenu(MW_VAR,s1,F("Marine")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,marineZone);
- s2=menu.addMenu(MW_VAR,s1,F("Grass Green")); //will call function 'White' if that menu selection is made.
- s2->addVar(MW_ACTION,grassgreenZone);
- s1=menu.addMenu(MW_SUBMENU,r,F("Custom Chasing"));
- s2=menu.addMenu(MW_VAR,s1,F("Rainbow"));
- s2->addVar(MW_ACTION,rainbowZone);
- s2=menu.addMenu(MW_VAR,s1,F("Rainbow Fade"));
- s2->addVar(MW_ACTION,rainbowfadeZone);
- s2=menu.addMenu(MW_VAR,s1,F("Long Streaks"));
- s2->addVar(MW_ACTION,longstreakZone);
- s2=menu.addMenu(MW_VAR,s1,F("Short Streaks"));
- s2->addVar(MW_ACTION,shortstreakZone);
- s2=menu.addMenu(MW_VAR,s1,F("Diamond Fade"));
- s2->addVar(MW_ACTION,diamondfadeZone);
- s2=menu.addMenu(MW_VAR,s1,F("Custom Lazer"));
- s2->addVar(MW_ACTION,customlazerZone);
- s2=menu.addMenu(MW_VAR,s1,F("Cops 1"));
- s2->addVar(MW_ACTION,copsZone);
- s2=menu.addMenu(MW_VAR,s1,F("Cops 2"));
- s2->addVar(MW_ACTION,cops2Zone);
- s1=menu.addMenu(MW_SUBMENU,r,F("Fading Colors"));
- s1=menu.addMenu(MW_SUBMENU,r,F("Christmas Colors"));
- s1=menu.addMenu(MW_SUBMENU,r,F("Holloween Colors"));
- s1=menu.addMenu(MW_SUBMENU,r,F("Easter Colors"));
- s1=menu.addMenu(MW_SUBMENU,r,F("Patriotic Colors"));
- s2=menu.addMenu(MW_VAR,s1,F("Red White Blue Chase"));
- s2->addVar(MW_ACTION,patriotic1Zone);
- menu.navButtons(UP_BUTTON_PIN,DOWN_BUTTON_PIN,ESCAPE_BUTTON_PIN,CONFIRM_BUTTON_PIN);
- //if a certain amount of time has passed, load the "user screen", function "screen"
- menu.addUsrScreen(screen, time);
- }
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
- void loop(){
- menu.draw();
- checkButtons();
- blinker();
- if(ledAction[led1Action] == 1 || ledAction[led2Action] == 1 || ledAction[led3Action] == 1 || ledAction[led4Action] == 1){
- zoneIncrementers();
- }
- LEDshow();
- FastLED.show();
- }
- void LEDshow() {
- if (ledAction[led1Action] == 1) {
- functionsArray [zone1Function] ();
- }
- if (ledAction[led2Action] == 1) {
- functionsArray [zone2Function] ();
- }
- if (ledAction[led3Action] == 1) {
- functionsArray [zone3Function] ();
- }
- if (ledAction[led4Action] == 1) {
- functionsArray [zone4Function] ();
- }
- }
- void zoneOn(){
- switch(zoneSetup) {
- case 1:
- ledAction[led1Action] = 1; //turn on it's buttons LED light and
- zoneSetup = 0; //let us no we are no longer setting up a zone
- digitalWrite(out1, LOW);//turn on the zones relay
- break;
- case 2:
- ledAction[led2Action] = 1;
- zoneSetup = 0;
- digitalWrite(out2, LOW);
- break;
- case 3:
- ledAction[led3Action] = 1;
- zoneSetup = 0;
- digitalWrite(out3, LOW);
- break;
- case 4:
- ledAction[led4Action] = 1;
- zoneSetup = 0;
- digitalWrite(out4, LOW);
- break;
- }
- }
- void patternShift(byte zone[]) {
- int tempZone;
- for (int i=24; i>1; i--)
- {
- tempZone = zone[23];
- zone[23] = zone[i];
- zone[i] = tempZone;
- }
- }
- void zoneIncrementers() {
- unsigned long z1 = millis();
- unsigned long z2 = millis();
- unsigned long z3 = millis();
- unsigned long z4 = millis();
- if(z1 - z1start >= z1Speed << 1){
- patternShift(zone1pattern);
- z1start = z1;
- }
- if(z2 - z2start >= z2Speed << 1){
- patternShift(zone2pattern);
- z2start = z2;
- }
- if(z3 - z3start >= z3Speed << 1){
- patternShift(zone3pattern);
- z3start = z3;
- }
- if(z4 - z4start >= z4Speed << 1){
- patternShift(zone4pattern);
- z4start = z4;
- }
- }
- bool FunctionForEachPixel (byte icNumber, byte index, int Function)
- {
- if (icNumber <= LastZone1Pixel && Function1 == Function){
- zRed = z1Red;
- zBlue = z1Blue;
- zGreen = z1Green;
- zSpeed = z1Speed;
- zonePattern = zone1pattern[index];
- return true ;
- } //function 2 is the selected function for zone 1
- if (icNumber > LastZone1Pixel && icNumber <= LastZone2Pixel && Function2 == Function) {
- zRed = z2Red;
- zBlue = z2Blue;
- zGreen = z2Green;
- zSpeed = z2Speed;
- zonePattern = zone2pattern[index];
- return true ;
- }
- if (icNumber > LastZone2Pixel && icNumber <= LastZone3Pixel && Function3 == Function) {
- zRed = z3Red;
- zBlue = z3Blue;
- zGreen = z3Green;
- zSpeed = z3Speed;
- zonePattern = zone3pattern[index];
- return true ;
- }
- if (icNumber > LastZone3Pixel && icNumber <= LastZone4Pixel && Function4 == Function) {
- zRed = z4Red;
- zBlue = z4Blue;
- zGreen = z4Green;
- zSpeed = z4Speed;
- zonePattern = zone4pattern[index];
- return true ;
- }
- return false ;
- }
- // zone color fuction setting functions O.o
- void zoneOff() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- ledAction[led1Action] = 0; //turn off that zone's button light and
- zoneSetup = 0;
- digitalWrite(out1, HIGH); //turn off the relay corresponding to the zone.
- zone1Function = 1;
- Function1 = 1;
- break;
- case 2:
- ledAction[led2Action] = 0;
- zoneSetup = 0;
- digitalWrite(out2, HIGH);
- zone2Function = 1;
- Function2 = 1;
- break;
- case 3:
- ledAction[led3Action] = 0;
- zoneSetup = 0;
- digitalWrite(out3, HIGH);
- zone3Function = 1;
- Function3 = 1;
- break;
- case 4:
- ledAction[led4Action] = 0;
- zoneSetup = 0;
- digitalWrite(out4, HIGH);
- zone4Function = 1;
- Function4 = 1;
- break;
- }
- off();
- }
- void setups(){
- redE.write(0);
- blueE.write(0);
- greenE.write(0);
- speedsE.write(0);
- int stime = 0;
- unsigned long ttime = 0;
- while (colorF == 0 || SpeedF == 0 || stime < 2500){
- setupScreen();
- colorSelect.poll();
- speedSelect.poll();
- encoderLimits();
- speedHandler();
- pwmControl();
- blinker();
- if(colorSelect.pushed()){
- if(newRedPos == 5){
- newRedPos = 0;
- }
- if(newGreenPos == 5){
- newGreenPos = 0;
- }
- if(newBluePos == 5){
- newBluePos = 0;
- }
- if(zoneSetup == 1) {
- z1Red = newRedPos << 1;
- z1Blue = newBluePos << 1;
- z1Green = newGreenPos << 1;
- }
- if(zoneSetup == 2) {
- z2Red = newRedPos << 1;
- z2Blue = newBluePos << 1;
- z2Green = newGreenPos << 1;
- }
- if(zoneSetup == 3) {
- z3Red = newRedPos << 1;
- z3Blue = newBluePos << 1;
- z3Green = newGreenPos << 1;
- }
- if(zoneSetup == 4) {
- z4Red = newRedPos << 1;
- z4Blue = newBluePos << 1;
- z4Green = newGreenPos << 1;
- }
- colorF = 1;
- }
- if(speedSelect.pushed()){
- if(zoneSetup == 1) {
- z1Speed = SpeedRead;
- }
- if(zoneSetup == 2){
- z2Speed = SpeedRead;
- }
- if(zoneSetup == 3){
- z3Speed = SpeedRead;
- }
- if(zoneSetup == 4){
- z4Speed = SpeedRead;
- }
- SpeedF = 1;
- }
- pwmControl();
- if(SpeedF == 0 || colorF == 0){
- ttime = millis();
- }
- if(SpeedF == colorF == 1){
- stime = millis() - ttime;
- }
- }
- }
- void speedHandler() {
- if(newSpeedPos >= 10 && newSpeedPos < 17){
- SpeedRead = 15;
- DisplaySpeed = 10;
- }
- else if(newSpeedPos < 24){
- SpeedRead = 65;
- DisplaySpeed = 9;
- }
- else if(newSpeedPos < 31){
- SpeedRead = 120;
- DisplaySpeed = 8;
- }
- else if(newSpeedPos < 38){
- SpeedRead = 180;
- DisplaySpeed = 7;
- }
- else if(newSpeedPos < 45){
- SpeedRead = 240;
- DisplaySpeed = 6;
- }
- else if(newSpeedPos < 52){
- SpeedRead = 300;
- DisplaySpeed = 5;
- }
- else if(newSpeedPos < 59){
- SpeedRead = 360;
- DisplaySpeed = 4;
- }
- else if(newSpeedPos < 66){
- SpeedRead = 420;
- DisplaySpeed = 3;
- }
- else if(newSpeedPos <= 73){
- SpeedRead = 480;
- DisplaySpeed = 2;
- }
- else if(newSpeedPos <= 80){
- SpeedRead = 500;
- DisplaySpeed = 1;
- }
- }
- void encoderLimits() {
- newRedPos = redE.read();
- newBluePos = blueE.read();
- newGreenPos = greenE.read();
- newSpeedPos = speedsE.read();
- if(newSpeedPos > 80) {
- newSpeedPos = 80;
- speedsE.write(80);
- }
- if(newSpeedPos < 10) {
- newSpeedPos = 10;
- speedsE.write(10);
- }
- if(newRedPos < 5) {
- newRedPos = 5;
- redE.write(5);
- }
- if(newRedPos > 127) {
- newRedPos = 127;
- redE.write(127);
- }
- if(newBluePos > 127) {
- newBluePos = 127;
- blueE.write(127);
- }
- if(newBluePos < 5) {
- newBluePos = 5;
- blueE.write(5);
- }
- if(newGreenPos > 127) {
- newGreenPos = 127;
- greenE.write(127);
- }
- if(newGreenPos < 5) {
- newGreenPos = 5;
- greenE.write(5);
- }
- }
- void setupScreen(){
- lcd.setCursor(0,0);
- lcd.print("Zone ");
- lcd.print(zoneSetup);
- lcd.print(" Program Setup");
- lcd.setCursor(0,1);
- lcd.print("Color Selected: ");
- if(colorF == 1) {
- lcd.print("Yes");
- }
- else {
- lcd.print("No");
- }
- lcd.setCursor(0,2);
- lcd.print("Speed Selected: ");
- if(SpeedF == 1) {
- lcd.print("Yes");
- }
- else {
- lcd.print("No");
- }
- lcd.setCursor(0,3);
- lcd.print("SP:");
- if((DisplaySpeed)<10){
- lcd.print(DisplaySpeed);
- lcd.print(" ");
- }
- else {
- lcd.print(DisplaySpeed);
- }
- lcd.setCursor(5,3);
- lcd.print(" R:");
- if(newRedPos == 5){
- lcd.print("0");
- }
- else {
- if((newRedPos >> 2)<10){
- lcd.print(newRedPos >> 2);
- lcd.print(" ");
- }
- else {
- lcd.print(newRedPos >> 2);
- }
- }
- lcd.setCursor(10,3);
- lcd.print(" G:");
- if(newGreenPos == 5){
- lcd.print("0");
- }
- else {
- if((newGreenPos >> 2)<10){
- lcd.print(newGreenPos >> 2);
- lcd.print(" ");
- }
- else {
- lcd.print(newGreenPos >> 2);
- }
- }
- lcd.setCursor(15,3);
- lcd.print(" B:");
- if(newBluePos == 5){
- lcd.print("0");
- }
- else {
- if((newBluePos >> 2)<10){
- lcd.print(newBluePos >> 2);
- lcd.print(" ");
- }
- else {
- lcd.print(newBluePos >> 2);
- }
- }
- }
- void pwmControl(){
- unsigned long SpeedTime = millis();
- if (SpeedTime - SpeedPrevTime > SpeedRead) {
- SpeedPrevTime = SpeedTime;
- on = !on;
- }
- if(SpeedF == 0){
- pwm.setPWM(8, on*4096, 0);
- //speed button green
- pwm.setPWM(9, on*4096, 0);
- //speed button red
- pwm.setPWM(10, on*4096, 0);
- }
- if(colorF == 0){
- if (newRedPos == 5){
- pwm.setPWM(0, 4096, 0); //big button Red
- pwm.setPWM(4, 4096, 0); //red rotary encoder
- }
- else {
- pwm.setPWM(0, newRedPos << 3, 0); //big button Red
- pwm.setPWM(4, newRedPos << 3, 0); //Red encoder
- }
- if (newGreenPos == 5){
- pwm.setPWM(1, 4096, 0); //big button Green
- pwm.setPWM(5, 4096, 0); //green rotary
- }
- else
- {
- pwm.setPWM(1, newGreenPos << 3, 0); //big button Green1
- pwm.setPWM(5, newGreenPos << 3, 0); //green rotary encoder
- }
- if (newBluePos == 5){
- pwm.setPWM(2, 4096, 0); //big button blue
- pwm.setPWM(6, 4096, 0); //blue rotary encoder
- }
- else {
- pwm.setPWM(2, newBluePos << 3, 0); //big button blue
- pwm.setPWM(6, newBluePos << 3, 0); //blue rotary encoder
- }
- }
- if(SpeedF == 1){
- pwm.setPWM(8, 40, 0);
- //speed button green
- pwm.setPWM(9, 40, 0);
- //speed button red
- pwm.setPWM(10, 30, 0);
- }
- if(colorF == 1){
- pwm.setPWM(0, 4096, 0);
- //big button green
- pwm.setPWM(1, 4096, 0);
- //big button blue
- pwm.setPWM(2, 4096, 0);
- //red rotary encoder
- pwm.setPWM(4, 25, 0);
- //green rotary encoder
- pwm.setPWM(5, 25, 0);
- //blue rotary encoder
- pwm.setPWM(6, 25, 0);
- }
- }
- void spacing() { //does nothing, so that the first array value for the color programs doesn't equal zero
- }
- void screen() {
- //these lines turn off or on any button LED, depending on its previous state. If the led was off before (blinking as a value of 2), it will
- //be off now, if the led was on (blinking as a value of 3), the LED will be on now.
- for (byte n = 0; n < 4; n++) {
- switch(ledAction[n])
- {
- case 2: // blinking but was off before it was blinking
- ledAction[n] = 0; //lets turn it off again
- break;
- case 3: // blinking but was on before it was blinking
- ledAction[n] = 1; //lets turn it on again
- break;
- }
- }
- zoneSetup = 0;
- //setting soneSetup to zero, lets us no that no zone is active, therefore no changes can be made.
- lcd.setCursor(0,0);
- lcd.print("Welcome to LEDbox!");
- lcd.setCursor(0,1);
- lcd.print(" Awaiting Input ");
- lcd.setCursor(0,2);
- lcd.print(" Use Buttons Below ");
- lcd.setCursor(0,3);
- lcd.print("1 2 3 4");
- }
- void checkButtons(){
- //debounce code to check for button presses
- zone1.poll();
- zone2.poll();
- zone3.poll();
- zone4.poll();
- // if zone 1's button was pressed
- if(zone1.pushed()) {
- colorF = 0;
- SpeedF = 0;
- for (byte n = 0; n < 4; n++) {
- switch(ledAction[n])
- {
- case 2: // blinking but was off before it was blinking
- ledAction[n] = 0; //lets turn it off again
- break;
- case 3: // blinking but was on before it was blinking
- ledAction[n] = 1; //lets turn it on again
- break;
- }
- }
- //if button one is off, now it is blinking. 2 signifies that it was previously off.
- if(ledAction[led1Action] == 0){
- ledAction[led1Action] = 2;
- }
- //if button one is on, now it is blinking. 3 signifies that it was previously on.
- if(ledAction[led1Action] == 1){
- ledAction[led1Action] = 3;
- }
- //simulate button press to bring up menu
- menu.actNavButtons(MW_BTL);
- //let the world know that we are in setting up zone 1
- zoneSetup = 1;
- }
- if(zone2.pushed()) {
- colorF = 0;
- SpeedF = 0;
- for (byte n = 0; n < 4; n++) {
- switch(ledAction[n])
- {
- case 2: // blinking but was off before it was blinking
- ledAction[n] = 0; //lets turn it off again
- break;
- case 3: // blinking but was on before it was blinking
- ledAction[n] = 1; //lets turn it on again
- break;
- }
- }
- if(ledAction[led2Action] == 0){
- ledAction[led2Action] = 2;
- }
- if(ledAction[led2Action] == 1){
- ledAction[led2Action] = 3;
- }
- menu.actNavButtons(MW_BTL);
- zoneSetup = 2;
- }
- if(zone3.pushed()) {
- colorF = 0;
- SpeedF = 0;
- for (byte n = 0; n < 4; n++) {
- switch(ledAction[n])
- {
- case 2: // blinking but was off before it was blinking
- ledAction[n] = 0; //lets turn it off again
- break;
- case 3: // blinking but was on before it was blinking
- ledAction[n] = 1; //lets turn it on again
- break;
- }
- }
- if(ledAction[led3Action] == 0){
- ledAction[led3Action] = 2;
- }
- if(ledAction[led3Action] == 1){
- ledAction[led3Action] = 3;
- }
- menu.actNavButtons(MW_BTL);
- zoneSetup = 3;
- }
- if(zone4.pushed()) {
- colorF = 0;
- SpeedF = 0;
- for (byte n = 0; n < 4; n++) {
- switch(ledAction[n])
- {
- case 2: // blinking but was off before it was blinking
- ledAction[n] = 0; //lets turn it off again
- break;
- case 3: // blinking but was on before it was blinking
- ledAction[n] = 1; //lets turn it on again
- break;
- }
- }
- if(ledAction[led4Action] == 0){
- ledAction[led4Action] = 2;
- }
- if(ledAction[led4Action] == 1){
- ledAction[led4Action] = 3;
- }
- menu.actNavButtons(MW_BTL);
- zoneSetup = 4;
- }
- }
- void blinker(){
- unsigned long ledCurrentMillis = millis();
- for (byte n = 0; n < 4; n++) {
- digitalWrite(pinForLedAtSwitch[n], buttonLEDstate[n]);
- switch(ledAction[n])
- {
- case 0: // steady off
- buttonLEDstate[n] = LOW;
- break;
- case 1: // steady on
- buttonLEDstate[n] = HIGH;
- break;
- case 2: // blinking but was off before it was blinking
- if (ledCurrentMillis - ledPrevMillis > ledinterval){
- ledPrevMillis = ledCurrentMillis;
- buttonLEDstate[n] = ! buttonLEDstate[n];
- }
- case 3: // blinking but was on before it was blinking
- if (ledCurrentMillis - ledPrevMillis > ledinterval){
- ledPrevMillis = ledCurrentMillis;
- buttonLEDstate[n] = ! buttonLEDstate[n];
- }
- break;
- }
- }
- }
- void customZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- SpeedF = 1;
- setups();
- zone1Function = 2;
- Function1 = 2;
- break;
- case 2:
- SpeedF = 1;
- setups();
- zone2Function = 2;
- Function2 = 2;
- break;
- case 3:
- SpeedF = 1;
- setups();
- zone3Function = 2;
- Function3 = 2;
- break;
- case 4:
- SpeedF = 1;
- setups();
- zone4Function = 2;
- Function4 = 2;
- break;
- }
- zoneOn();
- }
- void whiteZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 3;
- Function1 = 3;
- break;
- case 2:
- zone2Function = 3;
- Function2 = 3;
- break;
- case 3:
- zone3Function = 3;
- Function3 = 3;
- break;
- case 4:
- zone4Function = 3;
- Function4 = 3;
- break;
- }
- zoneOn();
- }
- void greenZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 4;
- Function1 = 4;
- break;
- case 2:
- zone2Function = 4;
- Function2 = 4;
- break;
- case 3:
- zone3Function = 4;
- Function3 = 4;
- break;
- case 4:
- zone4Function = 4;
- Function4 = 4;
- break;
- }
- zoneOn();
- }
- void redZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 5;
- Function1 = 5;
- break;
- case 2:
- zone2Function = 5;
- Function2 = 5;
- break;
- case 3:
- zone3Function = 5;
- Function3 = 5;
- break;
- case 4:
- zone4Function = 5;
- Function4 = 5;
- break;
- }
- zoneOn();
- }
- void blueZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 6;
- Function1 = 6;
- break;
- case 2:
- zone2Function = 6;
- Function2 = 6;
- break;
- case 3:
- zone3Function = 6;
- Function3 = 6;
- break;
- case 4:
- zone4Function = 6;
- Function4 = 6;
- break;
- }
- zoneOn();
- }
- void yellowZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 7;
- Function1 = 7;
- break;
- case 2:
- zone2Function = 7;
- Function2 = 7;
- break;
- case 3:
- zone3Function = 7;
- Function3 = 7;
- break;
- case 4:
- zone4Function = 7;
- Function4 = 7;
- break;
- }
- zoneOn();
- }
- void orangeZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 8;
- Function1 = 8;
- break;
- case 2:
- zone2Function = 8;
- Function2 = 8;
- break;
- case 3:
- zone3Function = 8;
- Function3 = 8;
- break;
- case 4:
- zone4Function = 8;
- Function4 = 8;
- break;
- }
- zoneOn();
- }
- void pinkZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 9;
- Function1 = 9;
- break;
- case 2:
- zone2Function = 9;
- Function2 = 9;
- break;
- case 3:
- zone3Function = 9;
- Function3 = 9;
- break;
- case 4:
- zone4Function = 9;
- Function4 = 9;
- break;
- }
- zoneOn();
- }
- void purpleZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 10;
- Function1 = 10;
- break;
- case 2:
- zone2Function = 10;
- Function2 = 10;
- break;
- case 3:
- zone3Function = 10;
- Function3 = 10;
- break;
- case 4:
- zone4Function = 10;
- Function4 = 10;
- break;
- }
- zoneOn();
- }
- void marineZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 11;
- Function1 = 11;
- break;
- case 2:
- zone2Function = 11;
- Function2 = 11;
- break;
- case 3:
- zone3Function = 11;
- Function3 = 11;
- break;
- case 4:
- zone4Function = 11;
- Function4 = 11;
- break;
- }
- zoneOn();
- }
- void grassgreenZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 12;
- Function1 = 12;
- break;
- case 2:
- zone2Function = 12;
- Function2 = 12;
- break;
- case 3:
- zone3Function = 12;
- Function3 = 12;
- break;
- case 4:
- zone4Function = 12;
- Function4 = 12;
- break;
- }
- zoneOn();
- }
- void rainbowZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- colorF = 1;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- zone1Function = 13;
- Function1 = 13;
- memcpy(zone1pattern, rainbowpattern, 24);
- break;
- case 2:
- setups();
- zone2Function = 13;
- Function2 = 13;
- memcpy(zone2pattern, rainbowpattern, 24);
- break;
- case 3:
- setups();
- zone3Function = 13;
- Function3 = 13;
- memcpy(zone3pattern, rainbowpattern, 24);
- break;
- case 4:
- setups();
- zone4Function = 13;
- Function4 = 13;
- memcpy(zone4pattern, rainbowpattern, 24);
- break;
- }
- zoneOn();
- }
- void rainbowfadeZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- colorF = 1;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- memcpy(zone1pattern, rainbowfadepattern, 24);
- zone1Function = 14;
- Function1 = 14;
- break;
- case 2:
- setups();
- memcpy(zone2pattern, rainbowfadepattern, 24);
- zone2Function = 14;
- Function2 = 14;
- break;
- case 3:
- setups();
- memcpy(zone3pattern, rainbowfadepattern, 24);
- zone3Function = 14;
- Function3 = 14;
- break;
- case 4:
- setups();
- memcpy(zone4pattern, rainbowfadepattern, 24);
- zone4Function = 14;
- Function4 = 14;
- break;
- }
- zoneOn();
- }
- void longstreakZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- memcpy(zone1pattern, longstreakspattern, 24);
- zone1Function = 15;
- Function1 = 15;
- break;
- case 2:
- setups();
- memcpy(zone2pattern, longstreakspattern, 24);
- zone2Function = 15;
- Function2 = 15;
- break;
- case 3:
- setups();
- memcpy(zone3pattern, longstreakspattern, 24);
- zone3Function = 15;
- Function3 = 15;
- break;
- case 4:
- setups();
- memcpy(zone4pattern, longstreakspattern, 24);
- zone4Function = 15;
- Function4 = 15;
- break;
- }
- zoneOn();
- }
- void shortstreakZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- memcpy(zone1pattern, shortstreakspattern, 24);
- zone1Function = 16;
- Function1 = 16;
- break;
- case 2:
- setups();
- memcpy(zone2pattern, shortstreakspattern, 24);
- zone2Function = 16;
- Function2 = 16;
- break;
- case 3:
- setups();
- memcpy(zone3pattern, shortstreakspattern, 24);
- zone3Function = 16;
- Function3 = 16;
- break;
- case 4:
- setups();
- memcpy(zone4pattern, shortstreakspattern, 24);
- zone4Function = 16;
- Function4 = 16;
- break;
- }
- zoneOn();
- }
- void diamondfadeZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- memcpy(zone1pattern, diamondfadepattern, 24);
- zone1Function = 17;
- Function1 = 17;
- break;
- case 2:
- setups();
- memcpy(zone2pattern, diamondfadepattern, 24);
- zone2Function = 17;
- Function2 = 17;
- break;
- case 3:
- setups();
- memcpy(zone3pattern, diamondfadepattern, 24);
- zone3Function = 17;
- Function3 = 17;
- break;
- case 4:
- setups();
- memcpy(zone4pattern, diamondfadepattern, 24);
- zone4Function = 17;
- Function4 = 17;
- break;
- }
- zoneOn();
- }
- void customlazerZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- zone1Function = 18;
- Function1 = 18;
- memcpy(zone1pattern, lazer, 24);
- break;
- case 2:
- setups();
- zone2Function = 18;
- Function2 = 18;
- memcpy(zone2pattern, lazer, 24);
- break;
- case 3:
- setups();
- zone3Function = 18;
- Function3 = 18;
- memcpy(zone3pattern, lazer, 24);
- break;
- case 4:
- setups();
- zone4Function = 18;
- Function4 = 18;
- memcpy(zone4pattern, lazer, 24);
- break;
- }
- zoneOn();
- }
- void copsZone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- memcpy(zone1pattern, copspattern, 24);
- zone1Function = 19;
- Function1 = 19;
- break;
- case 2:
- setups();
- memcpy(zone2pattern, copspattern, 24);
- zone2Function = 19;
- Function2 = 19;
- break;
- case 3:
- setups();
- memcpy(zone3pattern, copspattern, 24);
- zone3Function = 19;
- Function3 = 19;
- break;
- case 4:
- setups();
- memcpy(zone4pattern, copspattern, 24);
- zone4Function = 19;
- Function4 = 19;
- break;
- }
- zoneOn();
- }
- void cops2Zone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- setups();
- memcpy(zone1pattern, copspattern, 24);
- zone1Function = 20;
- Function1 = 20;
- break;
- case 2:
- setups();
- zone2Function = 20;
- Function2 = 20;
- memcpy(zone2pattern, copspattern, 24);
- break;
- case 3:
- setups();
- zone3Function = 20;
- Function3 = 20;
- memcpy(zone1pattern, copspattern, 24);
- break;
- case 4:
- setups();
- zone4Function = 20;
- Function4 = 20;
- memcpy(zone1pattern, copspattern, 24);
- break;
- }
- zoneOn();
- }
- void patriotic1Zone() {
- long int time = millis();
- long int timer2 = time + 3500;
- switch(zoneSetup){
- case 0:
- menu.addSplash(" Zone Not Chosen! \n Please Select Zone \nUsing Buttons Below\n Thank you ;) \n", timer2);
- break;
- case 1:
- zone1Function = 7;
- Function1 = 7;
- break;
- case 2:
- zone2Function = 7;
- Function2 = 7;
- break;
- case 3:
- zone3Function = 7;
- Function3 = 7;
- break;
- case 4:
- zone4Function = 7;
- Function4 = 7;
- break;
- }
- zoneOn();
- }
- // COLOR FUNCTIONS
- void off(){
- for (byte i=0; i<NUM_LEDS; i++) {
- if (FunctionForEachPixel (i, 1, 1)) {
- leds[i].r = 0;
- leds[i].g = 0;
- leds[i].b = 0;
- }
- }
- }
- void custom(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 2)) {
- leds[i].setRGB( zRed, zGreen, zBlue);
- }
- }
- }
- void white(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 3)) {
- leds[i].setRGB( 255, 244, 244);
- }
- }
- }
- void green(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 4)) {
- leds[i].setRGB( 0, 255, 0);
- }
- }
- }
- void red(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 5)) {
- leds[i].setRGB( 255, 0, 0);
- }
- }
- }
- void blue(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 6)) {
- leds[i].setRGB( 0, 0, 255);
- }
- }
- }
- void yellow(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 7)) {
- leds[i].setRGB( 255, 175, 0);
- }
- }
- }
- void orange(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 8)) {
- leds[i].setRGB( 255, 40, 0);
- }
- }
- }
- void pink(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 9)) {
- leds[i].setRGB( 255, 0, 40);
- }
- }
- }
- void purple(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 10)) {
- leds[i].setRGB( 85, 0, 85);
- }
- }
- }
- void marine(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 11)) {
- leds[i].setRGB( 0, 255, 200);
- }
- }
- }
- void grassgreen(){
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 12)) {
- leds[i].setRGB( 60, 255, 0);
- }
- }
- }
- void rainbow() {
- for(int i = 0 ; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 13)) {
- leds[i] = CHSV(zonePattern,255,255);
- }
- }
- }
- void rainbowfade() {
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 14)) {
- leds[i] = CHSV(zonePattern, 255, 255);
- }
- }
- }
- void longstreaks() {
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 15)) {
- leds[i].r = zRed;
- leds[i].b = zBlue;
- leds[i].g = zGreen;
- leds[i].nscale8_video(zonePattern);
- }
- }
- }
- void shortstreaks() {
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 16)) {
- leds[i].r = zRed;
- leds[i].b = zBlue;
- leds[i].g = zGreen;
- leds[i].nscale8_video(zonePattern);
- }
- }
- }
- void diamondfade() {
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 17)) {
- leds[i].r = zRed;
- leds[i].b = zBlue;
- leds[i].g = zGreen;
- leds[i].nscale8_video(zonePattern);
- }
- }
- }
- void customlazer() {
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 18)) {
- leds[i].r = zRed;
- leds[i].b = zBlue;
- leds[i].g = zGreen;
- leds[i].nscale8_video(zonePattern);
- }
- }
- }
- void cops() {
- unsigned long flasherTime = millis();
- static boolean flashflag = 0;
- int color = 0;
- int color2 = 0;
- for(int i = 0; i < NUM_LEDS; i++){
- const unsigned int idx = ( i % 24);
- if (FunctionForEachPixel (i, idx, 19)) {
- leds[i] = CHSV(zonePattern, 255, 255);
- }
- if(flasherTime - flasherstart >= flasherinterval){
- flashflag =! flashflag;
- flasherstart = flasherTime;
- }
- if(flashflag == 0){
- color = 255;
- color2 = 0;
- }
- else {
- color = 0;
- color2 = 255;
- }
- if (i <= LastZone1Pixel && Function1 == 19){
- leds[4].setRGB(color, color, color);
- leds[5].setRGB(color, color, color);
- leds[6].setRGB(color, color, color);
- leds[24].setRGB(color2, color2, color2);
- leds[25].setRGB(color2, color2, color2);
- leds[26].setRGB(color2, color2, color2);
- }//function 2 is the selected function for zone 1
- if (i > LastZone1Pixel && i <= LastZone2Pixel && Function2 == 19) {
- leds[34].setRGB(color, color, color);
- leds[35].setRGB(color, color, color);
- leds[36].setRGB(color, color, color);
- leds[54].setRGB(color2, color2, color2);
- leds[55].setRGB(color2, color2, color2);
- leds[56].setRGB(color2, color2, color2);
- }
- if (i > LastZone2Pixel && i <= LastZone3Pixel && Function3 == 19) {
- leds[64].setRGB(color, color, color);
- leds[65].setRGB(color, color, color);
- leds[66].setRGB(color, color, color);
- leds[84].setRGB(color2, color2, color2);
- leds[85].setRGB(color2, color2, color2);
- leds[86].setRGB(color2, color2, color2);
- }
- if (i > LastZone3Pixel && i <= LastZone4Pixel && Function4 == 19) {
- leds[94].setRGB(color, color, color);
- leds[95].setRGB(color, color, color);
- leds[96].setRGB(color, color, color);
- leds[114].setRGB(color2, color2, color2);
- leds[115].setRGB(color2, color2, color2);
- leds[116].setRGB(color2, color2, color2);
- }
- }
- }
- void cops1() {
- unsigned long flasherTime1 = millis();
- static boolean flashflagg = 0;
- int color1 = 0;
- int color12 = 0;
- byte a = LastZone1Pixel/2;
- byte b = ((LastZone2Pixel - LastZone1Pixel) / 2) + LastZone1Pixel;
- byte c = ((LastZone3Pixel - LastZone2Pixel) / 2) + LastZone2Pixel;
- byte d = ((LastZone4Pixel - LastZone3Pixel) / 2) + LastZone3Pixel;
- for(int i = 0; i <= a; i++) {
- FunctionForEachPixel (i, 1, 20);
- if(flasherTime1 - flasherstart1 >= 150){
- flashflagg =! flashflagg;
- flasherstart1 = flasherTime1;
- }
- if(flashflagg == 0){
- color1 = 255;
- color12 = 0;
- }
- else {
- color1 = 0;
- color12 = 255;
- }
- }
- const unsigned int idx = 2;
- for(int j = 0; j <= a; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color1, 0, color12);
- }
- }
- for(int j = a + 1; j <= LastZone1Pixel; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color12, 0, color1);
- }
- }
- for(int j = LastZone1Pixel + 1; j <= b; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color1, 0, color12);
- }
- }
- for(int j = b + 1; j <= LastZone2Pixel; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color12, 0, color1);
- }
- }
- for(int j = LastZone2Pixel + 1 ; j <= c; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color1, 0, color12);
- }
- }
- for(int j = c + 1; j <= LastZone3Pixel; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color12, 0, color1);
- }
- }
- for(int j = LastZone3Pixel + 1; j <= d; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color1, 0, color12);
- }
- }
- for(int j = d + 1; j <= LastZone4Pixel; j++) {
- if (FunctionForEachPixel (j, idx, 20)) {
- leds[j].setRGB(color12, 0, color1);
- }
- }
- }
- void patriotic1() {
- }
- void strobing() {
- }
Advertisement
Add Comment
Please, Sign In to add comment