IRremoteESP8266
Loading...
Searching...
No Matches
ir_LG.h
Go to the documentation of this file.
1// Copyright 2017-2021 David Conran
2
7
8// Supports:
9// Brand: LG, Model: 6711A20083V remote (LG - LG6711A20083V)
10// Brand: LG, Model: TS-H122ERM1 remote (LG - LG6711A20083V)
11// Brand: LG, Model: AKB74395308 remote (LG2)
12// Brand: LG, Model: S4-W12JA3AA A/C (LG2)
13// Brand: LG, Model: AKB75215403 remote (LG2)
14// Brand: LG, Model: AKB74955603 remote (LG2 - AKB74955603)
15// Brand: LG, Model: A4UW30GFA2 A/C (LG2 - AKB74955603 & AKB73757604)
16// Brand: LG, Model: AMNW09GSJA0 A/C (LG2 - AKB74955603)
17// Brand: LG, Model: AMNW24GTPA1 A/C (LG2 - AKB73757604)
18// Brand: LG, Model: AKB73757604 remote (LG2 - AKB73757604)
19// Brand: LG, Model: AKB73315611 remote (LG2 - AKB74955603)
20// Brand: LG, Model: MS05SQ NW0 A/C (LG2 - AKB74955603)
21// Brand: General Electric, Model: AG1BH09AW101 A/C (LG - GE6711AR2853M)
22// Brand: General Electric, Model: 6711AR2853M Remote (LG - GE6711AR2853M)
23
24#ifndef IR_LG_H_
25#define IR_LG_H_
26
27#define __STDC_LIMIT_MACROS
28#include <stdint.h>
29#ifndef UNIT_TEST
30#include <Arduino.h>
31#endif
32#include "IRremoteESP8266.h"
33#include "IRsend.h"
34#include "IRutils.h"
35#ifdef UNIT_TEST
36#include "IRsend_test.h"
37#endif
38
41 uint32_t raw;
42 struct {
43 uint32_t Sum :4;
44 uint32_t Fan :4;
45 uint32_t Temp :4;
46 uint32_t Mode :3;
47 uint32_t :3;
48 uint32_t Power:2;
49 uint32_t Sign :8;
50 };
51};
52
53const uint8_t kLgAcFanLowest = 0; // 0b0000
54const uint8_t kLgAcFanLow = 1; // 0b0001
55const uint8_t kLgAcFanMedium = 2; // 0b0010
56const uint8_t kLgAcFanMax = 4; // 0b0100
57const uint8_t kLgAcFanAuto = 5; // 0b0101
58const uint8_t kLgAcFanLowAlt = 9; // 0b1001
59const uint8_t kLgAcFanHigh = 10; // 0b1010
60// Nr. of slots in the look-up table
61const uint8_t kLgAcFanEntries = kLgAcFanHigh + 1;
62const uint8_t kLgAcTempAdjust = 15;
63const uint8_t kLgAcMinTemp = 16; // Celsius
64const uint8_t kLgAcMaxTemp = 30; // Celsius
65const uint8_t kLgAcCool = 0; // 0b000
66const uint8_t kLgAcDry = 1; // 0b001
67const uint8_t kLgAcFan = 2; // 0b010
68const uint8_t kLgAcAuto = 3; // 0b011
69const uint8_t kLgAcHeat = 4; // 0b100
70const uint8_t kLgAcPowerOff = 3; // 0b11
71const uint8_t kLgAcPowerOn = 0; // 0b00
72const uint8_t kLgAcSignature = 0x88;
73
74const uint32_t kLgAcOffCommand = 0x88C0051;
75const uint32_t kLgAcLightToggle = 0x88C00A6;
76
77const uint32_t kLgAcSwingVToggle = 0x8810001;
78const uint32_t kLgAcSwingSignature = 0x8813;
79const uint32_t kLgAcSwingVLowest = 0x8813048;
80const uint32_t kLgAcSwingVLow = 0x8813059;
81const uint32_t kLgAcSwingVMiddle = 0x881306A;
82const uint32_t kLgAcSwingVUpperMiddle = 0x881307B;
83const uint32_t kLgAcSwingVHigh = 0x881308C;
84const uint32_t kLgAcSwingVHighest = 0x881309D;
85const uint32_t kLgAcSwingVSwing = 0x8813149;
87const uint32_t kLgAcSwingVOff = 0x881315A;
88const uint8_t kLgAcSwingVLowest_Short = 0x04;
89const uint8_t kLgAcSwingVLow_Short = 0x05;
90const uint8_t kLgAcSwingVMiddle_Short = 0x06;
91const uint8_t kLgAcSwingVUpperMiddle_Short = 0x07;
92const uint8_t kLgAcSwingVHigh_Short = 0x08;
93const uint8_t kLgAcSwingVHighest_Short = 0x09;
94const uint8_t kLgAcSwingVSwing_Short = 0x14;
96const uint8_t kLgAcSwingVOff_Short = 0x15;
97
98// AKB73757604 Constants
99// SwingH
100const uint32_t kLgAcSwingHAuto = 0x881316B;
101const uint32_t kLgAcSwingHOff = 0x881317C;
102// SwingV
103const uint8_t kLgAcVaneSwingVHighest = 1;
104const uint8_t kLgAcVaneSwingVHigh = 2;
105const uint8_t kLgAcVaneSwingVUpperMiddle = 3;
106const uint8_t kLgAcVaneSwingVMiddle = 4;
107const uint8_t kLgAcVaneSwingVLow = 5;
108const uint8_t kLgAcVaneSwingVLowest = 6;
109const uint8_t kLgAcVaneSwingVSize = 8;
110const uint8_t kLgAcSwingVMaxVanes = 4;
111
112// Classes
114class IRLgAc {
115 public:
116 explicit IRLgAc(const uint16_t pin, const bool inverted = false,
117 const bool use_modulation = true);
118 void stateReset(void);
119 static uint8_t calcChecksum(const uint32_t state);
120 static bool validChecksum(const uint32_t state);
121 bool isValidLgAc(void) const;
122#if SEND_LG
123 void send(const uint16_t repeat = kLgDefaultRepeat);
128 int8_t calibrate(void) { return _irsend.calibrate(); }
129#endif // SEND_LG
130 void begin(void);
131 void on(void);
132 void off(void);
133 void setPower(const bool on);
134 bool getPower(void) const;
135 bool isOffCommand(void) const;
136 void setTemp(const uint8_t degrees);
137 uint8_t getTemp(void) const;
138 void setFan(const uint8_t speed);
139 uint8_t getFan(void) const;
140 void setMode(const uint8_t mode);
141 uint8_t getMode(void) const;
142 void setLight(const bool on);
143 bool getLight(void) const;
144 bool isLightToggle(void) const;
145 bool isSwing(void) const;
146 void setSwingH(const bool on);
147 bool getSwingH(void) const;
148 bool isSwingV(void) const;
149 bool isSwingVToggle(void) const;
150 bool isVaneSwingV(void) const;
151 void setSwingV(const uint32_t position);
152 uint32_t getSwingV(void) const;
153 void setVaneSwingV(const uint8_t vane, const uint8_t position);
154 uint8_t getVaneSwingV(const uint8_t vane) const;
155 static uint32_t calcVaneSwingV(const uint8_t vane, const uint8_t position);
156 static uint8_t getVaneCode(const uint32_t raw);
157 bool isSwingH(void) const;
158 void updateSwingPrev(void);
159 uint32_t getRaw(void);
160 void setRaw(const uint32_t new_code,
161 const decode_type_t protocol = decode_type_t::UNKNOWN);
162 static uint8_t convertMode(const stdAc::opmode_t mode);
163 static stdAc::opmode_t toCommonMode(const uint8_t mode);
164 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
165 static stdAc::swingv_t toCommonSwingV(const uint32_t code);
166 static stdAc::swingv_t toCommonVaneSwingV(const uint8_t pos);
167 static uint8_t convertFan(const stdAc::fanspeed_t speed);
168 static uint32_t convertSwingV(const stdAc::swingv_t swingv);
169 static uint8_t convertVaneSwingV(const stdAc::swingv_t swingv);
170 stdAc::state_t toCommon(const stdAc::state_t *prev = NULL) const;
171 String toString(void) const;
172 void setModel(const lg_ac_remote_model_t model);
173 lg_ac_remote_model_t getModel(void) const;
174#ifndef UNIT_TEST
175
176 private:
178#else // UNIT_TEST
180 IRsendTest _irsend;
182#endif // UNIT_TEST
184 uint8_t _temp;
185 bool _light;
186 uint32_t _swingv;
187 uint32_t _swingv_prev;
194 void checksum(void);
195 void _setTemp(const uint8_t value);
196 bool _isAKB74955603(void) const;
197 bool _isAKB73757604(void) const;
198 bool _isLG6711A20083V(void) const;
199 bool _isNormal(void) const;
200};
201
202#endif // IR_LG_H_
const uint16_t kLgDefaultRepeat
Definition IRremoteESP8266.h:1328
decode_type_t
Enumerator for defining and numbering of supported IR protocol.
Definition IRremoteESP8266.h:1036
@ UNKNOWN
Definition IRremoteESP8266.h:1037
std::string String
Definition IRremoteESP8266.h:1564
lg_ac_remote_model_t
LG A/C model numbers.
Definition IRsend.h:222
Class for handling detailed LG A/C messages.
Definition ir_LG.h:114
static uint32_t convertSwingV(const stdAc::swingv_t swingv)
Convert a stdAc::swingv_t enum into it's native setting.
Definition ir_LG.cpp:692
bool isSwingH(void) const
Check if the stored code is a SwingH message.
Definition ir_LG.cpp:555
bool isOffCommand(void) const
Is the message a Power Off message?
Definition ir_LG.cpp:440
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_LG.cpp:476
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_LG.cpp:637
lg_ac_remote_model_t getModel(void) const
Get the model of the A/C.
Definition ir_LG.cpp:329
void on(void)
Change the power setting to On.
Definition ir_LG.cpp:417
void setPower(const bool on)
Change the power setting.
Definition ir_LG.cpp:424
void updateSwingPrev(void)
Definition ir_LG.cpp:592
static stdAc::swingv_t toCommonVaneSwingV(const uint8_t pos)
Convert a native Vane specific Vertical Swing into its stdAc equivalent.
Definition ir_LG.cpp:731
bool _isAKB73757604(void) const
Check if the stored code must belong to a AKB73757604 model.
Definition ir_LG.cpp:342
uint8_t _temp
Definition ir_LG.h:184
static stdAc::swingv_t toCommonSwingV(const uint32_t code)
Convert a native Vertical Swing into its stdAc equivalent.
Definition ir_LG.cpp:707
uint32_t getSwingV(void) const
Get the Vertical Swing position setting of the A/C.
Definition ir_LG.cpp:600
LGProtocol _
Definition ir_LG.h:183
uint8_t _vaneswingv[kLgAcSwingVMaxVanes]
Definition ir_LG.h:188
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_LG.cpp:513
void _setTemp(const uint8_t value)
Set the temperature.
Definition ir_LG.cpp:457
bool isSwingVToggle(void) const
Check if the stored code is a SwingV Toggle message.
Definition ir_LG.cpp:537
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition ir_LG.cpp:412
bool _isNormal(void) const
Is the current message a normal (non-special) message?
Definition ir_LG.cpp:298
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_LG.cpp:801
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_LG.h:128
static bool validChecksum(const uint32_t state)
Verify the checksum is valid for a given state.
Definition ir_LG.cpp:405
bool getPower(void) const
Get the value of the current power setting.
Definition ir_LG.cpp:434
void stateReset(void)
Reset the internals of the object to a known good state.
Definition ir_LG.cpp:237
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_LG.cpp:521
bool _isLG6711A20083V(void) const
Check if the stored code must belong to a LG6711A20083V model.
Definition ir_LG.cpp:347
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_LG.cpp:517
void setSwingV(const uint32_t position)
Set the Vertical Swing mode of the A/C.
Definition ir_LG.cpp:578
static uint8_t getVaneCode(const uint32_t raw)
Get the vane code of a Vane Vertical Swing message.
Definition ir_LG.cpp:620
bool _light
Definition ir_LG.h:185
void off(void)
Change the power setting to Off.
Definition ir_LG.cpp:420
uint8_t getVaneSwingV(const uint8_t vane) const
Get the Vertical Swing position for the given vane of the A/C.
Definition ir_LG.cpp:613
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_LG.cpp:663
bool isLightToggle(void) const
Is the message a Light Toggle message?
Definition ir_LG.cpp:452
stdAc::state_t toCommon(const stdAc::state_t *prev=NULL) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_LG.cpp:758
bool _swingh_prev
Definition ir_LG.h:191
IRsend _irsend
Instance of the IR send class.
Definition ir_LG.h:177
bool _isAKB74955603(void) const
Check if the stored code must belong to a AKB74955603 model.
Definition ir_LG.cpp:334
bool _swingh
Definition ir_LG.h:190
void setLight(const bool on)
Change the light/led/display setting.
Definition ir_LG.cpp:444
lg_ac_remote_model_t _model
Model type.
Definition ir_LG.h:193
static uint8_t calcChecksum(const uint32_t state)
Calculate the checksum for a given state.
Definition ir_LG.cpp:398
bool isVaneSwingV(void) const
Check if the stored code is a vane specific SwingV message.
Definition ir_LG.cpp:569
bool getSwingH(void) const
Get the Horizontal Swing position setting of the A/C.
Definition ir_LG.cpp:561
decode_type_t _protocol
Protocol version.
Definition ir_LG.h:192
static uint32_t calcVaneSwingV(const uint8_t vane, const uint8_t position)
Calculate the Vane specific Vertical Swing code for the A/C.
Definition ir_LG.cpp:626
uint32_t _swingv
Definition ir_LG.h:186
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_LG.cpp:470
void setSwingH(const bool on)
Set the Horizontal Swing mode of the A/C.
Definition ir_LG.cpp:565
uint32_t _swingv_prev
Definition ir_LG.h:187
void begin(void)
Set up hardware to be able to send a message.
Definition ir_LG.cpp:249
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_LG.cpp:650
bool isSwingV(void) const
Check if the stored code is a non-vane SwingV message.
Definition ir_LG.cpp:547
bool isSwing(void) const
Check if the stored code is a Swing message.
Definition ir_LG.cpp:541
void setRaw(const uint32_t new_code, const decode_type_t protocol=decode_type_t::UNKNOWN)
Set the internal state from a valid code for this protocol.
Definition ir_LG.cpp:359
bool isValidLgAc(void) const
Check if the internal state looks like a valid LG A/C message.
Definition ir_LG.cpp:860
void setTemp(const uint8_t degrees)
Set the temperature.
Definition ir_LG.cpp:461
bool getLight(void) const
Get the value of the current light setting.
Definition ir_LG.cpp:448
void setModel(const lg_ac_remote_model_t model)
Set the model of the A/C to emulate.
Definition ir_LG.cpp:310
void send(const uint16_t repeat=kLgDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_LG.cpp:254
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_LG.cpp:677
static uint8_t convertVaneSwingV(const stdAc::swingv_t swingv)
Convert a stdAc::swingv_t enum into it's native setting.
Definition ir_LG.cpp:745
void setVaneSwingV(const uint8_t vane, const uint8_t position)
Set the per Vane Vertical Swing mode of the A/C.
Definition ir_LG.cpp:605
uint8_t _vaneswingv_prev[kLgAcSwingVMaxVanes]
Definition ir_LG.h:189
uint32_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition ir_LG.cpp:351
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 kLgAcSwingVLow_Short
Definition ir_LG.h:89
const uint8_t kLgAcVaneSwingVHighest
0b001
Definition ir_LG.h:103
const uint8_t kLgAcMaxTemp
Definition ir_LG.h:64
const uint32_t kLgAcSwingVLow
Definition ir_LG.h:80
const uint32_t kLgAcSwingHAuto
Definition ir_LG.h:100
const uint8_t kLgAcVaneSwingVUpperMiddle
0b011
Definition ir_LG.h:105
const uint8_t kLgAcTempAdjust
Definition ir_LG.h:62
const uint8_t kLgAcFanEntries
Definition ir_LG.h:61
const uint8_t kLgAcVaneSwingVMiddle
0b100
Definition ir_LG.h:106
const uint32_t kLgAcSwingVSwing
Definition ir_LG.h:85
const uint32_t kLgAcSwingVHighest
Definition ir_LG.h:84
const uint8_t kLgAcSwingVSwing_Short
Definition ir_LG.h:94
const uint8_t kLgAcSwingVHighest_Short
Definition ir_LG.h:93
const uint8_t kLgAcSwingVMiddle_Short
Definition ir_LG.h:90
const uint32_t kLgAcSwingSignature
Definition ir_LG.h:78
const uint8_t kLgAcVaneSwingVSize
Definition ir_LG.h:109
const uint8_t kLgAcVaneSwingVLowest
0b110
Definition ir_LG.h:108
const uint32_t kLgAcSwingVOff
Definition ir_LG.h:87
const uint8_t kLgAcPowerOff
Definition ir_LG.h:70
const uint8_t kLgAcCool
Definition ir_LG.h:65
const uint8_t kLgAcFanAuto
Definition ir_LG.h:57
const uint32_t kLgAcSwingVHigh
Definition ir_LG.h:83
const uint8_t kLgAcFanLowAlt
Definition ir_LG.h:58
const uint8_t kLgAcSwingVAuto_Short
Definition ir_LG.h:95
const uint32_t kLgAcSwingVLowest
Definition ir_LG.h:79
const uint8_t kLgAcSwingVUpperMiddle_Short
Definition ir_LG.h:91
const uint8_t kLgAcSwingVLowest_Short
Definition ir_LG.h:88
const uint8_t kLgAcFanLowest
Definition ir_LG.h:53
const uint8_t kLgAcHeat
Definition ir_LG.h:69
const uint32_t kLgAcSwingHOff
Definition ir_LG.h:101
const uint32_t kLgAcSwingVMiddle
Definition ir_LG.h:81
const uint32_t kLgAcLightToggle
Definition ir_LG.h:75
const uint8_t kLgAcSwingVOff_Short
Definition ir_LG.h:96
const uint8_t kLgAcPowerOn
Definition ir_LG.h:71
const uint8_t kLgAcFanHigh
Definition ir_LG.h:59
const uint32_t kLgAcSwingVToggle
Definition ir_LG.h:77
const uint8_t kLgAcDry
Definition ir_LG.h:66
const uint8_t kLgAcVaneSwingVLow
0b101
Definition ir_LG.h:107
const uint8_t kLgAcSignature
Definition ir_LG.h:72
const uint8_t kLgAcSwingVMaxVanes
Max Nr. of Vanes.
Definition ir_LG.h:110
const uint8_t kLgAcFanMedium
Definition ir_LG.h:55
const uint8_t kLgAcFanMax
Definition ir_LG.h:56
const uint8_t kLgAcVaneSwingVHigh
0b010
Definition ir_LG.h:104
const uint8_t kLgAcMinTemp
Definition ir_LG.h:63
const uint8_t kLgAcAuto
Definition ir_LG.h:68
const uint32_t kLgAcOffCommand
Definition ir_LG.h:74
const uint8_t kLgAcSwingVHigh_Short
Definition ir_LG.h:92
const uint32_t kLgAcSwingVAuto
Definition ir_LG.h:86
const uint32_t kLgAcSwingVUpperMiddle
Definition ir_LG.h:82
const uint8_t kLgAcFanLow
Definition ir_LG.h:54
const uint8_t kLgAcFan
Definition ir_LG.h:67
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
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 LG A/C message.
Definition ir_LG.h:40
uint32_t Sign
Definition ir_LG.h:49
uint32_t raw
The state of the IR remote in IR code form.
Definition ir_LG.h:41
uint32_t Power
Definition ir_LG.h:48
uint32_t Sum
Definition ir_LG.h:43
uint32_t Fan
Definition ir_LG.h:44
uint32_t Mode
Definition ir_LG.h:46
uint32_t Temp
Definition ir_LG.h:45