Skip to content

Commit d336bc5

Browse files
committed
Changed ifdefs for SEND and DECODE, created enum for decode_type_t. Corrected ifdef errors, issues #121, #122, #123).
1 parent 675f9fe commit d336bc5

File tree

2 files changed

+93
-73
lines changed

2 files changed

+93
-73
lines changed

IRremote.cpp

+46-31
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks
7474
// Debugging versions are in IRremote.cpp
7575
#endif
7676

77-
#ifdef NEC
77+
#ifdef SEND_NEC
7878
void IRsend::sendNEC(unsigned long data, int nbits)
7979
{
8080
enableIROut(38);
@@ -96,7 +96,7 @@ void IRsend::sendNEC(unsigned long data, int nbits)
9696
}
9797
#endif
9898

99-
#ifdef WHYNTER
99+
#ifdef SEND_WHYNTER
100100
void IRsend::sendWhynter(unsigned long data, int nbits) {
101101
enableIROut(38);
102102
mark(WHYNTER_ZERO_MARK);
@@ -119,7 +119,7 @@ void IRsend::sendWhynter(unsigned long data, int nbits) {
119119
}
120120
#endif
121121

122-
#ifdef SONY
122+
#ifdef SEND_SONY
123123
void IRsend::sendSony(unsigned long data, int nbits) {
124124
enableIROut(40);
125125
mark(SONY_HDR_MARK);
@@ -153,6 +153,7 @@ void IRsend::sendRaw(unsigned int buf[], int len, int hz)
153153
space(0); // Just to be sure
154154
}
155155

156+
#ifdef SEND_RC5
156157
// Note: first bit must be a one (start bit)
157158
void IRsend::sendRC5(unsigned long data, int nbits)
158159
{
@@ -174,7 +175,9 @@ void IRsend::sendRC5(unsigned long data, int nbits)
174175
}
175176
space(0); // Turn off at end
176177
}
178+
#endif
177179

180+
#ifdef SEND_RC6
178181
// Caller needs to take care of flipping the toggle bit
179182
void IRsend::sendRC6(unsigned long data, int nbits)
180183
{
@@ -206,8 +209,9 @@ void IRsend::sendRC6(unsigned long data, int nbits)
206209
}
207210
space(0); // Turn off at end
208211
}
212+
#endif
209213

210-
#ifdef PANASONIC
214+
#ifdef SEND_PANASONIC
211215
void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
212216
enableIROut(35);
213217
mark(PANASONIC_HDR_MARK);
@@ -237,7 +241,7 @@ void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
237241
}
238242
#endif
239243

240-
#ifdef JVC
244+
#ifdef SEND_JVC
241245
void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
242246
{
243247
enableIROut(38);
@@ -262,7 +266,7 @@ void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
262266
}
263267
#endif
264268

