Created
August 8, 2017 18:57
-
-
Save gravityoverdivinity/1350d8c597389670a6c30ef8da2f367f to your computer and use it in GitHub Desktop.
mirror animations 6 matrices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED_PIN 5 | |
#define NUM_LEDS_PER_STRIP 150 | |
// RGB Shades color order (Green/Red/Blue) | |
#define COLOR_ORDER GRB | |
#define CHIPSET WS2812B | |
// Global maximum brightness value, maximum 255 | |
#define MAXBRIGHTNESS 255 | |
#define STARTBRIGHTNESS 102 | |
// Cycle time (milliseconds between pattern changes) | |
#define cycleTime 15000 | |
// Hue time (milliseconds between hue increments) | |
#define hueTime 30 | |
// Time after changing settings before settings are saved to EEPROM | |
#define EEPROMDELAY 2000 | |
// Include FastLED library and other useful files | |
#include <FastLED.h> | |
#include <EEPROM.h> | |
#include "messages.h" | |
#include "font.h" | |
#include "XYmap.h" | |
#include "utils.h" | |
#include "effects.h" | |
#include "buttons.h" | |
// list of functions that will be displayed | |
functionList effectList[] = {threeSine, | |
threeDee, | |
scrollTextZero, | |
plasma, | |
confetti, | |
rider, | |
scrollTextOne, | |
glitter, | |
slantBars, | |
scrollTextTwo, | |
colorFill, | |
sideRain | |
}; | |
const byte numEffects = (sizeof(effectList)/sizeof(effectList[0])); | |
// Runs one time at the start of the program (power up or reset) | |
void setup() { | |
// check to see if EEPROM has been used yet | |
// if so, load the stored settings | |
byte eepromWasWritten = EEPROM.read(0); | |
if (eepromWasWritten == 99) { | |
currentEffect = EEPROM.read(1); | |
autoCycle = EEPROM.read(2); | |
currentBrightness = EEPROM.read(3); | |
} | |
if (currentEffect > (numEffects - 1)) currentEffect = 0; | |
// write FastLED configuration data | |
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, LAST_VISIBLE_LED + 1); | |
// tell FastLED there's 150 NEOPIXEL leds on pin 5 | |
FastLED.addLeds<NEOPIXEL, 5>(leds, NUM_LEDS_PER_STRIP); | |
// tell FastLED there's 150 NEOPIXEL leds on pin 6 | |
FastLED.addLeds<NEOPIXEL, 6>(leds, NUM_LEDS_PER_STRIP); | |
// tell FastLED there's 150 NEOPIXEL leds on pin 7 | |
FastLED.addLeds<NEOPIXEL, 7>(leds, NUM_LEDS_PER_STRIP); | |
// tell FastLED there's 150 NEOPIXEL leds on pin 8 | |
FastLED.addLeds<NEOPIXEL, 8>(leds, NUM_LEDS_PER_STRIP); | |
// tell FastLED there's 150 NEOPIXEL leds on pin 9 | |
FastLED.addLeds<NEOPIXEL, 9>(leds, NUM_LEDS_PER_STRIP); | |
// tell FastLED there's 150 NEOPIXEL leds on pin 10 | |
FastLED.addLeds<NEOPIXEL, 10>(leds, NUM_LEDS_PER_STRIP); | |
// set global brightness value | |
FastLED.setBrightness( scale8(currentBrightness, MAXBRIGHTNESS) ); | |
// configure input buttons | |
pinMode(MODEBUTTON, INPUT_PULLUP); | |
pinMode(BRIGHTNESSBUTTON, INPUT_PULLUP); | |
} | |
// Runs over and over until power off or reset | |
void loop() | |
{ | |
currentMillis = millis(); // save the current timer value | |
updateButtons(); // read, debounce, and process the buttons | |
doButtons(); // perform actions based on button state | |
checkEEPROM(); // update the EEPROM if necessary | |
// switch to a new effect every cycleTime milliseconds | |
if (currentMillis - cycleMillis > cycleTime && autoCycle == true) { | |
cycleMillis = currentMillis; | |
if (++currentEffect >= numEffects) currentEffect = 0; // loop to start of effect list | |
effectInit = false; // trigger effect initialization when new effect is selected | |
} | |
// increment the global hue value every hueTime milliseconds | |
if (currentMillis - hueMillis > hueTime) { | |
hueMillis = currentMillis; | |
hueCycle(1); // increment the global hue value | |
} | |
// run the currently selected effect every effectDelay milliseconds | |
if (currentMillis - effectMillis > effectDelay) { | |
effectMillis = currentMillis; | |
effectList[currentEffect](); // run the selected effect function | |
random16_add_entropy(1); // make the random values a bit more random-ish | |
} | |
// run a fade effect too if the confetti effect is running | |
if (effectList[currentEffect] == confetti) fadeAll(1); | |
FastLED.show(); // send the contents of the led memory to the LEDs | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment