# IRremoteESP8266: src/ir_LG.h Source File

ir_LG.h
Go to the documentation of this file.
// Copyright 2017, 2019 David Conran
// Supports:
// Brand: LG, Model: 6711A20083V remote (LG)
// Brand: LG, Model: AKB74395308 remote (LG2)
// Brand: LG, Model: S4-W12JA3AA A/C (LG2)
// Brand: LG, Model: AKB75215403 remote (LG2)
// Brand: General Electric, Model: AG1BH09AW101 Split A/C
// Brand: General Electric, Model: 6711AR2853M A/C Remote
#ifndef IR_LG_H_
#define IR_LG_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#include "IRutils.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
union LGProtocol{
uint32_t raw;
struct {
uint32_t Sum :4;
uint32_t Fan :3;
uint32_t :1;
uint32_t Temp :4;
uint32_t Mode :3;
uint32_t :3;
uint32_t Power:2;
uint32_t Sign :8;
};
};
const uint8_t kLgAcFanLowest = 0; // 0b000
const uint8_t kLgAcFanLow = 1; // 0b001
const uint8_t kLgAcFanMedium = 2; // 0b010
const uint8_t kLgAcFanHigh = 4; // 0b100
const uint8_t kLgAcFanAuto = 5; // 0b101
const uint8_t kLgAcTempAdjust = 15;
const uint8_t kLgAcMinTemp = 16; // Celsius
const uint8_t kLgAcMaxTemp = 30; // Celsius
const uint8_t kLgAcCool = 0; // 0b000
const uint8_t kLgAcDry = 1; // 0b001
const uint8_t kLgAcFan = 2; // 0b010
const uint8_t kLgAcAuto = 3; // 0b011
const uint8_t kLgAcHeat = 4; // 0b100
const uint8_t kLgAcPowerOff = 3; // 0b11
const uint8_t kLgAcPowerOn = 0; // 0b00
const uint8_t kLgAcSignature = 0x88;
const uint32_t kLgAcOffCommand = 0x88C0051;
// Classes
class IRLgAc {
public:
explicit IRLgAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
static uint8_t calcChecksum(const uint32_t state);
static bool validChecksum(const uint32_t state);
bool isValidLgAc(void) const;
#if SEND_LG
void send(const uint16_t repeat = kLgDefaultRepeat);
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_LG
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t degrees);
uint8_t getTemp(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
uint32_t getRaw(void);
void setRaw(const uint32_t new_code);
static uint8_t convertMode(const stdAc::opmode_t mode);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
stdAc::state_t toCommon(void) const;
String toString(void) const;
void setModel(const lg_ac_remote_model_t model);
lg_ac_remote_model_t getModel(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend;
#else // UNIT_TEST
IRsendTest _irsend;
#endif // UNIT_TEST
LGProtocol _;
uint8_t _temp;
decode_type_t _protocol;
void checksum(void);
void _setTemp(const uint8_t value);
};
#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:771
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:182
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:1178
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:988
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:170
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