forked from ToniA/arduino-heatpumpir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BalluHeatpumpIR.cpp
102 lines (84 loc) · 2.44 KB
/
BalluHeatpumpIR.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
#include <BalluHeatpumpIR.h>
BalluHeatpumpIR::BalluHeatpumpIR()
{
static const char model[] PROGMEM = "ballu";
static const char info[] PROGMEM = "{\"mdl\":\"ballu\",\"dn\":\"Ballu\",\"mT\":16,\"xT\":30,\"fs\":3}";
_model = model;
_info = info;
}
void BalluHeatpumpIR::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 operatingMode = BALLU_AIRCON_MODE_COOL;
uint8_t fanSpeed = BALLU_AIRCON_FAN_AUTO;
uint8_t temperature = 21;
uint8_t powerMode = 00;
if (powerModeCmd == POWER_OFF)
{
powerMode = BALLU_AIRCON_MODE_OFF;
}
else
{
switch (operatingModeCmd)
{
case MODE_COOL:
operatingMode = BALLU_AIRCON_MODE_COOL;
break;
case MODE_DRY:
operatingMode = BALLU_AIRCON_MODE_DRY;
break;
case MODE_FAN:
operatingMode = BALLU_AIRCON_MODE_FAN;
//temperatureCmd = 30;
break;
case MODE_HEAT:
operatingMode = BALLU_AIRCON_MODE_HEAT;
break;
}
}
switch (fanSpeedCmd)
{
case FAN_AUTO:
fanSpeed = BALLU_AIRCON_FAN_AUTO;
break;
case FAN_1:
fanSpeed = BALLU_AIRCON_FAN1;
break;
case FAN_2:
fanSpeed = BALLU_AIRCON_FAN2;
break;
case FAN_3:
fanSpeed = BALLU_AIRCON_FAN3;
break;
}
if (temperatureCmd > 15 && temperatureCmd < 31)
{
temperature = temperatureCmd;
}
sendBallu(IR, powerMode, operatingMode, fanSpeed, temperature);
}
void BalluHeatpumpIR::sendBallu(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature)
{
uint8_t BalluTemplate[] = { 0x83, 0x06, 0x04, 0x42, 0x00, 0x00 };
// 0 1 2 3 4 5
BalluTemplate[2] = fanSpeed;
BalluTemplate[3] =(temperature - 16) << 4;
BalluTemplate[3] |= operatingMode;
if (powerMode==BALLU_AIRCON_MODE_OFF) //83,06,04,72,00,00
{
BalluTemplate[2] = powerMode;
//BalluTemplate[3] = 0x72;
}
// 38 kHz PWM frequency
IR.setFrequency(38);
// Header
IR.mark(BALLU_AIRCON_HDR_MARK);
IR.space(BALLU_AIRCON_HDR_SPACE);
// Data
for (uint8_t i=0; i<sizeof(BalluTemplate); i++) {
IR.sendIRbyte(BalluTemplate[i], BALLU_AIRCON_BIT_MARK, BALLU_AIRCON_ZERO_SPACE, BALLU_AIRCON_ONE_SPACE);
}
// End mark
IR.mark(BALLU_AIRCON_BIT_MARK);
IR.space(0);
}