Initial Commit
This commit is contained in:
10
src/Alternate.cpp
Normal file
10
src/Alternate.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "Alternate.h"
|
||||
|
||||
void Alternate::execute(CRGB* leds) {
|
||||
for(uint16_t i = 0; i < NUMLEDS; i += alternateSize) {
|
||||
Utilities::setRange(leds, i, min(i + alternateSize, NUMLEDS), colors[((i / alternateSize) + alternateInt) % numColors]);
|
||||
}
|
||||
|
||||
alternateInt++;
|
||||
cycleCompleted();
|
||||
}
|
||||
17
src/Collision.cpp
Normal file
17
src/Collision.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "Collision.h"
|
||||
|
||||
void Collision::execute(CRGB* leds) {
|
||||
if(collisionInt == 0) {
|
||||
Utilities::setAll(leds, NUMLEDS, CRGB::Black);
|
||||
}
|
||||
|
||||
leds[collisionInt] = color1;
|
||||
leds[NUMLEDS - collisionInt - 1] = color2;
|
||||
|
||||
collisionInt++;
|
||||
|
||||
if(collisionInt >= NUMLEDS) {
|
||||
collisionInt = 0;
|
||||
cycleCompleted();
|
||||
}
|
||||
}
|
||||
20
src/CycleLight.cpp
Normal file
20
src/CycleLight.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "CycleLight.h"
|
||||
|
||||
void CycleLight::execute(CRGB* leds) {
|
||||
if(cycleLightInt == 0) {
|
||||
Utilities::setAll(leds, NUMLEDS, CRGB::Black);
|
||||
}
|
||||
|
||||
leds[cycleLightInt] = colors[cycleLightColor % numColors];
|
||||
|
||||
cycleLightInt++;
|
||||
|
||||
if(cycleLightInt >= NUMLEDS) {
|
||||
cycleLightInt = 0;
|
||||
cycleLightColor++;
|
||||
|
||||
if(cycleLightColor % numColors == 0) {
|
||||
cycleCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
src/FluidColor.cpp
Normal file
13
src/FluidColor.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "FluidColor.h"
|
||||
|
||||
void FluidColor::execute(CRGB* leds) {
|
||||
for(uint16_t i = 0; i < NUMLEDS; i++) {
|
||||
leds[i] = colors[(i + colorShifter) % 256];
|
||||
}
|
||||
|
||||
colorShifter++;
|
||||
|
||||
if(colorShifter % 256 == 0) {
|
||||
cycleCompleted();
|
||||
}
|
||||
}
|
||||
84
src/main.cpp
Normal file
84
src/main.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include <Arduino.h>
|
||||
#include <FastLED.h>
|
||||
#include "GlobalSettings.h"
|
||||
#include "Alternate.h"
|
||||
#include "Collision.h"
|
||||
#include "FluidColor.h"
|
||||
#include "CycleLight.h"
|
||||
|
||||
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
|
||||
// Required for Serial on Zero based boards
|
||||
#define Serial SERIAL_PORT_USBVIRTUAL
|
||||
#endif
|
||||
|
||||
void clearAll();
|
||||
|
||||
CRGB leds[NUMLEDS];
|
||||
|
||||
CRGB teamColors[] = {CRGB::Orange, CRGB::Green};
|
||||
|
||||
uint8_t currentMode = 0;
|
||||
|
||||
Alternate alternateTeamColors(200, 2, teamColors, 2);
|
||||
Collision collisionTeamColors(100, CRGB::Orange, CRGB::Green);
|
||||
FluidColor fluidColor(30);
|
||||
CycleLight cycleLightTeamColors(150, teamColors, 2);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while(!Serial) { delay(1); }
|
||||
|
||||
Serial.println(F("HELLO!"));
|
||||
FastLED.setMaxPowerInMilliWatts(400);
|
||||
|
||||
FastLED.addLeds<NEOPIXEL, OUTPUT_PIN>(leds, NUMLEDS);
|
||||
|
||||
alternateTeamColors.enable();
|
||||
collisionTeamColors.enable();
|
||||
fluidColor.enable();
|
||||
cycleLightTeamColors.enable();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
cycleLightTeamColors.update(leds);
|
||||
|
||||
FastLED.show();
|
||||
|
||||
delayMicroseconds(500);
|
||||
}
|
||||
|
||||
/*void loop() {
|
||||
if(currentMode == 0) {
|
||||
alternateTeamColors.update(leds);
|
||||
|
||||
if(alternateTeamColors.isFinished()) {
|
||||
currentMode++;
|
||||
collisionTeamColors.reinitialize();
|
||||
}
|
||||
} else if(currentMode == 1) {
|
||||
collisionTeamColors.update(leds);
|
||||
|
||||
if(collisionTeamColors.isFinished()) {
|
||||
currentMode = 2;
|
||||
fluidColor.reinitialize();
|
||||
}
|
||||
} else if(currentMode == 2) {
|
||||
fluidColor.update(leds);
|
||||
|
||||
if(fluidColor.isFinished()) {
|
||||
currentMode = 3;
|
||||
cycleLightTeamColors.reinitialize();
|
||||
}
|
||||
} else if(currentMode == 3) {
|
||||
cycleLightTeamColors.update(leds);
|
||||
|
||||
if(cycleLightTeamColors.isFinished()) {
|
||||
currentMode = 0;
|
||||
alternateTeamColors.reinitialize();
|
||||
}
|
||||
}
|
||||
|
||||
FastLED.show();
|
||||
delayMicroseconds(500);
|
||||
}*/
|
||||
|
||||
Reference in New Issue
Block a user