add startup colors, to keep powerbanks happy

This commit is contained in:
Sophie Schiller 2021-02-18 17:45:44 +01:00
parent 0a89fa271d
commit 1a56e9a6c2

View file

@ -20,9 +20,9 @@ const byte NUM_LEDS = 15;
const byte FRAMES_PER_SECOND = 60;
const float range = 0.5; //accelleration range in g
byte BRIGHTNESS = 2;
const byte COOLING = 47;
const byte SPARKING = 50;
byte BRIGHTNESS = 4;
const byte COOLING = 80;
const byte SPARKING = 60;
uint8_t gHue = 0;
@ -47,7 +47,7 @@ CRGB ledsR[NUM_LEDS * STRIPS];
CRGBPalette16 gPal;
CRGB flagcolors[3][6] {{CRGB::Red, CRGB::DarkOrange, CRGB::Yellow, CRGB::DarkGreen, CRGB::Blue, CRGB::DarkViolet},
{CRGB::DarkBlue, CRGB::DeepPink, CRGB::Gray, CRGB::Gray, CRGB::DeepPink, CRGB::DarkBlue},
{CRGB::DeepPink, CRGB::Gray, CRGB::DarkViolet, CRGB::Black, CRGB::Blue, CRGB::Black}};
{CRGB::Green, CRGB::Green, CRGB::Gray, CRGB::Gray, CRGB::Red, CRGB::Red}};
const byte modeSwitchPin = 2;
RotaryEncoder encoder(A2, A3);
@ -62,12 +62,17 @@ void setup() {
FastLED.addLeds<WS2812, 10, GRB>(ledsR, NUM_LEDS * 4, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2812, 11, GRB>(ledsR, NUM_LEDS * 5, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
FastLED.setMaxPowerInVoltsAndMilliamps(5,500);
fill_rainbow(ledsR, NUM_LEDS*STRIPS, 0, 5);
FastLED.show();
pinMode(modeSwitchPin, INPUT_PULLUP);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
attachInterrupt(digitalPinToInterrupt(modeSwitchPin), setMode, RISING);
PCICR |= (1 << PCIE1);
@ -302,6 +307,11 @@ void drawOff(){
fadeToBlackBy( leds, STRIPS*NUM_LEDS, 10);
}
void rainbow()
{
fill_rainbow( leds, NUM_LEDS * STRIPS, gHue, 5);
}
void setMode(){
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
@ -370,8 +380,9 @@ void loop() {
if (mode == 0) {
// === Read acceleromter data === //
float accCombined = calculateOrientationData();
enableLEDsOnAcceleration(accCombined);
//float accCombined = calculateOrientationData();
//enableLEDsOnAcceleration(accCombined);
rainbow();
}
else if ((mode == 1) || (mode == 2)) {
random16_add_entropy( random());
@ -392,7 +403,7 @@ void loop() {
else {
drawOff();
}
FastLED.setBrightness( BRIGHTNESS * 8 );
FastLED.setBrightness( BRIGHTNESS * 4 );
if (mode != 2){
for (uint8_t i=0; i<NUM_LEDS*STRIPS; i++) {
ledsR[NUM_LEDS*STRIPS-1-i] = leds[i];
@ -408,5 +419,3 @@ void loop() {
gHue++;
FastLED.delay(1000 / FRAMES_PER_SECOND);
}