IRremoteESP8266
Loading...
Searching...
No Matches
ir_Gree.h
Go to the documentation of this file.
1// Copyright 2016-2022 David Conran
2
8
9// Supports:
10// Brand: Ultimate, Model: Heat Pump
11// Brand: EKOKAI, Model: A/C
12// Brand: RusClimate, Model: EACS/I-09HAR_X/N3 A/C
13// Brand: RusClimate, Model: YAW1F remote
14// Brand: Green, Model: YBOFB remote
15// Brand: Green, Model: YBOFB2 remote
16// Brand: Gree, Model: YAA1FBF remote
17// Brand: Gree, Model: YB1F2F remote
18// Brand: Gree, Model: YAN1F1 remote
19// Brand: Gree, Model: YX1F2F remote (YX1FSF)
20// Brand: Gree, Model: VIR09HP115V1AH A/C
21// Brand: Gree, Model: VIR12HP230V1AH A/C
22// Brand: Amana, Model: PBC093G00CC A/C
23// Brand: Amana, Model: YX1FF remote
24// Brand: Cooper & Hunter, Model: YB1F2 remote
25// Brand: Cooper & Hunter, Model: CH-S09FTXG A/C
26// Brand: Vailland, Model: YACIFB remote
27// Brand: Vailland, Model: VAI5-035WNI A/C
28// Brand: Soleus Air, Model: window A/C (YX1FSF)
29
30#ifndef IR_GREE_H_
31#define IR_GREE_H_
32
33#define __STDC_LIMIT_MACROS
34#include <stdint.h>
35#ifndef UNIT_TEST
36#include <Arduino.h>
37#endif
38#include "IRremoteESP8266.h"
39#include "IRsend.h"
40#ifdef UNIT_TEST
41#include "IRsend_test.h"
42#endif
43
47 struct {
48 // Byte 0
49 uint8_t Mode :3;
50 uint8_t Power :1;
51 uint8_t Fan :2;
52 uint8_t SwingAuto :1;
53 uint8_t Sleep :1;
54 // Byte 1
55 uint8_t Temp :4;
56 uint8_t TimerHalfHr :1;
57 uint8_t TimerTensHr :2;
58 uint8_t TimerEnabled:1;
59 // Byte 2
60 uint8_t TimerHours:4;
61 uint8_t Turbo :1;
62 uint8_t Light :1;
63 uint8_t ModelA :1; // model==YAW1F
64 uint8_t Xfan :1;
65 // Byte 3
66 uint8_t :2;
68 uint8_t UseFahrenheit :1;
69 uint8_t unknown1 :4; // value=0b0101
70 // Byte 4
71 uint8_t SwingV :4;
72 uint8_t SwingH :3;
73 uint8_t :1;
74 // Byte 5
75 uint8_t DisplayTemp :2;
76 uint8_t IFeel :1;
77 uint8_t unknown2 :3; // value = 0b100
78 uint8_t WiFi :1;
79 uint8_t :1;
80 // Byte 6
81 uint8_t :8;
82 // Byte 7
83 uint8_t :2;
84 uint8_t Econo :1;
85 uint8_t :1;
86 uint8_t Sum :4;
87 };
88};
89
90// Constants
91
92const uint8_t kGreeAuto = 0;
93const uint8_t kGreeCool = 1;
94const uint8_t kGreeDry = 2;
95const uint8_t kGreeFan = 3;
96const uint8_t kGreeHeat = 4;
97const uint8_t kGreeEcono = 5;
98
99const uint8_t kGreeFanAuto = 0;
100const uint8_t kGreeFanMin = 1;
101const uint8_t kGreeFanMed = 2;
102const uint8_t kGreeFanMax = 3;
103
104const uint8_t kGreeMinTempC = 16; // Celsius
105const uint8_t kGreeMaxTempC = 30; // Celsius
106const uint8_t kGreeMinTempF = 61; // Fahrenheit
107const uint8_t kGreeMaxTempF = 86; // Fahrenheit
108const uint16_t kGreeTimerMax = 24 * 60;
109
110const uint8_t kGreeSwingLastPos = 0b0000; // 0
111const uint8_t kGreeSwingAuto = 0b0001; // 1
112const uint8_t kGreeSwingUp = 0b0010; // 2
113const uint8_t kGreeSwingMiddleUp = 0b0011; // 3
114const uint8_t kGreeSwingMiddle = 0b0100; // 4
115const uint8_t kGreeSwingMiddleDown = 0b0101; // 5
116const uint8_t kGreeSwingDown = 0b0110; // 6
117const uint8_t kGreeSwingDownAuto = 0b0111; // 7
118const uint8_t kGreeSwingMiddleAuto = 0b1001; // 9
119const uint8_t kGreeSwingUpAuto = 0b1011; // 11
120
121const uint8_t kGreeSwingHOff = 0b000; // 0
122const uint8_t kGreeSwingHAuto = 0b001; // 1
123const uint8_t kGreeSwingHMaxLeft = 0b010; // 2
124const uint8_t kGreeSwingHLeft = 0b011; // 3
125const uint8_t kGreeSwingHMiddle = 0b100; // 4
126const uint8_t kGreeSwingHRight = 0b101; // 5
127const uint8_t kGreeSwingHMaxRight = 0b110; // 6
128
129const uint8_t kGreeDisplayTempOff = 0b00; // 0
130const uint8_t kGreeDisplayTempSet = 0b01; // 1
131const uint8_t kGreeDisplayTempInside = 0b10; // 2
132const uint8_t kGreeDisplayTempOutside = 0b11; // 3
133
134// Legacy defines.
135#define GREE_AUTO kGreeAuto
136#define GREE_COOL kGreeCool
137#define GREE_DRY kGreeDry
138#define GREE_FAN kGreeFan
139#define GREE_HEAT kGreeHeat
140#define GREE_MIN_TEMP kGreeMinTempC
141#define GREE_MAX_TEMP kGreeMaxTempC
142#define GREE_FAN_MAX kGreeFanMax
143#define GREE_SWING_LAST_POS kGreeSwingLastPos
144#define GREE_SWING_AUTO kGreeSwingAuto
145#define GREE_SWING_UP kGreeSwingUp
146#define GREE_SWING_MIDDLE_UP kGreeSwingMiddleUp
147#define GREE_SWING_MIDDLE kGreeSwingMiddle
148#define GREE_SWING_MIDDLE_DOWN kGreeSwingMiddleDown
149#define GREE_SWING_DOWN kGreeSwingDown
150#define GREE_SWING_DOWN_AUTO kGreeSwingDownAuto
151#define GREE_SWING_MIDDLE_AUTO kGreeSwingMiddleAuto
152#define GREE_SWING_UP_AUTO kGreeSwingUpAuto
153
154// Classes
156class IRGreeAC {
157 public:
158 explicit IRGreeAC(
159 const uint16_t pin,
161 const bool inverted = false, const bool use_modulation = true);
162 void stateReset(void);
163#if SEND_GREE
164 void send(const uint16_t repeat = kGreeDefaultRepeat);
169 int8_t calibrate(void) { return _irsend.calibrate(); }
170#endif // SEND_GREE
171 void begin(void);
172 void on(void);
173 void off(void);
174 void setModel(const gree_ac_remote_model_t model);
176 void setPower(const bool on);
177 bool getPower(void) const;
178 void setTemp(const uint8_t temp, const bool fahrenheit = false);
179 uint8_t getTemp(void) const;
180 void setUseFahrenheit(const bool on);
181 bool getUseFahrenheit(void) const;
182 void setFan(const uint8_t speed);
183 uint8_t getFan(void) const;
184 void setMode(const uint8_t new_mode);
185 uint8_t getMode(void) const;
186 void setLight(const bool on);
187 bool getLight(void) const;
188 void setXFan(const bool on);
189 bool getXFan(void) const;
190 void setSleep(const bool on);
191 bool getSleep(void) const;
192 void setTurbo(const bool on);
193 bool getTurbo(void) const;
194 void setEcono(const bool on);
195 bool getEcono(void) const;
196 void setIFeel(const bool on);
197 bool getIFeel(void) const;
198 void setWiFi(const bool on);
199 bool getWiFi(void) const;
200 void setSwingVertical(const bool automatic, const uint8_t position);
201 bool getSwingVerticalAuto(void) const;
202 uint8_t getSwingVerticalPosition(void) const;
203 void setSwingHorizontal(const uint8_t position);
204 uint8_t getSwingHorizontal(void) const;
205 uint16_t getTimer(void) const;
206 void setTimer(const uint16_t minutes);
207 void setDisplayTempSource(const uint8_t mode);
208 uint8_t getDisplayTempSource(void) const;
209 static uint8_t convertMode(const stdAc::opmode_t mode);
210 static uint8_t convertFan(const stdAc::fanspeed_t speed);
211 static uint8_t convertSwingV(const stdAc::swingv_t swingv);
212 static uint8_t convertSwingH(const stdAc::swingh_t swingh);
213 static stdAc::opmode_t toCommonMode(const uint8_t mode);
214 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
215 static stdAc::swingv_t toCommonSwingV(const uint8_t pos);
216 static stdAc::swingh_t toCommonSwingH(const uint8_t pos);
218 uint8_t* getRaw(void);
219 void setRaw(const uint8_t new_code[]);
220 static bool validChecksum(const uint8_t state[],
221 const uint16_t length = kGreeStateLength);
222 String toString(void);
223#ifndef UNIT_TEST
224
225 private:
227#else // UNIT_TEST
229 IRsendTest _irsend;
231#endif // UNIT_TEST
234 void checksum(const uint16_t length = kGreeStateLength);
235 void fixup(void);
236 void setTimerEnabled(const bool on);
237 bool getTimerEnabled(void) const;
238};
239
240#endif // IR_GREE_H_
const uint16_t kGreeStateLength
Definition IRremoteESP8266.h:1278
const uint16_t kGreeDefaultRepeat
Definition IRremoteESP8266.h:1280
std::string String
Definition IRremoteESP8266.h:1564
gree_ac_remote_model_t
Gree A/C model numbers.
Definition IRsend.h:155
@ YAW1F
Definition IRsend.h:156
Class for handling detailed Gree A/C messages.
Definition ir_Gree.h:156
static stdAc::swingh_t toCommonSwingH(const uint8_t pos)
Convert a native Horizontal Swing into its stdAc equivalent.
Definition ir_Gree.cpp:574
void setTimerEnabled(const bool on)
Set the timer enable setting of the A/C.
Definition ir_Gree.cpp:425
void setModel(const gree_ac_remote_model_t model)
Set the model of the A/C to emulate.
Definition ir_Gree.cpp:187
void setPower(const bool on)
Change the power setting.
Definition ir_Gree.cpp:209
void setTemp(const uint8_t temp, const bool fahrenheit=false)
Set the temp. in degrees.
Definition ir_Gree.cpp:238
void setSwingVertical(const bool automatic, const uint8_t position)
Set the Vertical Swing mode of the A/C.
Definition ir_Gree.cpp:373
void setDisplayTempSource(const uint8_t mode)
Set temperature display mode. i.e. Internal, External temperature sensing.
Definition ir_Gree.cpp:466
String toString(void)
Convert the current internal state into a human readable string.
Definition ir_Gree.cpp:619
uint8_t getDisplayTempSource(void) const
Get the temperature display mode. i.e. Internal, External temperature sensing.
Definition ir_Gree.cpp:473
bool getTurbo(void) const
Get the Turbo setting of the A/C.
Definition ir_Gree.cpp:354
IRsend _irsend
Instance of the IR send class.
Definition ir_Gree.h:226
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Gree.cpp:491
uint16_t getTimer(void) const
Get the timer time value from the A/C.
Definition ir_Gree.cpp:433
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Gree.cpp:535
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Gree.cpp:137
void setEcono(const bool on)
Set the Econo setting of the A/C.
Definition ir_Gree.cpp:358
bool getTimerEnabled(void) const
Get the timer enabled setting of the A/C.
Definition ir_Gree.cpp:429
void off(void)
Change the power setting to Off.
Definition ir_Gree.cpp:204
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Gree.cpp:306
static stdAc::swingv_t toCommonSwingV(const uint8_t pos)
Convert a native Vertical Swing into its stdAc equivalent.
Definition ir_Gree.cpp:560
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition ir_Gree.cpp:346
bool getUseFahrenheit(void) const
Get the default temperature units in use.
Definition ir_Gree.cpp:230
uint8_t getSwingVerticalPosition(void) const
Get the Vertical Swing position setting of the A/C.
Definition ir_Gree.cpp:408
void setRaw(const uint8_t new_code[])
Set the internal state from a valid code for this protocol.
Definition ir_Gree.cpp:156
void fixup(void)
Fix up the internal state so it is correct.
Definition ir_Gree.cpp:131
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Gree.cpp:478
void stateReset(void)
Reset the internal state to a fixed known good state.
Definition ir_Gree.cpp:120
bool getLight(void) const
Get the Light (LED) setting of the A/C.
Definition ir_Gree.cpp:314
bool getEcono(void) const
Get the Econo setting of the A/C.
Definition ir_Gree.cpp:366
void setIFeel(const bool on)
Set the IFeel setting of the A/C.
Definition ir_Gree.cpp:318
void on(void)
Change the power setting to On.
Definition ir_Gree.cpp:201
void setLight(const bool on)
Set the Light (LED) setting of the A/C.
Definition ir_Gree.cpp:310
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Gree.cpp:218
bool getIFeel(void) const
Get the IFeel setting of the A/C.
Definition ir_Gree.cpp:322
static bool validChecksum(const uint8_t state[], const uint16_t length=kGreeStateLength)
Verify the checksum is valid for a given state.
Definition ir_Gree.cpp:179
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Gree.h:169
void setTimer(const uint16_t minutes)
Set the A/C's timer to turn off in X many minutes.
Definition ir_Gree.cpp:443
void setSwingHorizontal(const uint8_t position)
Set the Horizontal Swing mode of the A/C.
Definition ir_Gree.cpp:416
uint8_t getTemp(void) const
Get the set temperature.
Definition ir_Gree.cpp:261
void send(const uint16_t repeat=kGreeDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Gree.cpp:142
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Gree.cpp:274
GreeProtocol _
Definition ir_Gree.h:232
void setMode(const uint8_t new_mode)
Set the operating mode of the A/C.
Definition ir_Gree.cpp:287
bool getWiFi(void) const
Get the Wifi (enabled) setting of the A/C.
Definition ir_Gree.cpp:330
bool getXFan(void) const
Get the XFan (Mould) setting of the A/C.
Definition ir_Gree.cpp:338
void checksum(const uint16_t length=kGreeStateLength)
Calculate and set the checksum values for the internal state.
Definition ir_Gree.cpp:170
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Gree.cpp:588
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition ir_Gree.cpp:342
static uint8_t convertSwingH(const stdAc::swingh_t swingh)
Convert a stdAc::swingh_t enum into it's native setting.
Definition ir_Gree.cpp:520
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Gree.cpp:548
uint8_t getSwingHorizontal(void) const
Get the Horizontal Swing position setting of the A/C.
Definition ir_Gree.cpp:412
gree_ac_remote_model_t _model
Definition ir_Gree.h:233
static uint8_t convertSwingV(const stdAc::swingv_t swingv)
Convert a stdAc::swingv_t enum into it's native setting.
Definition ir_Gree.cpp:505
gree_ac_remote_model_t getModel(void) const
Get/Detect the model of the A/C.
Definition ir_Gree.cpp:198
void setTurbo(const bool on)
Set the Turbo setting of the A/C.
Definition ir_Gree.cpp:350
void setXFan(const bool on)
Set the XFan (Mould) setting of the A/C.
Definition ir_Gree.cpp:334
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Gree.cpp:283
void setUseFahrenheit(const bool on)
Set the default temperature units to use.
Definition ir_Gree.cpp:226
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Gree.cpp:149
bool getSwingVerticalAuto(void) const
Get the Vertical Swing Automatic mode setting of the A/C.
Definition ir_Gree.cpp:404
void setWiFi(const bool on)
Set the Wifi (enabled) setting of the A/C.
Definition ir_Gree.cpp:326
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 kGreeSwingHMiddle
Definition ir_Gree.h:125
const uint8_t kGreeSwingMiddle
Definition ir_Gree.h:114
const uint8_t kGreeCool
Definition ir_Gree.h:93
const uint8_t kGreeDisplayTempSet
Definition ir_Gree.h:130
const uint8_t kGreeFanMin
Definition ir_Gree.h:100
const uint8_t kGreeSwingHOff
Definition ir_Gree.h:121
const uint8_t kGreeSwingAuto
Definition ir_Gree.h:111
const uint8_t kGreeMaxTempC
Definition ir_Gree.h:105
const uint8_t kGreeSwingHMaxRight
Definition ir_Gree.h:127
const uint8_t kGreeSwingHMaxLeft
Definition ir_Gree.h:123
const uint8_t kGreeSwingLastPos
Definition ir_Gree.h:110
const uint8_t kGreeSwingHLeft
Definition ir_Gree.h:124
const uint8_t kGreeSwingUpAuto
Definition ir_Gree.h:119
const uint8_t kGreeMaxTempF
Definition ir_Gree.h:107
const uint8_t kGreeAuto
Definition ir_Gree.h:92
const uint8_t kGreeFanMed
Definition ir_Gree.h:101
const uint8_t kGreeDisplayTempOutside
Definition ir_Gree.h:132
const uint8_t kGreeDisplayTempInside
Definition ir_Gree.h:131
const uint16_t kGreeTimerMax
Definition ir_Gree.h:108
const uint8_t kGreeSwingHAuto
Definition ir_Gree.h:122
const uint8_t kGreeFanMax
Definition ir_Gree.h:102
const uint8_t kGreeSwingHRight
Definition ir_Gree.h:126
const uint8_t kGreeFan
Definition ir_Gree.h:95
const uint8_t kGreeDisplayTempOff
Definition ir_Gree.h:129
const uint8_t kGreeDry
Definition ir_Gree.h:94
const uint8_t kGreeFanAuto
Definition ir_Gree.h:99
const uint8_t kGreeSwingDown
Definition ir_Gree.h:116
const uint8_t kGreeSwingDownAuto
Definition ir_Gree.h:117
const uint8_t kGreeSwingMiddleAuto
Definition ir_Gree.h:118
const uint8_t kGreeSwingMiddleDown
Definition ir_Gree.h:115
const uint8_t kGreeMinTempF
Definition ir_Gree.h:106
const uint8_t kGreeMinTempC
Definition ir_Gree.h:104
const uint8_t kGreeHeat
Definition ir_Gree.h:96
const uint8_t kGreeSwingUp
Definition ir_Gree.h:112
const uint8_t kGreeSwingMiddleUp
Definition ir_Gree.h:113
const uint8_t kGreeEcono
Definition ir_Gree.h:97
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
swingh_t
Common A/C settings for Horizontal Swing.
Definition IRsend.h:100
swingv_t
Common A/C settings for Vertical Swing.
Definition IRsend.h:74
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Gree A/C message.
Definition ir_Gree.h:45
uint8_t Sleep
Definition ir_Gree.h:53
uint8_t TimerTensHr
Definition ir_Gree.h:57
uint8_t Turbo
Definition ir_Gree.h:61
uint8_t SwingH
Definition ir_Gree.h:72
uint8_t TimerHalfHr
Definition ir_Gree.h:56
uint8_t Xfan
Definition ir_Gree.h:64
uint8_t Temp
Definition ir_Gree.h:55
uint8_t UseFahrenheit
Definition ir_Gree.h:68
uint8_t SwingV
Definition ir_Gree.h:71
uint8_t IFeel
Definition ir_Gree.h:76
uint8_t TimerEnabled
Definition ir_Gree.h:58
uint8_t ModelA
Definition ir_Gree.h:63
uint8_t WiFi
Definition ir_Gree.h:78
uint8_t Light
Definition ir_Gree.h:62
uint8_t Sum
Definition ir_Gree.h:86
uint8_t TimerHours
Definition ir_Gree.h:60
uint8_t SwingAuto
Definition ir_Gree.h:52
uint8_t unknown2
Definition ir_Gree.h:77
uint8_t Mode
Definition ir_Gree.h:49
uint8_t Power
Definition ir_Gree.h:50
uint8_t Econo
Definition ir_Gree.h:84
uint8_t DisplayTemp
Definition ir_Gree.h:75
uint8_t remote_state[kGreeStateLength]
The state in native IR code form.
Definition ir_Gree.h:46
uint8_t TempExtraDegreeF
Definition ir_Gree.h:67
uint8_t unknown1
Definition ir_Gree.h:69
uint8_t Fan
Definition ir_Gree.h:51