IRremoteESP8266
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#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
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
61const uint8_t kTrotecIntro1 = 0x12;
62const uint8_t kTrotecIntro2 = 0x34;
63
64const uint8_t kTrotecAuto = 0;
65const uint8_t kTrotecCool = 1;
66const uint8_t kTrotecDry = 2;
67const uint8_t kTrotecFan = 3;
68
69const uint8_t kTrotecFanLow = 1;
70const uint8_t kTrotecFanMed = 2;
71const uint8_t kTrotecFanHigh = 3;
72
73const uint8_t kTrotecMinTemp = 18;
74const uint8_t kTrotecDefTemp = 25;
75const uint8_t kTrotecMaxTemp = 32;
76
77const uint8_t kTrotecMaxTimer = 23;
78
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
114const uint8_t kTrotec3550MinTempC = 16;
115const uint8_t kTrotec3550MaxTempC = 30;
116const uint8_t kTrotec3550MinTempF = 59;
117const 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
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:
187#else // UNIT_TEST
189 IRsendTest _irsend;
191#endif // UNIT_TEST
193 void checksum(void);
194};
195
196// Class
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:
244#else // UNIT_TEST
246 IRsendTest _irsend;
248#endif // UNIT_TEST
250 void checksum(void);
251};
252#endif // IR_TROTEC_H_
const uint16_t kTrotecDefaultRepeat
Definition IRremoteESP8266.h:1444
const uint16_t kTrotecStateLength
Definition IRremoteESP8266.h:1442
std::string String
Definition IRremoteESP8266.h:1564
Class for handling detailed Trotec 3550 A/C messages.
Definition ir_Trotec.h:198
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Trotec.cpp:553
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Trotec.cpp:482
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Trotec.cpp:486
void off(void)
Set the requested power state of the A/C to off.
Definition ir_Trotec.cpp:463
void setFan(const uint8_t fan)
Set the speed of the fan.
Definition ir_Trotec.cpp:475
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition ir_Trotec.cpp:440
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Trotec.cpp:629
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Trotec.cpp:592
bool getTempUnit(void) const
Get the current temperature unit setting.
Definition ir_Trotec.cpp:529
Trotec3550Protocol _
Definition ir_Trotec.h:249
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Trotec.cpp:603
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition ir_Trotec.cpp:455
IRsend _irsend
Instance of the IR send class.
Definition ir_Trotec.h:243
void setTemp(const uint8_t degrees, const bool celsius=true)
Set the temperature.
Definition ir_Trotec.cpp:497
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Trotec.cpp:580
void on(void)
Set the requested power state of the A/C to on.
Definition ir_Trotec.cpp:460
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Trotec.cpp:518
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Trotec.cpp:492
void setSwingV(const bool on)
Change the Vertical Swing setting.
Definition ir_Trotec.cpp:533
bool getSwingV(void) const
Get the value of the current Vertical Swing setting.
Definition ir_Trotec.cpp:537
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition ir_Trotec.cpp:437
uint16_t getTimer(void) const
Get the number of minutes of the Timer setting.
Definition ir_Trotec.cpp:541
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Trotec.h:208
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Trotec.cpp:471
void setPower(const bool state)
Change the power setting.
Definition ir_Trotec.cpp:467
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Trotec.cpp:414
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Trotec.cpp:409
void setTempUnit(const bool celsius)
Set the temperature unit that the A/C will use..
Definition ir_Trotec.cpp:525
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
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Trotec.cpp:448
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
void setTimer(const uint16_t mins)
Set the number of minutes of the Timer setting.
Definition ir_Trotec.cpp:545
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
Class for handling detailed Trotec A/C messages.
Definition ir_Trotec.h:133
void setFan(const uint8_t fan)
Definition ir_Trotec.h:159
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Trotec.cpp:77
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Trotec.cpp:294
void setPower(const bool state)
Change the power setting.
Definition ir_Trotec.cpp:143
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Trotec.cpp:218
IRsend _irsend
Instance of the IR send class.
Definition ir_Trotec.h:186
void setSpeed(const uint8_t fan)
Set the speed of the fan.
Definition ir_Trotec.cpp:155
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Trotec.cpp:245
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Trotec.cpp:188
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Trotec.cpp:149
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Trotec.cpp:124
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition ir_Trotec.cpp:194
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Trotec.cpp:257
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition ir_Trotec.cpp:131
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Trotec.h:143
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Trotec.cpp:168
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition ir_Trotec.cpp:105
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition ir_Trotec.cpp:200
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Trotec.cpp:174
uint8_t getTimer(void) const
Get the timer time in nr. of Hours.
Definition ir_Trotec.cpp:213
void on(void)
Set the requested power state of the A/C to on.
Definition ir_Trotec.cpp:136
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition ir_Trotec.cpp:110
void off(void)
Set the requested power state of the A/C to off.
Definition ir_Trotec.cpp:139
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
void setTimer(const uint8_t timer)
Set the timer time in nr. of Hours.
Definition ir_Trotec.cpp:206
TrotecProtocol _
Definition ir_Trotec.h:192
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
void setTemp(const uint8_t celsius)
Set the temperature.
Definition ir_Trotec.cpp:180
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Trotec.cpp:82
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
uint8_t getSpeed(void) const
Get the current fan speed setting.
Definition ir_Trotec.cpp:162
uint8_t getFan(void) const
Definition ir_Trotec.h:160
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Trotec.cpp:268
Class for sending all basic IR protocols.
Definition IRsend.h:249
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:209
const uint8_t kTrotecMinTemp
Definition ir_Trotec.h:73
const uint8_t kTrotecAuto
Definition ir_Trotec.h:64
const uint8_t kTrotecMaxTimer
Definition ir_Trotec.h:77
const uint8_t kTrotecFan
Definition ir_Trotec.h:67
const uint8_t kTrotecFanLow
Definition ir_Trotec.h:69
const uint8_t kTrotecIntro1
Definition ir_Trotec.h:61
const uint8_t kTrotec3550MinTempF
Definition ir_Trotec.h:116
const uint8_t kTrotecFanMed
Definition ir_Trotec.h:70
const uint8_t kTrotecDry
Definition ir_Trotec.h:66
const uint8_t kTrotecMaxTemp
Definition ir_Trotec.h:75
const uint8_t kTrotecDefTemp
Definition ir_Trotec.h:74
const uint8_t kTrotec3550MaxTempC
Definition ir_Trotec.h:115
const uint8_t kTrotecIntro2
Definition ir_Trotec.h:62
const uint8_t kTrotec3550MaxTempF
Definition ir_Trotec.h:117
const uint8_t kTrotec3550MinTempC
Definition ir_Trotec.h:114
const uint8_t kTrotecCool
Definition ir_Trotec.h:65
const uint8_t kTrotecFanHigh
Definition ir_Trotec.h:71
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:61
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:49
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Trotec 3550 A/C message.
Definition ir_Trotec.h:80
uint8_t TempC
Definition ir_Trotec.h:90
uint8_t TimerSet
Definition ir_Trotec.h:89
uint8_t Mode
Definition ir_Trotec.h:102
uint8_t TimerHrs
Definition ir_Trotec.h:92
uint8_t Power
Definition ir_Trotec.h:87
uint8_t Fan
Definition ir_Trotec.h:104
uint8_t TempF
Definition ir_Trotec.h:95
uint8_t Celsius
Definition ir_Trotec.h:108
uint8_t SwingV
Definition ir_Trotec.h:86
uint8_t Sum
Definition ir_Trotec.h:110
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition ir_Trotec.h:81
uint8_t Intro
Definition ir_Trotec.h:84
Native representation of a Trotec A/C message.
Definition ir_Trotec.h:28
uint8_t Timer
Definition ir_Trotec.h:49
uint8_t Intro2
Definition ir_Trotec.h:34
uint8_t Sum
Definition ir_Trotec.h:56
uint8_t Sleep
Definition ir_Trotec.h:44
uint8_t Temp
Definition ir_Trotec.h:42
uint8_t Power
Definition ir_Trotec.h:38
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition ir_Trotec.h:29
uint8_t Fan
Definition ir_Trotec.h:39
uint8_t Hours
Definition ir_Trotec.h:52
uint8_t Mode
Definition ir_Trotec.h:36
uint8_t Intro1
Definition ir_Trotec.h:32