From 1a56e9a6c279560580abda32fc14238e19a98942 Mon Sep 17 00:00:00 2001 From: Sophie Schiller Date: Thu, 18 Feb 2021 17:45:44 +0100 Subject: [PATCH] add startup colors, to keep powerbanks happy --- src/main.ino | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main.ino b/src/main.ino index 8477e52..b01a226 100644 --- a/src/main.ino +++ b/src/main.ino @@ -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; @@ -34,7 +34,7 @@ float h[NUM_BALLS] ; // An array of heights float vImpact0 = sqrt( -2 * GRAVITY * h0 ); // Impact velocity of the ball when it hits the ground if "dropped" from the top of the strip float vImpact[NUM_BALLS] ; // As time goes on the impact velocity will change, so make an array to store those values float tCycle[NUM_BALLS] ; // The time since the last time the ball struck the ground -byte pos[NUM_BALLS] ; // The integer position of the dot on the strip (LED index) +byte pos[NUM_BALLS] ; // The integer position of the dot on the strip (LED index) long tLast[NUM_BALLS] ; // The clock time of the last ground strike float COR[NUM_BALLS] ; // Coefficient of Restitution (bounce damping) @@ -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(ledsR, NUM_LEDS * 4, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.addLeds(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