forked from ToniA/Raw-IR-decoder-for-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MitsubishiElectric.cpp
176 lines (162 loc) · 4.15 KB
/
MitsubishiElectric.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
#include <Arduino.h>
bool decodeMitsubishiElectric(byte *bytes, int byteCount)
{
// If this looks like a Mitsubishi FD-25 or FE code...
if ( byteCount == 36 && bytes[0] == 0x23 &&
( (memcmp(bytes, bytes+18, 17) == 0) ||
((memcmp(bytes, bytes+18, 14) == 0) && bytes[32] == 0x24) ) ){
Serial.println(F("Looks like a Mitsubishi FD / FE / MSY series protocol"));
// Check if the checksum matches
byte checksum = 0;
for (int i=0; i<17; i++) {
checksum += bytes[i];
}
if (checksum == bytes[17]) {
Serial.println(F("Checksum matches"));
} else {
Serial.println(F("Checksum does not match"));
}
// Power mode
switch (bytes[5]) {
case 0x00:
Serial.println(F("POWER OFF"));
break;
case 0x20:
Serial.println(F("POWER ON"));
break;
default:
Serial.println(F("POWER unknown"));
break;
}
// Operating mode
switch (bytes[6] & 0x38) { // 0b00111000
case 0x38:
Serial.println(F("MODE FAN"));
break;
case 0x20:
Serial.println(F("MODE AUTO"));
break;
case 0x08:
if (bytes[15] == 0x20) {
Serial.println(F("MODE MAINTENANCE HEAT (FE only)"));
} else {
Serial.println(F("MODE HEAT"));
}
break;
case 0x18:
Serial.println(F("MODE COOL"));
break;
case 0x10:
Serial.println(F("MODE DRY"));
break;
default:
Serial.println(F("MODE unknown"));
break;
}
// I-See
switch (bytes[6] & 0x40) { // 0b01000000
case 0x40:
Serial.println(F("I-See: ON"));
break;
case 0x00:
Serial.println(F("I-See: OFF"));
break;
}
// Plasma
switch (bytes[15] & 0x40) { // 0b01000000
case 0x40:
Serial.println(F("Plasma: ON"));
break;
case 0x00:
Serial.println(F("Plasma: OFF"));
break;
}
// Temperature
Serial.print(F("Temperature: "));
if (bytes[7] == 0x00) {
Serial.println(F("10"));
} else {
Serial.println(bytes[7] + 16);
}
// Fan speed
switch (bytes[9] & 0x07) { // 0b00000111
case 0x00:
Serial.println(F("FAN AUTO"));
break;
case 0x01:
Serial.println(F("FAN 1"));
break;
case 0x02:
Serial.println(F("FAN 2"));
break;
case 0x03:
Serial.println(F("FAN 3"));
break;
case 0x04:
Serial.println(F("FAN 4"));
break;
default:
Serial.println(F("FAN unknown"));
break;
}
// Vertical air direction
switch (bytes[9] & 0xF8) { // 0b11111000
case 0x40: // 0b01000
Serial.println(F("VANE: AUTO1?"));
break;
case 0x48: // 0b01001
Serial.println(F("VANE: UP"));
break;
case 0x50: // 0b01010
Serial.println(F("VANE: UP-1"));
break;
case 0x58: // 0b01011
Serial.println(F("VANE: UP-2"));
break;
case 0x60: // 0b01100
Serial.println(F("VANE: UP-3"));
break;
case 0x68: // 0b01101
Serial.println(F("VANE: DOWN"));
break;
case 0x78: // 0b01111
Serial.println(F("VANE: SWING"));
break;
case 0x80: // 0b10000
Serial.println(F("VANE: AUTO2?"));
break;
case 0xB8: // 0b10111
Serial.println(F("VANE: AUTO3?"));
break;
default:
Serial.println(F("VANE: unknown"));
break;
}
// Horizontal air direction
switch (bytes[8] & 0xF0) { // 0b11110000
case 0x10:
Serial.println(F("WIDE VANE: LEFT"));
break;
case 0x20:
Serial.println(F("WIDE VANE: MIDDLE LEFT"));
break;
case 0x30:
Serial.println(F("WIDE VANE: MIDDLE"));
break;
case 0x40:
Serial.println(F("WIDE VANE: MIDDLE RIGHT"));
break;
case 0x50:
Serial.println(F("WIDE VANE: RIGHT"));
break;
case 0xC0:
Serial.println(F("WIDE VANE: SWING"));
break;
default:
Serial.println(F("WIDE VANE: unknown"));
break;
}
return true;
}
return false;
}