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 
25  uint64_t raw; // The state of the IR remote.
26  struct {
27  uint8_t Sum :8;
28  uint8_t Footer :8;
29  uint8_t TimerHours :5;
30  uint8_t :3;
31  uint8_t Temp :7;
32  uint8_t :1;
33  uint8_t Fan :3;
34  uint8_t :1;
35  uint8_t Sleep :1;
36  uint8_t Swing :1;
37  uint8_t UseFah :1;
38  uint8_t TimerEnable :1;
39  uint8_t Mode :4;
40  uint8_t FanChange :1;
41  uint8_t TempChange :1;
42  uint8_t TimerChange :1;
43  uint8_t Power :1;
44  uint8_t Header :8;
45  };
46 };
47 
48 // Constants
49 
50 const uint8_t kTechnibelAcTimerHoursOffset = 16;
51 const uint8_t kTechnibelAcTimerMax = 24;
52 
53 const uint8_t kTechnibelAcTempMinC = 16; // Deg C
54 const uint8_t kTechnibelAcTempMaxC = 31; // Deg C
55 const uint8_t kTechnibelAcTempMinF = 61; // Deg F
56 const uint8_t kTechnibelAcTempMaxF = 88; // Deg F
57 
58 const uint8_t kTechnibelAcFanSize = 4;
59 const uint8_t kTechnibelAcFanLow = 0b0001;
60 const uint8_t kTechnibelAcFanMedium = 0b0010;
61 const uint8_t kTechnibelAcFanHigh = 0b0100;
62 
63 const uint8_t kTechnibelAcCool = 0b0001;
64 const uint8_t kTechnibelAcDry = 0b0010;
65 const uint8_t kTechnibelAcFan = 0b0100;
66 const uint8_t kTechnibelAcHeat = 0b1000;
67 
68 const uint8_t kTechnibelAcHeaderOffset = 48;
69 const uint8_t kTechnibelAcHeader = 0b00011000;
70 
71 const uint64_t kTechnibelAcResetState = 0x180101140000EA;
72 
74 
75 // Classes
78  public:
79  explicit IRTechnibelAc(const uint16_t pin, const bool inverted = false,
80  const bool use_modulation = true);
81  void stateReset(void);
82 #if SEND_TECHNIBEL_AC
83  void send(const uint16_t repeat = kTechnibelAcDefaultRepeat);
88  int8_t calibrate(void) { return _irsend.calibrate(); }
89 #endif // SEND_TECHNIBEL_AC
90  void begin(void);
91  static uint8_t calcChecksum(const uint64_t state);
92  static bool validChecksum(const uint64_t state);
93  void setPower(const bool on);
94  bool getPower(void) const;
95  void on(void);
96  void off(void);
97  void setTempUnit(const bool celsius);
98  bool getTempUnit(void) const;
99  void setTemp(const uint8_t temp, const bool fahrenheit = false);
100  uint8_t getTemp(void) const;
101  void setFan(const uint8_t speed);
102  uint8_t getFan(void) const;
103  void setMode(const uint8_t mode);
104  uint8_t getMode(void) const;
105  void setSwing(const bool on);
106  bool getSwing(void) const;
107  static bool convertSwing(const stdAc::swingv_t swing);
108  static stdAc::swingv_t toCommonSwing(const bool swing);
109  void setSleep(const bool on);
110  bool getSleep(void) const;
111  void setTimerEnabled(const bool on);
112  bool getTimerEnabled(void) const;
113  void setTimer(const uint16_t nr_of_mins);
114  uint16_t getTimer(void) const;
115  uint64_t getRaw(void);
116  void setRaw(const uint64_t state);
117  static uint8_t convertMode(const stdAc::opmode_t mode);
118  static uint8_t convertFan(const stdAc::fanspeed_t speed);
119  static stdAc::opmode_t toCommonMode(const uint8_t mode);
120  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
121  stdAc::state_t toCommon(void) const;
122  String toString(void) const;
123 #ifndef UNIT_TEST
124 
125  private:
127 #else
128  IRsendTest _irsend;
129 #endif
131  uint8_t _saved_temp; // The previously user requested temp value.
132  uint8_t _saved_temp_units; // The previously user requested temp units.
133  void checksum(void);
134 };
135 #endif // IR_TECHNIBEL_H_
IRTechnibelAc::_irsend
IRsendTest _irsend
Definition: ir_Technibel.h:128
IRTechnibelAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Compute the checksum of the supplied state.
Definition: ir_Technibel.cpp:107
IRTechnibelAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Technibel.cpp:256
IRTechnibelAc::_
TechnibelProtocol _
Definition: ir_Technibel.h:130
TechnibelProtocol
Native representation of a Technibel A/C message.
Definition: ir_Technibel.h:24
kTechnibelAcTempMinF
const uint8_t kTechnibelAcTempMinF
Definition: ir_Technibel.h:55
IRTechnibelAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Technibel.cpp:194
stdAc::swingv_t
swingv_t
Common A/C settings for Vertical Swing.
Definition: IRsend.h:74
kTechnibelAcFanLow
const uint8_t kTechnibelAcFanLow
Definition: ir_Technibel.h:59
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRTechnibelAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Technibel.cpp:154
IRTechnibelAc::getSwing
bool getSwing(void) const
Get the (vertical) swing setting of the A/C.
Definition: ir_Technibel.cpp:304
IRTechnibelAc::getTempUnit
bool getTempUnit(void) const
Get the temperature unit setting.
Definition: ir_Technibel.cpp:177
kTechnibelAcFanSize
const uint8_t kTechnibelAcFanSize
Definition: ir_Technibel.h:58
IRTechnibelAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Technibel.cpp:287
IRTechnibelAc::setRaw
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition: ir_Technibel.cpp:146
IRTechnibelAc::IRTechnibelAc
IRTechnibelAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Technibel.cpp:89
TechnibelProtocol::TimerChange
uint8_t TimerChange
Definition: ir_Technibel.h:42
IRTechnibelAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Technibel.cpp:94
IRTechnibelAc::setTempUnit
void setTempUnit(const bool celsius)
Set the temperature unit setting.
Definition: ir_Technibel.cpp:170
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:350
IRTechnibelAc::checksum
void checksum(void)
Set the checksum of the internal state.
Definition: ir_Technibel.cpp:125
IRTechnibelAc::validChecksum
static bool validChecksum(const uint64_t state)
Confirm the checksum of the supplied state is valid.
Definition: ir_Technibel.cpp:119
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
TechnibelProtocol::Footer
uint8_t Footer
Definition: ir_Technibel.h:28
IRTechnibelAc::setTemp
void setTemp(const uint8_t temp, const bool fahrenheit=false)
Set the temperature.
Definition: ir_Technibel.cpp:184
IRTechnibelAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Technibel.cpp:219
TechnibelProtocol::TempChange
uint8_t TempChange
Definition: ir_Technibel.h:41
String
std::string String
Definition: IRremoteESP8266.h:1521
TechnibelProtocol::raw
uint64_t raw
Definition: ir_Technibel.h:25
kTechnibelAcTempMaxC
const uint8_t kTechnibelAcTempMaxC
Definition: ir_Technibel.h:54
TechnibelProtocol::UseFah
uint8_t UseFah
Definition: ir_Technibel.h:37
TechnibelProtocol::TimerHours
uint8_t TimerHours
Definition: ir_Technibel.h:29
TechnibelProtocol::Mode
uint8_t Mode
Definition: ir_Technibel.h:39
IRremoteESP8266.h
IRTechnibelAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Technibel.cpp:151
IRTechnibelAc::getTimerEnabled
bool getTimerEnabled(void) const
Is the timer function enabled?
Definition: ir_Technibel.cpp:342
IRTechnibelAc::toCommonSwing
static stdAc::swingv_t toCommonSwing(const bool swing)
Convert a native swing into its stdAc equivalent.
Definition: ir_Technibel.cpp:318
kTechnibelAcFanHigh
const uint8_t kTechnibelAcFanHigh
Definition: ir_Technibel.h:61
kTechnibelAcTimerMax
const uint8_t kTechnibelAcTimerMax
Definition: ir_Technibel.h:51
TechnibelProtocol::Sleep
uint8_t Sleep
Definition: ir_Technibel.h:35
TechnibelProtocol::Sum
uint8_t Sum
Definition: ir_Technibel.h:27
IRTechnibelAc::send
void send(const uint16_t repeat=kTechnibelAcDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Technibel.cpp:99
IRTechnibelAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Technibel.cpp:365
kTechnibelAcCool
const uint8_t kTechnibelAcCool
Definition: ir_Technibel.h:63
TechnibelProtocol::Swing
uint8_t Swing
Definition: ir_Technibel.h:36
kTechnibelAcFan
const uint8_t kTechnibelAcFan
Definition: ir_Technibel.h:65
IRTechnibelAc::stateReset
void stateReset(void)
Reset the internal state of the emulation.
Definition: ir_Technibel.cpp:131
kTechnibelAcHeader
const uint8_t kTechnibelAcHeader
Definition: ir_Technibel.h:69
IRTechnibelAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Technibel.cpp:164
IRTechnibelAc::getRaw
uint64_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_Technibel.cpp:139
kTechnibelAcHeat
const uint8_t kTechnibelAcHeat
Definition: ir_Technibel.h:66
IRTechnibelAc
Class for handling detailed Technibel A/C messages.
Definition: ir_Technibel.h:77
IRTechnibelAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Technibel.cpp:226
TechnibelProtocol::FanChange
uint8_t FanChange
Definition: ir_Technibel.h:40
IRTechnibelAc::_saved_temp
uint8_t _saved_temp
Definition: ir_Technibel.h:131
TechnibelProtocol::Temp
uint8_t Temp
Definition: ir_Technibel.h:31
kTechnibelAcHeaderOffset
const uint8_t kTechnibelAcHeaderOffset
Definition: ir_Technibel.h:68
TechnibelProtocol::Header
uint8_t Header
Definition: ir_Technibel.h:44
TechnibelProtocol::TimerEnable
uint8_t TimerEnable
Definition: ir_Technibel.h:38
kTechnibelAcTempMinC
const uint8_t kTechnibelAcTempMinC
Definition: ir_Technibel.h:53
TechnibelProtocol::Power
uint8_t Power
Definition: ir_Technibel.h:43
kTechnibelAcTimerHoursOffset
const uint8_t kTechnibelAcTimerHoursOffset
Definition: ir_Technibel.h:50
IRTechnibelAc::_saved_temp_units
uint8_t _saved_temp_units
Definition: ir_Technibel.h:132
kTechnibelAcResetState
const uint64_t kTechnibelAcResetState
Mode:Cool, Power:Off, fan:Low, temp:20, swing:Off, sleep:Off.
Definition: ir_Technibel.h:71
IRTechnibelAc::setTimerEnabled
void setTimerEnabled(const bool on)
Set the enable timer setting.
Definition: ir_Technibel.cpp:336
kTechnibelAcDefaultRepeat
const uint16_t kTechnibelAcDefaultRepeat
Definition: IRremoteESP8266.h:1223
IRTechnibelAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Technibel.cpp:250
IRTechnibelAc::setSwing
void setSwing(const bool on)
Set the (vertical) swing setting of the A/C.
Definition: ir_Technibel.cpp:298
IRTechnibelAc::getTimer
uint16_t getTimer(void) const
Get the timer time for when the A/C unit will switch power state.
Definition: ir_Technibel.cpp:359
IRTechnibelAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Technibel.cpp:391
IRTechnibelAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Technibel.h:88
IRTechnibelAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Technibel.cpp:240
kTechnibelAcFanMedium
const uint8_t kTechnibelAcFanMedium
Definition: ir_Technibel.h:60
TechnibelProtocol::Fan
uint8_t Fan
Definition: ir_Technibel.h:33
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
IRTechnibelAc::convertSwing
static bool convertSwing(const stdAc::swingv_t swing)
Convert a stdAc::swingv_t enum into it's native swing.
Definition: ir_Technibel.cpp:311
IRTechnibelAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Technibel.cpp:275
kTechnibelAcDry
const uint8_t kTechnibelAcDry
Definition: ir_Technibel.h:64
kTechnibelAcTempMaxF
const uint8_t kTechnibelAcTempMaxF
Definition: ir_Technibel.h:56
IRTechnibelAc::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Technibel.cpp:330
IRTechnibelAc::_irsend
IRsend _irsend
Definition: ir_Technibel.h:126
IRTechnibelAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Technibel.cpp:158
IRTechnibelAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Technibel.cpp:324
IRTechnibelAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Technibel.cpp:200
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49