forked from N00byEdge/IS1200-miniproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.c
42 lines (33 loc) · 831 Bytes
/
Input.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
#include "Input.h"
// TODO: Set up bus for buttons
// TODO: find pins for buttons
void buttonsInit(){
TRISDSET = 0x7 | (0x3 << 9); //0, 1, 2, 9, 10
TRISFSET = (1 << 1); // 1
}
unsigned getButtons() {
return ((PORTD >> 0) & 0x1) |
((PORTF >> 1) & 0x1) << 1 |
((PORTD >> 1) & 0x1) << 2 |
((PORTD >> 2) & 0x1) << 3 |
((PORTD >> 9) & 0x1) << 4 |
((PORTD >> 10) & 0x1) << 5;
}
unsigned getButtonAccept() {
return getButtons() & 0x1;
}
unsigned getButtonRotate() {
return (getButtons() >> 1) & 0x1;
}
unsigned getButtonUp() {
return (getButtons() >> 2) & 0x1;
}
unsigned getButtonDown() {
return (getButtons() >> 3) & 0x1;
}
unsigned getButtonLeft() {
return (getButtons() >> 4) & 0x1;
}
unsigned getButtonRight() {
return (getButtons() >> 5) & 0x1;
}