forked from ToniA/Raw-IR-decoder-for-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Toshiba.cpp
78 lines (67 loc) · 1.74 KB
/
Toshiba.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
#include <Arduino.h>
byte bitReverse(byte x);
// Toshiba RAS-10PKVP-ND
bool decodeToshiba(byte *bytes, int byteCount)
{
// If this looks like a Toshiba code...
if ( byteCount == 9 && bytes[0] == 0x4F && bytes[1] == 0xB0 && bytes[2] == 0xC0 && bytes[3] == 0x3F && bytes[4] == 0x80 ) {
Serial.println(F("Looks like a Toshiba protocol"));
// Power & operating mode
switch (bytes[6] & 0xF0) {
case 0x00:
Serial.println(F("MODE AUTO"));
break;
case 0x80:
Serial.println(F("MODE COOL"));
break;
case 0x40:
Serial.println(F("MODE DRY"));
break;
case 0xC0:
Serial.println(F("MODE HEAT"));
break;
case 0xE0:
Serial.println(F("POWER OFF"));
break;
}
// Temperature
Serial.print(F("Temperature: "));
Serial.println((bitReverse((bytes[5] & 0x07)) >> 4) + 17);
// Fan speed
switch (bytes[6] & 0x07) {
case 0x00:
Serial.println(F("FAN: AUTO"));
break;
case 0x02:
Serial.println(F("FAN: 1"));
break;
case 0x06:
Serial.println(F("FAN: 2"));
break;
case 0x01:
Serial.println(F("FAN: 3"));
break;
case 0x05:
Serial.println(F("FAN: 4"));
break;
case 0x03:
Serial.println(F("FAN: 5"));
break;
}
// Check if the checksum matches
byte checksum = 0x00;
for (byte i = 0; i < 8; i++) {
checksum ^= bytes[i];
}
Serial.print(F("Checksum '0x"));
Serial.print(checksum, HEX);
if ( bytes[8] == checksum ) {
Serial.println(F("' matches"));
} else {
Serial.print(F(" does not match "));
Serial.println(bytes[8], HEX);
}
return true;
}
return false;
}