IRremoteESP8266
ir_Delonghi.h
Go to the documentation of this file.
1 // Copyright 2020 David Conran
2 
7 
8 // Supports:
9 // Brand: Delonghi, Model: PAC A95
10 
11 #ifndef IR_DELONGHI_H_
12 #define IR_DELONGHI_H_
13 
14 #define __STDC_LIMIT_MACROS
15 #include <stdint.h>
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 /* State bit map:
26 
27 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------+
28 | FIXED HEADER | TEMPERATURE | FAN |F or C|
29 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------+
30  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
31 
32 +--+--+--+--+-----+-----+
33 |ON| MODE |Boost|Sleep|
34 +--+--+--+--+-----+-----+
35 16 17 18 19 20 21
36 
37 +--+--+------------+--+--+--+--+--+--+--+--+--+--+--+--+--+
38 | 0| 0|Timer Enable| ON TIME HOUR | 0 0| ON TIME MIN |
39 +--+--+------------+--+--+--+--+--+--+--+--+--+--+--+--+--+
40  22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
41 
42 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
43 | 0 0| OFF TIMER | CHECKSUM |
44 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
45  38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
46 
47 */
48 
49 // Constants
50 const uint8_t kDelonghiAcTempOffset = 8;
51 const uint8_t kDelonghiAcTempSize = 5;
52 const uint8_t kDelonghiAcTempMinC = 18; // Deg C
53 const uint8_t kDelonghiAcTempMaxC = 32; // Deg C
54 const uint8_t kDelonghiAcTempMinF = 64; // Deg F
55 const uint8_t kDelonghiAcTempMaxF = 90; // Deg F
56 const uint8_t kDelonghiAcTempAutoDryMode = 0;
57 const uint8_t kDelonghiAcTempFanMode = 0b00110;
59  kDelonghiAcTempSize; // 13
60 const uint8_t kDelonghiAcFanSize = 2;
61 const uint8_t kDelonghiAcFanAuto = 0b00;
62 const uint8_t kDelonghiAcFanHigh = 0b01;
63 const uint8_t kDelonghiAcFanMedium = 0b10;
64 const uint8_t kDelonghiAcFanLow = 0b11;
66  kDelonghiAcFanSize; // 15 (1 = Celsius, 0 = Fahrenheit)
67 const uint8_t kDelonghiAcPowerBit = kDelonghiAcTempUnitBit + 1; // 16
68 const uint8_t kDelonghiAcModeOffset = kDelonghiAcPowerBit + 1; // 17
69 const uint8_t kDelonghiAcModeSize = 3;
70 const uint8_t kDelonghiAcCool = 0b000;
71 const uint8_t kDelonghiAcDry = 0b001;
72 const uint8_t kDelonghiAcFan = 0b010;
73 const uint8_t kDelonghiAcAuto = 0b100;
75  kDelonghiAcModeSize; // 20 (Aka Turbo)
76 const uint8_t kDelonghiAcSleepBit = kDelonghiAcBoostBit + 1; // 21
77 // Two zero bits
79 const uint8_t kDelonghiAcHoursSize = 5; // Max 23 hrs
80 const uint8_t kDelonghiAcMinsSize = 6; // Max 59 mins
81 const uint16_t kDelonghiAcTimerMax = 23 * 60 + 59;
83  1; // 25
85  kDelonghiAcHoursSize + 2; // 32 (inc another two zero bits)
86 // Two zero bits
88  kDelonghiAcMinsSize + 2; // 40
90  1; // 41
92  kDelonghiAcHoursSize + 2; // 48 (inc another two zero bits)
93 // Two zero bits
95  kDelonghiAcMinsSize + 2; // 56
96 const uint8_t kDelonghiAcChecksumSize = 8;
97 
98 
99 // Classes
100 
103  public:
104  explicit IRDelonghiAc(const uint16_t pin, const bool inverted = false,
105  const bool use_modulation = true);
106  void stateReset();
107 #if SEND_DELONGHI_AC
108  void send(const uint16_t repeat = kDelonghiAcDefaultRepeat);
113  int8_t calibrate(void) { return _irsend.calibrate(); }
114 #endif // SEND_DELONGHI_AC
115  void begin();
116  static uint8_t calcChecksum(const uint64_t state);
117  static bool validChecksum(const uint64_t state);
118  void setPower(const bool on);
119  bool getPower();
120  void on();
121  void off();
122  void setTempUnit(const bool celsius);
123  bool getTempUnit(void);
124  void setTemp(const uint8_t temp, const bool fahrenheit = false,
125  const bool force = false);
126  uint8_t getTemp();
127  void setFan(const uint8_t speed);
128  uint8_t getFan();
129  void setMode(const uint8_t mode);
130  uint8_t getMode();
131  void setBoost(const bool on); // Aka Turbo
132  bool getBoost(); // Aka Turbo
133  void setSleep(const bool on);
134  bool getSleep();
135  void setOnTimerEnabled(const bool on);
136  bool getOnTimerEnabled(void);
137  void setOnTimer(const uint16_t nr_of_mins);
138  uint16_t getOnTimer(void);
139  void setOffTimerEnabled(const bool on);
140  bool getOffTimerEnabled(void);
141  void setOffTimer(const uint16_t nr_of_mins);
142  uint16_t getOffTimer(void);
143  uint64_t getRaw();
144  void setRaw(const uint64_t state);
145  uint8_t convertMode(const stdAc::opmode_t mode);
146  uint8_t convertFan(const stdAc::fanspeed_t speed);
147  static stdAc::opmode_t toCommonMode(const uint8_t mode);
148  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
149  stdAc::state_t toCommon(void);
150  String toString();
151 #ifndef UNIT_TEST
152 
153  private:
155 #else
156  IRsendTest _irsend;
158 #endif
160  uint64_t remote_state;
161  uint8_t _saved_temp;
163  void checksum(void);
164 };
165 #endif // IR_DELONGHI_H_
IRDelonghiAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_Delonghi.cpp:274
kDelonghiAcCool
const uint8_t kDelonghiAcCool
Definition: ir_Delonghi.h:70
IRDelonghiAc::getOnTimer
uint16_t getOnTimer(void)
Get the On timer time.
Definition: ir_Delonghi.cpp:393
kDelonghiAcTempOffset
const uint8_t kDelonghiAcTempOffset
Definition: ir_Delonghi.h:50
IRDelonghiAc::begin
void begin()
Set up hardware to be able to send a message.
Definition: ir_Delonghi.cpp:100
IRDelonghiAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Delonghi.cpp:221
IRDelonghiAc::send
void send(const uint16_t repeat=kDelonghiAcDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Delonghi.cpp:105
IRDelonghiAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_Delonghi.cpp:333
IRDelonghiAc::getTemp
uint8_t getTemp()
Get the current temperature setting.
Definition: ir_Delonghi.cpp:214
IRDelonghiAc::setRaw
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition: ir_Delonghi.cpp:153
kDelonghiAcTempFanMode
const uint8_t kDelonghiAcTempFanMode
Definition: ir_Delonghi.h:57
kDelonghiAcOnTimerHoursOffset
const uint8_t kDelonghiAcOnTimerHoursOffset
Definition: ir_Delonghi.h:82
IRDelonghiAc
Class for handling detailed Delonghi A/C messages.
Definition: ir_Delonghi.h:102
IRDelonghiAc::IRDelonghiAc
IRDelonghiAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Delonghi.cpp:95
kDelonghiAcModeOffset
const uint8_t kDelonghiAcModeOffset
Definition: ir_Delonghi.h:68
kDelonghiAcTempMinC
const uint8_t kDelonghiAcTempMinC
Definition: ir_Delonghi.h:52
kDelonghiAcFanHigh
const uint8_t kDelonghiAcFanHigh
Definition: ir_Delonghi.h:62
IRDelonghiAc::setOnTimer
void setOnTimer(const uint16_t nr_of_mins)
Set the On timer to activate in nr of minutes.
Definition: ir_Delonghi.cpp:381
IRDelonghiAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Delonghi.cpp:163
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
IRDelonghiAc::_saved_temp
uint8_t _saved_temp
The previously user requested temp value.
Definition: ir_Delonghi.h:161
kDelonghiAcOnTimerMinsOffset
const uint8_t kDelonghiAcOnTimerMinsOffset
Definition: ir_Delonghi.h:84
IRDelonghiAc::setOffTimerEnabled
void setOffTimerEnabled(const bool on)
Set the enable status of the Off Timer.
Definition: ir_Delonghi.cpp:402
kDelonghiAcFanMedium
const uint8_t kDelonghiAcFanMedium
Definition: ir_Delonghi.h:63
kDelonghiAcTempAutoDryMode
const uint8_t kDelonghiAcTempAutoDryMode
Definition: ir_Delonghi.h:56
kDelonghiAcFanLow
const uint8_t kDelonghiAcFanLow
Definition: ir_Delonghi.h:64
IRDelonghiAc::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Delonghi.cpp:125
IRDelonghiAc::on
void on()
Change the power setting to On.
Definition: ir_Delonghi.cpp:156
IRDelonghiAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Delonghi.cpp:317
IRsend.h
IRDelonghiAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Delonghi.h:113
IRDelonghiAc::stateReset
void stateReset()
Reset the internal state to a fixed known good state.
Definition: ir_Delonghi.cpp:138
IRDelonghiAc::getPower
bool getPower()
Get the value of the current power setting.
Definition: ir_Delonghi.cpp:169
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:176
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRDelonghiAc::getOnTimerEnabled
bool getOnTimerEnabled(void)
Get the enable status of the On Timer.
Definition: ir_Delonghi.cpp:374
IRDelonghiAc::convertFan
uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Delonghi.cpp:256
String
std::string String
Definition: IRremoteESP8266.h:1128
kDelonghiAcModeSize
const uint8_t kDelonghiAcModeSize
Definition: ir_Delonghi.h:69
kDelonghiAcFanAuto
const uint8_t kDelonghiAcFanAuto
Definition: ir_Delonghi.h:61
kDelonghiAcChecksumOffset
const uint8_t kDelonghiAcChecksumOffset
Definition: ir_Delonghi.h:94
IRDelonghiAc::setOnTimerEnabled
void setOnTimerEnabled(const bool on)
Set the enable status of the On Timer.
Definition: ir_Delonghi.cpp:368
kDelonghiAcTempSize
const uint8_t kDelonghiAcTempSize
Definition: ir_Delonghi.h:51
kDelonghiAcTempMaxF
const uint8_t kDelonghiAcTempMaxF
Definition: ir_Delonghi.h:55
IRDelonghiAc::getOffTimer
uint16_t getOffTimer(void)
Get the Off timer time.
Definition: ir_Delonghi.cpp:427
IRDelonghiAc::getBoost
bool getBoost()
Get the Boost (Turbo) mode of the A/C.
Definition: ir_Delonghi.cpp:350
IRremoteESP8266.h
kDelonghiAcAuto
const uint8_t kDelonghiAcAuto
Definition: ir_Delonghi.h:73
kDelonghiAcOffTimerMinsOffset
const uint8_t kDelonghiAcOffTimerMinsOffset
Definition: ir_Delonghi.h:91
kDelonghiAcBoostBit
const uint8_t kDelonghiAcBoostBit
Definition: ir_Delonghi.h:74
kDelonghiAcSleepBit
const uint8_t kDelonghiAcSleepBit
Definition: ir_Delonghi.h:76
kDelonghiAcPowerBit
const uint8_t kDelonghiAcPowerBit
Definition: ir_Delonghi.h:67
kDelonghiAcFanSize
const uint8_t kDelonghiAcFanSize
Definition: ir_Delonghi.h:60
IRDelonghiAc::getTempUnit
bool getTempUnit(void)
Get the temperature scale unit of measure currently in use.
Definition: ir_Delonghi.cpp:181
kDelonghiAcOnTimerEnableBit
const uint8_t kDelonghiAcOnTimerEnableBit
Definition: ir_Delonghi.h:78
IRDelonghiAc::checksum
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition: ir_Delonghi.cpp:132
IRDelonghiAc::setSleep
void setSleep(const bool on)
Set the Sleep mode of the A/C.
Definition: ir_Delonghi.cpp:356
kDelonghiAcDefaultRepeat
const uint16_t kDelonghiAcDefaultRepeat
Definition: IRremoteESP8266.h:887
IRDelonghiAc::_saved_temp_units
uint8_t _saved_temp_units
The previously user requested temp units.
Definition: ir_Delonghi.h:162
kDelonghiAcTimerMax
const uint16_t kDelonghiAcTimerMax
Definition: ir_Delonghi.h:81
IRDelonghiAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Delonghi.cpp:291
IRDelonghiAc::setTemp
void setTemp(const uint8_t temp, const bool fahrenheit=false, const bool force=false)
Set the temperature.
Definition: ir_Delonghi.cpp:189
IRDelonghiAc::setOffTimer
void setOffTimer(const uint16_t nr_of_mins)
Set the Off timer to activate in nr of minutes.
Definition: ir_Delonghi.cpp:415
IRDelonghiAc::getOffTimerEnabled
bool getOffTimerEnabled(void)
Get the enable status of the Off Timer.
Definition: ir_Delonghi.cpp:408
kDelonghiAcMinsSize
const uint8_t kDelonghiAcMinsSize
Definition: ir_Delonghi.h:80
IRDelonghiAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Delonghi.cpp:113
IRDelonghiAc::_irsend
IRsend _irsend
instance of the IR send class
Definition: ir_Delonghi.h:154
kDelonghiAcTempUnitBit
const uint8_t kDelonghiAcTempUnitBit
Definition: ir_Delonghi.h:65
IRDelonghiAc::setTempUnit
void setTempUnit(const bool celsius)
Change the temperature scale units.
Definition: ir_Delonghi.cpp:175
IRDelonghiAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_Delonghi.cpp:436
IRDelonghiAc::getSleep
bool getSleep()
Get the Sleep mode status of the A/C.
Definition: ir_Delonghi.cpp:362
IRDelonghiAc::remote_state
uint64_t remote_state
The state of the IR remote.
Definition: ir_Delonghi.h:160
IRDelonghiAc::getFan
uint8_t getFan()
Get the current native fan speed setting.
Definition: ir_Delonghi.cpp:249
kDelonghiAcOffTimerEnableBit
const uint8_t kDelonghiAcOffTimerEnableBit
Definition: ir_Delonghi.h:87
kDelonghiAcDry
const uint8_t kDelonghiAcDry
Definition: ir_Delonghi.h:71
kDelonghiAcFan
const uint8_t kDelonghiAcFan
Definition: ir_Delonghi.h:72
IRDelonghiAc::getRaw
uint64_t getRaw()
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Delonghi.cpp:146
kDelonghiAcChecksumSize
const uint8_t kDelonghiAcChecksumSize
Definition: ir_Delonghi.h:96
kDelonghiAcHoursSize
const uint8_t kDelonghiAcHoursSize
Definition: ir_Delonghi.h:79
IRDelonghiAc::getMode
uint8_t getMode()
Get the operating mode setting of the A/C.
Definition: ir_Delonghi.cpp:285
IRDelonghiAc::toString
String toString()
Convert the current internal state into a human readable string.
Definition: ir_Delonghi.cpp:462
kDelonghiAcFanOffset
const uint8_t kDelonghiAcFanOffset
Definition: ir_Delonghi.h:58
IRDelonghiAc::setBoost
void setBoost(const bool on)
Set the Boost (Turbo) mode of the A/C.
Definition: ir_Delonghi.cpp:344
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
IRDelonghiAc::off
void off()
Change the power setting to Off.
Definition: ir_Delonghi.cpp:159
kDelonghiAcTempMinF
const uint8_t kDelonghiAcTempMinF
Definition: ir_Delonghi.h:54
kDelonghiAcOffTimerHoursOffset
const uint8_t kDelonghiAcOffTimerHoursOffset
Definition: ir_Delonghi.h:89
kDelonghiAcTempMaxC
const uint8_t kDelonghiAcTempMaxC
Definition: ir_Delonghi.h:53
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46