# IRremoteESP8266: src/ir_Delonghi.h Source File

ir_Delonghi.h
Go to the documentation of this file.
// Copyright 2020 David Conran
// Supports:
// Brand: Delonghi, Model: PAC A95
#ifndef IR_DELONGHI_H_
#define IR_DELONGHI_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
union DelonghiProtocol{
uint64_t raw;
struct {
uint8_t :8; // Header
uint8_t Temp :5;
uint8_t Fan :2;
uint8_t Fahrenheit:1;
uint8_t Power :1;
uint8_t Mode :3;
uint8_t Boost :1;
uint8_t Sleep :1;
uint8_t :2;
uint8_t OnTimer :1;
uint8_t OnHours :5;
uint8_t :2;
uint8_t OnMins :6;
uint8_t :2;
uint8_t OffTimer :1;
uint8_t OffHours :5;
uint8_t :2;
uint8_t OffMins :6;
uint8_t :2;
uint8_t Sum :8;
};
};
// Constants
const uint8_t kDelonghiAcTempMinC = 18; // Deg C
const uint8_t kDelonghiAcTempMaxC = 32; // Deg C
const uint8_t kDelonghiAcTempMinF = 64; // Deg F
const uint8_t kDelonghiAcTempMaxF = 90; // Deg F
const uint8_t kDelonghiAcTempAutoDryMode = 0;
const uint8_t kDelonghiAcTempFanMode = 0b00110;
const uint8_t kDelonghiAcFanAuto = 0b00;
const uint8_t kDelonghiAcFanHigh = 0b01;
const uint8_t kDelonghiAcFanMedium = 0b10;
const uint8_t kDelonghiAcFanLow = 0b11;
const uint8_t kDelonghiAcCool = 0b000;
const uint8_t kDelonghiAcDry = 0b001;
const uint8_t kDelonghiAcFan = 0b010;
const uint8_t kDelonghiAcAuto = 0b100;
const uint16_t kDelonghiAcTimerMax = 23 * 60 + 59;
const uint8_t kDelonghiAcChecksumOffset = 56;
// Classes
class IRDelonghiAc {
public:
explicit IRDelonghiAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_DELONGHI_AC
void send(const uint16_t repeat = kDelonghiAcDefaultRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_DELONGHI_AC
void begin(void);
static uint8_t calcChecksum(const uint64_t state);
static bool validChecksum(const uint64_t state);
void setPower(const bool on);
bool getPower(void) const;
void on(void);
void off(void);
void setTempUnit(const bool celsius);
bool getTempUnit(void) const;
void setTemp(const uint8_t temp, const bool fahrenheit = false,
const bool force = false);
uint8_t getTemp(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setBoost(const bool on); // Aka Turbo
bool getBoost(void) const; // Aka Turbo
void setSleep(const bool on);
bool getSleep(void) const;
void setOnTimerEnabled(const bool on);
bool getOnTimerEnabled(void) const;
void setOnTimer(const uint16_t nr_of_mins);
uint16_t getOnTimer(void) const;
void setOffTimerEnabled(const bool on);
bool getOffTimerEnabled(void) const;
void setOffTimer(const uint16_t nr_of_mins);
uint16_t getOffTimer(void) const;
uint64_t getRaw(void);
void setRaw(const uint64_t state);
static uint8_t convertMode(const stdAc::opmode_t mode);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else
IRsendTest _irsend;
#endif
DelonghiProtocol _;
uint8_t _saved_temp;
uint8_t _saved_temp_units;
void checksum(void);
};
#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:58
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:182
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:1178
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:927
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:97
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:46