mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2026-01-04 12:32:51 +00:00
Merging Sharp
This commit is contained in:
71
IRremote.cpp
71
IRremote.cpp
@@ -458,6 +458,12 @@ int IRrecv::decode(decode_results *results) {
|
||||
if (decodeSanyo(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Sharp decode");
|
||||
#endif
|
||||
if (decodeSharp(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Mitsubishi decode");
|
||||
#endif
|
||||
@@ -618,6 +624,7 @@ long IRrecv::decodeSony(decode_results *results) {
|
||||
return DECODED;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
long IRrecv::decodeWhynter(decode_results *results) {
|
||||
long data = 0;
|
||||
|
||||
@@ -657,14 +664,7 @@ long IRrecv::decodeWhynter(decode_results *results) {
|
||||
data = (data << 1) | 1;
|
||||
}
|
||||
else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) {
|
||||
data <<= 1;
|
||||
}
|
||||
else {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
|
||||
// trailing mark
|
||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
|
||||
return ERR;
|
||||
@@ -677,6 +677,61 @@ long IRrecv::decodeWhynter(decode_results *results) {
|
||||
}
|
||||
|
||||
|
||||
=======
|
||||
long IRrecv::decodeSharp(decode_results *results) {
|
||||
long data = 0;
|
||||
if (irparams.rawlen < 32) {
|
||||
return ERR;
|
||||
}
|
||||
|
||||
int offset = 0; // Dont skip first space, check its size
|
||||
|
||||
if (results->rawbuf[offset] < SHARP_RPT_SPACE) {
|
||||
// Serial.print("IR Gap found: ");
|
||||
results->bits = 0;
|
||||
results->value = REPEAT;
|
||||
results->decode_type = SHARP;
|
||||
return DECODED;
|
||||
}
|
||||
|
||||
offset++;
|
||||
|
||||
while (offset + 1 < irparams.rawlen) {
|
||||
if (!MATCH_MARK(results->rawbuf[offset], SHARP_BIT_MARK)) {
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
if (MATCH_SPACE(results->rawbuf[offset], SHARP_ONE_SPACE)) {
|
||||
data = (data << 1) | 1;
|
||||
}
|
||||
else if (MATCH_SPACE(results->rawbuf[offset], SHARP_ZERO_SPACE)) {
|
||||
data <<= 1;
|
||||
}
|
||||
else {
|
||||
return ERR;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
|
||||
if (data & 1 || !(data & 2)) {
|
||||
return ERR;
|
||||
}
|
||||
|
||||
// Success
|
||||
results->bits = (offset - 1) / 2;
|
||||
if (results->bits < 15) {
|
||||
results->bits = 0;
|
||||
return ERR;
|
||||
}
|
||||
|
||||
results->sharpAddress = (data >> 10) & 0b11111;
|
||||
results->value = (data >> 2) & 0xff;
|
||||
results->decode_type = SHARP;
|
||||
return DECODED;
|
||||
}
|
||||
|
||||
>>>>>>> 0b9d907da992bbb56493164e79d37006ec52e777
|
||||
// I think this is a Sanyo decoder - serial = SA 8650B
|
||||
// Looks like Sony except for timings, 48 chars of data and time/space different
|
||||
long IRrecv::decodeSanyo(decode_results *results) {
|
||||
|
||||
11
IRremote.h
11
IRremote.h
@@ -29,9 +29,9 @@
|
||||
class decode_results {
|
||||
public:
|
||||
int decode_type; // NEC, SONY, RC5, UNKNOWN
|
||||
union { // This is used for decoding Panasonic and Sharp data
|
||||
unsigned int panasonicAddress;
|
||||
unsigned int sharpAddress;
|
||||
union {
|
||||
unsigned int panasonicAddress; // This is only used for decoding Panasonic data
|
||||
unsigned int sharpAddress; // This is only used for decoding Panasonic data
|
||||
};
|
||||
unsigned long value; // Decoded value
|
||||
int bits; // Number of bits in decoded value
|
||||
@@ -52,7 +52,11 @@ public:
|
||||
#define MITSUBISHI 10
|
||||
#define SAMSUNG 11
|
||||
#define LG 12
|
||||
<<<<<<< HEAD
|
||||
#define WHYNTER 13
|
||||
=======
|
||||
#define SHARP 13
|
||||
>>>>>>> 0b9d907da992bbb56493164e79d37006ec52e777
|
||||
#define UNKNOWN -1
|
||||
|
||||
// Decoded value for NEC when a repeat code is received
|
||||
@@ -72,6 +76,7 @@ private:
|
||||
int getRClevel(decode_results *results, int *offset, int *used, int t1);
|
||||
long decodeNEC(decode_results *results);
|
||||
long decodeSony(decode_results *results);
|
||||
long decodeSharp(decode_results *results);
|
||||
long decodeSanyo(decode_results *results);
|
||||
long decodeMitsubishi(decode_results *results);
|
||||
long decodeRC5(decode_results *results);
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
#define SHARP_ZERO_SPACE 795
|
||||
#define SHARP_GAP 600000
|
||||
#define SHARP_TOGGLE_MASK 0x3FF
|
||||
#define SHARP_RPT_SPACE 3000
|
||||
#define SHARP_RPT_SPACE 950 // 40ms
|
||||
|
||||
#define DISH_HDR_MARK 400
|
||||
#define DISH_HDR_SPACE 6100
|
||||
|
||||
@@ -49,6 +49,11 @@ void dump(decode_results *results) {
|
||||
Serial.print(results->panasonicAddress,HEX);
|
||||
Serial.print(" Value: ");
|
||||
}
|
||||
else if (results->decode_type == SHARP) {
|
||||
Serial.print("Decoded SHARP - Address: ");
|
||||
Serial.print(results->sharpAddress,HEX);
|
||||
Serial.print(" Value: ");
|
||||
}
|
||||
else if (results->decode_type == LG) {
|
||||
Serial.print("Decoded LG: ");
|
||||
}
|
||||
|
||||
@@ -48,5 +48,6 @@ SHARP LITERAL1
|
||||
PANASONIC LITERAL1
|
||||
JVC LITERAL1
|
||||
LG LITERAL1
|
||||
SHARP LITERAL1
|
||||
UNKNOWN LITERAL1
|
||||
REPEAT LITERAL1
|
||||
|
||||
Reference in New Issue
Block a user