-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIR_library.ino
173 lines (169 loc) · 4.13 KB
/
IR_library.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* Becker 780 car radio mod for adding bluetooth and other stuff to this radio.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* Infrared settings */
decode_results results;
uint16_t LastIRcode;
uint32_t IR_Timeout = millis();
bool IRBalance = false; //???? temp...
uint8_t IRControl = 0;
void Handle_IR()
{
if ((elapsedSince(IR_Timeout) > 150) && irrecv.decode(&results)) // IR remote check
{
//noInterrupts();
Serial.println(results.value, HEX);
if (results.value != 0xFFFF)
LastIRcode = results.value;
else
results.value = LastIRcode;
//TODO define the IR codes.
switch (results.value)
{
case 0x225D: // opnemen
break;
case 0x629D: // telefoon
break;
case 0x621D: // ophangen
break;
case 0x22DD: // CH+
break;
case 0x02FD: // CH-
break;
case 0x423D: // EQ
/*if (IRControl == 0)
{
WriteText("TONE");
IRControl++;
} else if (IRControl == 1)
{
WriteText("BAL");
IRControl++;
} else
{
WriteCBUS(LCD_Radiodata);
IRControl = 0;
}*/
break;
case 0x601F: // |<<
if (RadioMode == Mode_FM || RadioMode == Mode_AM)
{
Send_button_radio(BUTTON_seekmin);
}
break;
case 0x2857: // >>|
if (RadioMode == Mode_FM || RadioMode == Mode_AM)
{
Send_button_radio(BUTTON_seekplus);
}
break;
case 0x106F: // >||
break;
case 0x1867: // -
//if (IRControl > 0)
//{
// if (IRControl == 1)
// {
// Send_button_radio(BUTTON_d);
// } else
// {
// if (!IRBalance)
// {
// IRBalance = true;
// Send_button_radio(BUTTON_star);
// delay(300);
// //Send_button_radio(BUTTON_p);
// //delay(300);
// }
// Send_button_radio(BUTTON_d);
// }
//} else
Send_button_radio(BUTTON_volmin);
break;
case 0x304F: // +
//if (IRControl > 0)
//{
// if (IRControl == 1)
// {
// Send_button_radio(BUTTON_p);
// } else
// {
// if (!IRBalance)
// {
// IRBalance = true;
// Send_button_radio(BUTTON_star);
//
// delay(300);
// //Send_button_radio(BUTTON_d);
// //delay(300);
// }
// Send_button_radio(BUTTON_p);
//
// }
//} else
Send_button_radio(BUTTON_volplus);
break;
case 0x6897: // 0
case 0x30CF: // 1
case 0x18E7: // 2
case 0x7A85: // 3
case 0x10EF: // 4
case 0x38C7: // 5
case 0x5AA5: // 6
case 0x42BD: // 7
case 0x4AB5: // 8
case 0x52AD: // 9
if (RadioMode == Mode_FM || RadioMode == Mode_AM)
{
Send_button_radio(IRButton_Seek(results.value));
}
break;
}
//interrupts();
IR_Timeout = millis();
irrecv.resume();
}
}
uint8_t IRButton_Seek(uint16_t button)
{
switch (button)
{
case 0x6897: // 0
return BUTTON_10;
case 0x30CF: // 1
return BUTTON_1;
case 0x18E7: // 2
return BUTTON_2;
case 0x7A85: // 3
return BUTTON_3;
case 0x10EF: // 4
return BUTTON_4;
case 0x38C7: // 5
return BUTTON_5;
case 0x5AA5: // 6
return BUTTON_6;
case 0x42BD: // 7
return BUTTON_7;
case 0x4AB5: // 8
return BUTTON_8;
case 0x52AD: // 9
return BUTTON_9;
}
}