IRremoteESP8266
ir_Technibel.h
Go to the documentation of this file.
1 // Copyright 2020 Quentin Briollant
2 
5 
6 #ifndef IR_TECHNIBEL_H_
7 #define IR_TECHNIBEL_H_
8 
9 #define __STDC_LIMIT_MACROS
10 #include <stdint.h>
11 #ifndef UNIT_TEST
12 #include <Arduino.h>
13 #endif
14 #include "IRremoteESP8266.h"
15 #include "IRsend.h"
16 #ifdef UNIT_TEST
17 #include "IRsend_test.h"
18 #endif
19 
20 // Supports:
21 // Brand: Technibel, Model: IRO PLUS
22 
23 
24 /* State bit map:
25 
26 +--+--+--+--+--+--+--+--+--+------------+-----------+----------+--+--+--+--+
27 | FIXED HEADER |ON|TIMER CHANGE|TEMP CHANGE|FAN CHANGE| MODE |
28 +--+--+--+--+--+--+--+--+--+------------+-----------+----------+--+--+--+--+
29  55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
30 
31 +-----+------+-----+-----+---+--+--+--+---+--+--+--+--+--+--+--+
32 |TIMER|C OR F|SWING|SLEEP| 0 | FAN | 0 | TEMPERATURE |
33 +-----+------+-----+-----+---+--+--+--+---+--+--+--+--+--+--+--+
34  39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24
35 
36 +---+---+---+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
37 | 0 | 0 | 0 | ON TIME HOUR | FOOTER | CHECKSUM |
38 +---+---+---+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
39  23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
40 
41 
42 */
43 
44 // Constants
45 const uint8_t kTechnibelAcChecksumOffset = 0;
46 const uint8_t kTechnibelAcChecksumSize = 8;
47 
50 const uint8_t kTechnibelAcFooterSize = 8;
51 
54 const uint8_t kTechnibelAcHoursSize = 8; // Max 24 hrs
55 const uint8_t kTechnibelAcTimerMax = 24;
56 
59 const uint8_t kTechnibelAcTempSize = 8;
60 const uint8_t kTechnibelAcTempMinC = 16; // Deg C
61 const uint8_t kTechnibelAcTempMaxC = 31; // Deg C
62 const uint8_t kTechnibelAcTempMinF = 61; // Deg F
63 const uint8_t kTechnibelAcTempMaxF = 88; // Deg F
64 
67 const uint8_t kTechnibelAcFanSize = 4;
68 const uint8_t kTechnibelAcFanLow = 0b0001;
69 const uint8_t kTechnibelAcFanMedium = 0b0010;
70 const uint8_t kTechnibelAcFanHigh = 0b0100;
71 
74 
76 
77 // (0 = Celsius, 1 = Fahrenheit)
79 
81 
83 const uint8_t kTechnibelAcModeSize = 4;
84 const uint8_t kTechnibelAcCool = 0b0001;
85 const uint8_t kTechnibelAcDry = 0b0010;
86 const uint8_t kTechnibelAcFan = 0b0100;
87 const uint8_t kTechnibelAcHeat = 0b1000;
88 
91 
93 
95 
97 
99 const uint8_t kTechnibelAcHeaderSize = 8;
100 const uint8_t kTechnibelAcHeader = 0b00011000;
101 
102 const uint64_t kTechnibelAcResetState = 0x180101140000EA;
103 
105 
106 // Classes
108  public:
109  explicit IRTechnibelAc(const uint16_t pin, const bool inverted = false,
110  const bool use_modulation = true);
111  void stateReset();
112 #if SEND_TECHNIBEL_AC
113  void send(const uint16_t repeat = kTechnibelAcDefaultRepeat);
118  int8_t calibrate(void) { return _irsend.calibrate(); }
119 #endif // SEND_TECHNIBEL_AC
120  void begin();
121  static uint8_t calcChecksum(const uint64_t state);
122  static bool validChecksum(const uint64_t state);
123  void setPower(const bool on);
124  bool getPower();
125  void on();
126  void off();
127  void setTempUnit(const bool celsius);
128  bool getTempUnit(void);
129  void setTemp(const uint8_t temp, const bool fahrenheit = false);
130  uint8_t getTemp();
131  void setFan(const uint8_t speed);
132  uint8_t getFan();
133  void setMode(const uint8_t mode);
134  uint8_t getMode();
135  void setSwing(const bool on);
136  bool getSwing();
137  bool convertSwing(const stdAc::swingv_t swing);
138  stdAc::swingv_t toCommonSwing(const bool swing);
139  void setSleep(const bool on);
140  bool getSleep();
141  void setTimerEnabled(const bool on);
142  bool getTimerEnabled(void);
143  void setTimer(const uint16_t nr_of_mins);
144  uint16_t getTimer(void);
145  uint64_t getRaw();
146  void setRaw(const uint64_t state);
147  uint8_t convertMode(const stdAc::opmode_t mode);
148  uint8_t convertFan(const stdAc::fanspeed_t speed);
149  static stdAc::opmode_t toCommonMode(const uint8_t mode);
150  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
151  stdAc::state_t toCommon(void);
152  String toString();
153 #ifndef UNIT_TEST
154 
155  private:
157 #else
158  IRsendTest _irsend;
159 #endif
160  uint64_t remote_state; // The state of the IR remote.
161  uint8_t _saved_temp; // The previously user requested temp value.
162  uint8_t _saved_temp_units; // The previously user requested temp units.
163  void checksum(void);
164 };
165 #endif // IR_TECHNIBEL_H_
IRTechnibelAc::_irsend
IRsendTest _irsend
Definition: ir_Technibel.h:158
IRTechnibelAc::toString
String toString()
Convert the current internal state into a human readable string.
Definition: ir_Technibel.cpp:399
IRTechnibelAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Compute the checksum of the supplied state.
Definition: ir_Technibel.cpp:109
IRTechnibelAc::getTempUnit
bool getTempUnit(void)
Get the temperature unit setting.
Definition: ir_Technibel.cpp:180
IRTechnibelAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Technibel.cpp:260
IRTechnibelAc::getTemp
uint8_t getTemp()
Get the current temperature setting.
Definition: ir_Technibel.cpp:198
IRTechnibelAc::getTimer
uint16_t getTimer(void)
Get the timer time for when the A/C unit will switch power state.
Definition: ir_Technibel.cpp:365
IRTechnibelAc::stateReset
void stateReset()
Reset the internal state of the emulation.
Definition: ir_Technibel.cpp:134
kTechnibelAcFooterSize
const uint8_t kTechnibelAcFooterSize
Definition: ir_Technibel.h:50
kTechnibelAcTempMinF
const uint8_t kTechnibelAcTempMinF
Definition: ir_Technibel.h:62
IRTechnibelAc::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Technibel.cpp:96
stdAc::swingv_t
swingv_t
Common A/C settings for Vertical Swing.
Definition: IRsend.h:70
kTechnibelAcFanLow
const uint8_t kTechnibelAcFanLow
Definition: ir_Technibel.h:68
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kTechnibelAcFanSize
const uint8_t kTechnibelAcFanSize
Definition: ir_Technibel.h:67
IRTechnibelAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_Technibel.cpp:292
IRTechnibelAc::setRaw
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition: ir_Technibel.cpp:149
IRTechnibelAc::IRTechnibelAc
IRTechnibelAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Technibel.cpp:91
IRTechnibelAc::setTempUnit
void setTempUnit(const bool celsius)
Set the temperature unit setting.
Definition: ir_Technibel.cpp:173
IRsend.h
IRTechnibelAc::setTimer
void setTimer(const uint16_t nr_of_mins)
Set the timer for when the A/C unit will switch off.
Definition: ir_Technibel.cpp:355
IRTechnibelAc::checksum
void checksum(void)
Set the checksum of the internal state.
Definition: ir_Technibel.cpp:127
IRTechnibelAc::validChecksum
static bool validChecksum(const uint64_t state)
Confirm the checksum of the supplied state is valid.
Definition: ir_Technibel.cpp:121
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:176
kTechnibelAcChecksumOffset
const uint8_t kTechnibelAcChecksumOffset
Definition: ir_Technibel.h:45
kTechnibelAcTimerEnableBit
const uint8_t kTechnibelAcTimerEnableBit
Definition: ir_Technibel.h:80
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRTechnibelAc::getPower
bool getPower()
Get the value of the current power setting.
Definition: ir_Technibel.cpp:167
IRTechnibelAc::setTemp
void setTemp(const uint8_t temp, const bool fahrenheit=false)
Set the temperature.
Definition: ir_Technibel.cpp:187
IRTechnibelAc::remote_state
uint64_t remote_state
Definition: ir_Technibel.h:160
IRTechnibelAc::getRaw
uint64_t getRaw()
Get a copy of the internal state/code for this protocol.
Definition: ir_Technibel.cpp:142
String
std::string String
Definition: IRremoteESP8266.h:1148
kTechnibelAcTempMaxC
const uint8_t kTechnibelAcTempMaxC
Definition: ir_Technibel.h:61
kTechnibelAcTempOffset
const uint8_t kTechnibelAcTempOffset
Definition: ir_Technibel.h:57
kTechnibelAcSleepBit
const uint8_t kTechnibelAcSleepBit
Definition: ir_Technibel.h:72
IRremoteESP8266.h
IRTechnibelAc::toCommonSwing
stdAc::swingv_t toCommonSwing(const bool swing)
Convert a native swing into its stdAc equivilant.
Definition: ir_Technibel.cpp:323
kTechnibelAcFanOffset
const uint8_t kTechnibelAcFanOffset
Definition: ir_Technibel.h:65
kTechnibelAcFanHigh
const uint8_t kTechnibelAcFanHigh
Definition: ir_Technibel.h:70
kTechnibelAcTimerMax
const uint8_t kTechnibelAcTimerMax
Definition: ir_Technibel.h:55
IRTechnibelAc::send
void send(const uint16_t repeat=kTechnibelAcDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Technibel.cpp:101
IRTechnibelAc::off
void off()
Set the requested power state of the A/C to off.
Definition: ir_Technibel.cpp:157
kTechnibelAcCool
const uint8_t kTechnibelAcCool
Definition: ir_Technibel.h:84
kTechnibelAcTimerChangeBit
const uint8_t kTechnibelAcTimerChangeBit
Definition: ir_Technibel.h:94
kTechnibelAcFan
const uint8_t kTechnibelAcFan
Definition: ir_Technibel.h:86
kTechnibelAcHeader
const uint8_t kTechnibelAcHeader
Definition: ir_Technibel.h:100
IRTechnibelAc::getTimerEnabled
bool getTimerEnabled(void)
Is the timer function enabled?
Definition: ir_Technibel.cpp:347
IRTechnibelAc::getSleep
bool getSleep()
Get the Sleep setting of the A/C.
Definition: ir_Technibel.cpp:335
kTechnibelAcHeat
const uint8_t kTechnibelAcHeat
Definition: ir_Technibel.h:87
kTechnibelAcFanChangeBit
const uint8_t kTechnibelAcFanChangeBit
Definition: ir_Technibel.h:89
kTechnibelAcHeaderSize
const uint8_t kTechnibelAcHeaderSize
Definition: ir_Technibel.h:99
IRTechnibelAc
Definition: ir_Technibel.h:107
IRTechnibelAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_Technibel.cpp:373
kTechnibelAcPowerBit
const uint8_t kTechnibelAcPowerBit
Definition: ir_Technibel.h:96
IRTechnibelAc::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Technibel.cpp:230
kTechnibelAcSwingBit
const uint8_t kTechnibelAcSwingBit
Definition: ir_Technibel.h:75
IRTechnibelAc::_saved_temp
uint8_t _saved_temp
Definition: ir_Technibel.h:161
kTechnibelAcTempUnitBit
const uint8_t kTechnibelAcTempUnitBit
Definition: ir_Technibel.h:78
kTechnibelAcModeOffset
const uint8_t kTechnibelAcModeOffset
Definition: ir_Technibel.h:82
kTechnibelAcHeaderOffset
const uint8_t kTechnibelAcHeaderOffset
Definition: ir_Technibel.h:98
kTechnibelAcHoursSize
const uint8_t kTechnibelAcHoursSize
Definition: ir_Technibel.h:54
IRTechnibelAc::getSwing
bool getSwing()
Get the (vertical) swing setting of the A/C.
Definition: ir_Technibel.cpp:309
kTechnibelAcTempMinC
const uint8_t kTechnibelAcTempMinC
Definition: ir_Technibel.h:60
kTechnibelAcTempSize
const uint8_t kTechnibelAcTempSize
Definition: ir_Technibel.h:59
kTechnibelAcTimerHoursOffset
const uint8_t kTechnibelAcTimerHoursOffset
Definition: ir_Technibel.h:52
IRTechnibelAc::_saved_temp_units
uint8_t _saved_temp_units
Definition: ir_Technibel.h:162
IRTechnibelAc::getFan
uint8_t getFan()
Get the current fan speed setting.
Definition: ir_Technibel.cpp:223
kTechnibelAcResetState
const uint64_t kTechnibelAcResetState
Mode:Cool, Power:Off, fan:Low, temp:20, swing:Off, sleep:Off.
Definition: ir_Technibel.h:102
IRTechnibelAc::setTimerEnabled
void setTimerEnabled(const bool on)
Set the enable timer setting.
Definition: ir_Technibel.cpp:341
kTechnibelAcDefaultRepeat
const uint16_t kTechnibelAcDefaultRepeat
Definition: IRremoteESP8266.h:905
IRTechnibelAc::setSwing
void setSwing(const bool on)
Set the (vertical) swing setting of the A/C.
Definition: ir_Technibel.cpp:303
IRTechnibelAc::getMode
uint8_t getMode()
Get the operating mode setting of the A/C.
Definition: ir_Technibel.cpp:254
IRTechnibelAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Technibel.h:118
IRTechnibelAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_Technibel.cpp:244
kTechnibelAcFanMedium
const uint8_t kTechnibelAcFanMedium
Definition: ir_Technibel.h:69
kTechnibelAcFooterOffset
const uint8_t kTechnibelAcFooterOffset
Definition: ir_Technibel.h:48
IRTechnibelAc::on
void on()
Set the requested power state of the A/C to on.
Definition: ir_Technibel.cpp:154
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
IRTechnibelAc::convertSwing
bool convertSwing(const stdAc::swingv_t swing)
Convert a stdAc::swingv_t enum into it's native swing.
Definition: ir_Technibel.cpp:316
IRTechnibelAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Technibel.cpp:280
kTechnibelAcDry
const uint8_t kTechnibelAcDry
Definition: ir_Technibel.h:85
kTechnibelAcModeSize
const uint8_t kTechnibelAcModeSize
Definition: ir_Technibel.h:83
kTechnibelAcChecksumSize
const uint8_t kTechnibelAcChecksumSize
Definition: ir_Technibel.h:46
kTechnibelAcTempMaxF
const uint8_t kTechnibelAcTempMaxF
Definition: ir_Technibel.h:63
IRTechnibelAc::_irsend
IRsend _irsend
Definition: ir_Technibel.h:156
IRTechnibelAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Technibel.cpp:161
IRTechnibelAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Technibel.cpp:329
IRTechnibelAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Technibel.cpp:204
kTechnibelAcTempChangeBit
const uint8_t kTechnibelAcTempChangeBit
Definition: ir_Technibel.h:92
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46