forked from ToniA/Raw-IR-decoder-for-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hyundai.cpp
83 lines (74 loc) · 1.72 KB
/
Hyundai.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
#include <Arduino.h>
bool decodeHyundai(byte *bytes, int pulseCount)
{
// If this looks like a Hyundai code...
// Remote control Y512F2, Hyundai split-unit air conditioner
if ( pulseCount == 38 ) {
Serial.println(F("Looks like a Hyundai protocol"));
// Power mode
switch (bytes[0] & 0x08) {
case 0x00:
Serial.println(F("POWER OFF"));
break;
case 0x08:
Serial.println(F("POWER ON"));
break;
}
// Operating mode
switch (bytes[0] & 0x07) {
case 0x00:
Serial.println(F("MODE AUTO"));
break;
case 0x04:
Serial.println(F("MODE HEAT"));
break;
case 0x01:
Serial.println(F("MODE COOL"));
break;
case 0x02:
Serial.println(F("MODE DRY"));
break;
case 0x03:
Serial.println(F("MODE FAN"));
break;
}
// Temperature
Serial.print(F("Temperature: "));
Serial.println((bytes[1] & 0x0F) + 16);
// Fan speed
switch (bytes[0] & 0x30) {
case 0x00:
Serial.println(F("FAN: AUTO"));
break;
case 0x10:
Serial.println(F("FAN: 1"));
break;
case 0x20:
Serial.println(F("FAN: 2"));
break;
case 0x30:
Serial.println(F("FAN: 3"));
break;
}
// Sleep mode
switch (bytes[0] & 0x80) {
case 0x80:
Serial.println(F("SLEEP: ON"));
break;
case 0x00:
Serial.println(F("SLEEP: OFF"));
break;
}
// Air direction
switch (bytes[0] & 0x40) {
case 0x40:
Serial.println(F("SWING: ON"));
break;
case 0x00:
Serial.println(F("SWING: OFF"));
break;
}
return true;
}
return false;
}