mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-11 08:56:14 +00:00
Changed ifdefs for SEND and DECODE, created enum for decode_type_t. Corrected ifdef errors, issues #121, #122, #123).
This commit is contained in:
77
IRremote.cpp
77
IRremote.cpp
@@ -74,7 +74,7 @@ int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks
|
||||
// Debugging versions are in IRremote.cpp
|
||||
#endif
|
||||
|
||||
#ifdef NEC
|
||||
#ifdef SEND_NEC
|
||||
void IRsend::sendNEC(unsigned long data, int nbits)
|
||||
{
|
||||
enableIROut(38);
|
||||
@@ -96,7 +96,7 @@ void IRsend::sendNEC(unsigned long data, int nbits)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WHYNTER
|
||||
#ifdef SEND_WHYNTER
|
||||
void IRsend::sendWhynter(unsigned long data, int nbits) {
|
||||
enableIROut(38);
|
||||
mark(WHYNTER_ZERO_MARK);
|
||||
@@ -119,7 +119,7 @@ void IRsend::sendWhynter(unsigned long data, int nbits) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SONY
|
||||
#ifdef SEND_SONY
|
||||
void IRsend::sendSony(unsigned long data, int nbits) {
|
||||
enableIROut(40);
|
||||
mark(SONY_HDR_MARK);
|
||||
@@ -153,6 +153,7 @@ void IRsend::sendRaw(unsigned int buf[], int len, int hz)
|
||||
space(0); // Just to be sure
|
||||
}
|
||||
|
||||
#ifdef SEND_RC5
|
||||
// Note: first bit must be a one (start bit)
|
||||
void IRsend::sendRC5(unsigned long data, int nbits)
|
||||
{
|
||||
@@ -174,7 +175,9 @@ void IRsend::sendRC5(unsigned long data, int nbits)
|
||||
}
|
||||
space(0); // Turn off at end
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SEND_RC6
|
||||
// Caller needs to take care of flipping the toggle bit
|
||||
void IRsend::sendRC6(unsigned long data, int nbits)
|
||||
{
|
||||
@@ -206,8 +209,9 @@ void IRsend::sendRC6(unsigned long data, int nbits)
|
||||
}
|
||||
space(0); // Turn off at end
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PANASONIC
|
||||
#ifdef SEND_PANASONIC
|
||||
void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
|
||||
enableIROut(35);
|
||||
mark(PANASONIC_HDR_MARK);
|
||||
@@ -237,7 +241,7 @@ void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef JVC
|
||||
#ifdef SEND_JVC
|
||||
void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
|
||||
{
|
||||
enableIROut(38);
|
||||
@@ -262,7 +266,7 @@ void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMSUNG
|
||||
#ifdef SEND_SAMSUNG
|
||||
void IRsend::sendSAMSUNG(unsigned long data, int nbits)
|
||||
{
|
||||
enableIROut(38);
|
||||
@@ -454,7 +458,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
if (irparams.rcvstate != STATE_STOP) {
|
||||
return ERR;
|
||||
}
|
||||
#ifdef NEC
|
||||
#ifdef DECODE_NEC
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting NEC decode");
|
||||
#endif
|
||||
@@ -463,7 +467,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SONY
|
||||
#ifdef DECODE_SONY
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Sony decode");
|
||||
#endif
|
||||
@@ -472,7 +476,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SANYO
|
||||
#ifdef DECODE_SANYO
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Sanyo decode");
|
||||
#endif
|
||||
@@ -481,7 +485,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MITSUBISHI
|
||||
#ifdef DECODE_MITSUBISHI
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Mitsubishi decode");
|
||||
#endif
|
||||
@@ -490,7 +494,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RC5
|
||||
#ifdef DECODE_RC5
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting RC5 decode");
|
||||
#endif
|
||||
@@ -499,7 +503,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RC6
|
||||
#ifdef DECODE_RC6
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting RC6 decode");
|
||||
#endif
|
||||
@@ -508,7 +512,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PANASONIC
|
||||
#ifdef DECODE_PANASONIC
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Panasonic decode");
|
||||
#endif
|
||||
@@ -517,13 +521,16 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef JVC
|
||||
#ifdef DECODE_LG
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting LG decode");
|
||||
#endif
|
||||
if (decodeLG(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DECODE_JVC
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting JVC decode");
|
||||
#endif
|
||||
@@ -532,20 +539,24 @@ int IRrecv::decode(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMSUNG
|
||||
#ifdef DECODE_SAMSUNG
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting SAMSUNG decode");
|
||||
#endif
|
||||
if (decodeSAMSUNG(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DECODE_WHYNTER
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Whynter decode");
|
||||
#endif
|
||||
if (decodeWhynter(results)) {
|
||||
return DECODED;
|
||||
}
|
||||
// Aiwa RC-T501
|
||||
#endif
|
||||
|
||||
#ifdef AIWA_RC_T501
|
||||
#ifdef DEBUG
|
||||
Serial.println("Attempting Aiwa RC-T501 decode");
|
||||
@@ -566,7 +577,7 @@ int IRrecv::decode(decode_results *results) {
|
||||
return ERR;
|
||||
}
|
||||
|
||||
#ifdef NEC
|
||||
#ifdef DECODE_NEC
|
||||
// NECs have a repeat only 4 items long
|
||||
long IRrecv::decodeNEC(decode_results *results) {
|
||||
long data = 0;
|
||||
@@ -617,7 +628,7 @@ long IRrecv::decodeNEC(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SONY
|
||||
#ifdef DECODE_SONY
|
||||
long IRrecv::decodeSony(decode_results *results) {
|
||||
long data = 0;
|
||||
if (irparams.rawlen < 2 * SONY_BITS + 2) {
|
||||
@@ -631,7 +642,7 @@ long IRrecv::decodeSony(decode_results *results) {
|
||||
// Serial.print("IR Gap found: ");
|
||||
results->bits = 0;
|
||||
results->value = REPEAT;
|
||||
#ifdef SANYO
|
||||
#ifdef DECODE_SANYO
|
||||
results->decode_type = SANYO;
|
||||
#else
|
||||
results->decode_type = UNKNOWN;
|
||||
@@ -675,6 +686,7 @@ long IRrecv::decodeSony(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DECODE_WHYNTER
|
||||
long IRrecv::decodeWhynter(decode_results *results) {
|
||||
long data = 0;
|
||||
|
||||
@@ -732,9 +744,9 @@ long IRrecv::decodeWhynter(decode_results *results) {
|
||||
results->decode_type = WHYNTER;
|
||||
return DECODED;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SANYO
|
||||
#ifdef DECODE_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) {
|
||||
@@ -800,7 +812,7 @@ long IRrecv::decodeSanyo(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MITSUBISHI
|
||||
#ifdef DECODE_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);
|
||||
@@ -911,8 +923,8 @@ int IRrecv::getRClevel(decode_results *results, int *offset, int *used, int t1)
|
||||
#endif
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DECODE_RC5
|
||||
long IRrecv::decodeRC5(decode_results *results) {
|
||||
if (irparams.rawlen < MIN_RC5_SAMPLES + 2) {
|
||||
return ERR;
|
||||
@@ -947,7 +959,9 @@ long IRrecv::decodeRC5(decode_results *results) {
|
||||
results->decode_type = RC5;
|
||||
return DECODED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DECODE_RC6
|
||||
long IRrecv::decodeRC6(decode_results *results) {
|
||||
if (results->rawlen < MIN_RC6_SAMPLES) {
|
||||
return ERR;
|
||||
@@ -998,8 +1012,9 @@ long IRrecv::decodeRC6(decode_results *results) {
|
||||
results->decode_type = RC6;
|
||||
return DECODED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PANASONIC
|
||||
#ifdef DECODE_PANASONIC
|
||||
long IRrecv::decodePanasonic(decode_results *results) {
|
||||
unsigned long long data = 0;
|
||||
int offset = 1;
|
||||
@@ -1035,7 +1050,7 @@ long IRrecv::decodePanasonic(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LG
|
||||
#ifdef DECODE_LG
|
||||
long IRrecv::decodeLG(decode_results *results) {
|
||||
long data = 0;
|
||||
int offset = 1; // Skip first space
|
||||
@@ -1083,7 +1098,7 @@ long IRrecv::decodeLG(decode_results *results) {
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef JVC
|
||||
#ifdef DECODE_JVC
|
||||
long IRrecv::decodeJVC(decode_results *results) {
|
||||
long data = 0;
|
||||
int offset = 1; // Skip first space
|
||||
@@ -1137,7 +1152,7 @@ long IRrecv::decodeJVC(decode_results *results) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAMSUNG
|
||||
#ifdef DECODE_SAMSUNG
|
||||
// SAMSUNGs have a repeat only 4 items long
|
||||
long IRrecv::decodeSAMSUNG(decode_results *results) {
|
||||
long data = 0;
|
||||
@@ -1194,7 +1209,7 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
|
||||
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
|
||||
*
|
||||
*/
|
||||
#ifdef AIWA_RC_T501
|
||||
#ifdef DECODE_AIWA_RC_T501
|
||||
long IRrecv::decodeAiwaRCT501(decode_results *results) {
|
||||
int data = 0;
|
||||
int offset = 1; // skip first garbage read
|
||||
@@ -1326,7 +1341,7 @@ i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the
|
||||
linked LIRC file.
|
||||
*/
|
||||
|
||||
#ifdef IRsendSHARP
|
||||
#ifdef SEND_SHARP
|
||||
void IRsend::sendSharp(unsigned long data, int nbits) {
|
||||
unsigned long invertdata = data ^ SHARP_TOGGLE_MASK;
|
||||
enableIROut(38);
|
||||
@@ -1360,7 +1375,7 @@ void IRsend::sendSharp(unsigned int address, unsigned int command) {
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef IRsendDISH
|
||||
#ifdef SEND_DISH
|
||||
void IRsend::sendDISH(unsigned long data, int nbits)
|
||||
{
|
||||
enableIROut(56);
|
||||
@@ -1386,7 +1401,7 @@ void IRsend::sendDISH(unsigned long data, int nbits)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef AIWA_RC_T501
|
||||
#ifdef SEND_AIWA_RC_T501
|
||||
void IRsend::sendAiwaRCT501(int code) {
|
||||
// PRE-DATA, 26 bits, 0x227EEC0
|
||||
long int pre = 0x227EEC0;
|
||||
|
||||
91
IRremote.h
91
IRremote.h
@@ -25,10 +25,29 @@
|
||||
//#define DEBUG
|
||||
// #define TEST
|
||||
|
||||
enum decode_type_t {
|
||||
NEC = 1,
|
||||
SONY = 2,
|
||||
RC5 = 3,
|
||||
RC6 = 4,
|
||||
DISH = 5,
|
||||
SHARP = 6,
|
||||
PANASONIC = 7,
|
||||
JVC = 8,
|
||||
SANYO = 9,
|
||||
MITSUBISHI = 10,
|
||||
SAMSUNG = 11,
|
||||
LG = 12,
|
||||
WHYNTER = 13,
|
||||
AIWA_RC_T501 = 14,
|
||||
|
||||
UNKNOWN = -1
|
||||
};
|
||||
|
||||
// Results returned from the decoder
|
||||
class decode_results {
|
||||
public:
|
||||
int decode_type; // NEC, SONY, RC5, UNKNOWN
|
||||
decode_type_t decode_type; // NEC, SONY, RC5, UNKNOWN
|
||||
union { // This is used for decoding Panasonic and Sharp data
|
||||
unsigned int panasonicAddress;
|
||||
unsigned int sharpAddress;
|
||||
@@ -53,23 +72,6 @@ public:
|
||||
#define IRsendSAMSUNG
|
||||
#define IRsendRAW
|
||||
|
||||
// Values for decode_type
|
||||
#define NEC 1
|
||||
#define SONY 2
|
||||
#define RC5 3
|
||||
#define RC6 4
|
||||
#define DISH 5
|
||||
#define SHARP 6
|
||||
#define PANASONIC 7
|
||||
#define JVC 8
|
||||
#define SANYO 9
|
||||
#define MITSUBISHI 10
|
||||
#define SAMSUNG 11
|
||||
#define LG 12
|
||||
#define WHYNTER 13
|
||||
#define AIWA_RC_T501 14
|
||||
#define UNKNOWN -1
|
||||
|
||||
// Decoded value for NEC when a repeat code is received
|
||||
#define REPEAT 0xffffffff
|
||||
|
||||
@@ -85,42 +87,42 @@ public:
|
||||
private:
|
||||
// These are called by decode
|
||||
int getRClevel(decode_results *results, int *offset, int *used, int t1);
|
||||
#ifdef NEC
|
||||
#ifdef DECODE_NEC
|
||||
long decodeNEC(decode_results *results);
|
||||
#endif
|
||||
#ifdef SONY
|
||||
#ifdef DECODE_SONY
|
||||
long decodeSony(decode_results *results);
|
||||
#endif
|
||||
#ifdef SANYO
|
||||
#ifdef DECODE_SANYO
|
||||
long decodeSanyo(decode_results *results);
|
||||
#endif
|
||||
#ifdef MITSUBISHI
|
||||
#ifdef DECODE_MITSUBISHI
|
||||
long decodeMitsubishi(decode_results *results);
|
||||
#endif
|
||||
#ifdef RC5
|
||||
#ifdef DECODE_RC5
|
||||
long decodeRC5(decode_results *results);
|
||||
#endif
|
||||
#ifdef RC6
|
||||
#ifdef DECODE_RC6
|
||||
long decodeRC6(decode_results *results);
|
||||
#endif
|
||||
#ifdef PANASONIC
|
||||
#ifdef DECODE_PANASONIC
|
||||
long decodePanasonic(decode_results *results);
|
||||
#endif
|
||||
#ifdef LG
|
||||
#ifdef DECODE_LG
|
||||
long decodeLG(decode_results *results);
|
||||
#endif
|
||||
#ifdef JVC
|
||||
#ifdef DECODE_JVC
|
||||
long decodeJVC(decode_results *results);
|
||||
#endif
|
||||
#ifdef SAMSUNG
|
||||
#ifdef DECODE_SAMSUNG
|
||||
long decodeSAMSUNG(decode_results *results);
|
||||
#endif
|
||||
|
||||
#ifdef WHYNTER
|
||||
#ifdef DECODE_WHYNTER
|
||||
long decodeWhynter(decode_results *results);
|
||||
#endif
|
||||
|
||||
#ifdef AIWA_RC_T501
|
||||
#ifdef DECODE_AIWA_RC_T501
|
||||
long decodeAiwaRCT501(decode_results *results);
|
||||
#endif
|
||||
|
||||
@@ -141,41 +143,44 @@ class IRsend
|
||||
public:
|
||||
IRsend() {}
|
||||
void sendRaw(unsigned int buf[], int len, int hz);
|
||||
#ifdef SEND_RC5
|
||||
void sendRC5(unsigned long data, int nbits);
|
||||
#endif
|
||||
#ifdef SEND_RC6
|
||||
void sendRC6(unsigned long data, int nbits);
|
||||
|
||||
#ifdef WHYNTER
|
||||
#endif
|
||||
#ifdef SEND_WHYNTER
|
||||
void sendWhynter(unsigned long data, int nbits);
|
||||
#endif
|
||||
#ifdef NEC
|
||||
#ifdef SEND_NEC
|
||||
void sendNEC(unsigned long data, int nbits);
|
||||
#endif
|
||||
#ifdef SONY
|
||||
#ifdef SEND_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);
|
||||
#endif
|
||||
|
||||
#ifdef DISH
|
||||
#ifdef SEND_DISH
|
||||
void sendDISH(unsigned long data, int nbits);
|
||||
#endif
|
||||
#ifdef SHARP
|
||||
#ifdef SEND_SHARP
|
||||
void sendSharp(unsigned int address, unsigned int command);
|
||||
void sendSharpRaw(unsigned long data, int nbits);
|
||||
#endif
|
||||
#ifdef IRsendSHARP
|
||||
#ifdef SEND_IRsendSHARP
|
||||
void sendSharp(unsigned long data, int nbits);
|
||||
#endif
|
||||
#ifdef PANASONIC
|
||||
#ifdef SEND_PANASONIC
|
||||
void sendPanasonic(unsigned int address, unsigned long data);
|
||||
#endif
|
||||
#ifdef JVC
|
||||
#ifdef SEND_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
|
||||
#ifdef SEND_AIWA_RC_T501
|
||||
void sendAiwaRCT501(int code);
|
||||
#endif
|
||||
#ifdef SEND_SAMSUNG
|
||||
void sendSAMSUNG(unsigned long data, int nbits);
|
||||
#endif
|
||||
void enableIROut(int khz);
|
||||
|
||||
Reference in New Issue
Block a user