-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.c
70 lines (66 loc) · 1.32 KB
/
demo.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
#include <stdio.h>
#include <unistd.h>
#include "wiring.h"
void starter(char *b, char *dir)
{
printf("%s %s %s %s\n",b ,b ,b, dir);
}
void up_rise_starter()
{
starter("/\\","rising");
}
void up_fall_starter()
{
starter("/\\","falling");
}
void down_rise_starter()
{
starter("\\/","rising");
}
void down_fall_starter()
{
starter("\\/","falling");
}
void left_rise_starter()
{
starter("<","rising");
}
void left_fall_starter()
{
starter("<","falling");
}
void right_rise_starter()
{
starter(">","rising");
}
void right_fall_starter()
{
starter(">","falling");
}
void fire_rise_starter()
{
starter("Fire","rising");
}
void fire_fall_starter()
{
starter("Fire","falling");
}
int main()
{
init();
wiringPiISR(UP_1,INT_EDGE_RISING,&up_rise_starter);
wiringPiISR(DOWN_1,INT_EDGE_RISING,&down_rise_starter);
wiringPiISR(LEFT_1,INT_EDGE_RISING,&left_rise_starter);
wiringPiISR(RIGHT_1,INT_EDGE_RISING,&right_rise_starter);
wiringPiISR(FIRE_1,INT_EDGE_RISING,&fire_rise_starter);
wiringPiISR(UP_1,INT_EDGE_FALLING,&up_fall_starter);
wiringPiISR(DOWN_1,INT_EDGE_FALLING,&down_fall_starter);
wiringPiISR(LEFT_1,INT_EDGE_FALLING,&left_fall_starter);
wiringPiISR(RIGHT_1,INT_EDGE_FALLING,&right_fall_starter);
wiringPiISR(FIRE_1,INT_EDGE_FALLING,&fire_fall_starter);
while(1)
{
sleep(1);
}
return 0;
}