-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleds.h
70 lines (51 loc) · 1.49 KB
/
leds.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <FastLED.h>
CRGB leds[NUM_LEDS];
int LEDSTATE = 3;
long LastDebugTime = 0;
unsigned long LastLEDRun = 0;
bool Alertstate = false;
unsigned long AlarmTime = 0;
void LED_setup() {
// delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
Serial.println("Setting up LEDS");
AlarmTime = ALARM_ON;
}
void ApplyState(){
int color_set[3];
//memcpy(array2, array1, sizeof(array1));
//color_set = color_noinput;
memcpy(color_set, color_noinput, sizeof(color_noinput));
if(LEDSTATE == 1) {
memcpy(color_set, color_ok, sizeof(color_ok));
color_set[0] = SetRed;
color_set[1] = SetGreen;
color_set[2] = SetBlue;
}
if(LEDSTATE == 2) memcpy(color_set, color_limit, sizeof(color_limit));
if(LEDSTATE == 3){
if( (millis() - LastLEDRun) > AlarmTime ){
if(Alertstate){
memcpy(color_set, color_limit, sizeof(color_limit));
AlarmTime = ALARM_OFF;
}else{
memcpy(color_set, color_alert, sizeof(color_alert));
AlarmTime = ALARM_ON;
}
LastLEDRun = millis();
Alertstate = !Alertstate;
}
}
for(int LED = 0 ; LED < 4 ; LED++){
leds[LED].r = color_set[0];
leds[LED].g = color_set[1];
leds[LED].b = color_set[2];
}
FastLED.show();
}
void LED_loop()
{
ApplyState();
}