forked from mzillgith/libiec61850
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeaglebone_leds.c
63 lines (52 loc) · 1.07 KB
/
beaglebone_leds.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
/*
* beaglebone_leds.c
*/
#include <stdio.h>
#include "beaglebone_leds.h"
#ifndef SIMULATED
static void
writeToFile(char* filename, char* text)
{
FILE* file = fopen(filename, "w");
fprintf(file, "%s", text);
fclose(file);
}
#endif /* SIMULATED */
void
flashLED(char* led)
{
#ifndef SIMULATED
char filename[255];
sprintf(filename, "%s/trigger", led);
writeToFile(filename, "timer");
sprintf(filename, "%s/delay_on", led);
writeToFile(filename, "200");
sprintf(filename, "%s/delay_off", led);
writeToFile(filename, "200");
#else
printf("FLASH: %s\n", led);
#endif
}
void
switchLED(char* led, int value)
{
#ifndef SIMULATED
char filename[255];
char valueStr[10];
sprintf(filename, "%s/trigger", led);
writeToFile(filename, "none");
sprintf(filename, "%s/brightness", led);
sprintf(valueStr, "%i", value);
writeToFile(filename, valueStr);
#else
printf("SWITCH: %s %i\n", led, value);
#endif
}
void
initLEDs()
{
switchLED(LED1, 0);
switchLED(LED2, 0);
switchLED(LED3, 0);
switchLED(LED4, 0);
}