-
Notifications
You must be signed in to change notification settings - Fork 140
/
MitsubishiHeavyFDTCHeatpumpIR.cpp
129 lines (108 loc) · 3.95 KB
/
MitsubishiHeavyFDTCHeatpumpIR.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
#include <MitsubishiHeavyFDTCHeatpumpIR.h>
MitsubishiHeavyFDTCHeatpumpIR::MitsubishiHeavyFDTCHeatpumpIR() : HeatpumpIR()
{
static const char model[] PROGMEM = "mitsubishi_heavy_fdtc";
static const char info[] PROGMEM = "{\"mdl\":\"mitsubishi_heavy_fdtc\",\"dn\":\"Mitsubishi Heavy FDTC\",\"mT\":18,\"xT\":30,\"fs\":3}";
_model = model;
_info = info;
}
void MitsubishiHeavyFDTCHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd)
{
// Sensible defaults for the heat pump mode
uint8_t powerMode = MITSUBISHI_HEAVY_FDTC_MODE_ON;
uint8_t operatingMode = MITSUBISHI_HEAVY_FDTC_MODE_AUTO;
uint8_t fanSpeed = MITSUBISHI_HEAVY_FDTC_FAN1;
uint8_t temperature = 21;
uint8_t swingV = MITSUBISHI_HEAVY_FDTC_VS_UP;
if (powerModeCmd == POWER_OFF)
{
powerMode = MITSUBISHI_HEAVY_FDTC_MODE_OFF;
}
switch (operatingModeCmd)
{
case MODE_AUTO:
operatingMode = MITSUBISHI_HEAVY_FDTC_MODE_AUTO;
break;
case MODE_HEAT:
operatingMode = MITSUBISHI_HEAVY_FDTC_MODE_HEAT;
break;
case MODE_COOL:
operatingMode = MITSUBISHI_HEAVY_FDTC_MODE_COOL;
break;
case MODE_DRY:
operatingMode = MITSUBISHI_HEAVY_FDTC_MODE_DRY;
break;
case MODE_FAN:
operatingMode = MITSUBISHI_HEAVY_FDTC_MODE_FAN;
break;
}
switch (fanSpeedCmd)
{
case FAN_1:
fanSpeed = MITSUBISHI_HEAVY_FDTC_FAN1;
break;
case FAN_2:
fanSpeed = MITSUBISHI_HEAVY_FDTC_FAN2;
break;
case FAN_3:
fanSpeed = MITSUBISHI_HEAVY_FDTC_FAN3;
break;
}
if ( temperatureCmd > 17 && temperatureCmd < 31)
{
temperature = (temperatureCmd - 16) & 0x0F;
}
switch (swingVCmd)
{
case VDIR_SWING:
swingV = MITSUBISHI_HEAVY_FDTC_VS_SWING;
break;
case VDIR_UP:
swingV = MITSUBISHI_HEAVY_FDTC_VS_UP;
break;
case VDIR_MUP:
swingV = MITSUBISHI_HEAVY_FDTC_VS_MUP;
break;
case VDIR_MIDDLE:
swingV = MITSUBISHI_HEAVY_FDTC_VS_MUP;
break;
case VDIR_MDOWN:
swingV = MITSUBISHI_HEAVY_FDTC_VS_MDOWN;
break;
case VDIR_DOWN:
swingV = MITSUBISHI_HEAVY_FDTC_VS_DOWN;
break;
}
sendMitsubishiHeavyFDTC(IR, powerMode, operatingMode, fanSpeed, temperature, swingV);
}
void MitsubishiHeavyFDTCHeatpumpIR::sendMitsubishiHeavyFDTC(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingV)
{
//uint8_t MitsubishiHeavyFDTCTemplate[] = { 0x0B, 0x00, 0x00, 0x40, 0xF4, 0xFF, 0xFF, 0xBF}; //first byte could be 0B
uint8_t MitsubishiHeavyFDTCTemplate[] = { 0x0A, 0x00, 0x00, 0x40, 0xF4, 0xFF, 0xFF, 0xBF};
// 0 1 2 3 4 5 6 7
// Vertical air flow + fan speed
MitsubishiHeavyFDTCTemplate[1] |= (swingV & 0b01000000) | fanSpeed;
// Power state + operating mode + temperature
MitsubishiHeavyFDTCTemplate[2] |= operatingMode | powerMode | temperature;
// Vertical air flow
MitsubishiHeavyFDTCTemplate[3] |= (swingV & 0b00110000);
// There is no checksum, but some bytes are inverted
MitsubishiHeavyFDTCTemplate[4] = ~MitsubishiHeavyFDTCTemplate[0];
MitsubishiHeavyFDTCTemplate[5] = ~MitsubishiHeavyFDTCTemplate[1];
MitsubishiHeavyFDTCTemplate[6] = ~MitsubishiHeavyFDTCTemplate[2];
MitsubishiHeavyFDTCTemplate[7] = ~MitsubishiHeavyFDTCTemplate[3];
// 38 kHz PWM frequency
IR.setFrequency(38);
// Header
IR.mark(MITSUBISHI_HEAVY_FDTC_HDR_MARK);
IR.space(MITSUBISHI_HEAVY_FDTC_HDR_SPACE);
// Data
for (uint8_t i=0; i<sizeof(MitsubishiHeavyFDTCTemplate); i++) {
IR.sendIRbyte(MitsubishiHeavyFDTCTemplate[i], MITSUBISHI_HEAVY_FDTC_BIT_MARK, MITSUBISHI_HEAVY_FDTC_ZERO_SPACE, MITSUBISHI_HEAVY_FDTC_ONE_SPACE);
}
// End mark
IR.mark(MITSUBISHI_HEAVY_FDTC_BIT_MARK);
IR.space(MITSUBISHI_HEAVY_FDTC_HDR_SPACE);
IR.mark(MITSUBISHI_HEAVY_FDTC_BIT_MARK);
IR.space(0);
}