Skip to content

Commit 66c3b1f

Browse files
Darryl SmithDarryl Smith
Darryl Smith
authored and
Darryl Smith
committed
Updates for LG Air Conditioner Remote
1 parent 0af9c5a commit 66c3b1f

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

IRremote.cpp

+53
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
1515
*
1616
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
17+
* LG added by Darryl Smith (based on the JVC protocol)
1718
*/
1819

1920
#include "IRremote.h"
@@ -459,6 +460,12 @@ int IRrecv::decode(decode_results *results) {
459460
if (decodePanasonic(results)) {
460461
return DECODED;
461462
}
463+
#ifdef DEBUG
464+
Serial.println("Attempting LG decode");
465+
#endif
466+
if (decodeLG(results)) {
467+
return DECODED;
468+
}
462469
#ifdef DEBUG
463470
Serial.println("Attempting JVC decode");
464471
#endif
@@ -876,6 +883,52 @@ long IRrecv::decodePanasonic(decode_results *results) {
876883
results->bits = PANASONIC_BITS;
877884
return DECODED;
878885
}
886+
887+
long IRrecv::decodeLG(decode_results *results) {
888+
long data = 0;
889+
int offset = 1; // Skip first space
890+
891+
// Initial mark
892+
if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) {
893+
return ERR;
894+
}
895+
offset++;
896+
if (irparams.rawlen < 2 * LG_BITS + 1 ) {
897+
return ERR;
898+
}
899+
// Initial space
900+
if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) {
901+
return ERR;
902+
}
903+
offset++;
904+
for (int i = 0; i < LG_BITS; i++) {
905+
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) {
906+
return ERR;
907+
}
908+
offset++;
909+
if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) {
910+
data = (data << 1) | 1;
911+
}
912+
else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) {
913+
data <<= 1;
914+
}
915+
else {
916+
return ERR;
917+
}
918+
offset++;
919+
}
920+
//Stop bit
921+
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)){
922+
return ERR;
923+
}
924+
// Success
925+
results->bits = LG_BITS;
926+
results->value = data;
927+
results->decode_type = LG;
928+
return DECODED;
929+
}
930+
931+
879932
long IRrecv::decodeJVC(decode_results *results) {
880933
long data = 0;
881934
int offset = 1; // Skip first space

IRremote.h

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
1111
*
1212
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
13+
* LG added by Darryl Smith (based on the JVC protocol)
1314
*/
1415

1516
#ifndef IRremote_h
@@ -46,6 +47,7 @@ class decode_results {
4647
#define SANYO 9
4748
#define MITSUBISHI 10
4849
#define SAMSUNG 11
50+
#define LG 12
4951
#define UNKNOWN -1
5052

5153
// Decoded value for NEC when a repeat code is received
@@ -70,6 +72,7 @@ class IRrecv
7072
long decodeRC5(decode_results *results);
7173
long decodeRC6(decode_results *results);
7274
long decodePanasonic(decode_results *results);
75+
long decodeLG(decode_results *results);
7376
long decodeJVC(decode_results *results);
7477
long decodeSAMSUNG(decode_results *results);
7578
long decodeHash(decode_results *results);

IRremoteInt.h

+7
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@
159159
#define JVC_ZERO_SPACE 550
160160
#define JVC_RPT_LENGTH 60000
161161

162+
#define LG_HDR_MARK 8000
163+
#define LG_HDR_SPACE 4000
164+
#define LG_BIT_MARK 600
165+
#define LG_ONE_SPACE 1600
166+
#define LG_ZERO_SPACE 550
167+
#define LG_RPT_LENGTH 60000
168+
162169
#define SAMSUNG_HDR_MARK 5000
163170
#define SAMSUNG_HDR_SPACE 5000
164171
#define SAMSUNG_BIT_MARK 560

examples/IRrecvDump/IRrecvDump.ino

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright 2009 Ken Shirriff
66
* http://arcfn.com
77
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
8+
* LG added by Darryl Smith (based on the JVC protocol)
89
*/
910

1011
#include <IRremote.h>
@@ -48,6 +49,9 @@ void dump(decode_results *results) {
4849
Serial.print(results->panasonicAddress,HEX);
4950
Serial.print(" Value: ");
5051
}
52+
else if (results->decode_type == LG) {
53+
Serial.print("Decoded LG: ");
54+
}
5155
else if (results->decode_type == JVC) {
5256
Serial.print("Decoded JVC: ");
5357
}

0 commit comments

Comments
 (0)