-
Notifications
You must be signed in to change notification settings - Fork 0
/
IrHelper.ino
132 lines (128 loc) · 2.91 KB
/
IrHelper.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
void initIr() {
IrReceiver.begin(RECV_PIN);
Serial.print(F("[OK] Launching Remote IR Sensor on pin: "));
Serial.println(RECV_PIN);
}
#define zero 2774139135
#define one 2991390975
#define two 2974679295
#define three 2957967615
#define four 2924544255
#define five 2907832575
#define six 2891120895
#define seven 2857697535
#define eight 2840985855
#define nine 2824274175
int irToNumber(ul rawData)
{
int cif=-1;
switch (rawData) {
case zero:
cif=0; break;
case one:
cif=1; break;
case two:
cif=2; break;
case three:
cif=3; break;
case four:
cif=4; break;
case five:
cif=5; break;
case six:
cif=6; break;
case seven:
cif=7; break;
case eight:
cif=8; break;
case nine:
cif=9; break;
}
Serial.print(F("[OK] IRremote read cif: "));
Serial.println(cif);
return cif;
}
#define menu 2790850815
#define audio 3843686655
#define exit 2757427455
#define standby 3058237695
#define mute 3024814335
#define info 2690580735
#define volminus 3776839935
#define volplus 2740715775
#define fav 2807562495
#define chminus 3826974975
#define chplus 2707292415
#define zoom 3008102655
#define redbutton 3994091775
#define bluebutton 2941255935
#define ok 3760128255
#define recall 3910533375
void decodeIr(ul rawData)
{
switch (rawData) {
case menu:
readTime=true;
digit1=0; digit2=0; digit3=0; digit4=0;
poz=0;
Serial.println(F("[OK] Ready for Clock Input!"));
blink(5, 200);
break;
case audio:
digit1=0; digit2=0; digit3=0; digit4=0;
readAlarm=true;
poz=0;
Serial.println(F("[OK] Ready for Alarm Input!"));
blink(5, 200);
break;
case exit:
disableAlarm();
break;
case standby:
IR_REMOTE=!IR_REMOTE;
delay(20);
disabled=!disabled;
//disableDigits();
break;
case mute:
disabledSmall=!disabledSmall; break;
case info:
readSecs=!readSecs; break;
case volminus:
decreaseSeconds(); break;
case volplus:
increaseSeconds(); break;
case fav:
readHours=!readHours; break;
case chminus:
decreaseHours(); break;
case chplus:
increaseHours(); break;
case zoom:
readMinutes=!readMinutes; break;
case redbutton:
decreaseMinutes(); break;
case bluebutton:
increaseMinutes(); break;
case ok:
lightState=!lightState;
digitalWriteFast(LIGHT_PIN, lightState);
break;
case recall:
ALARM_RUNNING=!ALARM_RUNNING; break;
}
if (readTime==true||readAlarm==true) {
int cif=irToNumber(rawData);
setTime(cif);
}
}
void checkIr()
{
if (IrReceiver.decode()) {
ul rawData=IrReceiver.decodedIRData.decodedRawData;
IrReceiver.resume(); // Enable receiving of the next value
if (rawData==0) return;
Serial.print(F("[OK] Remote IR Raw Data: ")); Serial.println(rawData);
decodeIr(rawData);
}
}