IRremoteESP8266
ir_Neoclima.h
Go to the documentation of this file.
1 // Copyright 2019 David Conran
2 
8 
9 // Supports:
10 // Brand: Neoclima, Model: NS-09AHTI A/C
11 // Brand: Neoclima, Model: ZH/TY-01 remote
12 // Brand: Soleus Air, Model: TTWM1-10-01 A/C
13 // Brand: Soleus Air, Model: ZCF/TL-05 remote
14 
15 #ifndef IR_NEOCLIMA_H_
16 #define IR_NEOCLIMA_H_
17 
18 #define __STDC_LIMIT_MACROS
19 #include <stdint.h>
20 #ifndef UNIT_TEST
21 #include <Arduino.h>
22 #endif
23 #include "IRremoteESP8266.h"
24 #include "IRsend.h"
25 #ifdef UNIT_TEST
26 #include "IRsend_test.h"
27 #endif
28 
32  struct {
33  // Byte 0
34  uint8_t :8;
35  // Byte 1
36  uint8_t :1;
37  uint8_t CHeat :1;
38  uint8_t Ion :1;
39  uint8_t :5;
40  // Byte 2
41  uint8_t :8;
42  // Byte 3
43  uint8_t Light :1;
44  uint8_t :1;
45  uint8_t Hold :1;
46  uint8_t Turbo :1;
47  uint8_t Econo :1;
48  uint8_t :1;
49  uint8_t Eye :1;
50  uint8_t :1;
51  // Byte 4
52  uint8_t :8;
53  // Byte 5
54  uint8_t Button :5;
55  uint8_t :2;
56  uint8_t Fresh :1;
57  // Byte 6
58  uint8_t :8;
59  // Byte 7
60  uint8_t Sleep :1;
61  uint8_t Power :1;
62  uint8_t SwingV :2;
63  uint8_t SwingH :1;
64  uint8_t Fan :2;
65  uint8_t UseFah :1;
66  // Byte 8
67  uint8_t Follow :8;
68  // Byte 9
69  uint8_t Temp :5;
70  uint8_t Mode :3;
71  // Byte 10
72  uint8_t :8;
73  // Byte 11
74  uint8_t Sum :8;
75  };
76 };
77 
78 // Constants
79 
80 const uint8_t kNeoclimaButtonPower = 0x00;
81 const uint8_t kNeoclimaButtonMode = 0x01;
82 const uint8_t kNeoclimaButtonTempUp = 0x02;
83 const uint8_t kNeoclimaButtonTempDown = 0x03;
84 const uint8_t kNeoclimaButtonSwing = 0x04;
85 const uint8_t kNeoclimaButtonFanSpeed = 0x05;
86 const uint8_t kNeoclimaButtonAirFlow = 0x07;
87 const uint8_t kNeoclimaButtonHold = 0x08;
88 const uint8_t kNeoclimaButtonSleep = 0x09;
89 const uint8_t kNeoclimaButtonTurbo = 0x0A;
90 const uint8_t kNeoclimaButtonLight = 0x0B;
91 const uint8_t kNeoclimaButtonEcono = 0x0D;
92 const uint8_t kNeoclimaButtonEye = 0x0E;
93 const uint8_t kNeoclimaButtonFollow = 0x13;
94 const uint8_t kNeoclimaButtonIon = 0x14;
95 const uint8_t kNeoclimaButtonFresh = 0x15;
96 const uint8_t kNeoclimaButton8CHeat = 0x1D;
97 const uint8_t kNeoclimaButtonTempUnit = 0x1E;
98 
99 const uint8_t kNeoclimaSwingVOn = 0b01;
100 const uint8_t kNeoclimaSwingVOff = 0b10;
101 const uint8_t kNeoclimaFanAuto = 0b00;
102 const uint8_t kNeoclimaFanHigh = 0b01;
103 const uint8_t kNeoclimaFanMed = 0b10;
104 const uint8_t kNeoclimaFanLow = 0b11;
105 
106 const uint8_t kNeoclimaFollowMe = 0x5D; // Also 0x5F
107 
108 const uint8_t kNeoclimaMinTempC = 16; // 16C
109 const uint8_t kNeoclimaMaxTempC = 32; // 32C
110 const uint8_t kNeoclimaMinTempF = 61; // 61F
111 const uint8_t kNeoclimaMaxTempF = 90; // 90F
112 const uint8_t kNeoclimaAuto = 0b000;
113 const uint8_t kNeoclimaCool = 0b001;
114 const uint8_t kNeoclimaDry = 0b010;
115 const uint8_t kNeoclimaFan = 0b011;
116 const uint8_t kNeoclimaHeat = 0b100;
117 
118 // Classes
121  public:
122  explicit IRNeoclimaAc(const uint16_t pin, const bool inverted = false,
123  const bool use_modulation = true);
124  void stateReset(void);
125 #if SEND_NEOCLIMA
126  void send(const uint16_t repeat = kNeoclimaMinRepeat);
131  int8_t calibrate(void) { return _irsend.calibrate(); }
132 #endif // SEND_NEOCLIMA
133  void begin(void);
134  void setButton(const uint8_t button);
135  uint8_t getButton(void) const;
136  void on(void);
137  void off(void);
138  void setPower(const bool on);
139  bool getPower(void) const;
140  void setMode(const uint8_t mode);
141  uint8_t getMode(void) const;
142  void setTemp(const uint8_t temp, const bool celsius = true);
143  uint8_t getTemp(void) const;
144  void setFan(const uint8_t speed);
145  uint8_t getFan(void) const;
146  void setSwingV(const bool on);
147  bool getSwingV(void) const;
148  void setSwingH(const bool on);
149  bool getSwingH(void) const;
150  void setSleep(const bool on);
151  bool getSleep(void) const;
152  void setTurbo(const bool on);
153  bool getTurbo(void) const;
154  void setEcono(const bool on);
155  bool getEcono(void) const;
156  void setFresh(const bool on);
157  bool getFresh(void) const;
158  void setHold(const bool on);
159  bool getHold(void) const;
160  void setIon(const bool on);
161  bool getIon(void) const;
162  void setLight(const bool on);
163  bool getLight(void) const;
164  void set8CHeat(const bool on);
165  bool get8CHeat(void) const;
166  void setEye(const bool on);
167  bool getEye(void) const;
168  bool getTempUnits(void) const;
169  // DISABLED: See TODO in ir_Neoclima.cpp
170  // void setFollow(const bool on);
171  bool getFollow(void) const;
172  uint8_t* getRaw(void);
173  void setRaw(const uint8_t new_code[],
174  const uint16_t length = kNeoclimaStateLength);
175  static bool validChecksum(const uint8_t state[],
176  const uint16_t length = kNeoclimaStateLength);
177  static uint8_t calcChecksum(const uint8_t state[],
178  const uint16_t length = kNeoclimaStateLength);
179  String toString(void) const;
180  static uint8_t convertMode(const stdAc::opmode_t mode);
181  static uint8_t convertFan(const stdAc::fanspeed_t speed);
182  static stdAc::opmode_t toCommonMode(const uint8_t mode);
183  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
184  stdAc::state_t toCommon(void) const;
185 #ifndef UNIT_TEST
186 
187  private:
189 #else // UNIT_TEST
190  IRsendTest _irsend;
192 #endif // UNIT_TEST
195  void checksum(const uint16_t length = kNeoclimaStateLength);
196 };
197 
198 #endif // IR_NEOCLIMA_H_
IRNeoclimaAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_Neoclima.cpp:178
NeoclimaProtocol::Hold
uint8_t Hold
Definition: ir_Neoclima.h:45
kNeoclimaFanHigh
const uint8_t kNeoclimaFanHigh
Definition: ir_Neoclima.h:102
IRNeoclimaAc::getEcono
bool getEcono(void) const
Get the Economy (Energy Saver) setting of the A/C.
Definition: ir_Neoclima.cpp:375
IRNeoclimaAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Neoclima.cpp:305
kNeoclimaMinTempC
const uint8_t kNeoclimaMinTempC
Definition: ir_Neoclima.h:108
kNeoclimaButtonFanSpeed
const uint8_t kNeoclimaButtonFanSpeed
Definition: ir_Neoclima.h:85
kNeoclimaButtonTurbo
const uint8_t kNeoclimaButtonTurbo
Definition: ir_Neoclima.h:89
kNeoclimaFollowMe
const uint8_t kNeoclimaFollowMe
Definition: ir_Neoclima.h:106
IRNeoclimaAc::_
NeoclimaProtocol _
Definition: ir_Neoclima.h:194
NeoclimaProtocol::Mode
uint8_t Mode
Definition: ir_Neoclima.h:70
kNeoclimaMaxTempC
const uint8_t kNeoclimaMaxTempC
Definition: ir_Neoclima.h:109
NeoclimaProtocol::raw
uint8_t raw[kNeoclimaStateLength]
State of the remote in code.
Definition: ir_Neoclima.h:31
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
NeoclimaProtocol::SwingV
uint8_t SwingV
Definition: ir_Neoclima.h:62
kNeoclimaDry
const uint8_t kNeoclimaDry
Definition: ir_Neoclima.h:114
IRNeoclimaAc::calcChecksum
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kNeoclimaStateLength)
Calculate the checksum for a given state.
Definition: ir_Neoclima.cpp:83
IRNeoclimaAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Neoclima.h:131
NeoclimaProtocol::SwingH
uint8_t SwingH
Definition: ir_Neoclima.h:63
IRNeoclimaAc::set8CHeat
void set8CHeat(const bool on)
Set the 8°C Heat setting of the A/C.
Definition: ir_Neoclima.cpp:437
kNeoclimaButtonEye
const uint8_t kNeoclimaButtonEye
Definition: ir_Neoclima.h:92
kNeoclimaButtonPower
const uint8_t kNeoclimaButtonPower
Definition: ir_Neoclima.h:80
IRNeoclimaAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Neoclima.cpp:263
kNeoclimaSwingVOn
const uint8_t kNeoclimaSwingVOn
Definition: ir_Neoclima.h:99
kNeoclimaButtonMode
const uint8_t kNeoclimaButtonMode
Definition: ir_Neoclima.h:81
kNeoclimaStateLength
const uint16_t kNeoclimaStateLength
Definition: IRremoteESP8266.h:1333
NeoclimaProtocol
Native representation of a Neoclima A/C message.
Definition: ir_Neoclima.h:30
IRNeoclimaAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Neoclima.cpp:284
IRNeoclimaAc::setHold
void setHold(const bool on)
Set the Hold setting of the A/C.
Definition: ir_Neoclima.cpp:394
kNeoclimaMinTempF
const uint8_t kNeoclimaMinTempF
Definition: ir_Neoclima.h:110
IRNeoclimaAc::setRaw
void setRaw(const uint8_t new_code[], const uint16_t length=kNeoclimaStateLength)
Set the internal state from a valid code for this protocol.
Definition: ir_Neoclima.cpp:124
kNeoclimaButtonHold
const uint8_t kNeoclimaButtonHold
Definition: ir_Neoclima.h:87
NeoclimaProtocol::Power
uint8_t Power
Definition: ir_Neoclima.h:61
IRNeoclimaAc::setEcono
void setEcono(const bool on)
Set the Economy (Energy Saver) setting of the A/C.
Definition: ir_Neoclima.cpp:368
NeoclimaProtocol::Eye
uint8_t Eye
Definition: ir_Neoclima.h:49
IRNeoclimaAc::setTemp
void setTemp(const uint8_t temp, const bool celsius=true)
Set the temperature.
Definition: ir_Neoclima.cpp:239
IRsend.h
IRNeoclimaAc::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Neoclima.cpp:323
IRNeoclimaAc::getTurbo
bool getTurbo(void) const
Get the Turbo setting of the A/C.
Definition: ir_Neoclima.cpp:362
IRNeoclimaAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Neoclima.cpp:206
kNeoclimaAuto
const uint8_t kNeoclimaAuto
Definition: ir_Neoclima.h:112
kNeoclimaMaxTempF
const uint8_t kNeoclimaMaxTempF
Definition: ir_Neoclima.h:111
IRNeoclimaAc::setLight
void setLight(const bool on)
Set the Light(LED display) setting of the A/C.
Definition: ir_Neoclima.cpp:420
kNeoclimaFan
const uint8_t kNeoclimaFan
Definition: ir_Neoclima.h:115
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
IRNeoclimaAc::get8CHeat
bool get8CHeat(void) const
Get the 8°C Heat setting of the A/C.
Definition: ir_Neoclima.cpp:444
NeoclimaProtocol::Sleep
uint8_t Sleep
Definition: ir_Neoclima.h:60
IRNeoclimaAc::getRaw
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition: ir_Neoclima.cpp:116
kNeoclimaFanAuto
const uint8_t kNeoclimaFanAuto
Definition: ir_Neoclima.h:101
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
NeoclimaProtocol::Econo
uint8_t Econo
Definition: ir_Neoclima.h:47
String
std::string String
Definition: IRremoteESP8266.h:1521
IRNeoclimaAc::getEye
bool getEye(void) const
Get the Eye (Sensor) setting of the A/C.
Definition: ir_Neoclima.cpp:457
IRNeoclimaAc::getButton
uint8_t getButton(void) const
Get the Button/Command setting of the A/C.
Definition: ir_Neoclima.cpp:159
IRNeoclimaAc::getIon
bool getIon(void) const
Get the Ion (filter) setting of the A/C.
Definition: ir_Neoclima.cpp:414
kNeoclimaButtonFresh
const uint8_t kNeoclimaButtonFresh
Definition: ir_Neoclima.h:95
NeoclimaProtocol::Turbo
uint8_t Turbo
Definition: ir_Neoclima.h:46
kNeoclimaButtonEcono
const uint8_t kNeoclimaButtonEcono
Definition: ir_Neoclima.h:91
NeoclimaProtocol::Temp
uint8_t Temp
Definition: ir_Neoclima.h:69
kNeoclimaButtonAirFlow
const uint8_t kNeoclimaButtonAirFlow
Definition: ir_Neoclima.h:86
IRremoteESP8266.h
NeoclimaProtocol::Button
uint8_t Button
Definition: ir_Neoclima.h:54
NeoclimaProtocol::CHeat
uint8_t CHeat
Definition: ir_Neoclima.h:37
IRNeoclimaAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Neoclima.cpp:70
IRNeoclimaAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Neoclima.cpp:291
kNeoclimaButtonTempDown
const uint8_t kNeoclimaButtonTempDown
Definition: ir_Neoclima.h:83
IRNeoclimaAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Neoclima.cpp:77
kNeoclimaButtonLight
const uint8_t kNeoclimaButtonLight
Definition: ir_Neoclima.h:90
IRNeoclimaAc::setIon
void setIon(const bool on)
Set the Ion (filter) setting of the A/C.
Definition: ir_Neoclima.cpp:407
IRNeoclimaAc::getLight
bool getLight(void) const
Get the Light (LED display) setting of the A/C.
Definition: ir_Neoclima.cpp:427
NeoclimaProtocol::Follow
uint8_t Follow
Definition: ir_Neoclima.h:67
kNeoclimaButtonSwing
const uint8_t kNeoclimaButtonSwing
Definition: ir_Neoclima.h:84
kNeoclimaButtonFollow
const uint8_t kNeoclimaButtonFollow
Definition: ir_Neoclima.h:93
IRNeoclimaAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Neoclima.h:188
kNeoclimaSwingVOff
const uint8_t kNeoclimaSwingVOff
Definition: ir_Neoclima.h:100
IRNeoclimaAc::getSwingV
bool getSwingV(void) const
Get the vertical swing setting of the A/C.
Definition: ir_Neoclima.cpp:336
IRNeoclimaAc::setSwingV
void setSwingV(const bool on)
Set the vertical swing setting of the A/C.
Definition: ir_Neoclima.cpp:329
IRNeoclimaAc::setEye
void setEye(const bool on)
Set the Eye (Sensor) setting of the A/C.
Definition: ir_Neoclima.cpp:450
IRNeoclimaAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Neoclima.cpp:226
kNeoclimaButtonSleep
const uint8_t kNeoclimaButtonSleep
Definition: ir_Neoclima.h:88
IRNeoclimaAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Neoclima.cpp:486
IRNeoclimaAc::on
void on(void)
Set the requested power state of the A/C to on.
Definition: ir_Neoclima.cpp:164
NeoclimaProtocol::UseFah
uint8_t UseFah
Definition: ir_Neoclima.h:65
kNeoclimaFanMed
const uint8_t kNeoclimaFanMed
Definition: ir_Neoclima.h:103
IRNeoclimaAc::getFresh
bool getFresh(void) const
Get the Fresh (air) setting of the A/C.
Definition: ir_Neoclima.cpp:388
kNeoclimaButtonTempUnit
const uint8_t kNeoclimaButtonTempUnit
Definition: ir_Neoclima.h:97
IRNeoclimaAc::setFresh
void setFresh(const bool on)
Set the Fresh (air) setting of the A/C.
Definition: ir_Neoclima.cpp:381
IRNeoclimaAc::getHold
bool getHold(void) const
Get the Hold setting of the A/C.
Definition: ir_Neoclima.cpp:401
IRNeoclimaAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_Neoclima.cpp:171
kNeoclimaCool
const uint8_t kNeoclimaCool
Definition: ir_Neoclima.h:113
kNeoclimaButton8CHeat
const uint8_t kNeoclimaButton8CHeat
Definition: ir_Neoclima.h:96
NeoclimaProtocol::Ion
uint8_t Ion
Definition: ir_Neoclima.h:38
IRNeoclimaAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Neoclima.cpp:255
IRNeoclimaAc::getFollow
bool getFollow(void) const
Get the Follow Me setting of the A/C.
Definition: ir_Neoclima.cpp:480
IRNeoclimaAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Neoclima.cpp:213
kNeoclimaHeat
const uint8_t kNeoclimaHeat
Definition: ir_Neoclima.h:116
IRNeoclimaAc::setButton
void setButton(const uint8_t button)
Set the Button/Command pressed setting of the A/C.
Definition: ir_Neoclima.cpp:130
kNeoclimaButtonIon
const uint8_t kNeoclimaButtonIon
Definition: ir_Neoclima.h:94
IRNeoclimaAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Neoclima.cpp:514
NeoclimaProtocol::Sum
uint8_t Sum
Definition: ir_Neoclima.h:74
IRNeoclimaAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Neoclima.cpp:184
kNeoclimaFanLow
const uint8_t kNeoclimaFanLow
Definition: ir_Neoclima.h:104
IRNeoclimaAc::setTurbo
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition: ir_Neoclima.cpp:355
IRNeoclimaAc::getTempUnits
bool getTempUnits(void) const
Is the A/C unit using Fahrenheit or Celsius for temperature units.
Definition: ir_Neoclima.cpp:463
NeoclimaProtocol::Light
uint8_t Light
Definition: ir_Neoclima.h:43
IRNeoclimaAc::getSwingH
bool getSwingH(void) const
Get the horizontal swing (Air Flow) setting of the A/C.
Definition: ir_Neoclima.cpp:349
IRNeoclimaAc::checksum
void checksum(const uint16_t length=kNeoclimaStateLength)
Calculate & update the checksum for the internal state.
Definition: ir_Neoclima.cpp:101
IRNeoclimaAc::setSwingH
void setSwingH(const bool on)
Set the horizontal swing setting of the A/C.
Definition: ir_Neoclima.cpp:342
IRNeoclimaAc::send
void send(const uint16_t repeat=kNeoclimaMinRepeat)
Send the current internal state as an IR message.
Definition: ir_Neoclima.cpp:109
IRNeoclimaAc::off
void off(void)
Set the requested power state of the A/C to off.
Definition: ir_Neoclima.cpp:167
NeoclimaProtocol::Fan
uint8_t Fan
Definition: ir_Neoclima.h:64
NeoclimaProtocol::Fresh
uint8_t Fresh
Definition: ir_Neoclima.h:56
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
kNeoclimaMinRepeat
const uint16_t kNeoclimaMinRepeat
Definition: IRremoteESP8266.h:1335
IRNeoclimaAc::IRNeoclimaAc
IRNeoclimaAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Neoclima.cpp:63
IRNeoclimaAc
Class for handling detailed Neoclima A/C messages.
Definition: ir_Neoclima.h:120
IRNeoclimaAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Neoclima.cpp:316
IRNeoclimaAc::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kNeoclimaStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Neoclima.cpp:93
kNeoclimaButtonTempUp
const uint8_t kNeoclimaButtonTempUp
Definition: ir_Neoclima.h:82
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49