shared.vars tab
This is a REAL mess...
#include <Adafruit_NeoPixel.h>
#include <avr/interrupt.h>
const byte blinkPin = 13;
#define D_LEDS 0 //Debug LEDS
#define N_LEDS 20-D_LEDS //LEDS in strip (temporary for testing)
#define PIN 11 //output pin
#define worms 1 //max worms in animations
//#define TBpin 3 //testing button switches
//#define BBpin 4
const byte TBpin = 3;
const byte BBpin = 4;
const float piconv = 0.0175;
float Sindir[4]; // independent values for RGB and brightness sine waves
static float SinMod[4] = {random(0, 360), random(0, 360), random(0, 360), random(0, 360)}; //angular multipliers for each of R G B and Bright
//Cthulhu versions
float CSindir[4] = {0.5, 0.5, 1, 49}; // independent values for RGB and brightness sine waves
static float CSinMod[4] = {180,0,0,0}; //angular multipliers for each of R G B and Bright
int rebelstar;
byte LEDcolour[3]; //(RGB)
//a factor to manage high load. Set in each animation
float Loadfactor = 1;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
#include <PinChangeInterrupt.h>
byte colourpairs [5][2][3][2] = {
{ { { 0, 0}, { 50, 75}, {255, 255} }, { {200, 225}, { 0, 150}, { 0, 0} } }, //Colour Pair One, C1 : RMin, RMax, GMin, GMax, Bmin, Bmax , C2 : RMin, RMax, GMin, GMax, Bmin, Bmax
{ { { 0, 0}, { 0, 25}, {175, 255} }, { {225, 255}, {150, 175}, { 0, 0} } }, //Colour Pair Two
{ { {255, 255}, { 0, 55}, { 0, 55} }, { { 0, 55}, { 0, 55}, { 0, 255} } }, //Colour Pair Three
{ { { 0, 255}, { 0, 255}, { 0, 255} }, { { 0, 0}, { 0, 255}, { 0, 255} } }, //Colour Pair Four
{ { { 0, 0}, {150, 255}, { 0, 55} }, { {200, 255}, { 0, 0}, {200, 255} } }, //Colour Pair Five
};
float LEDSine[N_LEDS]; //used in sine wave anims but bad for memory
float LEDSinespeed[N_LEDS]; //used in sine wave anims but bad for memory
float LEDR[N_LEDS];
float LEDG[N_LEDS];
float LEDB[N_LEDS];
byte LEDONOFF[N_LEDS];
int debug = 1;
int bias[3] = {1, 1, 1}; //used in SPARKLE
int colA[3] = {0, 0, 0}; //current RGB
int colB[3] = {255, 255, 255}; //target RGB
int colfade[3]={0,0,0};
//Current limiter
float MasterLoadfactor = 1; //overall load factor applied to all animations
//Crossfader
int fadestep;
//Structural
long getcol;
float DS = 1; //speed of sine wave
float Master = 1; //controls overall brightness, 0 = totally off, 1 = full brightness! Has side effect of speeding up the shimmer as well.
long changecol = 5000; //time (ms) before colour change (0=off)
boolean sparkles = 1; //adds random colour sparkles, 1= on, 0 = off
boolean sparklim = 0; //limit sparkles to colour parameters
int chance;
int ms_delay;
int p; //pixel number primary;
int q; //pixel number secondary;
int i; //general increment
int j; //general increment
int jmax; //j maximum limit
int k; //general increment
int l; //general increment
float z;
//time variables
int pattern_max = 4; //highest pattern number
volatile int pattern;
int target_pattern;
int sub_pattern;
int this_pattern;
long TBpressed=millis();
long BBpressed=millis();
volatile byte state = LOW;
int maxBRT=255;
long blink_start;
long blink_on_for;
long blink_end;
long blink_off_for;
long ms_on;
long ms_off;
long start_time; //start of animation
long run_time; //duration of animation
long change_time = 10000; //time to change animation
long lastdel; //used by BLANK_ALL
float fadelength = 360;
static float fader = 0;
static float fade = fader / fadelength;
float DStot = 1; //experimental = an overall fade that colour and overall fade share.
float colDS = 1 * DStot; //speed of cosine wave for colour
float randomcolDS = 0;
float fadeDS = 0.50 * DStot; //speed of cosine wave for fade
static boolean showme = 0; //will display colour ranges at startup. Caution! Slow if wide range set!
int bugLED = 0; //testing - first (bugLED) LEDS can be used to indicate sketch state.
boolean sinONOFF = 1; //0 = sine wave off, 1 = sine wave on (effectively shimmer ON/OFF
boolean fadeONOFF = 1; //0 = fade off, 1 = fade on (time still runs but LEDs don't dim)
int maxcycles = 2;
static int cycle = 1; //cycle 0 = Blue, cycle 1 = yellow
static int colpair = random(0, 5);
static int phase = 1; //phase 0 = main, phase -1 = fade to black, phase 1 = fade in new colour *NOW STARTS ON FADE IN*
static long coltime; //start time of current cycle
static long runtime = 0; //run time of current cycle