-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
55 lines (49 loc) · 1.01 KB
/
main.c
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
#include <stdbool.h>
#include <signal.h>
#include <stdio.h>
#include "lights.h"
#include "bouncing_balls.h"
#include "light_effects.h"
volatile bool running = true;
static void ctrl_c_handler(int signum)
{
(void)(signum);
running = false;
}
static void setup_handlers(void)
{
struct sigaction sa =
{
.sa_handler = ctrl_c_handler
};
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
}
int main()
{
init_lights();
setup_handlers();
uint8_t mode = 0;
uint32_t color;
while (running)
{
switch (mode)
{
case 0:
BouncingBalls(255, 0, 0, 3);
break;
case 1:
color = get_random_color();
NewKITT(color >> 16, (color >> 8) & 0xFF, color & 0xFF, 8, 10, 50);
break;
case 2:
rainbowCycle(20);
default:
TwinkleRandom(20, 100, false);
break;
}
}
free_lights();
printf("Exiting \r\n");
return 0;
}