111 lines
2.0 KiB
C++
111 lines
2.0 KiB
C++
//Show LED Colors
|
|
void show_white(){
|
|
|
|
FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RBG>(leds, NUM_LEDS);
|
|
for(int i=0; i < NUM_LEDS; i = i+1 )
|
|
{
|
|
leds[i] = CRGB::White;
|
|
}
|
|
FastLED.show();
|
|
Serial.println("Light: WHITE");
|
|
}
|
|
|
|
//Show LED Colors
|
|
void show_black(){
|
|
|
|
FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RBG>(leds, NUM_LEDS);
|
|
for(int i=0; i < NUM_LEDS; i = i+1 )
|
|
{
|
|
leds[i] = CRGB::Black;
|
|
}
|
|
FastLED.show();
|
|
Serial.println("Light: BLACK");
|
|
}
|
|
|
|
//Show LED Colors
|
|
void show_green(){
|
|
|
|
FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RBG>(leds, NUM_LEDS);
|
|
for(int i=0; i < NUM_LEDS; i = i+1 )
|
|
{
|
|
leds[i] = CRGB::Green;
|
|
}
|
|
FastLED.show();
|
|
Serial.println("Light: GREEN");
|
|
}
|
|
|
|
void set_color(int r, int g, int b){
|
|
FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RBG>(leds, NUM_LEDS);
|
|
for(int i=0; i < NUM_LEDS; i = i+1 )
|
|
{
|
|
leds[i].setRGB( r, g, b);
|
|
}
|
|
FastLED.show();
|
|
Serial.println("Light: ");
|
|
Serial.println(r);
|
|
Serial.println(b);
|
|
Serial.println(g);
|
|
}
|
|
|
|
bool run_wake_up(long currentMillis){
|
|
if (alarm_started == true)
|
|
{
|
|
long delta = (currentMillis - startTime)/1000;
|
|
if (delta < 220){
|
|
set_color(30 + int(delta), int(delta)/4, 0);
|
|
}
|
|
else if(delta < 405){
|
|
set_color(255, int(delta - 220)+55, int((delta - 220)/4));
|
|
}
|
|
else if(delta < 605){
|
|
set_color(255, 255, int((delta - 405))+55);
|
|
}
|
|
else{
|
|
if (delta % 2 == 0){
|
|
show_white();
|
|
}
|
|
else{
|
|
show_black();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
else if (lamp_on == true){
|
|
|
|
}
|
|
else{
|
|
show_black();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void switch_lamp(){
|
|
if(lamp_on == false){
|
|
lamp_on = true;
|
|
show_white();
|
|
}
|
|
else{
|
|
lamp_on = false;
|
|
show_black();
|
|
}
|
|
}
|
|
|
|
void start_wake_light(long currentMillis){
|
|
if (alarm_started == false)
|
|
{
|
|
alarm_started = true;
|
|
startTime = currentMillis;
|
|
set_color(30, 0, 0);
|
|
}
|
|
}
|
|
|
|
void stop_wake_light(){
|
|
if (alarm_started == true)
|
|
{
|
|
alarm_started = false;
|
|
startTime = 0;
|
|
show_black();
|
|
}
|
|
}
|
|
|