265-
#ifdef SAMSUNG
269+
#ifdef SEND_SAMSUNG
266270
void IRsend::sendSAMSUNG(unsigned long data, int nbits)
267271
{
268272
enableIROut(38);
@@ -454,7 +458,7 @@ int IRrecv::decode(decode_results *results) {
454458
if (irparams.rcvstate != STATE_STOP) {
455459
return ERR;
456460
}
457-
#ifdef NEC
461+
#ifdef DECODE_NEC
458462
#ifdef DEBUG
459463
Serial.println("Attempting NEC decode");
460464
#endif
@@ -463,7 +467,7 @@ int IRrecv::decode(decode_results *results) {
463467
}
464468
#endif
465469

466-
#ifdef SONY
470+
#ifdef DECODE_SONY
467471
#ifdef DEBUG
468472
Serial.println("Attempting Sony decode");
469473
#endif
@@ -472,7 +476,7 @@ int IRrecv::decode(decode_results *results) {
472476
}
473477
#endif
474478

475-
#ifdef SANYO
479+
#ifdef DECODE_SANYO
476480
#ifdef DEBUG
477481
Serial.println("Attempting Sanyo decode");
478482
#endif
@@ -481,7 +485,7 @@ int IRrecv::decode(decode_results *results) {
481485
}
482486
#endif
483487

484-
#ifdef MITSUBISHI
488+
#ifdef DECODE_MITSUBISHI
485489
#ifdef DEBUG
486490
Serial.println("Attempting Mitsubishi decode");
487491
#endif
@@ -490,7 +494,7 @@ int IRrecv::decode(decode_results *results) {
490494
}
491495
#endif
492496

493-
#ifdef RC5
497+
#ifdef DECODE_RC5
494498
#ifdef DEBUG
495499
Serial.println("Attempting RC5 decode");
496500
#endif
@@ -499,7 +503,7 @@ int IRrecv::decode(decode_results *results) {
499503
}
500504
#endif
501505

502-
#ifdef RC6
506+
#ifdef DECODE_RC6
503507
#ifdef DEBUG
504508
Serial.println("Attempting RC6 decode");
505509
#endif
@@ -508,7 +512,7 @@ int IRrecv::decode(decode_results *results) {
508512
}
509513
#endif
510514

511-
#ifdef PANASONIC
515+
#ifdef DECODE_PANASONIC
512516
#ifdef DEBUG
513517
Serial.println("Attempting Panasonic decode");
514518
#endif
@@ -517,13 +521,16 @@ int IRrecv::decode(decode_results *results) {
517521
}
518522
#endif
519523

520-
#ifdef JVC
524+
#ifdef DECODE_LG
521525
#ifdef DEBUG
522526
Serial.println("Attempting LG decode");
523527
#endif
524528
if (decodeLG(results)) {
525529
return DECODED;
526530
}
531+
#endif
532+
533+
#ifdef DECODE_JVC
527534
#ifdef DEBUG
528535
Serial.println("Attempting JVC decode");
529536
#endif
@@ -532,20 +539,24 @@ int IRrecv::decode(decode_results *results) {
532539
}
533540
#endif
534541

535-
#ifdef SAMSUNG
542+
#ifdef DECODE_SAMSUNG
536543
#ifdef DEBUG
537544
Serial.println("Attempting SAMSUNG decode");
538545
#endif
539546
if (decodeSAMSUNG(results)) {
540547
return DECODED;
541548
}
549+
#endif
550+
551+
#ifdef DECODE_WHYNTER
542552
#ifdef DEBUG
543553
Serial.println("Attempting Whynter decode");
544554
#endif
545555
if (decodeWhynter(results)) {
546556
return DECODED;
547557
}
548-
// Aiwa RC-T501
558+
#endif
559+
549560
#ifdef AIWA_RC_T501
550561
#ifdef DEBUG
551562
Serial.println("Attempting Aiwa RC-T501 decode");
@@ -566,7 +577,7 @@ int IRrecv::decode(decode_results *results) {
566577
return ERR;
567578
}
568579

569-
#ifdef NEC
580+
#ifdef DECODE_NEC
570581
// NECs have a repeat only 4 items long
571582
long IRrecv::decodeNEC(decode_results *results) {
572583
long data = 0;
@@ -617,7 +628,7 @@ long IRrecv::decodeNEC(decode_results *results) {
617628
}
618629
#endif
619630

620-
#ifdef SONY
631+
#ifdef DECODE_SONY
621632
long IRrecv::decodeSony(decode_results *results) {
622633
long data = 0;
623634
if (irparams.rawlen < 2 * SONY_BITS + 2) {
@@ -631,7 +642,7 @@ long IRrecv::decodeSony(decode_results *results) {
631642
// Serial.print("IR Gap found: ");
632643
results->bits = 0;
633644
results->value = REPEAT;
634-
#ifdef SANYO
645+
#ifdef DECODE_SANYO
635646
results->decode_type = SANYO;
636647
#else
637648
results->decode_type = UNKNOWN;
@@ -675,6 +686,7 @@ long IRrecv::decodeSony(decode_results *results) {
675686
}
676687
#endif
677688

689+
#ifdef DECODE_WHYNTER
678690
long IRrecv::decodeWhynter(decode_results *results) {
679691
long data = 0;
680692

@@ -732,9 +744,9 @@ long IRrecv::decodeWhynter(decode_results *results) {
732744
results->decode_type = WHYNTER;
733745
return DECODED;
734746
}
747+
#endif
735748

736-
737-
#ifdef SANYO
749+
#ifdef DECODE_SANYO
738750
// I think this is a Sanyo decoder - serial = SA 8650B
739751
// Looks like Sony except for timings, 48 chars of data and time/space different
740752
long IRrecv::decodeSanyo(decode_results *results) {
@@ -800,7 +812,7 @@ long IRrecv::decodeSanyo(decode_results *results) {
800812
}
801813
#endif
802814

803-
#ifdef MITSUBISHI
815+
#ifdef DECODE_MITSUBISHI
804816
// Looks like Sony except for timings, 48 chars of data and time/space different
805817
long IRrecv::decodeMitsubishi(decode_results *results) {
806818
// 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)
911923
#endif
912924
return val;
913925
}
914-
#endif
915926

927+
#ifdef DECODE_RC5
916928
long IRrecv::decodeRC5(decode_results *results) {
917929
if (irparams.rawlen < MIN_RC5_SAMPLES + 2) {
918930
return ERR;
@@ -947,7 +959,9 @@ long IRrecv::decodeRC5(decode_results *results) {
947959
results->decode_type = RC5;
948960
return DECODED;
949961
}
962+
#endif
950963

964+
#ifdef DECODE_RC6
951965
long IRrecv::decodeRC6(decode_results *results) {
952966
if (results->rawlen < MIN_RC6_SAMPLES) {
953967
return ERR;
@@ -998,8 +1012,9 @@ long IRrecv::decodeRC6(decode_results *results) {
9981012
results->decode_type = RC6;
9991013
return DECODED;
10001014
}
1015+
#endif
10011016

1002-
#ifdef PANASONIC
1017+
#ifdef DECODE_PANASONIC
10031018
long IRrecv::decodePanasonic(decode_results *results) {
10041019
unsigned long long data = 0;
10051020
int offset = 1;
@@ -1035,7 +1050,7 @@ long IRrecv::decodePanasonic(decode_results *results) {
10351050
}
10361051
#endif
10371052

1038-
#ifdef LG
1053+
#ifdef DECODE_LG
10391054
long IRrecv::decodeLG(decode_results *results) {
10401055
long data = 0;
10411056
int offset = 1; // Skip first space
@@ -1083,7 +1098,7 @@ long IRrecv::decodeLG(decode_results *results) {
10831098

10841099
#endif
10851100

1086-
#ifdef JVC
1101+
#ifdef DECODE_JVC
10871102
long IRrecv::decodeJVC(decode_results *results) {
10881103
long data = 0;
10891104
int offset = 1; // Skip first space
@@ -1137,7 +1152,7 @@ long IRrecv::decodeJVC(decode_results *results) {
11371152
}
11381153
#endif
11391154

1140-
#ifdef SAMSUNG
1155+
#ifdef DECODE_SAMSUNG
11411156
// SAMSUNGs have a repeat only 4 items long
11421157
long IRrecv::decodeSAMSUNG(decode_results *results) {
11431158
long data = 0;
@@ -1194,7 +1209,7 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
11941209
* Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
11951210
*
11961211
*/
1197-
#ifdef AIWA_RC_T501
1212+
#ifdef DECODE_AIWA_RC_T501
11981213
long IRrecv::decodeAiwaRCT501(decode_results *results) {
11991214
int data = 0;
12001215
int offset = 1; // skip first garbage read
@@ -1326,7 +1341,7 @@ i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the
13261341
linked LIRC file.
13271342
*/
13281343

1329-
#ifdef IRsendSHARP
1344+
#ifdef SEND_SHARP
13301345
void IRsend::sendSharp(unsigned long data, int nbits) {
13311346
unsigned long invertdata = data ^ SHARP_TOGGLE_MASK;
13321347
enableIROut(38);
@@ -1360,7 +1375,7 @@ void IRsend::sendSharp(unsigned int address, unsigned int command) {
13601375

13611376
#endif
13621377

1363-
#ifdef IRsendDISH
1378+
#ifdef SEND_DISH
13641379
void IRsend::sendDISH(unsigned long data, int nbits)
13651380
{
13661381
enableIROut(56);
@@ -1386,7 +1401,7 @@ void IRsend::sendDISH(unsigned long data, int nbits)
13861401
*
13871402
*/
13881403

1389-
#ifdef AIWA_RC_T501
1404+
#ifdef SEND_AIWA_RC_T501
13901405
void IRsend::sendAiwaRCT501(int code) {
13911406
// PRE-DATA, 26 bits, 0x227EEC0
13921407
long int pre = 0x227EEC0;

0 commit comments

Comments
 (0)