IRremote
ac_LG.h
Go to the documentation of this file.
1 /*
2  * ac_LG.h
3  *
4  * Contains definitions for receiving and sending LG air conditioner IR Protocol
5  *
6  * This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
7  *
8  ************************************************************************************
9  * MIT License
10  *
11  * Copyright (c) 2021 Armin Joachimsmeyer
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a copy
14  * of this software and associated documentation files (the "Software"), to deal
15  * in the Software without restriction, including without limitation the rights
16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  * copies of the Software, and to permit persons to whom the Software is furnished
18  * to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in all
21  * copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
28  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29  *
30  ************************************************************************************
31  */
32 // see also: https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_LG.h
33 #ifndef _AC_LG_H
34 #define _AC_LG_H
35 
36 #include <Arduino.h>
37 
42 #define LG_ADDRESS 0x88
43 
44 /*
45  * The basic IR command codes
46  * Parts of the codes (especially the lower nibbles) may be modified to contain
47  * additional information like temperature, fan speed and minutes.
48  */
49 #define LG_SWITCH_ON_MASK 0x0800 // This bit is masked if we switch Power on
50 #define LG_MODE_COOLING 0x0800 // Temperature and fan speed in lower nibbles
51 #define LG_MODE_DEHUMIDIFIYING 0x0990 // sets also temperature to 24 and fan speed to 0
52 #define LG_MODE_FAN 0x0A30 // sets also temperature to 18
53 #define LG_MODE_AUTO 0x0B00 // The remote initially sets also temperature to 22 and fan speed to 4
54 #define LG_MODE_HEATING 0x0C00 // Temperature and fan speed in lower nibbles
55 #define LG_ENERGY_SAVING_ON 0x1004
56 #define LG_ENERGY_SAVING_OFF 0x1005
57 #define LG_JET_ON 0x1008
58 #define LG_WALL_SWING_ON 0x1314
59 #define LG_WALL_SWING_OFF 0x1315
60 #define LG_SWING_ON 0x1316 // not verified, for AKB73757604
61 #define LG_SWING_OFF 0x1317 // not verified, for AKB73757604
62 #define LG_TIMER_ON 0x8000 // relative minutes in lower nibbles
63 #define LG_TIMER_OFF 0x9000 // relative minutes in lower nibbles
64 #define LG_SLEEP 0xA000 // relative minutes in lower nibbles
65 #define LG_CLEAR_ALL 0xB000 // Timers and sleep
66 #define LG_POWER_DOWN 0xC005
67 #define LG_LIGHT 0xC00A
68 #define LG_AUTO_CLEAN_ON 0xC00B
69 #define LG_AUTO_CLEAN_OFF 0xC00C
70 
71 /*
72  * Commands as printed in menu and uses as first parameter for sendCommandAndParameter
73  */
74 #define LG_COMMAND_OFF '0'
75 #define LG_COMMAND_ON '1'
76 #define LG_COMMAND_SWING 's'
77 #define LG_COMMAND_AUTO_CLEAN 'a'
78 #define LG_COMMAND_JET 'j'
79 #define LG_COMMAND_ENERGY 'e'
80 #define LG_COMMAND_LIGHT 'l'
81 #define LG_COMMAND_FAN_SPEED 'f'
82 #define LG_COMMAND_TEMPERATURE 't'
83 #define LG_COMMAND_TEMPERATURE_PLUS '+'
84 #define LG_COMMAND_TEMPERATURE_MINUS '-'
85 #define LG_COMMAND_MODE 'm'
86 #define LG_COMMAND_SLEEP 'S'
87 #define LG_COMMAND_TIMER_ON 'T'
88 #define LG_COMMAND_TIMER_OFF 'O'
89 #define LG_COMMAND_CLEAR_ALL 'C'
90 
91 /*
92  * The modes are encoded as character values for easy printing :-)
93  */
94 #define AC_MODE_COOLING 'c'
95 #define AC_MODE_DEHUMIDIFIYING 'd'
96 #define AC_MODE_FAN 'f'
97 #define AC_MODE_AUTO 'a'
98 #define AC_MODE_HEATING 'h'
99 
100 // see https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_LG.h
101 union LGProtocol {
102  uint32_t raw;
103  struct {
104  uint32_t Checksum :4;
105  uint32_t Fan :3;
106  uint32_t FanExt :1;
107  uint32_t Temp :4;
108  uint32_t Mode :4; // highest bit 1 => Set temperature and ventilation by mode
109  uint32_t Function :3;
110  uint32_t SwitchOnMask :1; /* Content is 0 when switching from off to on */
111  uint32_t Signature :8; /* Content is 0x88, LG_ADDRESS */
112  };
113 };
114 
116 public:
117  bool sendCommandAndParameter(char aCommand, int aParameter);
118  void setType(bool aIsWallType);
119  void printMenu(Print *aSerial);
120  void sendIRCommand(uint16_t aCommand);
122  /*
123  * Internal state of the air condition
124  */
125 #define LG_IS_WALL_TYPE true
126 #define LG_IS_TOWER_TYPE false
127  bool ACIsWallType; // false : TOWER, true : WALL
128  bool PowerIsOn;
129 
130  // These value are encoded and sent by AC_LG_SendCommandAndParameter()
131  uint8_t FanIntensity = 1; // 0 -> low, 4 high, 5 -> cycle
132  uint8_t Temperature = 22; // temperature : 18 ~ 30
134  bool useLG2Protocol = false;
135 };
136 
138 #endif // _AC_LG_H
LGProtocol::SwitchOnMask
uint32_t SwitchOnMask
Definition: ac_LG.h:110
Aircondition_LG::Temperature
uint8_t Temperature
Definition: ac_LG.h:132
LGProtocol::FanExt
uint32_t FanExt
Definition: ac_LG.h:106
Aircondition_LG::setType
void setType(bool aIsWallType)
Definition: ac_LG.hpp:64
LGProtocol::Temp
uint32_t Temp
Definition: ac_LG.h:107
Aircondition_LG::ACIsWallType
bool ACIsWallType
Definition: ac_LG.h:127
Aircondition_LG::sendTemperatureFanSpeedAndMode
void sendTemperatureFanSpeedAndMode()
Definition: ac_LG.hpp:267
Aircondition_LG::Mode
uint8_t Mode
Definition: ac_LG.h:133
LGProtocol::Function
uint32_t Function
Definition: ac_LG.h:109
Aircondition_LG::useLG2Protocol
bool useLG2Protocol
Definition: ac_LG.h:134
Aircondition_LG::sendIRCommand
void sendIRCommand(uint16_t aCommand)
Definition: ac_LG.hpp:252
LGProtocol::raw
uint32_t raw
The state of the IR remote in IR code form.
Definition: ac_LG.h:102
Aircondition_LG::sendCommandAndParameter
bool sendCommandAndParameter(char aCommand, int aParameter)
Definition: ac_LG.hpp:102
Aircondition_LG::FanIntensity
uint8_t FanIntensity
Definition: ac_LG.h:131
Aircondition_LG
Definition: ac_LG.h:115
LGProtocol::Fan
uint32_t Fan
Definition: ac_LG.h:105
LGProtocol::Signature
uint32_t Signature
Definition: ac_LG.h:111
Aircondition_LG::PowerIsOn
bool PowerIsOn
Definition: ac_LG.h:128
LGProtocol::Checksum
uint32_t Checksum
Definition: ac_LG.h:104
AC_MODE_COOLING
#define AC_MODE_COOLING
Definition: ac_LG.h:94
LGProtocol::Mode
uint32_t Mode
Definition: ac_LG.h:108
Aircondition_LG::printMenu
void printMenu(Print *aSerial)
Definition: ac_LG.hpp:72
LGProtocol
Definition: ac_LG.h:101