IRremoteIDF
Infrared send & receive for ESP-IDF
Loading...
Searching...
No Matches
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#include "IRplatform.h"
19#include "IRremoteESP8266.h"
20#include "IRsend.h"
21#ifdef UNIT_TEST
22#include "IRsend_test.h"
23#endif
24
28 struct {
29 // Byte 0
30 uint8_t Intro1:8; // fixed value
31 // Byte 1
32 uint8_t Intro2:8; // fixed value
33 // Byte 2
34 uint8_t Mode :2;
35 uint8_t :1;
36 uint8_t Power :1;
37 uint8_t Fan :2;
38 uint8_t :2;
39 // Byte 3
40 uint8_t Temp :4;
41 uint8_t :3;
42 uint8_t Sleep :1;
43 // Byte 4
44 uint8_t :8;
45 // Byte 5
46 uint8_t :6;
47 uint8_t Timer :1;
48 uint8_t :1;
49 // Byte 6
50 uint8_t Hours :8;
51 // Byte 7
52 uint8_t :8;
53 // Byte 8
54 uint8_t Sum :8;
55 };
56};
57
58// Constants
59const uint8_t kTrotecIntro1 = 0x12;
60const uint8_t kTrotecIntro2 = 0x34;
61
62const uint8_t kTrotecAuto = 0;
63const uint8_t kTrotecCool = 1;
64const uint8_t kTrotecDry = 2;
65const uint8_t kTrotecFan = 3;
66
67const uint8_t kTrotecFanLow = 1;
68const uint8_t kTrotecFanMed = 2;
69const uint8_t kTrotecFanHigh = 3;
70
71const uint8_t kTrotecMinTemp = 18;
72const uint8_t kTrotecDefTemp = 25;
73const uint8_t kTrotecMaxTemp = 32;
74
75const uint8_t kTrotecMaxTimer = 23;
76
80 struct {
81 // Byte 0
82 uint8_t Intro: 8; // fixed value (0x55)
83 // Byte 1
84 uint8_t SwingV :1;
85 uint8_t Power :1;
86 uint8_t :1; // Unknown
87 uint8_t TimerSet :1;
88 uint8_t TempC :4; // Temp + kTrotec3550MinTempC for degC)
89 // Byte 2
90 uint8_t TimerHrs :4;
91 uint8_t :4; // Unknown
92 // Byte 3
93 uint8_t TempF :5; // Temp + kTrotec3550MinTempF for degF)
94 uint8_t :3; // Unknown
95 // Byte 4
96 uint8_t :8; // Unknown
97 // Byte 5
98 uint8_t :8; // Unknown
99 // Byte 6
100 uint8_t Mode :2;
101 uint8_t :2; // Unknown
102 uint8_t Fan :2;
103 uint8_t :2; // Unknown
104 // Byte 7
105 uint8_t :7; // Unknown
106 uint8_t Celsius :1; // DegC or DegF
107 // Byte 8
108 uint8_t Sum :8;
109 };
110};
111
112const uint8_t kTrotec3550MinTempC = 16;
113const uint8_t kTrotec3550MaxTempC = 30;
114const uint8_t kTrotec3550MinTempF = 59;
115const uint8_t kTrotec3550MaxTempF = 86;
116
117// Legacy defines. (Deprecated)
118#define TROTEC_AUTO kTrotecAuto
119#define TROTEC_COOL kTrotecCool
120#define TROTEC_DRY kTrotecDry
121#define TROTEC_FAN kTrotecFan
122#define TROTEC_FAN_LOW kTrotecFanLow
123#define TROTEC_FAN_MED kTrotecFanMed
124#define TROTEC_FAN_HIGH kTrotecFanHigh
125#define TROTEC_MIN_TEMP kTrotecMinTemp
126#define TROTEC_MAX_TEMP kTrotecMaxTemp
127#define TROTEC_MAX_TIMER kTrotecMaxTimer
128
129// Class
132 public:
133 explicit IRTrotecESP(const uint16_t pin, const bool inverted = false,
134 const bool use_modulation = true);
135#if SEND_TROTEC
136 void send(const uint16_t repeat = kTrotecDefaultRepeat);
141 int8_t calibrate(void) { return _irsend.calibrate(); }
142#endif // SEND_TROTEC
143 void begin(void);
144 void stateReset(void);
145
146 void on(void);
147 void off(void);
148 void setPower(const bool state);
149 bool getPower(void) const;
150
151 void setTemp(const uint8_t celsius);
152 uint8_t getTemp(void) const;
153
154 void setSpeed(const uint8_t fan);
155 uint8_t getSpeed(void) const;
156
157 void setFan(const uint8_t fan) { setSpeed(fan); }
158 uint8_t getFan(void) const { return getSpeed(); }
159
160 uint8_t getMode(void) const;
161 void setMode(const uint8_t mode);
162
163 bool getSleep(void) const;
164 void setSleep(const bool on);
165
166 uint8_t getTimer(void) const;
167 void setTimer(const uint8_t timer);
168
169 uint8_t* getRaw(void);
170 void setRaw(const uint8_t state[]);
171 static bool validChecksum(const uint8_t state[],
172 const uint16_t length = kTrotecStateLength);
173 static uint8_t calcChecksum(const uint8_t state[],
174 const uint16_t length = kTrotecStateLength);
175 static uint8_t convertMode(const stdAc::opmode_t mode);
176 static uint8_t convertFan(const stdAc::fanspeed_t speed);
177 static stdAc::opmode_t toCommonMode(const uint8_t mode);
178 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
179 stdAc::state_t toCommon(void) const;
180 String toString(void) const;
181#ifndef UNIT_TEST
182
183 private:
185#else // UNIT_TEST
187 IRsendTest _irsend;
189#endif // UNIT_TEST
191 void checksum(void);
192};
193
194// Class
197 public:
198 explicit IRTrotec3550(const uint16_t pin, const bool inverted = false,
199 const bool use_modulation = true);
200#if SEND_TROTEC_3550
201 void send(const uint16_t repeat = kTrotecDefaultRepeat);
206 int8_t calibrate(void) { return _irsend.calibrate(); }
207#endif // SEND_TROTEC_3550
208 void begin(void);
209 void stateReset(void);
210 void on(void);
211 void off(void);
212 void setPower(const bool state);
213 bool getPower(void) const;
214 void setTemp(const uint8_t degrees, const bool celsius = true);
215 uint8_t getTemp(void) const;
216 void setTempUnit(const bool celsius);
217 bool getTempUnit(void) const;
218 void setFan(const uint8_t fan);
219 uint8_t getFan(void) const;
220 uint8_t getMode(void) const;
221 void setMode(const uint8_t mode);
222 bool getSwingV(void) const;
223 void setSwingV(const bool on);
224 uint16_t getTimer(void) const;
225 void setTimer(const uint16_t mins);
226 uint8_t* getRaw(void);
227 void setRaw(const uint8_t state[]);
228 static bool validChecksum(const uint8_t state[],
229 const uint16_t length = kTrotecStateLength);
230 static uint8_t calcChecksum(const uint8_t state[],
231 const uint16_t length = kTrotecStateLength);
232 static uint8_t convertMode(const stdAc::opmode_t mode);
233 static uint8_t convertFan(const stdAc::fanspeed_t speed);
234 static stdAc::opmode_t toCommonMode(const uint8_t mode);
235 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
236 stdAc::state_t toCommon(void) const;
237 String toString(void) const;
238#ifndef UNIT_TEST
239
240 private:
242#else // UNIT_TEST
244 IRsendTest _irsend;
246#endif // UNIT_TEST
248 void checksum(void);
249};
250#endif // IR_TROTEC_H_
std::string String
The protocol code builds human readable output with String. On ESP-IDF that is just std::string.
Definition IRplatform.h:21
const uint16_t kTrotecDefaultRepeat
Definition IRremoteESP8266.h:1443
const uint16_t kTrotecStateLength
Definition IRremoteESP8266.h:1441
Class for handling detailed Trotec 3550 A/C messages.
Definition ir_Trotec.h:196
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Trotec.cpp:551
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Trotec.cpp:480
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Trotec.cpp:484
void off(void)
Set the requested power state of the A/C to off.
Definition ir_Trotec.cpp:461
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition ir_Trotec.cpp:473
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition ir_Trotec.cpp:438
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Trotec.cpp:627
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Trotec.cpp:590
bool getTempUnit(void) const
Get the current temperature unit setting.
Definition ir_Trotec.cpp:527
Trotec3550Protocol _
Definition ir_Trotec.h:247
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Trotec.cpp:601
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition ir_Trotec.cpp:453
IRsend _irsend
Instance of the IR send class.
Definition ir_Trotec.h:241
void setTemp(const uint8_t degrees, const bool celsius=true)
Set the temperature.
Definition ir_Trotec.cpp:495
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Trotec.cpp:578
void on(void)
Set the requested power state of the A/C to on.
Definition ir_Trotec.cpp:458
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Trotec.cpp:516
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Trotec.cpp:490
void setSwingV(const bool on)
Change the Vertical Swing setting.
Definition ir_Trotec.cpp:531
bool getSwingV(void) const
Get the value of the current Vertical Swing setting.
Definition ir_Trotec.cpp:535
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition ir_Trotec.cpp:435
uint16_t getTimer(void) const
Get the number of minutes of the Timer setting.
Definition ir_Trotec.cpp:539
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Trotec.h:206
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Trotec.cpp:469
void setPower(const bool state)
Change the power setting.
Definition ir_Trotec.cpp:465
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Trotec.cpp:412
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Trotec.cpp:407
void setTempUnit(const bool celsius)
Set the temperature unit that the A/C will use..
Definition ir_Trotec.cpp:523
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:430
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Trotec.cpp:446
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Trotec.cpp:564
void setTimer(const uint16_t mins)
Set the number of minutes of the Timer setting.
Definition ir_Trotec.cpp:543
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kTrotecStateLength)
Calculate the checksum for a given state.
Definition ir_Trotec.cpp:421
Class for handling detailed Trotec A/C messages.
Definition ir_Trotec.h:131
void setFan(const uint8_t fan)
Definition ir_Trotec.h:157
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Trotec.cpp:75
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Trotec.cpp:292
void setPower(const bool state)
Change the power setting.
Definition ir_Trotec.cpp:141
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Trotec.cpp:216
IRsend _irsend
Instance of the IR send class.
Definition ir_Trotec.h:184
void setSpeed(const uint8_t fan)
Set the speed of the fan.
Definition ir_Trotec.cpp:153
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Trotec.cpp:243
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Trotec.cpp:186
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Trotec.cpp:147
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Trotec.cpp:122
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition ir_Trotec.cpp:192
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Trotec.cpp:255
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition ir_Trotec.cpp:129
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Trotec.h:141
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Trotec.cpp:166
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition ir_Trotec.cpp:103
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition ir_Trotec.cpp:198
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Trotec.cpp:172
uint8_t getTimer(void) const
Get the timer time in nr. of Hours.
Definition ir_Trotec.cpp:211
void on(void)
Set the requested power state of the A/C to on.
Definition ir_Trotec.cpp:134
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition ir_Trotec.cpp:108
void off(void)
Set the requested power state of the A/C to off.
Definition ir_Trotec.cpp:137
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Trotec.cpp:229
void setTimer(const uint8_t timer)
Set the timer time in nr. of Hours.
Definition ir_Trotec.cpp:204
TrotecProtocol _
Definition ir_Trotec.h:190
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kTrotecStateLength)
Calculate the checksum for a given state.
Definition ir_Trotec.cpp:89
void setTemp(const uint8_t celsius)
Set the temperature.
Definition ir_Trotec.cpp:178
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Trotec.cpp:80
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:98
uint8_t getSpeed(void) const
Get the current fan speed setting.
Definition ir_Trotec.cpp:160
uint8_t getFan(void) const
Definition ir_Trotec.h:158
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Trotec.cpp:266
Class for sending all basic IR protocols.
Definition IRsend.h:256
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:286
const uint8_t kTrotecMinTemp
Definition ir_Trotec.h:71
const uint8_t kTrotecAuto
Definition ir_Trotec.h:62
const uint8_t kTrotecMaxTimer
Definition ir_Trotec.h:75
const uint8_t kTrotecFan
Definition ir_Trotec.h:65
const uint8_t kTrotecFanLow
Definition ir_Trotec.h:67
const uint8_t kTrotecIntro1
Definition ir_Trotec.h:59
const uint8_t kTrotec3550MinTempF
Definition ir_Trotec.h:114
const uint8_t kTrotecFanMed
Definition ir_Trotec.h:68
const uint8_t kTrotecDry
Definition ir_Trotec.h:64
const uint8_t kTrotecMaxTemp
Definition ir_Trotec.h:73
const uint8_t kTrotecDefTemp
Definition ir_Trotec.h:72
const uint8_t kTrotec3550MaxTempC
Definition ir_Trotec.h:113
const uint8_t kTrotecIntro2
Definition ir_Trotec.h:60
const uint8_t kTrotec3550MaxTempF
Definition ir_Trotec.h:115
const uint8_t kTrotec3550MinTempC
Definition ir_Trotec.h:112
const uint8_t kTrotecCool
Definition ir_Trotec.h:63
const uint8_t kTrotecFanHigh
Definition ir_Trotec.h:69
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:67
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:55
Structure to hold a common A/C state.
Definition IRsend.h:120
Native representation of a Trotec 3550 A/C message.
Definition ir_Trotec.h:78
uint8_t TempC
Definition ir_Trotec.h:88
uint8_t TimerSet
Definition ir_Trotec.h:87
uint8_t Mode
Definition ir_Trotec.h:100
uint8_t TimerHrs
Definition ir_Trotec.h:90
uint8_t Power
Definition ir_Trotec.h:85
uint8_t Fan
Definition ir_Trotec.h:102
uint8_t TempF
Definition ir_Trotec.h:93
uint8_t Celsius
Definition ir_Trotec.h:106
uint8_t SwingV
Definition ir_Trotec.h:84
uint8_t Sum
Definition ir_Trotec.h:108
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition ir_Trotec.h:79
uint8_t Intro
Definition ir_Trotec.h:82
Native representation of a Trotec A/C message.
Definition ir_Trotec.h:26
uint8_t Timer
Definition ir_Trotec.h:47
uint8_t Intro2
Definition ir_Trotec.h:32
uint8_t Sum
Definition ir_Trotec.h:54
uint8_t Sleep
Definition ir_Trotec.h:42
uint8_t Temp
Definition ir_Trotec.h:40
uint8_t Power
Definition ir_Trotec.h:36
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition ir_Trotec.h:27
uint8_t Fan
Definition ir_Trotec.h:37
uint8_t Hours
Definition ir_Trotec.h:50
uint8_t Mode
Definition ir_Trotec.h:34
uint8_t Intro1
Definition ir_Trotec.h:30