merging 110

This commit is contained in:
Joshua Noble
2015-03-15 13:28:46 -07:00
3 changed files with 147 additions and 8 deletions

View File

@@ -74,6 +74,7 @@ int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks
// Debugging versions are in IRremote.cpp
#endif
#ifdef NEC
void IRsend::sendNEC(unsigned long data, int nbits)
{
enableIROut(38);
@@ -93,7 +94,9 @@ void IRsend::sendNEC(unsigned long data, int nbits)
mark(NEC_BIT_MARK);
space(0);
}
#endif
#ifdef WHYNTER
void IRsend::sendWhynter(unsigned long data, int nbits) {
enableIROut(38);
mark(WHYNTER_ZERO_MARK);
@@ -114,7 +117,9 @@ void IRsend::sendWhynter(unsigned long data, int nbits) {
mark(WHYNTER_ZERO_MARK);
space(WHYNTER_ZERO_SPACE);
}
#endif
#ifdef SONY
void IRsend::sendSony(unsigned long data, int nbits) {
enableIROut(40);
mark(SONY_HDR_MARK);
@@ -132,6 +137,7 @@ void IRsend::sendSony(unsigned long data, int nbits) {
data <<= 1;
}
}
#endif
void IRsend::sendRaw(unsigned int buf[], int len, int hz)
{
@@ -200,6 +206,8 @@ void IRsend::sendRC6(unsigned long data, int nbits)
}
space(0); // Turn off at end
}
#ifdef PANASONIC
void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
enableIROut(35);
mark(PANASONIC_HDR_MARK);
@@ -227,6 +235,9 @@ void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
mark(PANASONIC_BIT_MARK);
space(0);
}
#endif
#ifdef JVC
void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
{
enableIROut(38);
@@ -249,7 +260,9 @@ void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
mark(JVC_BIT_MARK);
space(0);
}
#endif
#ifdef SAMSUNG
void IRsend::sendSAMSUNG(unsigned long data, int nbits)
{
enableIROut(38);
@@ -269,6 +282,7 @@ void IRsend::sendSAMSUNG(unsigned long data, int nbits)
mark(SAMSUNG_BIT_MARK);
space(0);
}
#endif
void IRsend::mark(int time) {
// Sends an IR mark for the specified number of microseconds.
@@ -440,48 +454,70 @@ int IRrecv::decode(decode_results *results) {
if (irparams.rcvstate != STATE_STOP) {
return ERR;
}
#ifdef NEC
#ifdef DEBUG
Serial.println("Attempting NEC decode");
#endif
if (decodeNEC(results)) {
return DECODED;
}
#endif
#ifdef SONY
#ifdef DEBUG
Serial.println("Attempting Sony decode");
#endif
if (decodeSony(results)) {
return DECODED;
}
#endif
#ifdef SANYO
#ifdef DEBUG
Serial.println("Attempting Sanyo decode");
#endif
if (decodeSanyo(results)) {
return DECODED;
}
#endif
#ifdef MITSUBISHI
#ifdef DEBUG
Serial.println("Attempting Mitsubishi decode");
#endif
if (decodeMitsubishi(results)) {
return DECODED;
}
#endif
#ifdef RC5
#ifdef DEBUG
Serial.println("Attempting RC5 decode");
#endif
if (decodeRC5(results)) {
return DECODED;
}
#endif
#ifdef RC6
#ifdef DEBUG
Serial.println("Attempting RC6 decode");
#endif
if (decodeRC6(results)) {
return DECODED;
}
#endif
#ifdef PANASONIC
#ifdef DEBUG
Serial.println("Attempting Panasonic decode");
#endif
if (decodePanasonic(results)) {
return DECODED;
}
#endif
#ifdef JVC
#ifdef DEBUG
Serial.println("Attempting LG decode");
#endif
@@ -494,6 +530,9 @@ int IRrecv::decode(decode_results *results) {
if (decodeJVC(results)) {
return DECODED;
}
#endif
#ifdef SAMSUNG
#ifdef DEBUG
Serial.println("Attempting SAMSUNG decode");
#endif
@@ -507,12 +546,15 @@ int IRrecv::decode(decode_results *results) {
return DECODED;
}
// Aiwa RC-T501
#ifdef AIWA_RC_T501
#ifdef DEBUG
Serial.println("Attempting Aiwa RC-T501 decode");
#endif
if (decodeAiwaRCT501(results)) {
return DECODED;
}
#endif
// decodeHash returns a hash on any input.
// Thus, it needs to be last in the list.
// If you add any decodes, add them before this.
@@ -524,6 +566,7 @@ int IRrecv::decode(decode_results *results) {
return ERR;
}
#ifdef NEC
// NECs have a repeat only 4 items long
long IRrecv::decodeNEC(decode_results *results) {
long data = 0;
@@ -572,7 +615,9 @@ long IRrecv::decodeNEC(decode_results *results) {
results->decode_type = NEC;
return DECODED;
}
#endif
#ifdef SONY
long IRrecv::decodeSony(decode_results *results) {
long data = 0;
if (irparams.rawlen < 2 * SONY_BITS + 2) {
@@ -586,7 +631,11 @@ long IRrecv::decodeSony(decode_results *results) {
// Serial.print("IR Gap found: ");
results->bits = 0;
results->value = REPEAT;
#ifdef SANYO
results->decode_type = SANYO;
#else
results->decode_type = UNKNOWN;
#endif
return DECODED;
}
offset++;
@@ -624,6 +673,7 @@ long IRrecv::decodeSony(decode_results *results) {
results->decode_type = SONY;
return DECODED;
}
#endif
long IRrecv::decodeWhynter(decode_results *results) {
long data = 0;
@@ -684,6 +734,7 @@ long IRrecv::decodeWhynter(decode_results *results) {
}
#ifdef SANYO
// 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) {
@@ -747,7 +798,9 @@ long IRrecv::decodeSanyo(decode_results *results) {
results->decode_type = SANYO;
return DECODED;
}
#endif
#ifdef MITSUBISHI
// Looks like Sony except for timings, 48 chars of data and time/space different
long IRrecv::decodeMitsubishi(decode_results *results) {
// Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
@@ -811,7 +864,7 @@ long IRrecv::decodeMitsubishi(decode_results *results) {
results->decode_type = MITSUBISHI;
return DECODED;
}
#endif
// Gets one undecoded level at a time from the raw buffer.
// The RC5/6 decoding is easier if the data is broken into time intervals.
@@ -858,6 +911,7 @@ int IRrecv::getRClevel(decode_results *results, int *offset, int *used, int t1)
#endif
return val;
}
#endif
long IRrecv::decodeRC5(decode_results *results) {
if (irparams.rawlen < MIN_RC5_SAMPLES + 2) {
@@ -944,6 +998,8 @@ long IRrecv::decodeRC6(decode_results *results) {
results->decode_type = RC6;
return DECODED;
}
#ifdef PANASONIC
long IRrecv::decodePanasonic(decode_results *results) {
unsigned long long data = 0;
int offset = 1;
@@ -977,7 +1033,9 @@ long IRrecv::decodePanasonic(decode_results *results) {
results->bits = PANASONIC_BITS;
return DECODED;
}
#endif
#ifdef LG
long IRrecv::decodeLG(decode_results *results) {
long data = 0;
int offset = 1; // Skip first space
@@ -1023,6 +1081,9 @@ long IRrecv::decodeLG(decode_results *results) {
}
#endif
#ifdef JVC
long IRrecv::decodeJVC(decode_results *results) {
long data = 0;
int offset = 1; // Skip first space
@@ -1074,7 +1135,9 @@ long IRrecv::decodeJVC(decode_results *results) {
results->decode_type = JVC;
return DECODED;
}
#endif
#ifdef SAMSUNG
// SAMSUNGs have a repeat only 4 items long
long IRrecv::decodeSAMSUNG(decode_results *results) {
long data = 0;
@@ -1123,6 +1186,7 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
results->decode_type = SAMSUNG;
return DECODED;
}
#endif
/**
* Aiwa system
@@ -1130,6 +1194,7 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
*
*/
#ifdef AIWA_RC_T501
long IRrecv::decodeAiwaRCT501(decode_results *results) {
int data = 0;
int offset = 1; // skip first garbage read
@@ -1183,6 +1248,8 @@ long IRrecv::decodeAiwaRCT501(decode_results *results) {
return DECODED;
}
#endif
/* -----------------------------------------------------------------------
* hashdecode - decode an arbitrary IR code.
* Instead of decoding using a standard encoding scheme
@@ -1259,7 +1326,9 @@ i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the
linked LIRC file.
*/
void IRsend::sendSharpRaw(unsigned long data, int nbits) {
#ifdef IRsendSHARP
void IRsend::sendSharp(unsigned long data, int nbits) {
unsigned long invertdata = data ^ SHARP_TOGGLE_MASK;
enableIROut(38);
// Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
@@ -1289,7 +1358,11 @@ void IRsend::sendSharp(unsigned int address, unsigned int command) {
sendSharpRaw((address << 10) | (command << 2) | 2, 15);
}
void IRsend::sendDISH(unsigned long data, int nbits) {
#endif
#ifdef IRsendDISH
void IRsend::sendDISH(unsigned long data, int nbits)
{
enableIROut(56);
mark(DISH_HDR_MARK);
space(DISH_HDR_SPACE);
@@ -1305,13 +1378,15 @@ void IRsend::sendDISH(unsigned long data, int nbits) {
data <<= 1;
}
}
#endif
/**
* Aiwa system
* Remote control RC-T501
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
*
*/
#ifdef AIWA_RC_T501
void IRsend::sendAiwaRCT501(int code) {
// PRE-DATA, 26 bits, 0x227EEC0
long int pre = 0x227EEC0;
@@ -1354,4 +1429,5 @@ void IRsend::sendAiwaRCT501(int code) {
mark(AIWA_RC_T501_BIT_MARK);
space(0);
}
}
#endif

View File

@@ -39,6 +39,20 @@ public:
int rawlen; // Number of records in rawbuf.
};
// Send types
#define IRsendNEC
#define IRsendSONY
#define IRsendRC5
#define IRsendRC6
#define IRsendDISH
#define IRsendSHARP
#define IRsendPANASONIC
#define IRsendJVC
#define IRsendSANYO
#define IRsendMITSUBISHI
#define IRsendSAMSUNG
#define IRsendRAW
// Values for decode_type
#define NEC 1
#define SONY 2
@@ -71,18 +85,45 @@ public:
private:
// These are called by decode
int getRClevel(decode_results *results, int *offset, int *used, int t1);
#ifdef NEC
long decodeNEC(decode_results *results);
#endif
#ifdef SONY
long decodeSony(decode_results *results);
#endif
#ifdef SANYO
long decodeSanyo(decode_results *results);
#endif
#ifdef MITSUBISHI
long decodeMitsubishi(decode_results *results);
#endif
#ifdef RC5
long decodeRC5(decode_results *results);
#endif
#ifdef RC6
long decodeRC6(decode_results *results);
#endif
#ifdef PANASONIC
long decodePanasonic(decode_results *results);
#endif
#ifdef LG
long decodeLG(decode_results *results);
#endif
#ifdef JVC
long decodeJVC(decode_results *results);
#endif
#ifdef SAMSUNG
long decodeSAMSUNG(decode_results *results);
#endif
#ifdef WHYNTER
long decodeWhynter(decode_results *results);
#endif
#ifdef AIWA_RC_T501
long decodeAiwaRCT501(decode_results *results);
#endif
long decodeHash(decode_results *results);
int compare(unsigned int oldval, unsigned int newval);
@@ -99,23 +140,44 @@ class IRsend
{
public:
IRsend() {}
void sendRaw(unsigned int buf[], int len, int hz);
void sendRC5(unsigned long data, int nbits);
void sendRC6(unsigned long data, int nbits);
#ifdef WHYNTER
void sendWhynter(unsigned long data, int nbits);
#endif
#ifdef NEC
void sendNEC(unsigned long data, int nbits);
#endif
#ifdef SONY
void sendSony(unsigned long data, int nbits);
// Neither Sanyo nor Mitsubishi send is implemented yet
// void sendSanyo(unsigned long data, int nbits);
// void sendMitsubishi(unsigned long data, int nbits);
void sendRaw(unsigned int buf[], int len, int hz);
void sendRC5(unsigned long data, int nbits);
void sendRC6(unsigned long data, int nbits);
#endif
#ifdef DISH
void sendDISH(unsigned long data, int nbits);
#endif
#ifdef SHARP
void sendSharp(unsigned int address, unsigned int command);
void sendSharpRaw(unsigned long data, int nbits);
#endif
#ifdef IRsendSHARP
void sendSharp(unsigned long data, int nbits);
#endif
#ifdef PANASONIC
void sendPanasonic(unsigned int address, unsigned long data);
#endif
#ifdef JVC
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:
#endif
#ifdef SAMSUNG
void sendSAMSUNG(unsigned long data, int nbits);
#endif
void enableIROut(int khz);
VIRTUAL void mark(int usec);
VIRTUAL void space(int usec);

View File

@@ -9,6 +9,7 @@
#include "IRremote.h"
#define POWER 0x7F80
#define AIWA_RC_T501
IRsend irsend;