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 
31 const uint8_t kLgAcChecksumOffset = 0; // Nr. of bits
32 const uint8_t kLgAcChecksumSize = kNibbleSize; // Nr. of bits
33 const uint8_t kLgAcFanOffset = 4; // Nr. of bits
34 const uint8_t kLgAcFanSize = 3; // Nr. of bits
35 const uint8_t kLgAcFanLowest = 0; // 0b000
36 const uint8_t kLgAcFanLow = 1; // 0b001
37 const uint8_t kLgAcFanMedium = 2; // 0b010
38 const uint8_t kLgAcFanHigh = 4; // 0b100
39 const uint8_t kLgAcFanAuto = 5; // 0b101
40 const uint8_t kLgAcTempOffset = 8; // Nr. of bits
41 const uint8_t kLgAcTempSize = 4; // Nr. of bits
42 const uint8_t kLgAcTempAdjust = 15;
43 const uint8_t kLgAcMinTemp = 16; // Celsius
44 const uint8_t kLgAcMaxTemp = 30; // Celsius
45 const uint8_t kLgAcModeOffset = 12; // Nr. of bits
46 const uint8_t kLgAcModeSize = 3; // Nr. of bits
47 const uint8_t kLgAcCool = 0; // 0b000
48 const uint8_t kLgAcDry = 1; // 0b001
49 const uint8_t kLgAcFan = 2; // 0b010
50 const uint8_t kLgAcAuto = 3; // 0b011
51 const uint8_t kLgAcHeat = 4; // 0b100
52 const uint8_t kLgAcPowerOffset = 18; // Nr. of bits
53 const uint8_t kLgAcPowerSize = 2; // Nr. of bits
54 const uint8_t kLgAcPowerOff = 3; // 0b11
55 const uint8_t kLgAcPowerOn = 0; // 0b00
56 const uint8_t kLgAcSignatureOffset = 20; // Nr. of bits
57 const uint8_t kLgAcSignatureSize = 8; // Nr. of bits
58 const uint8_t kLgAcSignature = 0x88;
59 
60 const uint32_t kLgAcOffCommand = 0x88C0051;
61 
62 // Classes
64 class IRLgAc {
65  public:
66  explicit IRLgAc(const uint16_t pin, const bool inverted = false,
67  const bool use_modulation = true);
68  void stateReset(void);
69  static uint8_t calcChecksum(const uint32_t state);
70  static bool validChecksum(const uint32_t state);
71  bool isValidLgAc(void);
72 #if SEND_LG
73  void send(const uint16_t repeat = kLgDefaultRepeat);
78  int8_t calibrate(void) { return _irsend.calibrate(); }
79 #endif // SEND_LG
80  void begin(void);
81  void on(void);
82  void off(void);
83  void setPower(const bool on);
84  bool getPower(void);
85  void setTemp(const uint8_t degrees);
86  uint8_t getTemp(void);
87  void setFan(const uint8_t speed);
88  uint8_t getFan(void);
89  void setMode(const uint8_t mode);
90  uint8_t getMode(void);
91  uint32_t getRaw(void);
92  void setRaw(const uint32_t new_code);
93  uint8_t convertMode(const stdAc::opmode_t mode);
94  static stdAc::opmode_t toCommonMode(const uint8_t mode);
95  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
96  static uint8_t convertFan(const stdAc::fanspeed_t speed);
98  String toString(void);
99  void setModel(const lg_ac_remote_model_t model);
101 #ifndef UNIT_TEST
102 
103  private:
105 #else // UNIT_TEST
106  IRsendTest _irsend;
108 #endif // UNIT_TEST
110  uint32_t remote_state;
111  uint8_t _temp;
113  void checksum(void);
114  void _setTemp(const uint8_t value);
115 };
116 
117 #endif // IR_LG_H_
kLgAcFanMedium
const uint8_t kLgAcFanMedium
Definition: ir_LG.h:37
IRLgAc::_setTemp
void _setTemp(const uint8_t value)
Set the temperature.
Definition: ir_LG.cpp:375
IRLgAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivilant.
Definition: ir_LG.cpp:458
decode_type_t
decode_type_t
Enumerator for defining and numbering of supported IR protocol.
Definition: IRremoteESP8266.h:736
IRLgAc::getRaw
uint32_t getRaw(void)
Get a copy of the internal state/code for this protocol.
Definition: ir_LG.cpp:314
IRLgAc::_protocol
decode_type_t _protocol
Definition: ir_LG.h:112
kLgAcFanSize
const uint8_t kLgAcFanSize
Definition: ir_LG.h:34
IRLgAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_LG.h:78
kLgAcFanAuto
const uint8_t kLgAcFanAuto
Definition: ir_LG.h:39
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:58
kLgAcFanOffset
const uint8_t kLgAcFanOffset
Definition: ir_LG.h:33
kLgAcPowerOff
const uint8_t kLgAcPowerOff
Definition: ir_LG.h:54
IRLgAc::getModel
lg_ac_remote_model_t getModel(void)
Get the model of the A/C.
Definition: ir_LG.cpp:301
kLgAcFanLowest
const uint8_t kLgAcFanLowest
Definition: ir_LG.h:35
IRLgAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_LG.cpp:400
IRLgAc::toString
String toString(void)
Convert the current internal state into a human readable string.
Definition: ir_LG.cpp:523
IRLgAc::getMode
uint8_t getMode(void)
Get the operating mode setting of the A/C.
Definition: ir_LG.cpp:422
kLgAcFanHigh
const uint8_t kLgAcFanHigh
Definition: ir_LG.h:38
IRsend.h
kLgAcPowerOffset
const uint8_t kLgAcPowerOffset
Definition: ir_LG.h:52
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:176
kLgAcDry
const uint8_t kLgAcDry
Definition: ir_LG.h:48
IRLgAc::setTemp
void setTemp(const uint8_t degrees)
Set the temperature.
Definition: ir_LG.cpp:381
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kLgAcTempOffset
const uint8_t kLgAcTempOffset
Definition: ir_LG.h:40
kLgAcOffCommand
const uint32_t kLgAcOffCommand
Definition: ir_LG.h:60
String
std::string String
Definition: IRremoteESP8266.h:1128
kNibbleSize
const uint8_t kNibbleSize
Definition: IRutils.h:17
IRLgAc::calcChecksum
static uint8_t calcChecksum(const uint32_t state)
Calculate the checksum for a given state.
Definition: ir_LG.cpp:330
kLgAcFanLow
const uint8_t kLgAcFanLow
Definition: ir_LG.h:36
IRLgAc::setModel
void setModel(const lg_ac_remote_model_t model)
Set the model of the A/C to emulate.
Definition: ir_LG.cpp:287
kLgDefaultRepeat
const uint16_t kLgDefaultRepeat
Definition: IRremoteESP8266.h:944
kLgAcMaxTemp
const uint8_t kLgAcMaxTemp
Definition: ir_LG.h:44
IRLgAc::IRLgAc
IRLgAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_LG.cpp:259
kLgAcSignature
const uint8_t kLgAcSignature
Definition: ir_LG.h:58
IRremoteESP8266.h
kLgAcSignatureSize
const uint8_t kLgAcSignatureSize
Definition: ir_LG.h:57
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:471
kLgAcTempSize
const uint8_t kLgAcTempSize
Definition: ir_LG.h:41
IRLgAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivilant.
Definition: ir_LG.cpp:485
IRLgAc::toCommon
stdAc::state_t toCommon(void)
Convert the current internal state into its stdAc::state_t equivilant.
Definition: ir_LG.cpp:497
kLgAcCool
const uint8_t kLgAcCool
Definition: ir_LG.h:47
kLgAcHeat
const uint8_t kLgAcHeat
Definition: ir_LG.h:51
IRLgAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_LG.cpp:270
kLgAcChecksumSize
const uint8_t kLgAcChecksumSize
Definition: ir_LG.h:32
kLgAcPowerSize
const uint8_t kLgAcPowerSize
Definition: ir_LG.h:53
IRLgAc::getFan
uint8_t getFan(void)
Get the current fan speed setting.
Definition: ir_LG.cpp:416
IRLgAc
Class for handling detailed LG A/C messages.
Definition: ir_LG.h:64
IRutils.h
kLgAcSignatureOffset
const uint8_t kLgAcSignatureOffset
Definition: ir_LG.h:56
kLgAcModeSize
const uint8_t kLgAcModeSize
Definition: ir_LG.h:46
IRLgAc::remote_state
uint32_t remote_state
The state of the IR remote in IR code form.
Definition: ir_LG.h:110
lg_ac_remote_model_t
lg_ac_remote_model_t
LG A/C model numbers.
Definition: IRsend.h:164
IRLgAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_LG.cpp:428
IRLgAc::_temp
uint8_t _temp
Definition: ir_LG.h:111
kLgAcModeOffset
const uint8_t kLgAcModeOffset
Definition: ir_LG.h:45
kLgAcAuto
const uint8_t kLgAcAuto
Definition: ir_LG.h:50
IRLgAc::setRaw
void setRaw(const uint32_t new_code)
Set the internal state from a valid code for this protocol.
Definition: ir_LG.cpp:321
kLgAcPowerOn
const uint8_t kLgAcPowerOn
Definition: ir_LG.h:55
IRLgAc::getTemp
uint8_t getTemp(void)
Get the current temperature setting.
Definition: ir_LG.cpp:390
IRLgAc::off
void off(void)
Change the power setting to Off.
Definition: ir_LG.cpp:352
IRLgAc::getPower
bool getPower(void)
Get the value of the current power setting.
Definition: ir_LG.cpp:367
IRLgAc::checksum
void checksum(void)
Calculate and set the checksum values for the internal state.
Definition: ir_LG.cpp:343
IRLgAc::stateReset
void stateReset(void)
Reset the internals of the object to a known good state.
Definition: ir_LG.cpp:264
kLgAcChecksumOffset
const uint8_t kLgAcChecksumOffset
Definition: ir_LG.h:31
kLgAcMinTemp
const uint8_t kLgAcMinTemp
Definition: ir_LG.h:43
kLgAcTempAdjust
const uint8_t kLgAcTempAdjust
Definition: ir_LG.h:42
IRLgAc::convertMode
uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_LG.cpp:445
IRLgAc::setPower
void setPower(const bool on)
Change the power setting.
Definition: ir_LG.cpp:356
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:275
IRLgAc::validChecksum
static bool validChecksum(const uint32_t state)
Verify the checksum is valid for a given state.
Definition: ir_LG.cpp:337
kLgAcFan
const uint8_t kLgAcFan
Definition: ir_LG.h:49
IRLgAc::on
void on(void)
Change the power setting to On.
Definition: ir_LG.cpp:349
IRLgAc::isValidLgAc
bool isValidLgAc(void)
Check if the internal state looks like a valud LG A/C message.
Definition: ir_LG.cpp:540
IRLgAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_LG.h:104
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:46