add startup colors, to keep powerbanks happy
This commit is contained in:
parent
0a89fa271d
commit
1a56e9a6c2
1 changed files with 20 additions and 11 deletions
29
src/main.ino
29
src/main.ino
|
@ -20,9 +20,9 @@ const byte NUM_LEDS = 15;
|
||||||
const byte FRAMES_PER_SECOND = 60;
|
const byte FRAMES_PER_SECOND = 60;
|
||||||
const float range = 0.5; //accelleration range in g
|
const float range = 0.5; //accelleration range in g
|
||||||
|
|
||||||
byte BRIGHTNESS = 2;
|
byte BRIGHTNESS = 4;
|
||||||
const byte COOLING = 47;
|
const byte COOLING = 80;
|
||||||
const byte SPARKING = 50;
|
const byte SPARKING = 60;
|
||||||
uint8_t gHue = 0;
|
uint8_t gHue = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ CRGB ledsR[NUM_LEDS * STRIPS];
|
||||||
CRGBPalette16 gPal;
|
CRGBPalette16 gPal;
|
||||||
CRGB flagcolors[3][6] {{CRGB::Red, CRGB::DarkOrange, CRGB::Yellow, CRGB::DarkGreen, CRGB::Blue, CRGB::DarkViolet},
|
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::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;
|
const byte modeSwitchPin = 2;
|
||||||
RotaryEncoder encoder(A2, A3);
|
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, 10, GRB>(ledsR, NUM_LEDS * 4, NUM_LEDS).setCorrection( TypicalLEDStrip );
|
||||||
FastLED.addLeds<WS2812, 11, GRB>(ledsR, NUM_LEDS * 5, NUM_LEDS).setCorrection( TypicalLEDStrip );
|
FastLED.addLeds<WS2812, 11, GRB>(ledsR, NUM_LEDS * 5, NUM_LEDS).setCorrection( TypicalLEDStrip );
|
||||||
FastLED.setBrightness( BRIGHTNESS );
|
FastLED.setBrightness( BRIGHTNESS );
|
||||||
|
FastLED.setMaxPowerInVoltsAndMilliamps(5,500);
|
||||||
|
fill_rainbow(ledsR, NUM_LEDS*STRIPS, 0, 5);
|
||||||
|
FastLED.show();
|
||||||
|
|
||||||
pinMode(modeSwitchPin, INPUT_PULLUP);
|
pinMode(modeSwitchPin, INPUT_PULLUP);
|
||||||
pinMode(3, OUTPUT);
|
pinMode(3, OUTPUT);
|
||||||
pinMode(4, OUTPUT);
|
pinMode(4, OUTPUT);
|
||||||
pinMode(5, OUTPUT);
|
pinMode(5, OUTPUT);
|
||||||
|
digitalWrite(3, HIGH);
|
||||||
|
digitalWrite(4, LOW);
|
||||||
|
digitalWrite(5, LOW);
|
||||||
attachInterrupt(digitalPinToInterrupt(modeSwitchPin), setMode, RISING);
|
attachInterrupt(digitalPinToInterrupt(modeSwitchPin), setMode, RISING);
|
||||||
|
|
||||||
PCICR |= (1 << PCIE1);
|
PCICR |= (1 << PCIE1);
|
||||||
|
@ -302,6 +307,11 @@ void drawOff(){
|
||||||
fadeToBlackBy( leds, STRIPS*NUM_LEDS, 10);
|
fadeToBlackBy( leds, STRIPS*NUM_LEDS, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rainbow()
|
||||||
|
{
|
||||||
|
fill_rainbow( leds, NUM_LEDS * STRIPS, gHue, 5);
|
||||||
|
}
|
||||||
|
|
||||||
void setMode(){
|
void setMode(){
|
||||||
static unsigned long last_interrupt_time = 0;
|
static unsigned long last_interrupt_time = 0;
|
||||||
unsigned long interrupt_time = millis();
|
unsigned long interrupt_time = millis();
|
||||||
|
@ -370,8 +380,9 @@ void loop() {
|
||||||
|
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
// === Read acceleromter data === //
|
// === Read acceleromter data === //
|
||||||
float accCombined = calculateOrientationData();
|
//float accCombined = calculateOrientationData();
|
||||||
enableLEDsOnAcceleration(accCombined);
|
//enableLEDsOnAcceleration(accCombined);
|
||||||
|
rainbow();
|
||||||
}
|
}
|
||||||
else if ((mode == 1) || (mode == 2)) {
|
else if ((mode == 1) || (mode == 2)) {
|
||||||
random16_add_entropy( random());
|
random16_add_entropy( random());
|
||||||
|
@ -392,7 +403,7 @@ void loop() {
|
||||||
else {
|
else {
|
||||||
drawOff();
|
drawOff();
|
||||||
}
|
}
|
||||||
FastLED.setBrightness( BRIGHTNESS * 8 );
|
FastLED.setBrightness( BRIGHTNESS * 4 );
|
||||||
if (mode != 2){
|
if (mode != 2){
|
||||||
for (uint8_t i=0; i<NUM_LEDS*STRIPS; i++) {
|
for (uint8_t i=0; i<NUM_LEDS*STRIPS; i++) {
|
||||||
ledsR[NUM_LEDS*STRIPS-1-i] = leds[i];
|
ledsR[NUM_LEDS*STRIPS-1-i] = leds[i];
|
||||||
|
@ -408,5 +419,3 @@ void loop() {
|
||||||
gHue++;
|
gHue++;
|
||||||
FastLED.delay(1000 / FRAMES_PER_SECOND);
|
FastLED.delay(1000 / FRAMES_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue