IRremoteESP8266
Loading...
Searching...
No Matches
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
80const uint8_t kNeoclimaButtonPower = 0x00;
81const uint8_t kNeoclimaButtonMode = 0x01;
82const uint8_t kNeoclimaButtonTempUp = 0x02;
83const uint8_t kNeoclimaButtonTempDown = 0x03;
84const uint8_t kNeoclimaButtonSwing = 0x04;
85const uint8_t kNeoclimaButtonFanSpeed = 0x05;
86const uint8_t kNeoclimaButtonAirFlow = 0x07;
87const uint8_t kNeoclimaButtonHold = 0x08;
88const uint8_t kNeoclimaButtonSleep = 0x09;
89const uint8_t kNeoclimaButtonTurbo = 0x0A;
90const uint8_t kNeoclimaButtonLight = 0x0B;
91const uint8_t kNeoclimaButtonEcono = 0x0D;
92const uint8_t kNeoclimaButtonEye = 0x0E;
93const uint8_t kNeoclimaButtonFollow = 0x13;
94const uint8_t kNeoclimaButtonIon = 0x14;
95const uint8_t kNeoclimaButtonFresh = 0x15;
96const uint8_t kNeoclimaButton8CHeat = 0x1D;
97const uint8_t kNeoclimaButtonTempUnit = 0x1E;
98
99const uint8_t kNeoclimaSwingVOn = 0b01;
100const uint8_t kNeoclimaSwingVOff = 0b10;
101const uint8_t kNeoclimaFanAuto = 0b00;
102const uint8_t kNeoclimaFanHigh = 0b01;
103const uint8_t kNeoclimaFanMed = 0b10;
104const uint8_t kNeoclimaFanLow = 0b11;
105
106const uint8_t kNeoclimaFollowMe = 0x5D; // Also 0x5F
107
108const uint8_t kNeoclimaMinTempC = 16; // 16C
109const uint8_t kNeoclimaMaxTempC = 32; // 32C
110const uint8_t kNeoclimaMinTempF = 61; // 61F
111const uint8_t kNeoclimaMaxTempF = 90; // 90F
112const uint8_t kNeoclimaAuto = 0b000;
113const uint8_t kNeoclimaCool = 0b001;
114const uint8_t kNeoclimaDry = 0b010;
115const uint8_t kNeoclimaFan = 0b011;
116const 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
191 IRsendTest _irsend;
193#endif // UNIT_TEST
195 void checksum(const uint16_t length = kNeoclimaStateLength);
196};
197
198#endif // IR_NEOCLIMA_H_
const uint16_t kNeoclimaMinRepeat
Definition IRremoteESP8266.h:1365
const uint16_t kNeoclimaStateLength
Definition IRremoteESP8266.h:1363
std::string String
Definition IRremoteESP8266.h:1564
Class for handling detailed Neoclima A/C messages.
Definition ir_Neoclima.h:120
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Neoclima.cpp:486
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Neoclima.cpp:255
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Neoclima.cpp:178
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition ir_Neoclima.cpp:323
bool getTempUnits(void) const
Is the A/C unit using Fahrenheit or Celsius for temperature units.
Definition ir_Neoclima.cpp:463
void setSwingH(const bool on)
Set the horizontal swing setting of the A/C.
Definition ir_Neoclima.cpp:342
void setLight(const bool on)
Set the Light(LED display) setting of the A/C.
Definition ir_Neoclima.cpp:420
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Neoclima.cpp:116
uint8_t getButton(void) const
Get the Button/Command setting of the A/C.
Definition ir_Neoclima.cpp:159
void send(const uint16_t repeat=kNeoclimaMinRepeat)
Send the current internal state as an IR message.
Definition ir_Neoclima.cpp:109
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Neoclima.cpp:226
bool getEye(void) const
Get the Eye (Sensor) setting of the A/C.
Definition ir_Neoclima.cpp:457
bool getLight(void) const
Get the Light (LED display) setting of the A/C.
Definition ir_Neoclima.cpp:427
void setHold(const bool on)
Set the Hold setting of the A/C.
Definition ir_Neoclima.cpp:394
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Neoclima.cpp:206
void set8CHeat(const bool on)
Set the 8°C Heat setting of the A/C.
Definition ir_Neoclima.cpp:437
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
IRsend _irsend
Instance of the IR send class.
Definition ir_Neoclima.h:188
NeoclimaProtocol _
Definition ir_Neoclima.h:194
bool getIon(void) const
Get the Ion (filter) setting of the A/C.
Definition ir_Neoclima.cpp:414
void setIon(const bool on)
Set the Ion (filter) setting of the A/C.
Definition ir_Neoclima.cpp:407
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition ir_Neoclima.cpp:70
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Neoclima.cpp:305
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Neoclima.cpp:514
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
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Neoclima.cpp:284
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Neoclima.cpp:213
void setFresh(const bool on)
Set the Fresh (air) setting of the A/C.
Definition ir_Neoclima.cpp:381
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Neoclima.h:131
bool getFollow(void) const
Get the Follow Me setting of the A/C.
Definition ir_Neoclima.cpp:480
void setButton(const uint8_t button)
Set the Button/Command pressed setting of the A/C.
Definition ir_Neoclima.cpp:130
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
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Neoclima.cpp:263
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Neoclima.cpp:77
bool getTurbo(void) const
Get the Turbo setting of the A/C.
Definition ir_Neoclima.cpp:362
void off(void)
Set the requested power state of the A/C to off.
Definition ir_Neoclima.cpp:167
bool getSwingH(void) const
Get the horizontal swing (Air Flow) setting of the A/C.
Definition ir_Neoclima.cpp:349
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition ir_Neoclima.cpp:355
void setSwingV(const bool on)
Set the vertical swing setting of the A/C.
Definition ir_Neoclima.cpp:329
bool getSwingV(void) const
Get the vertical swing setting of the A/C.
Definition ir_Neoclima.cpp:336
void setEye(const bool on)
Set the Eye (Sensor) setting of the A/C.
Definition ir_Neoclima.cpp:450
void on(void)
Set the requested power state of the A/C to on.
Definition ir_Neoclima.cpp:164
bool get8CHeat(void) const
Get the 8°C Heat setting of the A/C.
Definition ir_Neoclima.cpp:444
void setPower(const bool on)
Change the power setting.
Definition ir_Neoclima.cpp:171
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
void checksum(const uint16_t length=kNeoclimaStateLength)
Calculate & update the checksum for the internal state.
Definition ir_Neoclima.cpp:101
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition ir_Neoclima.cpp:316
bool getFresh(void) const
Get the Fresh (air) setting of the A/C.
Definition ir_Neoclima.cpp:388
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Neoclima.cpp:184
bool getHold(void) const
Get the Hold setting of the A/C.
Definition ir_Neoclima.cpp:401
void setTemp(const uint8_t temp, const bool celsius=true)
Set the temperature.
Definition ir_Neoclima.cpp:239
bool getEcono(void) const
Get the Economy (Energy Saver) setting of the A/C.
Definition ir_Neoclima.cpp:375
void setEcono(const bool on)
Set the Economy (Energy Saver) setting of the A/C.
Definition ir_Neoclima.cpp:368
Class for sending all basic IR protocols.
Definition IRsend.h:249
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:209
const uint8_t kNeoclimaButtonPower
Definition ir_Neoclima.h:80
const uint8_t kNeoclimaButtonIon
Definition ir_Neoclima.h:94
const uint8_t kNeoclimaFanMed
Definition ir_Neoclima.h:103
const uint8_t kNeoclimaMinTempC
Definition ir_Neoclima.h:108
const uint8_t kNeoclimaButtonEcono
Definition ir_Neoclima.h:91
const uint8_t kNeoclimaAuto
Definition ir_Neoclima.h:112
const uint8_t kNeoclimaFollowMe
Definition ir_Neoclima.h:106
const uint8_t kNeoclimaButtonMode
Definition ir_Neoclima.h:81
const uint8_t kNeoclimaFanHigh
Definition ir_Neoclima.h:102
const uint8_t kNeoclimaButtonFollow
Definition ir_Neoclima.h:93
const uint8_t kNeoclimaHeat
Definition ir_Neoclima.h:116
const uint8_t kNeoclimaButtonFresh
Definition ir_Neoclima.h:95
const uint8_t kNeoclimaButtonEye
Definition ir_Neoclima.h:92
const uint8_t kNeoclimaSwingVOn
Definition ir_Neoclima.h:99
const uint8_t kNeoclimaFanAuto
Definition ir_Neoclima.h:101
const uint8_t kNeoclimaMaxTempF
Definition ir_Neoclima.h:111
const uint8_t kNeoclimaMaxTempC
Definition ir_Neoclima.h:109
const uint8_t kNeoclimaFan
Definition ir_Neoclima.h:115
const uint8_t kNeoclimaButtonHold
Definition ir_Neoclima.h:87
const uint8_t kNeoclimaButtonFanSpeed
Definition ir_Neoclima.h:85
const uint8_t kNeoclimaButtonAirFlow
Definition ir_Neoclima.h:86
const uint8_t kNeoclimaDry
Definition ir_Neoclima.h:114
const uint8_t kNeoclimaButtonTempUp
Definition ir_Neoclima.h:82
const uint8_t kNeoclimaCool
Definition ir_Neoclima.h:113
const uint8_t kNeoclimaMinTempF
Definition ir_Neoclima.h:110
const uint8_t kNeoclimaButtonLight
Definition ir_Neoclima.h:90
const uint8_t kNeoclimaFanLow
Definition ir_Neoclima.h:104
const uint8_t kNeoclimaSwingVOff
Definition ir_Neoclima.h:100
const uint8_t kNeoclimaButton8CHeat
Definition ir_Neoclima.h:96
const uint8_t kNeoclimaButtonTempUnit
Definition ir_Neoclima.h:97
const uint8_t kNeoclimaButtonSleep
Definition ir_Neoclima.h:88
const uint8_t kNeoclimaButtonTempDown
Definition ir_Neoclima.h:83
const uint8_t kNeoclimaButtonSwing
Definition ir_Neoclima.h:84
const uint8_t kNeoclimaButtonTurbo
Definition ir_Neoclima.h:89
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:61
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:49
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Neoclima A/C message.
Definition ir_Neoclima.h:30
uint8_t Power
Definition ir_Neoclima.h:61
uint8_t SwingH
Definition ir_Neoclima.h:63
uint8_t Turbo
Definition ir_Neoclima.h:46
uint8_t Light
Definition ir_Neoclima.h:43
uint8_t SwingV
Definition ir_Neoclima.h:62
uint8_t Eye
Definition ir_Neoclima.h:49
uint8_t Temp
Definition ir_Neoclima.h:69
uint8_t Follow
Definition ir_Neoclima.h:67
uint8_t Sum
Definition ir_Neoclima.h:74
uint8_t raw[kNeoclimaStateLength]
State of the remote in code.
Definition ir_Neoclima.h:31
uint8_t Hold
Definition ir_Neoclima.h:45
uint8_t CHeat
Definition ir_Neoclima.h:37
uint8_t Sleep
Definition ir_Neoclima.h:60
uint8_t Fan
Definition ir_Neoclima.h:64
uint8_t Fresh
Definition ir_Neoclima.h:56
uint8_t Mode
Definition ir_Neoclima.h:70
uint8_t UseFah
Definition ir_Neoclima.h:65
uint8_t Econo
Definition ir_Neoclima.h:47
uint8_t Button
Definition ir_Neoclima.h:54
uint8_t Ion
Definition ir_Neoclima.h:38