-
Notifications
You must be signed in to change notification settings - Fork 0
/
led.cpp
66 lines (55 loc) · 1.02 KB
/
led.cpp
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
#include "led.h"
#define SLOW_FLASH (200)
#define FAST_FLASH (20)
#define led PB8
void Led_init(void);
void Led_flasher(int delay);
void Led_init(void)
{
led.mode(OUTPUT_PP);
led.reset();
}
void Led_flasher(int delay)
{
led.set();
delay_ms(delay);
led.reset();
delay_ms(delay);
}
void Led_event_flasher(int event)
{
int fast = 0;
int slow = 0;
switch(event)
{
case IMU_CALIBRATION:
{
slow = 1;
while(slow--)
Led_flasher( 6 * SLOW_FLASH);
break;
}
case ACC_CALIBRATION:
{
fast = 0;
slow = 5;
while(slow--)
Led_flasher(SLOW_FLASH);
while(fast--)
Led_flasher(FAST_FLASH);
break;
}
case GYRO_CALIBRATION:
{
fast = 30;
slow = 0;
while(slow--)
Led_flasher(SLOW_FLASH);
while(fast--)
Led_flasher(FAST_FLASH);
break;
}
default:
break;
}
}