-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathled.ino
64 lines (55 loc) · 1.08 KB
/
led.ino
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
unsigned long NextLEDs=0;
void SetupLEDs(void)
{
#ifdef LED_WARN
pinMode(LED_WARN, OUTPUT);
digitalWrite(LED_WARN, 1);
#endif
#ifdef LED_OK
pinMode(LED_OK, OUTPUT);
digitalWrite(LED_OK, 0);
#endif
#ifdef LED_STATUS
pinMode(LED_STATUS, OUTPUT);
digitalWrite(LED_STATUS, 0);
#endif
#ifdef LED_TX
pinMode(LED_TX, OUTPUT);
digitalWrite(LED_TX, 0);
#endif
}
void ControlLEDs(int LEDStatus, int LEDOK, int LEDWarn)
{
#ifdef LED_STATUS
digitalWrite(LED_STATUS, LEDStatus);
#endif
#ifdef LED_OK
digitalWrite(LED_OK, LEDOK);
#endif
#ifdef LED_WARN
digitalWrite(LED_WARN, LEDWarn);
#endif
}
void CheckLEDs(void)
{
if (millis() >= NextLEDs)
{
static byte Flash=0;
// This would normally be the only LED for status (i.e. no OK or WARN LEDs)
if (GPS.Altitude > 1000)
{
// All off
ControlLEDs(0,0,0);
}
else if ((GPS.FixType == 3) && (GPS.Satellites >= 4))
{
ControlLEDs(Flash, Flash, 0);
}
else
{
ControlLEDs(1, 0, Flash);
}
NextLEDs = millis() + 500L;
Flash = 1-Flash;
}
}