IRremoteESP8266: src/ir_LG.h Source File

IRremoteESP8266

ir_LG.h
Go to the documentation of this file.
1 // Copyright 2017, 2019 David Conran
2
6
7
8 // Supports:
9 // Brand: LG, Model: 6711A20083V remote (LG)
10 // Brand: LG, Model: AKB74395308 remote (LG2)
11 // Brand: LG, Model: S4-W12JA3AA A/C (LG2)
12 // Brand: LG, Model: AKB75215403 remote (LG2)
13 // Brand: General Electric, Model: AG1BH09AW101 Split A/C
14 // Brand: General Electric, Model: 6711AR2853M A/C Remote
15
16 #ifndef IR_LG_H_
17 #define IR_LG_H_
18
19 #define __STDC_LIMIT_MACROS
20 #include <stdint.h>
21 #ifndef UNIT_TEST
22 #include <Arduino.h>
23 #endif
24 #include "IRremoteESP8266.h"
25 #include "IRsend.h"
26 #include "IRutils.h"
27 #ifdef UNIT_TEST
28 #include "IRsend_test.h"
29 #endif
30
32 union LGProtocol{
33 uint32_t raw;
34 struct {
35 uint32_t Sum :4;
36 uint32_t Fan :3;
37 uint32_t :1;
38 uint32_t Temp :4;
39 uint32_t Mode :3;
40 uint32_t :3;
41 uint32_t Power:2;
42 uint32_t Sign :8;
43 };
44 };
45
46 const uint8_t kLgAcFanLowest = 0; // 0b000
47 const uint8_t kLgAcFanLow = 1; // 0b001
48 const uint8_t kLgAcFanMedium = 2; // 0b010
49 const uint8_t kLgAcFanHigh = 4; // 0b100
50 const uint8_t kLgAcFanAuto = 5; // 0b101
51 const uint8_t kLgAcTempAdjust = 15;
52 const uint8_t kLgAcMinTemp = 16; // Celsius
53 const uint8_t kLgAcMaxTemp = 30; // Celsius
54 const uint8_t kLgAcCool = 0; // 0b000
55 const uint8_t kLgAcDry = 1; // 0b001
56 const uint8_t kLgAcFan = 2; // 0b010
57 const uint8_t kLgAcAuto = 3; // 0b011
58 const uint8_t kLgAcHeat = 4; // 0b100
59 const uint8_t kLgAcPowerOff = 3; // 0b11
60 const uint8_t kLgAcPowerOn = 0; // 0b00
61 const uint8_t kLgAcSignature = 0x88;
62
63 const uint32_t kLgAcOffCommand = 0x88C0051;
64
65 // Classes
67 class IRLgAc {
68 public:
69 explicit IRLgAc(const uint16_t pin, const bool inverted = false,
70 const bool use_modulation = true);
71 void stateReset(void);
72 static uint8_t calcChecksum(const uint32_t state);
73 static bool validChecksum(const uint32_t state);
74 bool isValidLgAc(void) const;
75 #if SEND_LG
76 void send(const uint16_t repeat = kLgDefaultRepeat);
81 int8_t calibrate(void) { return _irsend.calibrate(); }
82 #endif // SEND_LG
83 void begin(void);
84 void on(void);
85 void off(void);
86 void setPower(const bool on);
87 bool getPower(void) const;
88 void setTemp(const uint8_t degrees);
89 uint8_t getTemp(void) const;
90 void setFan(const uint8_t speed);
91 uint8_t getFan(void) const;
92 void setMode(const uint8_t mode);
93 uint8_t getMode(void) const;
94 uint32_t getRaw(void);
95 void setRaw(const uint32_t new_code);
96 static uint8_t convertMode(const stdAc::opmode_t mode);
97 static stdAc::opmode_t toCommonMode(const uint8_t mode);
98 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
99 static uint8_t convertFan(const stdAc::fanspeed_t speed);
100 stdAc::state_t toCommon(void) const;
101 String toString(void) const;
102 void setModel(const lg_ac_remote_model_t model);
103 lg_ac_remote_model_t getModel(void) const;
104 #ifndef UNIT_TEST
105
106 private:
107 IRsend _irsend;
108 #else // UNIT_TEST
109 IRsendTest _irsend;
111 #endif // UNIT_TEST
113 LGProtocol _;
114 uint8_t _temp;
115 decode_type_t _protocol;
116 void checksum(void);
117 void _setTemp(const uint8_t value);
118 };
119
120 #endif // IR_LG_H_
kLgAcFanMedium
const uint8_t kLgAcFanMedium
Definition: ir_LG.h:48
IRLgAc::toCommon
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_LG.cpp:449
IRLgAc::_setTemp
void _setTemp(const uint8_t value)
Set the temperature.
Definition: ir_LG.cpp:328
IRLgAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_LG.cpp:410
IRLgAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_LG.cpp:368
decode_type_t
decode_type_t
Enumerator for defining and numbering of supported IR protocol.
Definition: IRremoteESP8266.h:785
IRLgAc::getRaw
uint32_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_LG.cpp:269
IRLgAc::_protocol
decode_type_t _protocol
model
Definition: ir_LG.h:115
IRLgAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_LG.cpp:343
IRLgAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_LG.h:81
kLgAcFanAuto
const uint8_t kLgAcFanAuto
Definition: ir_LG.h:50
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kLgAcPowerOff
const uint8_t kLgAcPowerOff
Definition: ir_LG.h:59
kLgAcFanLowest
const uint8_t kLgAcFanLowest
Definition: ir_LG.h:46
IRLgAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_LG.cpp:352
IRLgAc::getPower
bool getPower(void) const
Get the value of the current power setting.
Definition: ir_LG.cpp:321
LGProtocol::Temp
uint32_t Temp
Definition: ir_LG.h:38
kLgAcFanHigh
const uint8_t kLgAcFanHigh
Definition: ir_LG.h:49
IRsend.h
LGProtocol::Sign
uint32_t Sign
Definition: ir_LG.h:42
IRLgAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_LG.cpp:475
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:187
kLgAcDry
const uint8_t kLgAcDry
Definition: ir_LG.h:55
IRLgAc::setTemp
void setTemp(const uint8_t degrees)
Set the temperature.
Definition: ir_LG.cpp:334
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
IRLgAc::_
LGProtocol _
Definition: ir_LG.h:113
kLgAcOffCommand
const uint32_t kLgAcOffCommand
Definition: ir_LG.h:63
String
std::string String
Definition: IRremoteESP8266.h:1199
IRLgAc::calcChecksum
static uint8_t calcChecksum(const uint32_t state)
Calculate the checksum for a given state.
Definition: ir_LG.cpp:285
kLgAcFanLow
const uint8_t kLgAcFanLow
Definition: ir_LG.h:47
IRLgAc::setModel
void setModel(const lg_ac_remote_model_t model)
Set the model of the A/C to emulate.
Definition: ir_LG.cpp:242
kLgDefaultRepeat
const uint16_t kLgDefaultRepeat
Definition: IRremoteESP8266.h:1006
kLgAcMaxTemp
const uint8_t kLgAcMaxTemp
Definition: ir_LG.h:53
IRLgAc::IRLgAc
IRLgAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_LG.cpp:214
kLgAcSignature
const uint8_t kLgAcSignature
Definition: ir_LG.h:61
IRremoteESP8266.h
IRLgAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_LG.cpp:423
IRLgAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_LG.cpp:374
IRLgAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_LG.cpp:437
LGProtocol::raw
uint32_t raw
The state of the IR remote in IR code form.
Definition: ir_LG.h:33
kLgAcCool
const uint8_t kLgAcCool
Definition: ir_LG.h:54
kLgAcHeat
const uint8_t kLgAcHeat
Definition: ir_LG.h:58
IRLgAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_LG.cpp:225
IRLgAc
Class for handling detailed LG A/C messages.
Definition: ir_LG.h:67
IRutils.h
IRLgAc::getModel
lg_ac_remote_model_t getModel(void) const
Get the model of the A/C.
Definition: ir_LG.cpp:256
LGProtocol::Fan
uint32_t Fan
Definition: ir_LG.h:36
lg_ac_remote_model_t
lg_ac_remote_model_t
LG A/C model numbers.
Definition: IRsend.h:175
IRLgAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_LG.cpp:380
IRLgAc::_temp
uint8_t _temp
Definition: ir_LG.h:114
kLgAcAuto
const uint8_t kLgAcAuto
Definition: ir_LG.h:57
IRLgAc::setRaw
void setRaw(const uint32_t new_code)
Set the internal state from a valid code for this protocol.
Definition: ir_LG.cpp:276
kLgAcPowerOn
const uint8_t kLgAcPowerOn
Definition: ir_LG.h:60
IRLgAc::off
void off(void)
Change the power setting to Off.
Definition: ir_LG.cpp:307
IRLgAc::checksum
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition: ir_LG.cpp:299
IRLgAc::stateReset
void stateReset(void)
Reset the internals of the object to a known good state.
Definition: ir_LG.cpp:219
kLgAcMinTemp
const uint8_t kLgAcMinTemp
Definition: ir_LG.h:52
kLgAcTempAdjust
const uint8_t kLgAcTempAdjust
Definition: ir_LG.h:51
LGProtocol::Mode
uint32_t Mode
Definition: ir_LG.h:39
LGProtocol::Sum
uint32_t Sum
Definition: ir_LG.h:35
IRLgAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_LG.cpp:397
IRLgAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_LG.cpp:311
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:97
IRLgAc::send
void send(const uint16_t repeat=kLgDefaultRepeat)
Send the current internal state as an IR message.
Definition: ir_LG.cpp:230
IRLgAc::validChecksum
static bool validChecksum(const uint32_t state)
Verify the checksum is valid for a given state.
Definition: ir_LG.cpp:292
kLgAcFan
const uint8_t kLgAcFan
Definition: ir_LG.h:56
IRLgAc::on
void on(void)
Change the power setting to On.
Definition: ir_LG.cpp:304
LGProtocol::Power
uint32_t Power
Definition: ir_LG.h:41
IRLgAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_LG.h:107
LGProtocol
Native representation of a LG A/C message.
Definition: ir_LG.h:32
IRLgAc::isValidLgAc
bool isValidLgAc(void) const
Check if the internal state looks like a valid LG A/C message.
Definition: ir_LG.cpp:492
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46