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 
27  uint64_t raw;
28  struct {
29  uint8_t :8; // Header
30  uint8_t Temp :5;
31  uint8_t Fan :2;
32  uint8_t Fahrenheit:1;
33  uint8_t Power :1;
34  uint8_t Mode :3;
35  uint8_t Boost :1;
36  uint8_t Sleep :1;
37  uint8_t :2;
38  uint8_t OnTimer :1;
39  uint8_t OnHours :5;
40  uint8_t :2;
41  uint8_t OnMins :6;
42  uint8_t :2;
43  uint8_t OffTimer :1;
44  uint8_t OffHours :5;
45  uint8_t :2;
46  uint8_t OffMins :6;
47  uint8_t :2;
48  uint8_t Sum :8;
49  };
50 };
51 
52 // Constants
53 const uint8_t kDelonghiAcTempMinC = 18; // Deg C
54 const uint8_t kDelonghiAcTempMaxC = 32; // Deg C
55 const uint8_t kDelonghiAcTempMinF = 64; // Deg F
56 const uint8_t kDelonghiAcTempMaxF = 90; // Deg F
57 const uint8_t kDelonghiAcTempAutoDryMode = 0;
58 const uint8_t kDelonghiAcTempFanMode = 0b00110;
59 const uint8_t kDelonghiAcFanAuto = 0b00;
60 const uint8_t kDelonghiAcFanHigh = 0b01;
61 const uint8_t kDelonghiAcFanMedium = 0b10;
62 const uint8_t kDelonghiAcFanLow = 0b11;
63 const uint8_t kDelonghiAcCool = 0b000;
64 const uint8_t kDelonghiAcDry = 0b001;
65 const uint8_t kDelonghiAcFan = 0b010;
66 const uint8_t kDelonghiAcAuto = 0b100;
67 const uint16_t kDelonghiAcTimerMax = 23 * 60 + 59;
68 const uint8_t kDelonghiAcChecksumOffset = 56;
69 
70 // Classes
71 
73 class IRDelonghiAc {
74  public:
75  explicit IRDelonghiAc(const uint16_t pin, const bool inverted = false,
76  const bool use_modulation = true);
77  void stateReset(void);
78 #if SEND_DELONGHI_AC
79  void send(const uint16_t repeat = kDelonghiAcDefaultRepeat);
84  int8_t calibrate(void) { return _irsend.calibrate(); }
85 #endif // SEND_DELONGHI_AC
86  void begin(void);
87  static uint8_t calcChecksum(const uint64_t state);
88  static bool validChecksum(const uint64_t state);
89  void setPower(const bool on);
90  bool getPower(void) const;
91  void on(void);
92  void off(void);
93  void setTempUnit(const bool celsius);
94  bool getTempUnit(void) const;
95  void setTemp(const uint8_t temp, const bool fahrenheit = false,
96  const bool force = false);
97  uint8_t getTemp(void) const;
98  void setFan(const uint8_t speed);
99  uint8_t getFan(void) const;
100  void setMode(const uint8_t mode);
101  uint8_t getMode(void) const;
102  void setBoost(const bool on); // Aka Turbo
103  bool getBoost(void) const; // Aka Turbo
104  void setSleep(const bool on);
105  bool getSleep(void) const;
106  void setOnTimerEnabled(const bool on);
107  bool getOnTimerEnabled(void) const;
108  void setOnTimer(const uint16_t nr_of_mins);
109  uint16_t getOnTimer(void) const;
110  void setOffTimerEnabled(const bool on);
111  bool getOffTimerEnabled(void) const;
112  void setOffTimer(const uint16_t nr_of_mins);
113  uint16_t getOffTimer(void) const;
114  uint64_t getRaw(void);
115  void setRaw(const uint64_t state);
116  static uint8_t convertMode(const stdAc::opmode_t mode);
117  static uint8_t convertFan(const stdAc::fanspeed_t speed);
118  static stdAc::opmode_t toCommonMode(const uint8_t mode);
119  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
120  stdAc::state_t toCommon(void) const;
121  String toString(void) const;
122 #ifndef UNIT_TEST
123 
124  private:
126 #else
127  IRsendTest _irsend;
129 #endif
132  uint8_t _saved_temp;
134  void checksum(void);
135 };
136 #endif // IR_DELONGHI_H_
DelonghiProtocol::OnTimer
uint8_t OnTimer
Definition: ir_Delonghi.h:38
IRDelonghiAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Delonghi.cpp:270
DelonghiProtocol::OnMins
uint8_t OnMins
Definition: ir_Delonghi.h:41
kDelonghiAcCool
const uint8_t kDelonghiAcCool
Definition: ir_Delonghi.h:63
IRDelonghiAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Delonghi.cpp:217
IRDelonghiAc::send
void send(const uint16_t repeat=kDelonghiAcDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_Delonghi.cpp:103
IRDelonghiAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Delonghi.cpp:330
IRDelonghiAc::setRaw
void setRaw(const uint64_t state)
Set the internal state from a valid code for this protocol.
Definition: ir_Delonghi.cpp:150
DelonghiProtocol::Mode
uint8_t Mode
Definition: ir_Delonghi.h:34
kDelonghiAcTempFanMode
const uint8_t kDelonghiAcTempFanMode
Definition: ir_Delonghi.h:58
IRDelonghiAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Delonghi.cpp:449
DelonghiProtocol::Temp
uint8_t Temp
Definition: ir_Delonghi.h:30
IRDelonghiAc::on
void on(void)
Change the power setting to On.
Definition: ir_Delonghi.cpp:153
IRDelonghiAc
Class for handling detailed Delonghi A/C messages.
Definition: ir_Delonghi.h:73
IRDelonghiAc::IRDelonghiAc
IRDelonghiAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Delonghi.cpp:93
kDelonghiAcTempMinC
const uint8_t kDelonghiAcTempMinC
Definition: ir_Delonghi.h:53
kDelonghiAcFanHigh
const uint8_t kDelonghiAcFanHigh
Definition: ir_Delonghi.h:60
IRDelonghiAc::setOnTimer
void setOnTimer(const uint16_t nr_of_mins)
Set the On timer to activate in nr of minutes.
Definition: ir_Delonghi.cpp:378
IRDelonghiAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Delonghi.cpp:160
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRDelonghiAc::_saved_temp
uint8_t _saved_temp
The previously user requested temp value.
Definition: ir_Delonghi.h:132
IRDelonghiAc::setOffTimerEnabled
void setOffTimerEnabled(const bool on)
Set the enable status of the Off Timer.
Definition: ir_Delonghi.cpp:394
kDelonghiAcFanMedium
const uint8_t kDelonghiAcFanMedium
Definition: ir_Delonghi.h:61
kDelonghiAcTempAutoDryMode
const uint8_t kDelonghiAcTempAutoDryMode
Definition: ir_Delonghi.h:57
IRDelonghiAc::getOffTimerEnabled
bool getOffTimerEnabled(void) const
Get the enable status of the Off Timer.
Definition: ir_Delonghi.cpp:400
kDelonghiAcFanLow
const uint8_t kDelonghiAcFanLow
Definition: ir_Delonghi.h:62
DelonghiProtocol::OffTimer
uint8_t OffTimer
Definition: ir_Delonghi.h:43
IRDelonghiAc::validChecksum
static bool validChecksum(const uint64_t state)
Verify the checksum is valid for a given state.
Definition: ir_Delonghi.cpp:123
IRDelonghiAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Delonghi.cpp:314
IRsend.h
IRDelonghiAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Delonghi.h:84
IRDelonghiAc::_
DelonghiProtocol _
Definition: ir_Delonghi.h:131
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
DelonghiProtocol::OnHours
uint8_t OnHours
Definition: ir_Delonghi.h:39
IRDelonghiAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Delonghi.cpp:98
IRDelonghiAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Delonghi.cpp:166
IRDelonghiAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Delonghi.cpp:252
String
std::string String
Definition: IRremoteESP8266.h:1521
IRDelonghiAc::getTempUnit
bool getTempUnit(void) const
Get the temperature scale unit of measure currently in use.
Definition: ir_Delonghi.cpp:178
DelonghiProtocol::Power
uint8_t Power
Definition: ir_Delonghi.h:33
IRDelonghiAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Delonghi.cpp:281
IRDelonghiAc::getOnTimer
uint16_t getOnTimer(void) const
Get the On timer time.
Definition: ir_Delonghi.cpp:388
IRDelonghiAc::getOffTimer
uint16_t getOffTimer(void) const
Get the Off timer time.
Definition: ir_Delonghi.cpp:417
kDelonghiAcFanAuto
const uint8_t kDelonghiAcFanAuto
Definition: ir_Delonghi.h:59
kDelonghiAcChecksumOffset
const uint8_t kDelonghiAcChecksumOffset
Definition: ir_Delonghi.h:68
IRDelonghiAc::setOnTimerEnabled
void setOnTimerEnabled(const bool on)
Set the enable status of the On Timer.
Definition: ir_Delonghi.cpp:365
kDelonghiAcTempMaxF
const uint8_t kDelonghiAcTempMaxF
Definition: ir_Delonghi.h:56
IRremoteESP8266.h
kDelonghiAcAuto
const uint8_t kDelonghiAcAuto
Definition: ir_Delonghi.h:66
IRDelonghiAc::getSleep
bool getSleep(void) const
Get the Sleep mode status of the A/C.
Definition: ir_Delonghi.cpp:359
DelonghiProtocol::Fahrenheit
uint8_t Fahrenheit
Definition: ir_Delonghi.h:32
DelonghiProtocol::Boost
uint8_t Boost
Definition: ir_Delonghi.h:35
IRDelonghiAc::getBoost
bool getBoost(void) const
Get the Boost (Turbo) mode of the A/C.
Definition: ir_Delonghi.cpp:347
IRDelonghiAc::checksum
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition: ir_Delonghi.cpp:130
IRDelonghiAc::setSleep
void setSleep(const bool on)
Set the Sleep mode of the A/C.
Definition: ir_Delonghi.cpp:353
kDelonghiAcDefaultRepeat
const uint16_t kDelonghiAcDefaultRepeat
Definition: IRremoteESP8266.h:1221
IRDelonghiAc::_saved_temp_units
uint8_t _saved_temp_units
The previously user requested temp units.
Definition: ir_Delonghi.h:133
kDelonghiAcTimerMax
const uint16_t kDelonghiAcTimerMax
Definition: ir_Delonghi.h:67
DelonghiProtocol::Fan
uint8_t Fan
Definition: ir_Delonghi.h:31
IRDelonghiAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Delonghi.cpp:287
IRDelonghiAc::getOnTimerEnabled
bool getOnTimerEnabled(void) const
Get the enable status of the On Timer.
Definition: ir_Delonghi.cpp:371
IRDelonghiAc::setTemp
void setTemp(const uint8_t temp, const bool fahrenheit=false, const bool force=false)
Set the temperature.
Definition: ir_Delonghi.cpp:186
IRDelonghiAc::setOffTimer
void setOffTimer(const uint16_t nr_of_mins)
Set the Off timer to activate in nr of minutes.
Definition: ir_Delonghi.cpp:407
IRDelonghiAc::getRaw
uint64_t getRaw(void)
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Delonghi.cpp:143
IRDelonghiAc::calcChecksum
static uint8_t calcChecksum(const uint64_t state)
Calculate the checksum for a given state.
Definition: ir_Delonghi.cpp:111
IRDelonghiAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Delonghi.cpp:210
IRDelonghiAc::_irsend
IRsend _irsend
instance of the IR send class
Definition: ir_Delonghi.h:125
IRDelonghiAc::setTempUnit
void setTempUnit(const bool celsius)
Change the temperature scale units.
Definition: ir_Delonghi.cpp:172
IRDelonghiAc::getFan
uint8_t getFan(void) const
Get the current native fan speed setting.
Definition: ir_Delonghi.cpp:245
DelonghiProtocol::OffHours
uint8_t OffHours
Definition: ir_Delonghi.h:44
kDelonghiAcDry
const uint8_t kDelonghiAcDry
Definition: ir_Delonghi.h:64
DelonghiProtocol::OffMins
uint8_t OffMins
Definition: ir_Delonghi.h:46
kDelonghiAcFan
const uint8_t kDelonghiAcFan
Definition: ir_Delonghi.h:65
DelonghiProtocol::Sum
uint8_t Sum
Definition: ir_Delonghi.h:48
DelonghiProtocol::Sleep
uint8_t Sleep
Definition: ir_Delonghi.h:36
IRDelonghiAc::stateReset
void stateReset(void)
Reset the internal state to a fixed known good state.
Definition: ir_Delonghi.cpp:135
DelonghiProtocol::raw
uint64_t raw
The state of the IR remote.
Definition: ir_Delonghi.h:27
DelonghiProtocol
Native representation of a Delonghi A/C message.
Definition: ir_Delonghi.h:26
IRDelonghiAc::setBoost
void setBoost(const bool on)
Set the Boost (Turbo) mode of the A/C.
Definition: ir_Delonghi.cpp:341
IRDelonghiAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Delonghi.cpp:423
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
kDelonghiAcTempMinF
const uint8_t kDelonghiAcTempMinF
Definition: ir_Delonghi.h:55
IRDelonghiAc::off
void off(void)
Change the power setting to Off.
Definition: ir_Delonghi.cpp:156
kDelonghiAcTempMaxC
const uint8_t kDelonghiAcTempMaxC
Definition: ir_Delonghi.h:54
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49