IRremoteESP8266
ir_Ecoclim.h
Go to the documentation of this file.
1 // Copyright 2021 David Conran
2 
6 
7 // Supports:
8 // Brand: EcoClim, Model: HYSFR-P348 remote
9 // Brand: EcoClim, Model: ZC200DPO A/C
10 
11 #ifndef IR_ECOCLIM_H_
12 #define IR_ECOCLIM_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 // Constants
26 // Modes
27 const uint8_t kEcoclimAuto = 0b000;
28 const uint8_t kEcoclimCool = 0b001;
29 const uint8_t kEcoclimDry = 0b010;
30 const uint8_t kEcoclimRecycle = 0b011;
31 const uint8_t kEcoclimFan = 0b100;
32 const uint8_t kEcoclimHeat = 0b101;
33 const uint8_t kEcoclimSleep = 0b111;
34 // Fan Control
35 const uint8_t kEcoclimFanMin = 0b00;
36 const uint8_t kEcoclimFanMed = 0b01;
37 const uint8_t kEcoclimFanMax = 0b10;
38 const uint8_t kEcoclimFanAuto = 0b11;
39 // DIP settings
40 const uint8_t kEcoclimDipMaster = 0b0000;
41 const uint8_t kEcoclimDipSlave = 0b0111;
42 // Temperature
43 const uint8_t kEcoclimTempMin = 5; // Celsius
44 const uint8_t kEcoclimTempMax = kEcoclimTempMin + 31; // Celsius
45 // Timer
46 const uint16_t kEcoclimTimerDisable = 0x1F * 60 + 7 * 10; // 4774
47 
48 // Power: Off, Mode: Auto, Temp: 11C, Sensor: 22C, Fan: Auto, Clock: 00:00
49 const uint64_t kEcoclimDefaultState = 0x11063000FFFF02;
50 
53  uint64_t raw;
54  struct { // Only 56 bits (7 bytes are used.
55  // Byte
56  uint64_t :3;
57  uint64_t :1;
58  uint64_t DipConfig :4;
59  // Byte
60  uint64_t OffTenMins :3;
61  uint64_t OffHours :5;
62  // Byte
63  uint64_t OnTenMins :3;
64  uint64_t OnHours :5;
65  // Byte+Byte
66  uint64_t Clock :11;
67  uint64_t :1;
68  uint64_t Fan :2;
69  uint64_t Power :1;
70  uint64_t Clear :1; // Not sure what this is
71  // Byte
72  uint64_t Temp :5;
73  uint64_t Mode :3;
74  // Byte
75  uint64_t SensorTemp :5;
76  uint64_t :3;
77  };
78 };
79 
80 // Classes
81 
84 class IREcoclimAc {
85  public:
86  explicit IREcoclimAc(const uint16_t pin, const bool inverted = false,
87  const bool use_modulation = true);
88  void stateReset(void);
89 #if SEND_ECOCLIM
90  void send(const uint16_t repeat = kNoRepeat);
95  int8_t calibrate(void) { return _irsend.calibrate(); }
96 #endif // SEND_ECOCLIM
97  void begin(void);
98  void on(void);
99  void off(void);
100  void setPower(const bool on);
101  bool getPower(void) const;
102  void setTemp(const uint8_t celsius);
103  uint8_t getTemp(void) const;
104  void setSensorTemp(const uint8_t celsius);
105  uint8_t getSensorTemp(void) const;
106  void setFan(const uint8_t speed);
107  uint8_t getFan(void) const;
108  void setMode(const uint8_t mode);
109  uint8_t getMode(void) const;
110  void setClock(const uint16_t nr_of_mins);
111  uint16_t getClock(void) const;
112  uint64_t getRaw(void) const;
113  void setRaw(const uint64_t new_code);
114  void setType(const uint8_t code);
115  uint8_t getType(void) const;
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  void setOnTimer(const uint16_t nr_of_mins);
122  uint16_t getOnTimer(void) const;
123  bool isOnTimerEnabled(void) const;
124  void disableOnTimer(void);
125  void setOffTimer(const uint16_t nr_of_mins);
126  uint16_t getOffTimer(void) const;
127  bool isOffTimerEnabled(void) const;
128  void disableOffTimer(void);
129  String toString(void) const;
130 #ifndef UNIT_TEST
131 
132  private:
134 #else // UNIT_TEST
135  IRsendTest _irsend;
137 #endif // UNIT_TEST
140 };
141 
142 #endif // IR_ECOCLIM_H_
IREcoclimAc::isOnTimerEnabled
bool isOnTimerEnabled(void) const
Check if the On Timer is enabled.
Definition: ir_Ecoclim.cpp:322
EcoclimProtocol::OffHours
uint64_t OffHours
Off Timer nr of Hours.
Definition: ir_Ecoclim.h:61
EcoclimProtocol::Mode
uint64_t Mode
Operating Mode.
Definition: ir_Ecoclim.h:73
EcoclimProtocol::OnTenMins
uint64_t OnTenMins
On Timer minutes (in tens of mins)
Definition: ir_Ecoclim.h:63
IREcoclimAc::getRaw
uint64_t getRaw(void) const
Get a copy of the internal state as a valid code for this protocol.
Definition: ir_Ecoclim.cpp:146
kEcoclimDipMaster
const uint8_t kEcoclimDipMaster
Definition: ir_Ecoclim.h:40
kEcoclimFanMed
const uint8_t kEcoclimFanMed
1
Definition: ir_Ecoclim.h:36
IREcoclimAc::stateReset
void stateReset(void)
Reset the internal state to a fixed known good state.
Definition: ir_Ecoclim.cpp:131
IREcoclimAc::getType
uint8_t getType(void) const
Get the Unit type/DIP switch settings of the remote.
Definition: ir_Ecoclim.cpp:290
IREcoclimAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Ecoclim.cpp:361
IREcoclimAc::setSensorTemp
void setSensorTemp(const uint8_t celsius)
Set the sensor temperature.
Definition: ir_Ecoclim.cpp:167
EcoclimProtocol::Fan
uint64_t Fan
Fan Speed.
Definition: ir_Ecoclim.h:68
IREcoclimAc::getSensorTemp
uint8_t getSensorTemp(void) const
Get the sensor temperature setting.
Definition: ir_Ecoclim.cpp:176
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IREcoclimAc::getClock
uint16_t getClock(void) const
Get the clock time of the A/C unit.
Definition: ir_Ecoclim.cpp:280
IREcoclimAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Ecoclim.cpp:196
kEcoclimDefaultState
const uint64_t kEcoclimDefaultState
Definition: ir_Ecoclim.h:49
kEcoclimFanMin
const uint8_t kEcoclimFanMin
0
Definition: ir_Ecoclim.h:35
IREcoclimAc::on
void on(void)
Change the power setting to On.
Definition: ir_Ecoclim.cpp:189
kEcoclimDipSlave
const uint8_t kEcoclimDipSlave
Definition: ir_Ecoclim.h:41
IRsend.h
kEcoclimSleep
const uint8_t kEcoclimSleep
7
Definition: ir_Ecoclim.h:33
IREcoclimAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Ecoclim.cpp:186
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
EcoclimProtocol::raw
uint64_t raw
The state in IR code form.
Definition: ir_Ecoclim.h:53
String
std::string String
Definition: IRremoteESP8266.h:1521
kEcoclimTempMin
const uint8_t kEcoclimTempMin
Definition: ir_Ecoclim.h:43
IREcoclimAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Ecoclim.cpp:163
kEcoclimFanMax
const uint8_t kEcoclimFanMax
2
Definition: ir_Ecoclim.h:37
kEcoclimFanAuto
const uint8_t kEcoclimFanAuto
3
Definition: ir_Ecoclim.h:38
kEcoclimTimerDisable
const uint16_t kEcoclimTimerDisable
Definition: ir_Ecoclim.h:46
IREcoclimAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a standard A/C mode into its native mode.
Definition: ir_Ecoclim.cpp:255
IREcoclimAc::off
void off(void)
Change the power setting to Off.
Definition: ir_Ecoclim.cpp:192
IREcoclimAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Ecoclim.cpp:221
EcoclimProtocol::Clock
uint64_t Clock
Definition: ir_Ecoclim.h:66
IREcoclimAc::setRaw
void setRaw(const uint64_t new_code)
Set the internal state from a valid code for this protocol.
Definition: ir_Ecoclim.cpp:150
IREcoclimAc::setTemp
void setTemp(const uint8_t celsius)
Set the temperature.
Definition: ir_Ecoclim.cpp:154
kEcoclimTempMax
const uint8_t kEcoclimTempMax
Definition: ir_Ecoclim.h:44
IRremoteESP8266.h
kEcoclimRecycle
const uint8_t kEcoclimRecycle
3
Definition: ir_Ecoclim.h:30
IREcoclimAc::setOffTimer
void setOffTimer(const uint16_t nr_of_mins)
Set & enable the Off Timer for the A/C.
Definition: ir_Ecoclim.cpp:334
IREcoclimAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Ecoclim.cpp:236
IREcoclimAc::isOffTimerEnabled
bool isOffTimerEnabled(void) const
Check if the Off Timer is enabled.
Definition: ir_Ecoclim.cpp:349
EcoclimProtocol::Clear
uint64_t Clear
Definition: ir_Ecoclim.h:70
kEcoclimCool
const uint8_t kEcoclimCool
1
Definition: ir_Ecoclim.h:28
kNoRepeat
const uint16_t kNoRepeat
Definition: IRremoteESP8266.h:1145
IREcoclimAc::setType
void setType(const uint8_t code)
Set the Unit type/DIP switch settings for the remote.
Definition: ir_Ecoclim.cpp:294
EcoclimProtocol::Power
uint64_t Power
Power control.
Definition: ir_Ecoclim.h:69
kEcoclimDry
const uint8_t kEcoclimDry
2
Definition: ir_Ecoclim.h:29
IREcoclimAc::send
void send(const uint16_t repeat=kNoRepeat)
Send the current internal state as an IR message.
Definition: ir_Ecoclim.cpp:139
IREcoclimAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Ecoclim.cpp:182
IREcoclimAc::setClock
void setClock(const uint16_t nr_of_mins)
Set the clock time on the A/C unit.
Definition: ir_Ecoclim.cpp:284
EcoclimProtocol::Temp
uint64_t Temp
Desired Temperature (Celsius)
Definition: ir_Ecoclim.h:72
IREcoclimAc::getOnTimer
uint16_t getOnTimer(void) const
Get the On Timer for the A/C.
Definition: ir_Ecoclim.cpp:316
IREcoclimAc::disableOnTimer
void disableOnTimer(void)
Disable & clear the On Timer.
Definition: ir_Ecoclim.cpp:327
IREcoclimAc::IREcoclimAc
IREcoclimAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Ecoclim.cpp:126
IREcoclimAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Ecoclim.h:133
IREcoclimAc
Class for handling detailed EcoClim A/C 56 bit messages.
Definition: ir_Ecoclim.h:84
IREcoclimAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Ecoclim.cpp:134
kEcoclimAuto
const uint8_t kEcoclimAuto
0. a.k.a Slave
Definition: ir_Ecoclim.h:27
IREcoclimAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Ecoclim.h:95
IREcoclimAc::toString
String toString(void) const
Convert the internal state into a human readable string.
Definition: ir_Ecoclim.cpp:388
IREcoclimAc::getOffTimer
uint16_t getOffTimer(void) const
Get the Off Timer for the A/C.
Definition: ir_Ecoclim.cpp:343
kEcoclimHeat
const uint8_t kEcoclimHeat
5
Definition: ir_Ecoclim.h:32
EcoclimProtocol::OnHours
uint64_t OnHours
On Timer nr of Hours.
Definition: ir_Ecoclim.h:64
IREcoclimAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Ecoclim.cpp:200
EcoclimProtocol::SensorTemp
uint64_t SensorTemp
Sensed Temperature (Celsius)
Definition: ir_Ecoclim.h:75
IREcoclimAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Ecoclim.cpp:207
EcoclimProtocol
Native representation of a Ecoclim A/C message.
Definition: ir_Ecoclim.h:52
IREcoclimAc::disableOffTimer
void disableOffTimer(void)
Disable & clear the Off Timer.
Definition: ir_Ecoclim.cpp:354
IREcoclimAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode to it's common stdAc::opmode_t equivalent.
Definition: ir_Ecoclim.cpp:268
IREcoclimAc::_
EcoclimProtocol _
The state of the IR remote in IR code form.
Definition: ir_Ecoclim.h:139
IREcoclimAc::setOnTimer
void setOnTimer(const uint16_t nr_of_mins)
Set & enable the On Timer for the A/C.
Definition: ir_Ecoclim.cpp:307
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
IREcoclimAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Ecoclim.cpp:232
EcoclimProtocol::DipConfig
uint64_t DipConfig
0b0000 = Master, 0b0111 = Slave
Definition: ir_Ecoclim.h:58
kEcoclimFan
const uint8_t kEcoclimFan
4
Definition: ir_Ecoclim.h:31
EcoclimProtocol::OffTenMins
uint64_t OffTenMins
Off Timer minutes (in tens of mins)
Definition: ir_Ecoclim.h:60
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49