mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-22 06:16:17 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2dbfee0c2e | ||
|
|
49855488d5 | ||
|
|
e04e7d31b7 | ||
|
|
0096727887 | ||
|
|
74622ec776 | ||
|
|
9a5d40a74c | ||
|
|
1cf65bbcde | ||
|
|
2926b33526 | ||
|
|
ccc7ad9627 | ||
|
|
50530b6519 | ||
|
|
095d8241f1 | ||
|
|
bed4cc5c97 | ||
|
|
93c6e4af55 | ||
|
|
3722d6a0cb | ||
|
|
14f4c7af77 | ||
|
|
3dd4ff6f5f | ||
|
|
32e3bf780f | ||
|
|
806d3246f9 | ||
|
|
f0670efe86 |
339
IRremote.cpp
339
IRremote.cpp
@@ -17,7 +17,6 @@
|
|||||||
* LG added by Darryl Smith (based on the JVC protocol)
|
* LG added by Darryl Smith (based on the JVC protocol)
|
||||||
* Whynter A/C ARC-110WD added by Francesco Meschia
|
* Whynter A/C ARC-110WD added by Francesco Meschia
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "IRremote.h"
|
#include "IRremote.h"
|
||||||
#include "IRremoteInt.h"
|
#include "IRremoteInt.h"
|
||||||
|
|
||||||
@@ -31,39 +30,39 @@ volatile irparams_t irparams;
|
|||||||
// Normally macros are used for efficiency
|
// Normally macros are used for efficiency
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int MATCH(int measured, int desired) {
|
int MATCH(int measured, int desired) {
|
||||||
Serial.print("Testing: ");
|
Serial.print(F("Testing: "));
|
||||||
Serial.print(TICKS_LOW(desired), DEC);
|
Serial.print(TICKS_LOW(desired), DEC);
|
||||||
Serial.print(" <= ");
|
Serial.print(F(" <= "));
|
||||||
Serial.print(measured, DEC);
|
Serial.print(measured, DEC);
|
||||||
Serial.print(" <= ");
|
Serial.print(F(" <= "));
|
||||||
Serial.println(TICKS_HIGH(desired), DEC);
|
Serial.println(TICKS_HIGH(desired), DEC);
|
||||||
return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);
|
return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MATCH_MARK(int measured_ticks, int desired_us) {
|
int MATCH_MARK(int measured_ticks, int desired_us) {
|
||||||
Serial.print("Testing mark ");
|
Serial.print(F("Testing mark "));
|
||||||
Serial.print(measured_ticks * USECPERTICK, DEC);
|
Serial.print(measured_ticks * USECPERTICK, DEC);
|
||||||
Serial.print(" vs ");
|
Serial.print(F(" vs "));
|
||||||
Serial.print(desired_us, DEC);
|
Serial.print(desired_us, DEC);
|
||||||
Serial.print(": ");
|
Serial.print(F(": "));
|
||||||
Serial.print(TICKS_LOW(desired_us + MARK_EXCESS), DEC);
|
Serial.print(TICKS_LOW(desired_us + MARK_EXCESS), DEC);
|
||||||
Serial.print(" <= ");
|
Serial.print(F(" <= "));
|
||||||
Serial.print(measured_ticks, DEC);
|
Serial.print(measured_ticks, DEC);
|
||||||
Serial.print(" <= ");
|
Serial.print(F(" <= "));
|
||||||
Serial.println(TICKS_HIGH(desired_us + MARK_EXCESS), DEC);
|
Serial.println(TICKS_HIGH(desired_us + MARK_EXCESS), DEC);
|
||||||
return measured_ticks >= TICKS_LOW(desired_us + MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS);
|
return measured_ticks >= TICKS_LOW(desired_us + MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MATCH_SPACE(int measured_ticks, int desired_us) {
|
int MATCH_SPACE(int measured_ticks, int desired_us) {
|
||||||
Serial.print("Testing space ");
|
Serial.print(F("Testing space "));
|
||||||
Serial.print(measured_ticks * USECPERTICK, DEC);
|
Serial.print(measured_ticks * USECPERTICK, DEC);
|
||||||
Serial.print(" vs ");
|
Serial.print(F(" vs "));
|
||||||
Serial.print(desired_us, DEC);
|
Serial.print(desired_us, DEC);
|
||||||
Serial.print(": ");
|
Serial.print(F(": "));
|
||||||
Serial.print(TICKS_LOW(desired_us - MARK_EXCESS), DEC);
|
Serial.print(TICKS_LOW(desired_us - MARK_EXCESS), DEC);
|
||||||
Serial.print(" <= ");
|
Serial.print(F(" <= "));
|
||||||
Serial.print(measured_ticks, DEC);
|
Serial.print(measured_ticks, DEC);
|
||||||
Serial.print(" <= ");
|
Serial.print(F(" <= "));
|
||||||
Serial.println(TICKS_HIGH(desired_us - MARK_EXCESS), DEC);
|
Serial.println(TICKS_HIGH(desired_us - MARK_EXCESS), DEC);
|
||||||
return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS);
|
return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS);
|
||||||
}
|
}
|
||||||
@@ -311,6 +310,74 @@ void IRsend::enableIROut(int khz) {
|
|||||||
// The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A.
|
// The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A.
|
||||||
TIMER_CONFIG_KHZ(khz);
|
TIMER_CONFIG_KHZ(khz);
|
||||||
}
|
}
|
||||||
|
/* Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand )
|
||||||
|
|
||||||
|
The Dish send function needs to be repeated 4 times, and the Sharp function
|
||||||
|
has the necessary repeat built in because of the need to invert the signal.
|
||||||
|
|
||||||
|
Sharp protocol documentation:
|
||||||
|
http://www.sbprojects.com/knowledge/ir/sharp.htm
|
||||||
|
|
||||||
|
Here are the LIRC files that I found that seem to match the remote codes
|
||||||
|
from the oscilloscope:
|
||||||
|
|
||||||
|
Sharp LCD TV:
|
||||||
|
http://lirc.sourceforge.net/remotes/sharp/GA538WJSA
|
||||||
|
|
||||||
|
DISH NETWORK (echostar 301):
|
||||||
|
http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
|
||||||
|
|
||||||
|
For the DISH codes, only send the last for characters of the hex.
|
||||||
|
i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the
|
||||||
|
linked LIRC file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void IRsend::sendSharpRaw(unsigned long data, int nbits) {
|
||||||
|
enableIROut(38);
|
||||||
|
|
||||||
|
// Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
|
||||||
|
// much more reliable. That's the exact behaviour of CD-S6470 remote control.
|
||||||
|
for (int n = 0; n < 3; n++) {
|
||||||
|
for (int i = 1 << (nbits-1); i > 0; i>>=1) {
|
||||||
|
if (data & i) {
|
||||||
|
mark(SHARP_BIT_MARK);
|
||||||
|
space(SHARP_ONE_SPACE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mark(SHARP_BIT_MARK);
|
||||||
|
space(SHARP_ZERO_SPACE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mark(SHARP_BIT_MARK);
|
||||||
|
space(SHARP_ZERO_SPACE);
|
||||||
|
delay(40);
|
||||||
|
|
||||||
|
data = data ^ SHARP_TOGGLE_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sharp send compatible with data obtained through decodeSharp
|
||||||
|
void IRsend::sendSharp(unsigned int address, unsigned int command) {
|
||||||
|
sendSharpRaw((address << 10) | (command << 2) | 2, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRsend::sendDISH(unsigned long data, int nbits) {
|
||||||
|
enableIROut(56);
|
||||||
|
mark(DISH_HDR_MARK);
|
||||||
|
space(DISH_HDR_SPACE);
|
||||||
|
for (int i = 0; i < nbits; i++) {
|
||||||
|
if (data & DISH_TOP_BIT) {
|
||||||
|
mark(DISH_BIT_MARK);
|
||||||
|
space(DISH_ONE_SPACE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mark(DISH_BIT_MARK);
|
||||||
|
space(DISH_ZERO_SPACE);
|
||||||
|
}
|
||||||
|
data <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IRrecv::IRrecv(int recvpin)
|
IRrecv::IRrecv(int recvpin)
|
||||||
{
|
{
|
||||||
@@ -441,71 +508,84 @@ int IRrecv::decode(decode_results *results) {
|
|||||||
return ERR;
|
return ERR;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting NEC decode");
|
Serial.println(F("Attempting NEC decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeNEC(results)) {
|
if (decodeNEC(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting Sony decode");
|
Serial.println(F("Attempting Sony decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeSony(results)) {
|
if (decodeSony(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting Sanyo decode");
|
Serial.println(F("Attempting Sanyo decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeSanyo(results)) {
|
if (decodeSanyo(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting Mitsubishi decode");
|
Serial.println(F("Attempting Sharp decode"));
|
||||||
|
#endif
|
||||||
|
if (decodeSharp(results)) {
|
||||||
|
return DECODED;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
Serial.println(F("Attempting Mitsubishi decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeMitsubishi(results)) {
|
if (decodeMitsubishi(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting RC5 decode");
|
Serial.println(F("Attempting RC5 decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeRC5(results)) {
|
if (decodeRC5(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting RC6 decode");
|
Serial.println(F("Attempting RC6 decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeRC6(results)) {
|
if (decodeRC6(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting Panasonic decode");
|
Serial.println(F("Attempting Panasonic decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodePanasonic(results)) {
|
if (decodePanasonic(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting LG decode");
|
Serial.println(F("Attempting LG decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeLG(results)) {
|
if (decodeLG(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting JVC decode");
|
Serial.println(F("Attempting JVC decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeJVC(results)) {
|
if (decodeJVC(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting SAMSUNG decode");
|
Serial.println(F("Attempting SAMSUNG decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeSAMSUNG(results)) {
|
if (decodeSAMSUNG(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Attempting Whynter decode");
|
Serial.println(F("Attempting Whynter decode"));
|
||||||
#endif
|
#endif
|
||||||
if (decodeWhynter(results)) {
|
if (decodeWhynter(results)) {
|
||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
|
// Aiwa RC-T501
|
||||||
|
#ifdef DEBUG
|
||||||
|
Serial.println("Attempting Aiwa RC-T501 decode");
|
||||||
|
#endif
|
||||||
|
if (decodeAiwaRCT501(results)) {
|
||||||
|
return DECODED;
|
||||||
|
}
|
||||||
// decodeHash returns a hash on any input.
|
// decodeHash returns a hash on any input.
|
||||||
// Thus, it needs to be last in the list.
|
// Thus, it needs to be last in the list.
|
||||||
// If you add any decodes, add them before this.
|
// If you add any decodes, add them before this.
|
||||||
@@ -576,7 +656,7 @@ long IRrecv::decodeSony(decode_results *results) {
|
|||||||
// Some Sony's deliver repeats fast after first
|
// Some Sony's deliver repeats fast after first
|
||||||
// unfortunately can't spot difference from of repeat from two fast clicks
|
// unfortunately can't spot difference from of repeat from two fast clicks
|
||||||
if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) {
|
if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) {
|
||||||
// Serial.print("IR Gap found: ");
|
// Serial.print(F("IR Gap found: "));
|
||||||
results->bits = 0;
|
results->bits = 0;
|
||||||
results->value = REPEAT;
|
results->value = REPEAT;
|
||||||
results->decode_type = SANYO;
|
results->decode_type = SANYO;
|
||||||
@@ -657,13 +737,6 @@ long IRrecv::decodeWhynter(decode_results *results) {
|
|||||||
data = (data << 1) | 1;
|
data = (data << 1) | 1;
|
||||||
}
|
}
|
||||||
else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) {
|
else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) {
|
||||||
data <<= 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return ERR;
|
|
||||||
}
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// trailing mark
|
// trailing mark
|
||||||
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
|
if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
|
||||||
@@ -677,6 +750,59 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
// I think this is a Sanyo decoder - serial = SA 8650B
|
// I think this is a Sanyo decoder - serial = SA 8650B
|
||||||
// Looks like Sony except for timings, 48 chars of data and time/space different
|
// Looks like Sony except for timings, 48 chars of data and time/space different
|
||||||
long IRrecv::decodeSanyo(decode_results *results) {
|
long IRrecv::decodeSanyo(decode_results *results) {
|
||||||
@@ -687,13 +813,13 @@ long IRrecv::decodeSanyo(decode_results *results) {
|
|||||||
int offset = 0; // Skip first space
|
int offset = 0; // Skip first space
|
||||||
// Initial space
|
// Initial space
|
||||||
/* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
|
/* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
|
||||||
Serial.print("IR Gap: ");
|
Serial.print(F("IR Gap: "));
|
||||||
Serial.println( results->rawbuf[offset]);
|
Serial.println( results->rawbuf[offset]);
|
||||||
Serial.println( "test against:");
|
Serial.println(F("test against:"));
|
||||||
Serial.println(results->rawbuf[offset]);
|
Serial.println(results->rawbuf[offset]);
|
||||||
*/
|
*/
|
||||||
if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
|
if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
|
||||||
// Serial.print("IR Gap found: ");
|
// Serial.print(F("IR Gap found: "));
|
||||||
results->bits = 0;
|
results->bits = 0;
|
||||||
results->value = REPEAT;
|
results->value = REPEAT;
|
||||||
results->decode_type = SANYO;
|
results->decode_type = SANYO;
|
||||||
@@ -743,7 +869,7 @@ long IRrecv::decodeSanyo(decode_results *results) {
|
|||||||
|
|
||||||
// Looks like Sony except for timings, 48 chars of data and time/space different
|
// Looks like Sony except for timings, 48 chars of data and time/space different
|
||||||
long IRrecv::decodeMitsubishi(decode_results *results) {
|
long IRrecv::decodeMitsubishi(decode_results *results) {
|
||||||
// Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
|
// Serial.print(F("?!? decoding Mitsubishi:"));Serial.print(irparams.rawlen); Serial.print(F(" want ")); Serial.println( 2 * MITSUBISHI_BITS + 2);
|
||||||
long data = 0;
|
long data = 0;
|
||||||
if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) {
|
if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) {
|
||||||
return ERR;
|
return ERR;
|
||||||
@@ -751,14 +877,14 @@ long IRrecv::decodeMitsubishi(decode_results *results) {
|
|||||||
int offset = 0; // Skip first space
|
int offset = 0; // Skip first space
|
||||||
// Initial space
|
// Initial space
|
||||||
/* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
|
/* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
|
||||||
Serial.print("IR Gap: ");
|
Serial.print(F("IR Gap: "));
|
||||||
Serial.println( results->rawbuf[offset]);
|
Serial.println( results->rawbuf[offset]);
|
||||||
Serial.println( "test against:");
|
Serial.println(F("test against:"));
|
||||||
Serial.println(results->rawbuf[offset]);
|
Serial.println(results->rawbuf[offset]);
|
||||||
*/
|
*/
|
||||||
/* Not seeing double keys from Mitsubishi
|
/* Not seeing double keys from Mitsubishi
|
||||||
if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) {
|
if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) {
|
||||||
// Serial.print("IR Gap found: ");
|
// Serial.print(F("IR Gap found: "));
|
||||||
results->bits = 0;
|
results->bits = 0;
|
||||||
results->value = REPEAT;
|
results->value = REPEAT;
|
||||||
results->decode_type = MITSUBISHI;
|
results->decode_type = MITSUBISHI;
|
||||||
@@ -783,12 +909,12 @@ long IRrecv::decodeMitsubishi(decode_results *results) {
|
|||||||
data <<= 1;
|
data <<= 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Serial.println("A"); Serial.println(offset); Serial.println(results->rawbuf[offset]);
|
// Serial.println(F("A")); Serial.println(offset); Serial.println(results->rawbuf[offset]);
|
||||||
return ERR;
|
return ERR;
|
||||||
}
|
}
|
||||||
offset++;
|
offset++;
|
||||||
if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) {
|
if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) {
|
||||||
// Serial.println("B"); Serial.println(offset); Serial.println(results->rawbuf[offset]);
|
// Serial.println(F("B")); Serial.println(offset); Serial.println(results->rawbuf[offset]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
offset++;
|
offset++;
|
||||||
@@ -843,10 +969,10 @@ int IRrecv::getRClevel(decode_results *results, int *offset, int *used, int t1)
|
|||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (val == MARK) {
|
if (val == MARK) {
|
||||||
Serial.println("MARK");
|
Serial.println(F("MARK"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.println("SPACE");
|
Serial.println(F("SPACE"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return val;
|
return val;
|
||||||
@@ -1117,6 +1243,65 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
|
|||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aiwa system
|
||||||
|
* Remote control RC-T501
|
||||||
|
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
long IRrecv::decodeAiwaRCT501(decode_results *results) {
|
||||||
|
int data = 0;
|
||||||
|
int offset = 1; // skip first garbage read
|
||||||
|
|
||||||
|
// Check SIZE
|
||||||
|
if(irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) {
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check HDR
|
||||||
|
if(!MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_HDR_MARK)) {
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
offset++;
|
||||||
|
|
||||||
|
// Check HDR space
|
||||||
|
if(!MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_HDR_SPACE)) {
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
offset++;
|
||||||
|
|
||||||
|
offset += 26; // skip pre-data - optional
|
||||||
|
while(offset < irparams.rawlen - 4) {
|
||||||
|
if(MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) {
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ONE & ZERO
|
||||||
|
if(MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) {
|
||||||
|
data = (data << 1) | 1;
|
||||||
|
}
|
||||||
|
else if(MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) {
|
||||||
|
data <<= 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// End of one & zero detected
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
|
||||||
|
results->bits = (offset - 1) / 2;
|
||||||
|
if(results->bits < 42) {
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
results->value = data;
|
||||||
|
results->decode_type = AIWA_RC_T501;
|
||||||
|
return DECODED;
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
* hashdecode - decode an arbitrary IR code.
|
* hashdecode - decode an arbitrary IR code.
|
||||||
* Instead of decoding using a standard encoding scheme
|
* Instead of decoding using a standard encoding scheme
|
||||||
@@ -1171,71 +1356,5 @@ long IRrecv::decodeHash(decode_results *results) {
|
|||||||
return DECODED;
|
return DECODED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand )
|
|
||||||
|
|
||||||
The Dish send function needs to be repeated 4 times, and the Sharp function
|
|
||||||
has the necessary repeat built in because of the need to invert the signal.
|
|
||||||
|
|
||||||
Sharp protocol documentation:
|
|
||||||
http://www.sbprojects.com/knowledge/ir/sharp.htm
|
|
||||||
|
|
||||||
Here are the LIRC files that I found that seem to match the remote codes
|
|
||||||
from the oscilloscope:
|
|
||||||
|
|
||||||
Sharp LCD TV:
|
|
||||||
http://lirc.sourceforge.net/remotes/sharp/GA538WJSA
|
|
||||||
|
|
||||||
DISH NETWORK (echostar 301):
|
|
||||||
http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx
|
|
||||||
|
|
||||||
For the DISH codes, only send the last for characters of the hex.
|
|
||||||
i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the
|
|
||||||
linked LIRC file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void IRsend::sendSharpRaw(unsigned long data, int nbits) {
|
|
||||||
enableIROut(38);
|
|
||||||
|
|
||||||
// Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
|
|
||||||
// much more reliable. That's the exact behaviour of CD-S6470 remote control.
|
|
||||||
for (int n = 0; n < 3; n++) {
|
|
||||||
for (int i = 1 << (nbits-1); i > 0; i>>=1) {
|
|
||||||
if (data & i) {
|
|
||||||
mark(SHARP_BIT_MARK);
|
|
||||||
space(SHARP_ONE_SPACE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mark(SHARP_BIT_MARK);
|
|
||||||
space(SHARP_ZERO_SPACE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mark(SHARP_BIT_MARK);
|
|
||||||
space(SHARP_ZERO_SPACE);
|
|
||||||
delay(40);
|
|
||||||
|
|
||||||
data = data ^ SHARP_TOGGLE_MASK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sharp send compatible with data obtained through decodeSharp
|
|
||||||
void IRsend::sendSharp(unsigned int address, unsigned int command) {
|
|
||||||
sendSharpRaw((address << 10) | (command << 2) | 2, 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRsend::sendDISH(unsigned long data, int nbits) {
|
|
||||||
enableIROut(56);
|
|
||||||
mark(DISH_HDR_MARK);
|
|
||||||
space(DISH_HDR_SPACE);
|
|
||||||
for (int i = 0; i < nbits; i++) {
|
|
||||||
if (data & DISH_TOP_BIT) {
|
|
||||||
mark(DISH_BIT_MARK);
|
|
||||||
space(DISH_ONE_SPACE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mark(DISH_BIT_MARK);
|
|
||||||
space(DISH_ZERO_SPACE);
|
|
||||||
}
|
|
||||||
data <<= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
20
IRremote.h
20
IRremote.h
@@ -17,6 +17,13 @@
|
|||||||
#ifndef IRremote_h
|
#ifndef IRremote_h
|
||||||
#define IRremote_h
|
#define IRremote_h
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
|
#include <Arduino.h>
|
||||||
|
#else
|
||||||
|
#include <WProgram.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// The following are compile-time library options.
|
// The following are compile-time library options.
|
||||||
// If you change them, recompile the library.
|
// If you change them, recompile the library.
|
||||||
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
|
// If DEBUG is defined, a lot of debugging output will be printed during decoding.
|
||||||
@@ -28,13 +35,15 @@
|
|||||||
// Results returned from the decoder
|
// Results returned from the decoder
|
||||||
class decode_results {
|
class decode_results {
|
||||||
public:
|
public:
|
||||||
int decode_type; // NEC, SONY, RC5, UNKNOWN
|
int8_t decode_type; // NEC, SONY, RC5, UNKNOWN
|
||||||
|
int8_t bits; // Number of bits in decoded value
|
||||||
|
unsigned long value; // Decoded value
|
||||||
|
|
||||||
union { // This is used for decoding Panasonic and Sharp data
|
union { // This is used for decoding Panasonic and Sharp data
|
||||||
unsigned int panasonicAddress;
|
unsigned int panasonicAddress;
|
||||||
unsigned int sharpAddress;
|
unsigned int sharpAddress;
|
||||||
};
|
};
|
||||||
unsigned long value; // Decoded value
|
|
||||||
int bits; // Number of bits in decoded value
|
|
||||||
volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks
|
volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks
|
||||||
int rawlen; // Number of records in rawbuf.
|
int rawlen; // Number of records in rawbuf.
|
||||||
};
|
};
|
||||||
@@ -53,6 +62,8 @@ public:
|
|||||||
#define SAMSUNG 11
|
#define SAMSUNG 11
|
||||||
#define LG 12
|
#define LG 12
|
||||||
#define WHYNTER 13
|
#define WHYNTER 13
|
||||||
|
#define Sharp 14
|
||||||
|
#define AIWA_RC_T501 15
|
||||||
#define UNKNOWN -1
|
#define UNKNOWN -1
|
||||||
|
|
||||||
// Decoded value for NEC when a repeat code is received
|
// Decoded value for NEC when a repeat code is received
|
||||||
@@ -72,6 +83,7 @@ private:
|
|||||||
int getRClevel(decode_results *results, int *offset, int *used, int t1);
|
int getRClevel(decode_results *results, int *offset, int *used, int t1);
|
||||||
long decodeNEC(decode_results *results);
|
long decodeNEC(decode_results *results);
|
||||||
long decodeSony(decode_results *results);
|
long decodeSony(decode_results *results);
|
||||||
|
long decodeSharp(decode_results *results);
|
||||||
long decodeSanyo(decode_results *results);
|
long decodeSanyo(decode_results *results);
|
||||||
long decodeMitsubishi(decode_results *results);
|
long decodeMitsubishi(decode_results *results);
|
||||||
long decodeRC5(decode_results *results);
|
long decodeRC5(decode_results *results);
|
||||||
@@ -81,6 +93,7 @@ private:
|
|||||||
long decodeJVC(decode_results *results);
|
long decodeJVC(decode_results *results);
|
||||||
long decodeSAMSUNG(decode_results *results);
|
long decodeSAMSUNG(decode_results *results);
|
||||||
long decodeWhynter(decode_results *results);
|
long decodeWhynter(decode_results *results);
|
||||||
|
long decodeAiwaRCT501(decode_results *results);
|
||||||
long decodeHash(decode_results *results);
|
long decodeHash(decode_results *results);
|
||||||
int compare(unsigned int oldval, unsigned int newval);
|
int compare(unsigned int oldval, unsigned int newval);
|
||||||
|
|
||||||
@@ -111,6 +124,7 @@ public:
|
|||||||
void sendSharpRaw(unsigned long data, int nbits);
|
void sendSharpRaw(unsigned long data, int nbits);
|
||||||
void sendPanasonic(unsigned int address, unsigned long data);
|
void sendPanasonic(unsigned int address, unsigned long data);
|
||||||
void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
|
void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
|
||||||
|
void sendAiwaRCT501(int code);
|
||||||
// private:
|
// private:
|
||||||
void sendSAMSUNG(unsigned long data, int nbits);
|
void sendSAMSUNG(unsigned long data, int nbits);
|
||||||
void enableIROut(int khz);
|
void enableIROut(int khz);
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
#define SHARP_ZERO_SPACE 795
|
#define SHARP_ZERO_SPACE 795
|
||||||
#define SHARP_GAP 600000
|
#define SHARP_GAP 600000
|
||||||
#define SHARP_TOGGLE_MASK 0x3FF
|
#define SHARP_TOGGLE_MASK 0x3FF
|
||||||
#define SHARP_RPT_SPACE 3000
|
#define SHARP_RPT_SPACE 950 // 40ms
|
||||||
|
|
||||||
#define DISH_HDR_MARK 400
|
#define DISH_HDR_MARK 400
|
||||||
#define DISH_HDR_SPACE 6100
|
#define DISH_HDR_SPACE 6100
|
||||||
@@ -190,6 +190,20 @@
|
|||||||
#define SHARP_BITS 15
|
#define SHARP_BITS 15
|
||||||
#define DISH_BITS 16
|
#define DISH_BITS 16
|
||||||
|
|
||||||
|
// AIWA RC T501
|
||||||
|
// Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
|
||||||
|
#define AIWA_RC_T501_HZ 38
|
||||||
|
#define AIWA_RC_T501_BITS 15
|
||||||
|
#define AIWA_RC_T501_PRE_BITS 26
|
||||||
|
#define AIWA_RC_T501_POST_BITS 1
|
||||||
|
#define AIWA_RC_T501_SUM_BITS AIWA_RC_T501_PRE_BITS+AIWA_RC_T501_BITS+AIWA_RC_T501_POST_BITS
|
||||||
|
#define AIWA_RC_T501_HDR_MARK 8800
|
||||||
|
#define AIWA_RC_T501_HDR_SPACE 4500
|
||||||
|
#define AIWA_RC_T501_BIT_MARK 500
|
||||||
|
#define AIWA_RC_T501_ONE_SPACE 600
|
||||||
|
#define AIWA_RC_T501_ZERO_SPACE 1700
|
||||||
|
|
||||||
|
|
||||||
#define TOLERANCE 25 // percent tolerance in measurements
|
#define TOLERANCE 25 // percent tolerance in measurements
|
||||||
#define LTOL (1.0 - TOLERANCE/100.)
|
#define LTOL (1.0 - TOLERANCE/100.)
|
||||||
#define UTOL (1.0 + TOLERANCE/100.)
|
#define UTOL (1.0 + TOLERANCE/100.)
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ This library enables you to send and receive using infra-red signals on an ardui
|
|||||||
|
|
||||||
Check [here](http://shirriff.github.io/Arduino-IRremote/) for tutorials and more information.
|
Check [here](http://shirriff.github.io/Arduino-IRremote/) for tutorials and more information.
|
||||||
|
|
||||||
## Version - 1.00
|
## Version - 1.01
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
1. Navigate to the [Releases](https://github.com/shirriff/Arduino-IRremote/releases) page.
|
1. Navigate to the [Releases](https://github.com/shirriff/Arduino-IRremote/releases) page.
|
||||||
|
|||||||
13
changelog.md
Normal file
13
changelog.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Change Log
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [1.0.1] - 2015-03-08
|
||||||
|
### Added
|
||||||
|
- Support for Sharp Decoding
|
||||||
|
- Support for Aiwa Decoding
|
||||||
|
- Changelog documentation
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Improved memory management in debugging
|
||||||
|
- Use of F() macro saves RAM
|
||||||
25
examples/AiwaRCT501SendDemo/AiwaRCT501SendDemo.ino
Normal file
25
examples/AiwaRCT501SendDemo/AiwaRCT501SendDemo.ino
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
|
||||||
|
* An IR LED must be connected to Arduino PWM pin 3.
|
||||||
|
* Version 0.1 July, 2009
|
||||||
|
* Copyright 2009 Ken Shirriff
|
||||||
|
* http://arcfn.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "IRremote.h"
|
||||||
|
|
||||||
|
#define POWER 0x7F80
|
||||||
|
|
||||||
|
IRsend irsend;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
Serial.println("Arduino Ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (Serial.read() != -1) {
|
||||||
|
irsend.sendAiwaRCT501(POWER);
|
||||||
|
delay(60); // Optional
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,11 +49,20 @@ void dump(decode_results *results) {
|
|||||||
Serial.print(results->panasonicAddress,HEX);
|
Serial.print(results->panasonicAddress,HEX);
|
||||||
Serial.print(" Value: ");
|
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) {
|
else if (results->decode_type == LG) {
|
||||||
Serial.print("Decoded LG: ");
|
Serial.print("Decoded LG: ");
|
||||||
}
|
}
|
||||||
else if (results->decode_type == JVC) {
|
else if (results->decode_type == JVC) {
|
||||||
Serial.print("Decoded JVC: ");
|
Serial.print("Decoded JVC: ");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (results->decode_type == AIWA_RC_T501) {
|
||||||
|
Serial.print("Decoded AIWA RC T501: ");
|
||||||
}
|
}
|
||||||
else if (results->decode_type == WHYNTER) {
|
else if (results->decode_type == WHYNTER) {
|
||||||
Serial.print("Decoded Whynter: ");
|
Serial.print("Decoded Whynter: ");
|
||||||
|
|||||||
@@ -48,5 +48,6 @@ SHARP LITERAL1
|
|||||||
PANASONIC LITERAL1
|
PANASONIC LITERAL1
|
||||||
JVC LITERAL1
|
JVC LITERAL1
|
||||||
LG LITERAL1
|
LG LITERAL1
|
||||||
|
SHARP LITERAL1
|
||||||
UNKNOWN LITERAL1
|
UNKNOWN LITERAL1
|
||||||
REPEAT LITERAL1
|
REPEAT LITERAL1
|
||||||
|
|||||||
Reference in New Issue
Block a user