IRremoteESP8266

ir_Trotec.h
Go to the documentation of this file.
1 // Copyright 2017 stufisher
2 // Copyright 2019 crankyoldgit
3
8
9 // Supports:
10 // Brand: Trotec, Model: PAC 3200 A/C (TROTEC)
11 // Brand: Trotec, Model: PAC 3550 Pro A/C (TROTEC_3550)
12 // Brand: Duux, Model: Blizzard Smart 10K / DXMA04 A/C (TROTEC)
13 // For Trotec Model PAC 3900 X, use the Midea protocol instead.
14
15 #ifndef IR_TROTEC_H_
16 #define IR_TROTEC_H_
17
18 #ifndef UNIT_TEST
19 #include <Arduino.h>
20 #endif
21 #include "IRremoteESP8266.h"
22 #include "IRsend.h"
23 #ifdef UNIT_TEST
24 #include "IRsend_test.h"
25 #endif
26
28 union TrotecProtocol{
29 uint8_t raw[kTrotecStateLength];
30 struct {
31 // Byte 0
32 uint8_t Intro1:8; // fixed value
33 // Byte 1
34 uint8_t Intro2:8; // fixed value
35 // Byte 2
36 uint8_t Mode :2;
37 uint8_t :1;
38 uint8_t Power :1;
39 uint8_t Fan :2;
40 uint8_t :2;
41 // Byte 3
42 uint8_t Temp :4;
43 uint8_t :3;
44 uint8_t Sleep :1;
45 // Byte 4
46 uint8_t :8;
47 // Byte 5
48 uint8_t :6;
49 uint8_t Timer :1;
50 uint8_t :1;
51 // Byte 6
52 uint8_t Hours :8;
53 // Byte 7
54 uint8_t :8;
55 // Byte 8
56 uint8_t Sum :8;
57 };
58 };
59
60 // Constants
61 const uint8_t kTrotecIntro1 = 0x12;
62 const uint8_t kTrotecIntro2 = 0x34;
63
64 const uint8_t kTrotecAuto = 0;
65 const uint8_t kTrotecCool = 1;
66 const uint8_t kTrotecDry = 2;
67 const uint8_t kTrotecFan = 3;
68
69 const uint8_t kTrotecFanLow = 1;
70 const uint8_t kTrotecFanMed = 2;
71 const uint8_t kTrotecFanHigh = 3;
72
73 const uint8_t kTrotecMinTemp = 18;
74 const uint8_t kTrotecDefTemp = 25;
75 const uint8_t kTrotecMaxTemp = 32;
76
77 const uint8_t kTrotecMaxTimer = 23;
78
80 union Trotec3550Protocol{
81 uint8_t raw[kTrotecStateLength];
82 struct {
83 // Byte 0
84 uint8_t Intro: 8; // fixed value (0x55)
85 // Byte 1
86 uint8_t SwingV :1;
87 uint8_t Power :1;
88 uint8_t :1; // Unknown
89 uint8_t TimerSet :1;
90 uint8_t TempC :4; // Temp + kTrotec3550MinTempC for degC)
91 // Byte 2
92 uint8_t TimerHrs :4;
93 uint8_t :4; // Unknown
94 // Byte 3
95 uint8_t TempF :5; // Temp + kTrotec3550MinTempF for degF)
96 uint8_t :3; // Unknown
97 // Byte 4
98 uint8_t :8; // Unknown
99 // Byte 5
100 uint8_t :8; // Unknown
101 // Byte 6
102 uint8_t Mode :2;
103 uint8_t :2; // Unknown
104 uint8_t Fan :2;
105 uint8_t :2; // Unknown
106 // Byte 7
107 uint8_t :7; // Unknown
108 uint8_t Celsius :1; // DegC or DegF
109 // Byte 8
110 uint8_t Sum :8;
111 };
112 };
113
114 const uint8_t kTrotec3550MinTempC = 16;
115 const uint8_t kTrotec3550MaxTempC = 30;
116 const uint8_t kTrotec3550MinTempF = 59;
117 const uint8_t kTrotec3550MaxTempF = 86;
118
119 // Legacy defines. (Deprecated)
120 #define TROTEC_AUTO kTrotecAuto
121 #define TROTEC_COOL kTrotecCool
122 #define TROTEC_DRY kTrotecDry
123 #define TROTEC_FAN kTrotecFan
124 #define TROTEC_FAN_LOW kTrotecFanLow
125 #define TROTEC_FAN_MED kTrotecFanMed
126 #define TROTEC_FAN_HIGH kTrotecFanHigh
127 #define TROTEC_MIN_TEMP kTrotecMinTemp
128 #define TROTEC_MAX_TEMP kTrotecMaxTemp
129 #define TROTEC_MAX_TIMER kTrotecMaxTimer
130
131 // Class
133 class IRTrotecESP {
134 public:
135 explicit IRTrotecESP(const uint16_t pin, const bool inverted = false,
136 const bool use_modulation = true);
137 #if SEND_TROTEC
138 void send(const uint16_t repeat = kTrotecDefaultRepeat);
143 int8_t calibrate(void) { return _irsend.calibrate(); }
144 #endif // SEND_TROTEC
145 void begin(void);
146 void stateReset(void);
147
148 void on(void);
149 void off(void);
150 void setPower(const bool state);
151 bool getPower(void) const;
152
153 void setTemp(const uint8_t celsius);
154 uint8_t getTemp(void) const;
155
156 void setSpeed(const uint8_t fan);
157 uint8_t getSpeed(void) const;
158
159 void setFan(const uint8_t fan) { setSpeed(fan); }
160 uint8_t getFan(void) const { return getSpeed(); }
161
162 uint8_t getMode(void) const;
163 void setMode(const uint8_t mode);
164
165 bool getSleep(void) const;
166 void setSleep(const bool on);
167
168 uint8_t getTimer(void) const;
169 void setTimer(const uint8_t timer);
170
171 uint8_t* getRaw(void);
172 void setRaw(const uint8_t state[]);
173 static bool validChecksum(const uint8_t state[],
174 const uint16_t length = kTrotecStateLength);
175 static uint8_t calcChecksum(const uint8_t state[],
176 const uint16_t length = kTrotecStateLength);
177 static uint8_t convertMode(const stdAc::opmode_t mode);
178 static uint8_t convertFan(const stdAc::fanspeed_t speed);
179 static stdAc::opmode_t toCommonMode(const uint8_t mode);
180 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
181 stdAc::state_t toCommon(void) const;
182 String toString(void) const;
183 #ifndef UNIT_TEST
184
185 private:
186 IRsend _irsend;
187 #else // UNIT_TEST
188 IRsendTest _irsend;
190 #endif // UNIT_TEST
192 TrotecProtocol _;
193 void checksum(void);
194 };
195
196 // Class
198 class IRTrotec3550 {
199 public:
200 explicit IRTrotec3550(const uint16_t pin, const bool inverted = false,
201 const bool use_modulation = true);
202 #if SEND_TROTEC_3550
203 void send(const uint16_t repeat = kTrotecDefaultRepeat);
208 int8_t calibrate(void) { return _irsend.calibrate(); }
209 #endif // SEND_TROTEC_3550
210 void begin(void);
211 void stateReset(void);
212 void on(void);
213 void off(void);
214 void setPower(const bool state);
215 bool getPower(void) const;
216 void setTemp(const uint8_t degrees, const bool celsius = true);
217 uint8_t getTemp(void) const;
218 void setTempUnit(const bool celsius);
219 bool getTempUnit(void) const;
220 void setFan(const uint8_t fan);
221 uint8_t getFan(void) const;
222 uint8_t getMode(void) const;
223 void setMode(const uint8_t mode);
224 bool getSwingV(void) const;
225 void setSwingV(const bool on);
226 uint16_t getTimer(void) const;
227 void setTimer(const uint16_t mins);
228 uint8_t* getRaw(void);
229 void setRaw(const uint8_t state[]);
230 static bool validChecksum(const uint8_t state[],
231 const uint16_t length = kTrotecStateLength);
232 static uint8_t calcChecksum(const uint8_t state[],
233 const uint16_t length = kTrotecStateLength);
234 static uint8_t convertMode(const stdAc::opmode_t mode);
235 static uint8_t convertFan(const stdAc::fanspeed_t speed);
236 static stdAc::opmode_t toCommonMode(const uint8_t mode);
237 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
238 stdAc::state_t toCommon(void) const;
239 String toString(void) const;
240 #ifndef UNIT_TEST
241
242 private:
243 IRsend _irsend;
244 #else // UNIT_TEST
245 IRsendTest _irsend;
247 #endif // UNIT_TEST
249 Trotec3550Protocol _;
250 void checksum(void);
251 };
252 #endif // IR_TROTEC_H_
IRTrotec3550::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Trotec.cpp:460
IRTrotec3550::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Trotec.cpp:518
IRTrotec3550::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kTrotecStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Trotec.cpp:432
Trotec3550Protocol::Power
uint8_t Power
Definition: ir_Trotec.h:87
IRTrotecESP::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Trotec.cpp:268
IRTrotecESP::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Trotec.cpp:105
IRTrotec3550::IRTrotec3550
IRTrotec3550(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Trotec.cpp:404
IRTrotecESP::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Trotec.cpp:174
IRTrotec3550::send
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Trotec.cpp:414
TrotecProtocol::Hours
uint8_t Hours
Definition: ir_Trotec.h:52
kTrotecDefaultRepeat
const uint16_t kTrotecDefaultRepeat
Definition: IRremoteESP8266.h:1414
Trotec3550Protocol::SwingV
uint8_t SwingV
Definition: ir_Trotec.h:86
IRTrotec3550::setFan
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Trotec.cpp:475
Trotec3550Protocol::Fan
uint8_t Fan
Definition: ir_Trotec.h:104
TrotecProtocol::Sleep
uint8_t Sleep
Definition: ir_Trotec.h:44
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
Trotec3550Protocol::TempC
uint8_t TempC
Definition: ir_Trotec.h:90
IRTrotec3550::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Trotec.cpp:492
Trotec3550Protocol::Intro
uint8_t Intro
Definition: ir_Trotec.h:84
IRTrotec3550::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Trotec.cpp:566
IRTrotec3550::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Trotec.cpp:486
IRTrotec3550::setSwingV
void setSwingV(const bool on)
Change the Vertical Swing setting.
Definition: ir_Trotec.cpp:533
IRTrotecESP::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Trotec.cpp:294
IRTrotec3550::setTimer
void setTimer(const uint16_t mins)
Set the number of minutes of the Timer setting.
Definition: ir_Trotec.cpp:545
IRTrotecESP::setFan
void setFan(const uint8_t fan)
Definition: ir_Trotec.h:159
IRTrotec3550::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Trotec.cpp:463
IRTrotecESP::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Trotec.cpp:77
TrotecProtocol::Intro1
uint8_t Intro1
Definition: ir_Trotec.h:32
kTrotecFanMed
const uint8_t kTrotecFanMed
Definition: ir_Trotec.h:70
Trotec3550Protocol::Sum
uint8_t Sum
Definition: ir_Trotec.h:110
IRTrotecESP::getTimer
uint8_t getTimer(void) const
Get the timer time in nr. of Hours.
Definition: ir_Trotec.cpp:213
IRsend.h
IRTrotecESP::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Trotec.cpp:124
kTrotecIntro2
const uint8_t kTrotecIntro2
Definition: ir_Trotec.h:62
TrotecProtocol::Power
uint8_t Power
Definition: ir_Trotec.h:38
IRTrotec3550::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Trotec.cpp:482
Trotec3550Protocol::Mode
uint8_t Mode
Definition: ir_Trotec.h:102
IRTrotec3550::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Trotec.cpp:448
Trotec3550Protocol
Native representation of a Trotec 3550 A/C message.
Definition: ir_Trotec.h:80
kTrotecFanHigh
const uint8_t kTrotecFanHigh
Definition: ir_Trotec.h:71
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRTrotec3550::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Trotec.cpp:440
IRTrotec3550::getTimer
uint16_t getTimer(void) const
Get the number of minutes of the Timer setting.
Definition: ir_Trotec.cpp:541
TrotecProtocol::Sum
uint8_t Sum
Definition: ir_Trotec.h:56
String
std::string String
Definition: IRremoteESP8266.h:1521
IRTrotecESP::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Trotec.cpp:149
IRTrotecESP::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kTrotecStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Trotec.cpp:100
kTrotecMinTemp
const uint8_t kTrotecMinTemp
Definition: ir_Trotec.h:73
kTrotecDefTemp
const uint8_t kTrotecDefTemp
Definition: ir_Trotec.h:74
IRTrotecESP::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Trotec.cpp:136
IRTrotec3550::getTempUnit
bool getTempUnit(void) const
Get the current temperature unit setting.
Definition: ir_Trotec.cpp:529
kTrotecMaxTimer
const uint8_t kTrotecMaxTimer
Definition: ir_Trotec.h:77
Trotec3550Protocol::Celsius
uint8_t Celsius
Definition: ir_Trotec.h:108
IRremoteESP8266.h
IRTrotecESP::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Trotec.cpp:200
IRTrotecESP::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Trotec.cpp:218
TrotecProtocol
Native representation of a Trotec A/C message.
Definition: ir_Trotec.h:28
kTrotecDry
const uint8_t kTrotecDry
Definition: ir_Trotec.h:66
Trotec3550Protocol::raw
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition: ir_Trotec.h:81
kTrotec3550MaxTempF
const uint8_t kTrotec3550MaxTempF
Definition: ir_Trotec.h:117
IRTrotecESP::setTemp
void setTemp(const uint8_t celsius)
Set the temperature.
Definition: ir_Trotec.cpp:180
IRTrotec3550::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Trotec.cpp:471
IRTrotecESP::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Trotec.cpp:168
kTrotecStateLength
const uint16_t kTrotecStateLength
Definition: IRremoteESP8266.h:1412
IRTrotec3550::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Trotec.cpp:580
TrotecProtocol::Temp
uint8_t Temp
Definition: ir_Trotec.h:42
kTrotecMaxTemp
const uint8_t kTrotecMaxTemp
Definition: ir_Trotec.h:75
kTrotecFanLow
const uint8_t kTrotecFanLow
Definition: ir_Trotec.h:69
Trotec3550Protocol::TempF
uint8_t TempF
Definition: ir_Trotec.h:95
TrotecProtocol::raw
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition: ir_Trotec.h:29
IRTrotec3550::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Trotec.cpp:437
kTrotec3550MaxTempC
const uint8_t kTrotec3550MaxTempC
Definition: ir_Trotec.h:115
IRTrotec3550::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Trotec.h:243
IRTrotecESP::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Trotec.cpp:110
IRTrotecESP::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Trotec.h:143
IRTrotec3550
Class for handling detailed Trotec 3550 A/C messages.
Definition: ir_Trotec.h:198
IRTrotecESP::setTimer
void setTimer(const uint8_t timer)
Set the timer time in nr. of Hours.
Definition: ir_Trotec.cpp:206
TrotecProtocol::Mode
uint8_t Mode
Definition: ir_Trotec.h:36
IRTrotecESP::getFan
uint8_t getFan(void) const
Definition: ir_Trotec.h:160
IRTrotecESP::setPower
void setPower(const bool state)
Change the power setting.
Definition: ir_Trotec.cpp:143
kTrotecFan
const uint8_t kTrotecFan
Definition: ir_Trotec.h:67
IRTrotec3550::setRaw
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition: ir_Trotec.cpp:455
IRTrotecESP::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Trotec.cpp:245
IRTrotecESP::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Trotec.h:186
kTrotecCool
const uint8_t kTrotecCool
Definition: ir_Trotec.h:65
IRTrotecESP::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Trotec.cpp:194
IRTrotecESP::getSpeed
uint8_t getSpeed(void) const
Get the current fan speed setting.
Definition: ir_Trotec.cpp:162
IRTrotecESP::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Trotec.cpp:139
Trotec3550Protocol::TimerSet
uint8_t TimerSet
Definition: ir_Trotec.h:89
TrotecProtocol::Intro2
uint8_t Intro2
Definition: ir_Trotec.h:34
IRTrotec3550::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Trotec.h:208
IRTrotecESP::_
TrotecProtocol _
Definition: ir_Trotec.h:192
IRTrotecESP::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kTrotecStateLength)
Calculate the checksum for a given state.
Definition: ir_Trotec.cpp:91
IRTrotecESP::send
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Trotec.cpp:82
TrotecProtocol::Fan
uint8_t Fan
Definition: ir_Trotec.h:39
IRTrotec3550::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Trotec.cpp:553
IRTrotec3550::setPower
void setPower(const bool state)
Change the power setting.
Definition: ir_Trotec.cpp:467
kTrotecAuto
const uint8_t kTrotecAuto
Definition: ir_Trotec.h:64
IRTrotec3550::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kTrotecStateLength)
Calculate the checksum for a given state.
Definition: ir_Trotec.cpp:423
IRTrotecESP::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Trotec.cpp:257
IRTrotecESP
Class for handling detailed Trotec A/C messages.
Definition: ir_Trotec.h:133
IRTrotec3550::_
Trotec3550Protocol _
Definition: ir_Trotec.h:249
Trotec3550Protocol::TimerHrs
uint8_t TimerHrs
Definition: ir_Trotec.h:92
IRTrotec3550::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Trotec.cpp:603
IRTrotec3550::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Trotec.cpp:629
IRTrotecESP::IRTrotecESP
IRTrotecESP(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Trotec.cpp:72
IRTrotec3550::setTemp
void setTemp(const uint8_t degrees, const bool celsius=true)
Set the temperature.
Definition: ir_Trotec.cpp:497
TrotecProtocol::Timer
uint8_t Timer
Definition: ir_Trotec.h:49
IRTrotecESP::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Trotec.cpp:231
kTrotec3550MinTempF
const uint8_t kTrotec3550MinTempF
Definition: ir_Trotec.h:116
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
IRTrotec3550::getSwingV
bool getSwingV(void) const
Get the value of the current Vertical Swing setting.
Definition: ir_Trotec.cpp:537
kTrotec3550MinTempC
const uint8_t kTrotec3550MinTempC
Definition: ir_Trotec.h:114
kTrotecIntro1
const uint8_t kTrotecIntro1
Definition: ir_Trotec.h:61
IRTrotecESP::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Trotec.cpp:188
IRTrotec3550::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Trotec.cpp:592
IRTrotecESP::setRaw
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition: ir_Trotec.cpp:131
IRTrotecESP::setSpeed
void setSpeed(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Trotec.cpp:155
IRTrotec3550::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Trotec.cpp:409
IRTrotec3550::setTempUnit
void setTempUnit(const bool celsius)
Set the temperature unit that the A/C will use..
Definition: ir_Trotec.cpp:525
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49