parent
d6027e093b
commit
d630525841
@ -1,23 +1,53 @@
|
||||
#include "FastLED.h"
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
#define NUM_STRIPS 2
|
||||
#define NUM_LEDS_PER_STRIP 10
|
||||
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
|
||||
#define PIN_STRIP1 34
|
||||
#define NUM_LEDS 40
|
||||
#define PIN_STRIP 17
|
||||
bool shouldUpdateLights = false;
|
||||
|
||||
void setupLights() {
|
||||
FastLED.addLeds<NEOPIXEL, PIN_STRIP1>(leds[0], NUM_LEDS_PER_STRIP);
|
||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, PIN_STRIP, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
void lightOff() {
|
||||
for(int i = 0; i < NUM_LEDS; i++) {
|
||||
pixels.setPixelColor(i, pixels.Color(0,0,0));
|
||||
}
|
||||
portDISABLE_INTERRUPTS();
|
||||
pixels.show();
|
||||
portENABLE_INTERRUPTS();
|
||||
}
|
||||
|
||||
void loopLights() {
|
||||
// This outer loop will go over each strip, one at a time
|
||||
for(int x = 0; x < NUM_STRIPS; x++) {
|
||||
// This inner loop will go over each led in the current strip, one at a time
|
||||
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
|
||||
leds[x][i] = CRGB::Red;
|
||||
FastLED.show();
|
||||
leds[x][i] = CRGB::Black;
|
||||
delay(100);
|
||||
}
|
||||
void lightWhite() {
|
||||
for(int i = 0; i < NUM_LEDS; i++) {
|
||||
pixels.setPixelColor(i, pixels.Color(180,180,180));
|
||||
}
|
||||
portDISABLE_INTERRUPTS();
|
||||
pixels.show();
|
||||
portENABLE_INTERRUPTS();
|
||||
}
|
||||
|
||||
void lightBackFront() {
|
||||
// Implement me :-)
|
||||
for(int i = 0; i < NUM_LEDS; i++) {
|
||||
pixels.setPixelColor(i, pixels.Color(180,180,180));
|
||||
}
|
||||
portDISABLE_INTERRUPTS();
|
||||
pixels.show();
|
||||
portENABLE_INTERRUPTS();
|
||||
}
|
||||
|
||||
void updateLights() {
|
||||
if(lightActive) {
|
||||
lightWhite();
|
||||
}else {
|
||||
lightOff();
|
||||
}
|
||||
|
||||
shouldUpdateLights = false;
|
||||
}
|
||||
|
||||
void setupLights() {
|
||||
portDISABLE_INTERRUPTS();
|
||||
pixels.begin();
|
||||
portENABLE_INTERRUPTS();
|
||||
delay(1);
|
||||
lightOff();
|
||||
}
|
Loading…
Reference in new issue