IRremoteESP8266: src/ir_Trotec.h Source File

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
25 // Constants
26 // Byte 0
27 const uint8_t kTrotecIntro1 = 0x12;
28
29 // Byte 1
30 const uint8_t kTrotecIntro2 = 0x34;
31
32 // Byte 2
33 const uint8_t kTrotecModeOffset = 0;
34 const uint8_t kTrotecModeSize = 2; // Nr. of bits
35 const uint8_t kTrotecAuto = 0;
36 const uint8_t kTrotecCool = 1;
37 const uint8_t kTrotecDry = 2;
38 const uint8_t kTrotecFan = 3;
39
40 const uint8_t kTrotecPowerBitOffset = 3;
41
42 const uint8_t kTrotecFanOffset = 4;
43 const uint8_t kTrotecFanSize = 2; // Nr. of bits
44 const uint8_t kTrotecFanLow = 1;
45 const uint8_t kTrotecFanMed = 2;
46 const uint8_t kTrotecFanHigh = 3;
47
48 // Byte 3
49 const uint8_t kTrotecTempOffset = 0;
50 const uint8_t kTrotecTempSize = 4; // Nr. of bits
51 const uint8_t kTrotecMinTemp = 18;
52 const uint8_t kTrotecDefTemp = 25;
53 const uint8_t kTrotecMaxTemp = 32;
54 const uint8_t kTrotecSleepBitOffset = 7;
55
56 // Byte 5
57 const uint8_t kTrotecTimerBitOffset = 6;
58
59 // Byte 6
60 const uint8_t kTrotecMaxTimer = 23;
61
62 // Legacy defines. (Deprecated)
63 #define TROTEC_AUTO kTrotecAuto
64 #define TROTEC_COOL kTrotecCool
65 #define TROTEC_DRY kTrotecDry
66 #define TROTEC_FAN kTrotecFan
67 #define TROTEC_FAN_LOW kTrotecFanLow
68 #define TROTEC_FAN_MED kTrotecFanMed
69 #define TROTEC_FAN_HIGH kTrotecFanHigh
70 #define TROTEC_MIN_TEMP kTrotecMinTemp
71 #define TROTEC_MAX_TEMP kTrotecMaxTemp
72 #define TROTEC_MAX_TIMER kTrotecMaxTimer
73
74 // Class
76 class IRTrotecESP {
77 public:
78 explicit IRTrotecESP(const uint16_t pin, const bool inverted = false,
79 const bool use_modulation = true);
80 #if SEND_TROTEC
81 void send(const uint16_t repeat = kTrotecDefaultRepeat);
86 int8_t calibrate(void) { return _irsend.calibrate(); }
87 #endif // SEND_TROTEC
88 void begin(void);
89 void stateReset(void);
90
91 void on(void);
92 void off(void);
93 void setPower(const bool state);
94 bool getPower(void);
95
96 void setTemp(const uint8_t celsius);
97 uint8_t getTemp(void);
98
99 void setSpeed(const uint8_t fan);
100 uint8_t getSpeed(void);
101
102 uint8_t getMode(void);
103 void setMode(const uint8_t mode);
104
105 bool getSleep(void);
106 void setSleep(const bool on);
107
108 uint8_t getTimer(void);
109 void setTimer(const uint8_t timer);
110
111 uint8_t* getRaw(void);
112 void setRaw(const uint8_t state[]);
113 static bool validChecksum(const uint8_t state[],
114 const uint16_t length = kTrotecStateLength);
115 uint8_t convertMode(const stdAc::opmode_t mode);
116 uint8_t convertFan(const stdAc::fanspeed_t speed);
117 static stdAc::opmode_t toCommonMode(const uint8_t mode);
118 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
119 stdAc::state_t toCommon(void);
120 String toString(void);
121 #ifndef UNIT_TEST
122
123 private:
124 IRsend _irsend;
125 #else // UNIT_TEST
126 IRsendTest _irsend;
128 #endif // UNIT_TEST
130 uint8_t remote_state[kTrotecStateLength];
131 static uint8_t calcChecksum(const uint8_t state[],
132 const uint16_t length = kTrotecStateLength);
133 void checksum(void);
134 };
135
136 #endif // IR_TROTEC_H_
IRTrotecESP::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_Trotec.cpp:184
kTrotecFanOffset
const uint8_t kTrotecFanOffset
Definition: ir_Trotec.h:42
IRTrotecESP::checksum
void checksum(void)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Trotec.cpp:98
kTrotecTimerBitOffset
const uint8_t kTrotecTimerBitOffset
Definition: ir_Trotec.h:57
IRTrotecESP::getSleep
bool getSleep(void)
Get the Sleep setting of the A/C.
Definition: ir_Trotec.cpp:197
kTrotecDefaultRepeat
const uint16_t kTrotecDefaultRepeat
Definition: IRremoteESP8266.h:1105
IRTrotecESP::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_Trotec.cpp:169
kTrotecSleepBitOffset
const uint8_t kTrotecSleepBitOffset
Definition: ir_Trotec.h:54
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRTrotecESP::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_Trotec.cpp:291
IRTrotecESP::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Trotec.cpp:70
IRTrotecESP::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_Trotec.cpp:143
kTrotecFanMed
const uint8_t kTrotecFanMed
Definition: ir_Trotec.h:45
IRsend.h
IRTrotecESP::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Trotec.cpp:118
kTrotecIntro2
const uint8_t kTrotecIntro2
Definition: ir_Trotec.h:30
kTrotecFanHigh
const uint8_t kTrotecFanHigh
Definition: ir_Trotec.h:46
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
String
std::string String
Definition: IRremoteESP8266.h:1199
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:93
kTrotecMinTemp
const uint8_t kTrotecMinTemp
Definition: ir_Trotec.h:51
kTrotecDefTemp
const uint8_t kTrotecDefTemp
Definition: ir_Trotec.h:52
IRTrotecESP::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Trotec.cpp:130
kTrotecMaxTimer
const uint8_t kTrotecMaxTimer
Definition: ir_Trotec.h:60
IRTrotecESP::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Trotec.cpp:265
IRremoteESP8266.h
IRTrotecESP::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Trotec.cpp:215
kTrotecDry
const uint8_t kTrotecDry
Definition: ir_Trotec.h:37
kTrotecTempOffset
const uint8_t kTrotecTempOffset
Definition: ir_Trotec.h:49
IRTrotecESP::getTimer
uint8_t getTimer(void)
Get the timer time in nr. of Hours.
Definition: ir_Trotec.cpp:210
IRTrotecESP::setTemp
void setTemp(const uint8_t celsius)
Set the temperature.
Definition: ir_Trotec.cpp:175
IRTrotecESP::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Trotec.cpp:162
kTrotecStateLength
const uint16_t kTrotecStateLength
Definition: IRremoteESP8266.h:1103
kTrotecMaxTemp
const uint8_t kTrotecMaxTemp
Definition: ir_Trotec.h:53
kTrotecFanLow
const uint8_t kTrotecFanLow
Definition: ir_Trotec.h:44
IRTrotecESP::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Trotec.cpp:104
IRTrotecESP::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Trotec.h:86
IRTrotecESP::setTimer
void setTimer(const uint8_t timer)
Set the timer time in nr. of Hours.
Definition: ir_Trotec.cpp:203
IRTrotecESP::setPower
void setPower(const bool state)
Change the power setting.
Definition: ir_Trotec.cpp:137
kTrotecFan
const uint8_t kTrotecFan
Definition: ir_Trotec.h:38
kTrotecModeSize
const uint8_t kTrotecModeSize
Definition: ir_Trotec.h:34
IRTrotecESP::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Trotec.cpp:242
IRTrotecESP::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Trotec.h:124
kTrotecCool
const uint8_t kTrotecCool
Definition: ir_Trotec.h:36
IRTrotecESP::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Trotec.cpp:191
IRTrotecESP::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Trotec.cpp:133
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:84
IRTrotecESP::send
void send(const uint16_t repeat=kTrotecDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Trotec.cpp:75
IRTrotecESP::remote_state
uint8_t remote_state[kTrotecStateLength]
Remote state in IR code form.
Definition: ir_Trotec.h:130
kTrotecModeOffset
const uint8_t kTrotecModeOffset
Definition: ir_Trotec.h:33
kTrotecAuto
const uint8_t kTrotecAuto
Definition: ir_Trotec.h:35
IRTrotecESP::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Trotec.cpp:254
IRTrotecESP
Class for handling detailed Trotec A/C messages.
Definition: ir_Trotec.h:76
kTrotecFanSize
const uint8_t kTrotecFanSize
Definition: ir_Trotec.h:43
IRTrotecESP::getSpeed
uint8_t getSpeed(void)
Get the current fan speed setting.
Definition: ir_Trotec.cpp:156
IRTrotecESP::IRTrotecESP
IRTrotecESP(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Trotec.cpp:65
kTrotecTempSize
const uint8_t kTrotecTempSize
Definition: ir_Trotec.h:50
IRTrotecESP::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Trotec.cpp:228
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
kTrotecIntro1
const uint8_t kTrotecIntro1
Definition: ir_Trotec.h:27
IRTrotecESP::setRaw
void setRaw(const uint8_t state[])
Set the internal state from a valid code for this protocol.
Definition: ir_Trotec.cpp:125
IRTrotecESP::setSpeed
void setSpeed(const uint8_t fan)
Set the speed of the fan.
Definition: ir_Trotec.cpp:149
kTrotecPowerBitOffset
const uint8_t kTrotecPowerBitOffset
Definition: ir_Trotec.h:40
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46