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 
14 #ifndef IR_TROTEC_H_
15 #define IR_TROTEC_H_
16 
17 #ifndef UNIT_TEST
18 #include <Arduino.h>
19 #endif
20 #include "IRremoteESP8266.h"
21 #include "IRsend.h"
22 #ifdef UNIT_TEST
23 #include "IRsend_test.h"
24 #endif
25 
29  struct {
30  // Byte 0
31  uint8_t Intro1:8; // fixed value
32  // Byte 1
33  uint8_t Intro2:8; // fixed value
34  // Byte 2
35  uint8_t Mode :2;
36  uint8_t :1;
37  uint8_t Power :1;
38  uint8_t Fan :2;
39  uint8_t :2;
40  // Byte 3
41  uint8_t Temp :4;
42  uint8_t :3;
43  uint8_t Sleep :1;
44  // Byte 4
45  uint8_t :8;
46  // Byte 5
47  uint8_t :6;
48  uint8_t Timer :1;
49  uint8_t :1;
50  // Byte 6
51  uint8_t Hours :8;
52  // Byte 7
53  uint8_t :8;
54  // Byte 8
55  uint8_t Sum :8;
56  };
57 };
58 
59 // Constants
60 const uint8_t kTrotecIntro1 = 0x12;
61 const uint8_t kTrotecIntro2 = 0x34;
62 
63 const uint8_t kTrotecAuto = 0;
64 const uint8_t kTrotecCool = 1;
65 const uint8_t kTrotecDry = 2;
66 const uint8_t kTrotecFan = 3;
67 
68 const uint8_t kTrotecFanLow = 1;
69 const uint8_t kTrotecFanMed = 2;
70 const uint8_t kTrotecFanHigh = 3;
71 
72 const uint8_t kTrotecMinTemp = 18;
73 const uint8_t kTrotecDefTemp = 25;
74 const uint8_t kTrotecMaxTemp = 32;
75 
76 const uint8_t kTrotecMaxTimer = 23;
77 
81  struct {
82  // Byte 0
83  uint8_t Intro: 8; // fixed value (0x55)
84  // Byte 1
85  uint8_t SwingV :1;
86  uint8_t Power :1;
87  uint8_t :1; // Unknown
88  uint8_t TimerSet :1;
89  uint8_t TempC :4; // Temp + kTrotec3550MinTempC for degC)
90  // Byte 2
91  uint8_t TimerHrs :4;
92  uint8_t :4; // Unknown
93  // Byte 3
94  uint8_t TempF :5; // Temp + kTrotec3550MinTempF for degF)
95  uint8_t :3; // Unknown
96  // Byte 4
97  uint8_t :8; // Unknown
98  // Byte 5
99  uint8_t :8; // Unknown
100  // Byte 6
101  uint8_t Mode :2;
102  uint8_t :2; // Unknown
103  uint8_t Fan :2;
104  uint8_t :2; // Unknown
105  // Byte 7
106  uint8_t :7; // Unknown
107  uint8_t Celsius :1; // DegC or DegF
108  // Byte 8
109  uint8_t Sum :8;
110  };
111 };
112 
113 const uint8_t kTrotec3550MinTempC = 16;
114 const uint8_t kTrotec3550MaxTempC = 30;
115 const uint8_t kTrotec3550MinTempF = 59;
116 const uint8_t kTrotec3550MaxTempF = 86;
117 
118 // Legacy defines. (Deprecated)
119 #define TROTEC_AUTO kTrotecAuto
120 #define TROTEC_COOL kTrotecCool
121 #define TROTEC_DRY kTrotecDry
122 #define TROTEC_FAN kTrotecFan
123 #define TROTEC_FAN_LOW kTrotecFanLow
124 #define TROTEC_FAN_MED kTrotecFanMed
125 #define TROTEC_FAN_HIGH kTrotecFanHigh
126 #define TROTEC_MIN_TEMP kTrotecMinTemp
127 #define TROTEC_MAX_TEMP kTrotecMaxTemp
128 #define TROTEC_MAX_TIMER kTrotecMaxTimer
129 
130 // Class
132 class IRTrotecESP {
133  public:
134  explicit IRTrotecESP(const uint16_t pin, const bool inverted = false,
135  const bool use_modulation = true);
136 #if SEND_TROTEC
137  void send(const uint16_t repeat = kTrotecDefaultRepeat);
142  int8_t calibrate(void) { return _irsend.calibrate(); }
143 #endif // SEND_TROTEC
144  void begin(void);
145  void stateReset(void);
146 
147  void on(void);
148  void off(void);
149  void setPower(const bool state);
150  bool getPower(void) const;
151 
152  void setTemp(const uint8_t celsius);
153  uint8_t getTemp(void) const;
154 
155  void setSpeed(const uint8_t fan);
156  uint8_t getSpeed(void) const;
157 
158  void setFan(const uint8_t fan) { setSpeed(fan); }
159  uint8_t getFan(void) const { return getSpeed(); }
160 
161  uint8_t getMode(void) const;
162  void setMode(const uint8_t mode);
163 
164  bool getSleep(void) const;
165  void setSleep(const bool on);
166 
167  uint8_t getTimer(void) const;
168  void setTimer(const uint8_t timer);
169 
170  uint8_t* getRaw(void);
171  void setRaw(const uint8_t state[]);
172  static bool validChecksum(const uint8_t state[],
173  const uint16_t length = kTrotecStateLength);
174  static uint8_t calcChecksum(const uint8_t state[],
175  const uint16_t length = kTrotecStateLength);
176  static uint8_t convertMode(const stdAc::opmode_t mode);
177  static uint8_t convertFan(const stdAc::fanspeed_t speed);
178  static stdAc::opmode_t toCommonMode(const uint8_t mode);
179  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
180  stdAc::state_t toCommon(void) const;
181  String toString(void) const;
182 #ifndef UNIT_TEST
183 
184  private:
186 #else // UNIT_TEST
187  IRsendTest _irsend;
189 #endif // UNIT_TEST
192  void checksum(void);
193 };
194 
195 // Class
198  public:
199  explicit IRTrotec3550(const uint16_t pin, const bool inverted = false,
200  const bool use_modulation = true);
201 #if SEND_TROTEC_3550
202  void send(const uint16_t repeat = kTrotecDefaultRepeat);
207  int8_t calibrate(void) { return _irsend.calibrate(); }
208 #endif // SEND_TROTEC_3550
209  void begin(void);
210  void stateReset(void);
211  void on(void);
212  void off(void);
213  void setPower(const bool state);
214  bool getPower(void) const;
215  void setTemp(const uint8_t degrees, const bool celsius = true);
216  uint8_t getTemp(void) const;
217  void setTempUnit(const bool celsius);
218  bool getTempUnit(void) const;
219  void setFan(const uint8_t fan);
220  uint8_t getFan(void) const;
221  uint8_t getMode(void) const;
222  void setMode(const uint8_t mode);
223  bool getSwingV(void) const;
224  void setSwingV(const bool on);
225  uint16_t getTimer(void) const;
226  void setTimer(const uint16_t mins);
227  uint8_t* getRaw(void);
228  void setRaw(const uint8_t state[]);
229  static bool validChecksum(const uint8_t state[],
230  const uint16_t length = kTrotecStateLength);
231  static uint8_t calcChecksum(const uint8_t state[],
232  const uint16_t length = kTrotecStateLength);
233  static uint8_t convertMode(const stdAc::opmode_t mode);
234  static uint8_t convertFan(const stdAc::fanspeed_t speed);
235  static stdAc::opmode_t toCommonMode(const uint8_t mode);
236  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
237  stdAc::state_t toCommon(void) const;
238  String toString(void) const;
239 #ifndef UNIT_TEST
240 
241  private:
243 #else // UNIT_TEST
244  IRsendTest _irsend;
246 #endif // UNIT_TEST
249  void checksum(void);
250 };
251 #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:86
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:51
kTrotecDefaultRepeat
const uint16_t kTrotecDefaultRepeat
Definition: IRremoteESP8266.h:1182
Trotec3550Protocol::SwingV
uint8_t SwingV
Definition: ir_Trotec.h:85
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:103
TrotecProtocol::Sleep
uint8_t Sleep
Definition: ir_Trotec.h:43
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
Trotec3550Protocol::TempC
uint8_t TempC
Definition: ir_Trotec.h:89
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:83
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:158
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:31
kTrotecFanMed
const uint8_t kTrotecFanMed
Definition: ir_Trotec.h:69
Trotec3550Protocol::Sum
uint8_t Sum
Definition: ir_Trotec.h:109
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:61
TrotecProtocol::Power
uint8_t Power
Definition: ir_Trotec.h:37
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:101
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:79
kTrotecFanHigh
const uint8_t kTrotecFanHigh
Definition: ir_Trotec.h:70
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:190
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:55
String
std::string String
Definition: IRremoteESP8266.h:1279
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:72
kTrotecDefTemp
const uint8_t kTrotecDefTemp
Definition: ir_Trotec.h:73
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:76
Trotec3550Protocol::Celsius
uint8_t Celsius
Definition: ir_Trotec.h:107
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:27
kTrotecDry
const uint8_t kTrotecDry
Definition: ir_Trotec.h:65
Trotec3550Protocol::raw
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition: ir_Trotec.h:80
kTrotec3550MaxTempF
const uint8_t kTrotec3550MaxTempF
Definition: ir_Trotec.h:116
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:1180
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:41
kTrotecMaxTemp
const uint8_t kTrotecMaxTemp
Definition: ir_Trotec.h:74
kTrotecFanLow
const uint8_t kTrotecFanLow
Definition: ir_Trotec.h:68
Trotec3550Protocol::TempF
uint8_t TempF
Definition: ir_Trotec.h:94
TrotecProtocol::raw
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition: ir_Trotec.h:28
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:114
IRTrotec3550::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Trotec.h:242
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:142
IRTrotec3550
Class for handling detailed Trotec 3550 A/C messages.
Definition: ir_Trotec.h:197
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:35
IRTrotecESP::getFan
uint8_t getFan(void) const
Definition: ir_Trotec.h:159
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:66
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:185
kTrotecCool
const uint8_t kTrotecCool
Definition: ir_Trotec.h:64
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:88
TrotecProtocol::Intro2
uint8_t Intro2
Definition: ir_Trotec.h:33
IRTrotec3550::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Trotec.h:207
IRTrotecESP::_
TrotecProtocol _
Definition: ir_Trotec.h:191
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:38
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:63
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:132
IRTrotec3550::_
Trotec3550Protocol _
Definition: ir_Trotec.h:248
Trotec3550Protocol::TimerHrs
uint8_t TimerHrs
Definition: ir_Trotec.h:91
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:48
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:115
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
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:113
kTrotecIntro1
const uint8_t kTrotecIntro1
Definition: ir_Trotec.h:60
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:46