forked from ToniA/Raw-IR-decoder-for-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MitsubishiHeavy.cpp
307 lines (288 loc) · 7.23 KB
/
MitsubishiHeavy.cpp
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#include <Arduino.h>
bool decodeMitsubishiHeavy(byte *bytes, int byteCount)
{
// If this looks like a Mitsubishi Heavy...
if ( byteCount == 11 && bytes[0] == 0x52 && bytes[1] == 0xAE && bytes[2] == 0xC3 && bytes[3] == 0x26 && bytes[4] == 0xD9) {
Serial.println(F("Looks like a Mitsubishi Heavy ZJ-S protocol"));
Serial.println(F("Model SRKxxZJ-S Remote Control RKX502A001C"));
// Power mode
switch (bytes[9] & 0x08) {
case 0x00:
Serial.println(F("POWER ON"));
break;
case 0x08:
Serial.println(F("POWER OFF"));
break;
}
// Operating mode
switch (bytes[9] & 0x07) {
case 0x07:
Serial.println(F("MODE AUTO"));
break;
case 0x03:
Serial.println(F("MODE HEAT"));
break;
case 0x06:
Serial.println(F("MODE COOL"));
break;
case 0x05:
Serial.println(F("MODE DRY"));
break;
case 0x04:
Serial.println(F("MODE FAN"));
break;
}
// Temperature
Serial.print(F("Temperature: "));
Serial.println((~((bytes[9] & 0xF0) >> 4) & 0x0F) + 17);
// Fan speed
switch (bytes[7] & 0xE0) {
case 0xE0:
Serial.println(F("FAN AUTO"));
break;
case 0xA0:
Serial.println(F("FAN 1"));
break;
case 0x80:
Serial.println(F("FAN 2"));
break;
case 0x60:
Serial.println(F("FAN 3"));
break;
case 0x20:
Serial.println(F("HI POWER MODE"));
break;
case 0x00:
Serial.println(F("ECONO MODE"));
break;
}
// Vertical air direction
Serial.print(F("Vertical air direction: "));
switch ((bytes[5] & 0b00000010) | (bytes[7] & 0b00011000)) {
case 0x0A:
Serial.println(F("SWING"));
break;
case 0x02:
Serial.println(F("UP"));
break;
case 0x18:
Serial.println(F("MIDDLE UP"));
break;
case 0x10:
Serial.println(F("MIDDLE"));
break;
case 0x08:
Serial.println(F("MIDDLE DOWN"));
break;
case 0x00:
Serial.println(F("DOWN"));
break;
case 0x1A:
Serial.println(F("STOP"));
break;
}
// Horizontal air direction
Serial.print(F("Horizontal air direction: "));
switch (bytes[5] & 0b11001100) {
case 0xC8:
Serial.println(F("LEFT"));
break;
case 0x88:
Serial.println(F("MIDDLE LEFT"));
break;
case 0x48:
Serial.println(F("MIDDLE"));
break;
case 0x08:
Serial.println(F("MIDDLE RIGHT"));
break;
case 0xC4:
Serial.println(F("RIGHT"));
break;
case 0x84:
Serial.println(F("LEFT RIGHT"));
break;
case 0x44:
Serial.println(F("RIGHT LEFT"));
break;
case 0x4C:
Serial.println(F("SWING"));
break;
case 0xCC:
Serial.println(F("STOP"));
break;
case 0x04:
Serial.println(F("3D AUTO"));
break;
}
// Clean
Serial.print(F("Clean: "));
switch (bytes[5] & 0x20) {
case 0x00:
Serial.println(F("ON"));
break;
case 0x20:
Serial.println(F("OFF"));
break;
}
return true;
} else if ( byteCount == 19 && bytes[0] == 0x52 && bytes[1] == 0xAE && bytes[2] == 0xC3 && bytes[3] == 0x1A && bytes[4] == 0xE5) {
Serial.println(F("Looks like a Mitsubishi Heavy ZM-S protocol"));
Serial.println(F("Model SRKxxZM-S Remote Control RLA502A700B"));
// Power mode
switch (bytes[5] & 0x08) {
case 0x00:
Serial.println(F("POWER ON"));
break;
case 0x08:
Serial.println(F("POWER OFF"));
break;
}
// Operating mode
switch (bytes[5] & 0x07) {
case 0x07:
Serial.println(F("MODE AUTO"));
break;
case 0x03:
Serial.println(F("MODE HEAT"));
break;
case 0x06:
Serial.println(F("MODE COOL"));
break;
case 0x05:
Serial.println(F("MODE DRY"));
break;
case 0x04:
Serial.println(F("MODE FAN"));
break;
}
// Temperature
Serial.print(F("Temperature: "));
Serial.println((~(bytes[7]) & 0x0F) + 17);
// Fan speed
switch (bytes[9] & 0x0F) {
case 0x0F:
Serial.println(F("FAN AUTO"));
break;
case 0x0E:
Serial.println(F("FAN 1"));
break;
case 0x0D:
Serial.println(F("FAN 2"));
break;
case 0x0C:
Serial.println(F("FAN 3"));
break;
case 0x0B:
Serial.println(F("FAN 4"));
break;
case 0x07:
Serial.println(F("HI POWER MODE"));
break;
case 0x09:
Serial.println(F("ECONO MODE"));
break;
}
// Vertical air direction
Serial.print(F("Vertical air direction: "));
switch ((bytes[11] & 0b11100000)) {
case 0xE0:
Serial.println(F("SWING"));
break;
case 0xC0:
Serial.println(F("UP"));
break;
case 0xA0:
Serial.println(F("MIDDLE UP"));
break;
case 0x80:
Serial.println(F("MIDDLE"));
break;
case 0x60:
Serial.println(F("MIDDLE DOWN"));
break;
case 0x40:
Serial.println(F("DOWN"));
break;
case 0x20:
Serial.println(F("STOP"));
break;
}
// Horizontal air direction
Serial.print(F("Horizontal air direction: "));
switch (bytes[13] & 0x0F) {
case 0x0E:
Serial.println(F("LEFT"));
break;
case 0x0D:
Serial.println(F("MIDDLE LEFT"));
break;
case 0x0C:
Serial.println(F("MIDDLE"));
break;
case 0x0B:
Serial.println(F("MIDDLE RIGHT"));
break;
case 0x0A:
Serial.println(F("RIGHT"));
break;
case 0x08:
Serial.println(F("LEFT RIGHT"));
break;
case 0x09:
Serial.println(F("RIGHT LEFT"));
break;
case 0x0F:
Serial.println(F("SWING"));
break;
case 0x07:
Serial.println(F("STOP"));
break;
}
// 3D Auto
Serial.print(F("3D Auto: "));
switch (bytes[11] & 0b00010010) {
case 0x00:
Serial.println(F("ON"));
break;
case 0x12:
Serial.println(F("OFF"));
break;
}
// Night setback
Serial.print(F("Night setback: "));
switch (bytes[15] & 0x40) {
case 0x00:
Serial.println(F("ON"));
break;
case 0x40:
Serial.println(F("OFF"));
break;
}
// Silent mode
Serial.print(F("Silent mode: "));
switch (bytes[15] & 0x80) {
case 0x00:
Serial.println(F("ON"));
break;
case 0x80:
Serial.println(F("OFF"));
break;
}
// Clean and alergen
Serial.print(F("Clean or Alergen: "));
switch (bytes[5] & 0x60) {
case 0x00:
Serial.println(F("CLEAN"));
break;
case 0x20:
Serial.println(F("ALERGEN"));
break;
case 0x60:
Serial.println(F("OFF"));
break;
}
return true;
}
return false;
}