-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.ino
108 lines (105 loc) · 2.21 KB
/
Input.ino
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
105
106
107
108
void led_UP(){
if(volume==0){
setColor(0,0,0);
}
if(volume==1){
setColor(255,0,255);
}
if(volume==4){
setColor(0,0,255);
}
if(volume == 9){
setColor(0,255,0);
}
if(volume == 14){
setColor(255,255,0);
}
if(volume == 19){
setColor(0,255,255);
}
if(volume == 24){
setColor(255,0,0);
}
if(volume==29){
setColor(0,0,255);
}
}
void led_DOWWN(){
if(volume== 0){
setColor(0,0,0);
}
if(volume== 4){
setColor(255,0,255);
}
if(volume == 9){
setColor(0,0,255);
}
if(volume == 14){
setColor(0,255,0);
}
if(volume ==19){
setColor(255,255,0);
}
if(volume == 24){
setColor(0,255,255);
}
if(volume == 29){
setColor(255,0,0);
}
}
void leftButtonISR()
{
led_UP();
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 150ms, assume it's a bounce and ignore
if (interrupt_time - last_interrupt_time > 150)
{
updateScreen = true;
if(inSideMenuSelection && sMenuSelection < 2)
{
sMenuSelection++;
}
else if(selection < 4 && sMenuSelection == 1)
{
selection++;
}
else if(selection == 1 && volume < 30 &&sMenuSelection == 2 && !inSideMenuSelection)
{
volume++;
}
else if(selection == 2 && eq < 5 && sMenuSelection == 2 && !inSideMenuSelection)
{
eq++;
}
}
last_interrupt_time = interrupt_time;
}
void rightButtonISR()
{
led_DOWWN();
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 150, assume it's a bounce and ignore
if (interrupt_time - last_interrupt_time > 150)
{
updateScreen = true;
if(inSideMenuSelection && sMenuSelection > 1)
{
sMenuSelection--;
}
else if(selection > 1 && sMenuSelection == 1)
{
selection--;
}
else if(selection == 1 && volume > 0 &&sMenuSelection == 2)
{
volume--;
}
else if(selection == 2 && eq > 0 && sMenuSelection == 2)
{
eq--;
}
}
last_interrupt_time = interrupt_time;
}