IRremoteIDF
Infrared send & receive for ESP-IDF
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#include "IRplatform.h"
21#include "IRremoteESP8266.h"
22#include "IRsend.h"
23#ifdef UNIT_TEST
24#include "IRsend_test.h"
25#endif
26
30 struct {
31 // Byte 0
32 uint8_t :8;
33 // Byte 1
34 uint8_t :1;
35 uint8_t CHeat :1;
36 uint8_t Ion :1;
37 uint8_t :5;
38 // Byte 2
39 uint8_t :8;
40 // Byte 3
41 uint8_t Light :1;
42 uint8_t :1;
43 uint8_t Hold :1;
44 uint8_t Turbo :1;
45 uint8_t Econo :1;
46 uint8_t :1;
47 uint8_t Eye :1;
48 uint8_t :1;
49 // Byte 4
50 uint8_t :8;
51 // Byte 5
52 uint8_t Button :5;
53 uint8_t :2;
54 uint8_t Fresh :1;
55 // Byte 6
56 uint8_t :8;
57 // Byte 7
58 uint8_t Sleep :1;
59 uint8_t Power :1;
60 uint8_t SwingV :2;
61 uint8_t SwingH :1;
62 uint8_t Fan :2;
63 uint8_t UseFah :1;
64 // Byte 8
65 uint8_t Follow :8;
66 // Byte 9
67 uint8_t Temp :5;
68 uint8_t Mode :3;
69 // Byte 10
70 uint8_t :8;
71 // Byte 11
72 uint8_t Sum :8;
73 };
74};
75
76// Constants
77
78const uint8_t kNeoclimaButtonPower = 0x00;
79const uint8_t kNeoclimaButtonMode = 0x01;
80const uint8_t kNeoclimaButtonTempUp = 0x02;
81const uint8_t kNeoclimaButtonTempDown = 0x03;
82const uint8_t kNeoclimaButtonSwing = 0x04;
83const uint8_t kNeoclimaButtonFanSpeed = 0x05;
84const uint8_t kNeoclimaButtonAirFlow = 0x07;
85const uint8_t kNeoclimaButtonHold = 0x08;
86const uint8_t kNeoclimaButtonSleep = 0x09;
87const uint8_t kNeoclimaButtonTurbo = 0x0A;
88const uint8_t kNeoclimaButtonLight = 0x0B;
89const uint8_t kNeoclimaButtonEcono = 0x0D;
90const uint8_t kNeoclimaButtonEye = 0x0E;
91const uint8_t kNeoclimaButtonFollow = 0x13;
92const uint8_t kNeoclimaButtonIon = 0x14;
93const uint8_t kNeoclimaButtonFresh = 0x15;
94const uint8_t kNeoclimaButton8CHeat = 0x1D;
95const uint8_t kNeoclimaButtonTempUnit = 0x1E;
96
97const uint8_t kNeoclimaSwingVOn = 0b01;
98const uint8_t kNeoclimaSwingVOff = 0b10;
99const uint8_t kNeoclimaFanAuto = 0b00;
100const uint8_t kNeoclimaFanHigh = 0b01;
101const uint8_t kNeoclimaFanMed = 0b10;
102const uint8_t kNeoclimaFanLow = 0b11;
103
104const uint8_t kNeoclimaFollowMe = 0x5D; // Also 0x5F
105
106const uint8_t kNeoclimaMinTempC = 16; // 16C
107const uint8_t kNeoclimaMaxTempC = 32; // 32C
108const uint8_t kNeoclimaMinTempF = 61; // 61F
109const uint8_t kNeoclimaMaxTempF = 90; // 90F
110const uint8_t kNeoclimaAuto = 0b000;
111const uint8_t kNeoclimaCool = 0b001;
112const uint8_t kNeoclimaDry = 0b010;
113const uint8_t kNeoclimaFan = 0b011;
114const uint8_t kNeoclimaHeat = 0b100;
115
116// Classes
119 public:
120 explicit IRNeoclimaAc(const uint16_t pin, const bool inverted = false,
121 const bool use_modulation = true);
122 void stateReset(void);
123#if SEND_NEOCLIMA
124 void send(const uint16_t repeat = kNeoclimaMinRepeat);
129 int8_t calibrate(void) { return _irsend.calibrate(); }
130#endif // SEND_NEOCLIMA
131 void begin(void);
132 void setButton(const uint8_t button);
133 uint8_t getButton(void) const;
134 void on(void);
135 void off(void);
136 void setPower(const bool on);
137 bool getPower(void) const;
138 void setMode(const uint8_t mode);
139 uint8_t getMode(void) const;
140 void setTemp(const uint8_t temp, const bool celsius = true);
141 uint8_t getTemp(void) const;
142 void setFan(const uint8_t speed);
143 uint8_t getFan(void) const;
144 void setSwingV(const bool on);
145 bool getSwingV(void) const;
146 void setSwingH(const bool on);
147 bool getSwingH(void) const;
148 void setSleep(const bool on);
149 bool getSleep(void) const;
150 void setTurbo(const bool on);
151 bool getTurbo(void) const;
152 void setEcono(const bool on);
153 bool getEcono(void) const;
154 void setFresh(const bool on);
155 bool getFresh(void) const;
156 void setHold(const bool on);
157 bool getHold(void) const;
158 void setIon(const bool on);
159 bool getIon(void) const;
160 void setLight(const bool on);
161 bool getLight(void) const;
162 void set8CHeat(const bool on);
163 bool get8CHeat(void) const;
164 void setEye(const bool on);
165 bool getEye(void) const;
166 bool getTempUnits(void) const;
167 // DISABLED: See TODO in ir_Neoclima.cpp
168 // void setFollow(const bool on);
169 bool getFollow(void) const;
170 uint8_t* getRaw(void);
171 void setRaw(const uint8_t new_code[],
172 const uint16_t length = kNeoclimaStateLength);
173 static bool validChecksum(const uint8_t state[],
174 const uint16_t length = kNeoclimaStateLength);
175 static uint8_t calcChecksum(const uint8_t state[],
176 const uint16_t length = kNeoclimaStateLength);
177 String toString(void) const;
178 static uint8_t convertMode(const stdAc::opmode_t mode);
179 static uint8_t convertFan(const stdAc::fanspeed_t speed);
180 static stdAc::opmode_t toCommonMode(const uint8_t mode);
181 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
182 stdAc::state_t toCommon(void) const;
183#ifndef UNIT_TEST
184
185 private:
187#else // UNIT_TEST
189 IRsendTest _irsend;
191#endif // UNIT_TEST
193 void checksum(const uint16_t length = kNeoclimaStateLength);
194};
195
196#endif // IR_NEOCLIMA_H_
std::string String
The protocol code builds human readable output with String. On ESP-IDF that is just std::string.
Definition IRplatform.h:21
const uint16_t kNeoclimaMinRepeat
Definition IRremoteESP8266.h:1364
const uint16_t kNeoclimaStateLength
Definition IRremoteESP8266.h:1362
Class for handling detailed Neoclima A/C messages.
Definition ir_Neoclima.h:118
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:186
NeoclimaProtocol _
Definition ir_Neoclima.h:192
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:129
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:256
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:286
const uint8_t kNeoclimaButtonPower
Definition ir_Neoclima.h:78
const uint8_t kNeoclimaButtonIon
Definition ir_Neoclima.h:92
const uint8_t kNeoclimaFanMed
Definition ir_Neoclima.h:101
const uint8_t kNeoclimaMinTempC
Definition ir_Neoclima.h:106
const uint8_t kNeoclimaButtonEcono
Definition ir_Neoclima.h:89
const uint8_t kNeoclimaAuto
Definition ir_Neoclima.h:110
const uint8_t kNeoclimaFollowMe
Definition ir_Neoclima.h:104
const uint8_t kNeoclimaButtonMode
Definition ir_Neoclima.h:79
const uint8_t kNeoclimaFanHigh
Definition ir_Neoclima.h:100
const uint8_t kNeoclimaButtonFollow
Definition ir_Neoclima.h:91
const uint8_t kNeoclimaHeat
Definition ir_Neoclima.h:114
const uint8_t kNeoclimaButtonFresh
Definition ir_Neoclima.h:93
const uint8_t kNeoclimaButtonEye
Definition ir_Neoclima.h:90
const uint8_t kNeoclimaSwingVOn
Definition ir_Neoclima.h:97
const uint8_t kNeoclimaFanAuto
Definition ir_Neoclima.h:99
const uint8_t kNeoclimaMaxTempF
Definition ir_Neoclima.h:109
const uint8_t kNeoclimaMaxTempC
Definition ir_Neoclima.h:107
const uint8_t kNeoclimaFan
Definition ir_Neoclima.h:113
const uint8_t kNeoclimaButtonHold
Definition ir_Neoclima.h:85
const uint8_t kNeoclimaButtonFanSpeed
Definition ir_Neoclima.h:83
const uint8_t kNeoclimaButtonAirFlow
Definition ir_Neoclima.h:84
const uint8_t kNeoclimaDry
Definition ir_Neoclima.h:112
const uint8_t kNeoclimaButtonTempUp
Definition ir_Neoclima.h:80
const uint8_t kNeoclimaCool
Definition ir_Neoclima.h:111
const uint8_t kNeoclimaMinTempF
Definition ir_Neoclima.h:108
const uint8_t kNeoclimaButtonLight
Definition ir_Neoclima.h:88
const uint8_t kNeoclimaFanLow
Definition ir_Neoclima.h:102
const uint8_t kNeoclimaSwingVOff
Definition ir_Neoclima.h:98
const uint8_t kNeoclimaButton8CHeat
Definition ir_Neoclima.h:94
const uint8_t kNeoclimaButtonTempUnit
Definition ir_Neoclima.h:95
const uint8_t kNeoclimaButtonSleep
Definition ir_Neoclima.h:86
const uint8_t kNeoclimaButtonTempDown
Definition ir_Neoclima.h:81
const uint8_t kNeoclimaButtonSwing
Definition ir_Neoclima.h:82
const uint8_t kNeoclimaButtonTurbo
Definition ir_Neoclima.h:87
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:67
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:55
Structure to hold a common A/C state.
Definition IRsend.h:120
Native representation of a Neoclima A/C message.
Definition ir_Neoclima.h:28
uint8_t Power
Definition ir_Neoclima.h:59
uint8_t SwingH
Definition ir_Neoclima.h:61
uint8_t Turbo
Definition ir_Neoclima.h:44
uint8_t Light
Definition ir_Neoclima.h:41
uint8_t SwingV
Definition ir_Neoclima.h:60
uint8_t Eye
Definition ir_Neoclima.h:47
uint8_t Temp
Definition ir_Neoclima.h:67
uint8_t Follow
Definition ir_Neoclima.h:65
uint8_t Sum
Definition ir_Neoclima.h:72
uint8_t raw[kNeoclimaStateLength]
State of the remote in code.
Definition ir_Neoclima.h:29
uint8_t Hold
Definition ir_Neoclima.h:43
uint8_t CHeat
Definition ir_Neoclima.h:35
uint8_t Sleep
Definition ir_Neoclima.h:58
uint8_t Fan
Definition ir_Neoclima.h:62
uint8_t Fresh
Definition ir_Neoclima.h:54
uint8_t Mode
Definition ir_Neoclima.h:68
uint8_t UseFah
Definition ir_Neoclima.h:63
uint8_t Econo
Definition ir_Neoclima.h:45
uint8_t Button
Definition ir_Neoclima.h:52
uint8_t Ion
Definition ir_Neoclima.h:36