Updates for LG Air Conditioner Remote

This commit is contained in:
Darryl Smith
2014-07-10 08:27:36 +10:00
parent 0af9c5a9e9
commit 66c3b1f47c
4 changed files with 67 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
*
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
* LG added by Darryl Smith (based on the JVC protocol)
*/
#include "IRremote.h"
@@ -459,6 +460,12 @@ int IRrecv::decode(decode_results *results) {
if (decodePanasonic(results)) {
return DECODED;
}
#ifdef DEBUG
Serial.println("Attempting LG decode");
#endif
if (decodeLG(results)) {
return DECODED;
}
#ifdef DEBUG
Serial.println("Attempting JVC decode");
#endif
@@ -876,6 +883,52 @@ long IRrecv::decodePanasonic(decode_results *results) {
results->bits = PANASONIC_BITS;
return DECODED;
}
long IRrecv::decodeLG(decode_results *results) {
long data = 0;
int offset = 1; // Skip first space
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) {
return ERR;
}
offset++;
if (irparams.rawlen < 2 * LG_BITS + 1 ) {
return ERR;
}
// Initial space
if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) {
return ERR;
}
offset++;
for (int i = 0; i < LG_BITS; i++) {
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) {
return ERR;
}
offset++;
if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) {
data = (data << 1) | 1;
}
else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) {
data <<= 1;
}
else {
return ERR;
}
offset++;
}
//Stop bit
if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)){
return ERR;
}
// Success
results->bits = LG_BITS;
results->value = data;
results->decode_type = LG;
return DECODED;
}
long IRrecv::decodeJVC(decode_results *results) {
long data = 0;
int offset = 1; // Skip first space

View File

@@ -10,6 +10,7 @@
* Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
*
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
* LG added by Darryl Smith (based on the JVC protocol)
*/
#ifndef IRremote_h
@@ -46,6 +47,7 @@ public:
#define SANYO 9
#define MITSUBISHI 10
#define SAMSUNG 11
#define LG 12
#define UNKNOWN -1
// Decoded value for NEC when a repeat code is received
@@ -70,6 +72,7 @@ private:
long decodeRC5(decode_results *results);
long decodeRC6(decode_results *results);
long decodePanasonic(decode_results *results);
long decodeLG(decode_results *results);
long decodeJVC(decode_results *results);
long decodeSAMSUNG(decode_results *results);
long decodeHash(decode_results *results);

View File

@@ -159,6 +159,13 @@
#define JVC_ZERO_SPACE 550
#define JVC_RPT_LENGTH 60000
#define LG_HDR_MARK 8000
#define LG_HDR_SPACE 4000
#define LG_BIT_MARK 600
#define LG_ONE_SPACE 1600
#define LG_ZERO_SPACE 550
#define LG_RPT_LENGTH 60000
#define SAMSUNG_HDR_MARK 5000
#define SAMSUNG_HDR_SPACE 5000
#define SAMSUNG_BIT_MARK 560

View File

@@ -5,6 +5,7 @@
* Copyright 2009 Ken Shirriff
* http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
* LG added by Darryl Smith (based on the JVC protocol)
*/
#include <IRremote.h>
@@ -48,6 +49,9 @@ void dump(decode_results *results) {
Serial.print(results->panasonicAddress,HEX);
Serial.print(" Value: ");
}
else if (results->decode_type == LG) {
Serial.print("Decoded LG: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}