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
11 // Brand: Duux, Model: Blizzard Smart 10K / DXMA04 A/C
12 
13 #ifndef IR_TROTEC_H_
14 #define IR_TROTEC_H_
15 
16 #ifndef UNIT_TEST
17 #include <Arduino.h>
18 #endif
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
59 const uint8_t kTrotecIntro1 = 0x12;
60 const uint8_t kTrotecIntro2 = 0x34;
61 
62 const uint8_t kTrotecAuto = 0;
63 const uint8_t kTrotecCool = 1;
64 const uint8_t kTrotecDry = 2;
65 const uint8_t kTrotecFan = 3;
66 
67 const uint8_t kTrotecFanLow = 1;
68 const uint8_t kTrotecFanMed = 2;
69 const uint8_t kTrotecFanHigh = 3;
70 
71 const uint8_t kTrotecMinTemp = 18;
72 const uint8_t kTrotecDefTemp = 25;
73 const uint8_t kTrotecMaxTemp = 32;
74 
75 const uint8_t kTrotecMaxTimer = 23;
76 
77 // Legacy defines. (Deprecated)
78 #define TROTEC_AUTO kTrotecAuto
79 #define TROTEC_COOL kTrotecCool
80 #define TROTEC_DRY kTrotecDry
81 #define TROTEC_FAN kTrotecFan
82 #define TROTEC_FAN_LOW kTrotecFanLow
83 #define TROTEC_FAN_MED kTrotecFanMed
84 #define TROTEC_FAN_HIGH kTrotecFanHigh
85 #define TROTEC_MIN_TEMP kTrotecMinTemp
86 #define TROTEC_MAX_TEMP kTrotecMaxTemp
87 #define TROTEC_MAX_TIMER kTrotecMaxTimer
88 
89 // Class
91 class IRTrotecESP {
92  public:
93  explicit IRTrotecESP(const uint16_t pin, const bool inverted = false,
94  const bool use_modulation = true);
95 #if SEND_TROTEC
96  void send(const uint16_t repeat = kTrotecDefaultRepeat);
101  int8_t calibrate(void) { return _irsend.calibrate(); }
102 #endif // SEND_TROTEC
103  void begin(void);
104  void stateReset(void);
105 
106  void on(void);
107  void off(void);
108  void setPower(const bool state);
109  bool getPower(void) const;
110 
111  void setTemp(const uint8_t celsius);
112  uint8_t getTemp(void) const;
113 
114  void setSpeed(const uint8_t fan);
115  uint8_t getSpeed(void) const;
116 
117  void setFan(const uint8_t fan) { setSpeed(fan); }
118  uint8_t getFan(void) const { return getSpeed(); }
119 
120  uint8_t getMode(void) const;
121  void setMode(const uint8_t mode);
122 
123  bool getSleep(void) const;
124  void setSleep(const bool on);
125 
126  uint8_t getTimer(void) const;
127  void setTimer(const uint8_t timer);
128 
129  uint8_t* getRaw(void);
130  void setRaw(const uint8_t state[]);
131  static bool validChecksum(const uint8_t state[],
132  const uint16_t length = kTrotecStateLength);
133  static uint8_t convertMode(const stdAc::opmode_t mode);
134  static uint8_t convertFan(const stdAc::fanspeed_t speed);
135  static stdAc::opmode_t toCommonMode(const uint8_t mode);
136  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
137  stdAc::state_t toCommon(void) const;
138  String toString(void) const;
139 #ifndef UNIT_TEST
140 
141  private:
143 #else // UNIT_TEST
144  IRsendTest _irsend;
146 #endif // UNIT_TEST
149  static uint8_t calcChecksum(const uint8_t state[],
150  const uint16_t length = kTrotecStateLength);
151  void checksum(void);
152 };
153 
154 #endif // IR_TROTEC_H_
IRTrotecESP::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Trotec.cpp:259
IRTrotecESP::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Trotec.cpp:96
IRTrotecESP::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Trotec.cpp:165
TrotecProtocol::Hours
uint8_t Hours
Definition: ir_Trotec.h:50
kTrotecDefaultRepeat
const uint16_t kTrotecDefaultRepeat
Definition: IRremoteESP8266.h:1113
TrotecProtocol::Sleep
uint8_t Sleep
Definition: ir_Trotec.h:42
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRTrotecESP::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Trotec.cpp:285
IRTrotecESP::setFan
void setFan(const uint8_t fan)
Definition: ir_Trotec.h:117
IRTrotecESP::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Trotec.cpp:68
TrotecProtocol::Intro1
uint8_t Intro1
Definition: ir_Trotec.h:30
kTrotecFanMed
const uint8_t kTrotecFanMed
Definition: ir_Trotec.h:68
IRTrotecESP::getTimer
uint8_t getTimer(void) const
Get the timer time in nr. of Hours.
Definition: ir_Trotec.cpp:204
IRsend.h
IRTrotecESP::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Trotec.cpp:115
kTrotecIntro2
const uint8_t kTrotecIntro2
Definition: ir_Trotec.h:60
TrotecProtocol::Power
uint8_t Power
Definition: ir_Trotec.h:36
kTrotecFanHigh
const uint8_t kTrotecFanHigh
Definition: ir_Trotec.h:69
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:187
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
TrotecProtocol::Sum
uint8_t Sum
Definition: ir_Trotec.h:54
String
std::string String
Definition: IRremoteESP8266.h:1208
IRTrotecESP::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Trotec.cpp:140
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:91
kTrotecMinTemp
const uint8_t kTrotecMinTemp
Definition: ir_Trotec.h:71
kTrotecDefTemp
const uint8_t kTrotecDefTemp
Definition: ir_Trotec.h:72
IRTrotecESP::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Trotec.cpp:127
kTrotecMaxTimer
const uint8_t kTrotecMaxTimer
Definition: ir_Trotec.h:75
IRremoteESP8266.h
IRTrotecESP::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Trotec.cpp:191
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:209
TrotecProtocol
Native representation of a Trotec A/C message.
Definition: ir_Trotec.h:26
kTrotecDry
const uint8_t kTrotecDry
Definition: ir_Trotec.h:64
IRTrotecESP::setTemp
void setTemp(const uint8_t celsius)
Set the temperature.
Definition: ir_Trotec.cpp:171
IRTrotecESP::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Trotec.cpp:159
kTrotecStateLength
const uint16_t kTrotecStateLength
Definition: IRremoteESP8266.h:1111
TrotecProtocol::Temp
uint8_t Temp
Definition: ir_Trotec.h:40
kTrotecMaxTemp
const uint8_t kTrotecMaxTemp
Definition: ir_Trotec.h:73
kTrotecFanLow
const uint8_t kTrotecFanLow
Definition: ir_Trotec.h:67
TrotecProtocol::raw
uint8_t raw[kTrotecStateLength]
Remote state in IR code form.
Definition: ir_Trotec.h:27
IRTrotecESP::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Trotec.cpp:101
IRTrotecESP::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Trotec.h:101
IRTrotecESP::setTimer
void setTimer(const uint8_t timer)
Set the timer time in nr. of Hours.
Definition: ir_Trotec.cpp:197
TrotecProtocol::Mode
uint8_t Mode
Definition: ir_Trotec.h:34
IRTrotecESP::getFan
uint8_t getFan(void) const
Definition: ir_Trotec.h:118
IRTrotecESP::setPower
void setPower(const bool state)
Change the power setting.
Definition: ir_Trotec.cpp:134
kTrotecFan
const uint8_t kTrotecFan
Definition: ir_Trotec.h:65
IRTrotecESP::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Trotec.cpp:236
IRTrotecESP::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Trotec.h:142
kTrotecCool
const uint8_t kTrotecCool
Definition: ir_Trotec.h:63
IRTrotecESP::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Trotec.cpp:185
IRTrotecESP::getSpeed
uint8_t getSpeed(void) const
Get the current fan speed setting.
Definition: ir_Trotec.cpp:153
IRTrotecESP::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Trotec.cpp:130
TrotecProtocol::Intro2
uint8_t Intro2
Definition: ir_Trotec.h:32
IRTrotecESP::_
TrotecProtocol _
Definition: ir_Trotec.h:148
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:82
IRTrotecESP::send
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Trotec.cpp:73
TrotecProtocol::Fan
uint8_t Fan
Definition: ir_Trotec.h:37
kTrotecAuto
const uint8_t kTrotecAuto
Definition: ir_Trotec.h:62
IRTrotecESP::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Trotec.cpp:248
IRTrotecESP
Class for handling detailed Trotec A/C messages.
Definition: ir_Trotec.h:91
IRTrotecESP::IRTrotecESP
IRTrotecESP(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Trotec.cpp:63
TrotecProtocol::Timer
uint8_t Timer
Definition: ir_Trotec.h:47
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:222
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kTrotecIntro1
const uint8_t kTrotecIntro1
Definition: ir_Trotec.h:59
IRTrotecESP::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Trotec.cpp:179
IRTrotecESP::setRaw
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition: ir_Trotec.cpp:122
IRTrotecESP::setSpeed
void setSpeed(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Trotec.cpp:146
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46