forked from wgalen/stagekit
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
104 lines (102 loc) · 3.32 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
#include "stagekit.h"
int main()
{
int i;
unsigned int color;
printf("Initializing StageKit...\n");
char* errorStr = "";
char* foundfile = "";
int error = sk_init(NULL, &foundfile, &errorStr);
if (error != 0) {
printf("%s\n", errorStr);
exit(error);
}
printf("Found StageKit on %s\n", foundfile);
printf("0 - Panic\n");
printf("1-5 - Strobe\n");
printf("6 - Set red lights\n");
printf("7 - Set yellow lights\n");
printf("8 - Set green lights\n");
printf("9 - Set blue lights\n");
printf("10 - Fog on\n");
printf("11 - Fog off\n");
while (i != -1)
{
if (scanf("%i", &i) == EOF)
{
return 0;
}
switch (i)
{
case 0:
error = sk_alloff(&errorStr);
printf("Turned off everything\n");
break;
case 1:
error = sk_setstrobe(0, &errorStr);
printf("Turned off strobe\n");
break;
case 2:
error = sk_setstrobe(1, &errorStr);
printf("Started a slow strobe\n");
break;
case 3:
error = sk_setstrobe(2, &errorStr);
printf("Started a medium strobe\n");
break;
case 4:
error = sk_setstrobe(3, &errorStr);
printf("Started a fast strobe\n");
break;
case 5:
error = sk_setstrobe(4, &errorStr);
printf("Started the fastest strobe\n");
break;
case 6:
printf("Enter a value (in hex) for the red lights:");
scanf("%2x", &color);
error = sk_setred(color, &errorStr);
printf("Sent %2x to the red array\n", color);
break;
case 7:
printf("Enter a value (in hex) for the yellow lights:");
scanf("%2x", &color);
error = sk_setyellow(color, &errorStr);
printf("Sent %2x to the yellow array\n", color);
break;
case 8:
printf("Enter a value (in hex) for the green lights:");
scanf("%2x", &color);
error = sk_setgreen(color, &errorStr);
printf("Sent %2hx to the green array\n", color);
break;
case 9:
printf("Enter a value (in hex) for the blue lights:");
scanf("%2x", &color);
error = sk_setblue(color, &errorStr);
printf("Sent %2x to the blue array\n", color);
break;
case 10:
error = sk_setfog(true, &errorStr);
printf("Fog engaged\n");
break;
case 11:
error = sk_setfog(false, &errorStr);
printf("Fog disengaged\n");
break;
case 12:
error = 0;
usleep(60000);
break;
}
if (error != 0) {
printf("%s\n", errorStr);
exit(error);
}
}
return 0;
}