10000 Added possibility to exclude non-necessary libraries by comment lines… · ajitjadhav28/Arduino-IRremote@549d92d · GitHub
[go: up one dir, main page]

Skip to content

Commit 549d92d

Browse files
committed
Added possibility to exclude non-necessary libraries by comment lines in IRremote.h
1 parent 0de2d18 commit 549d92d

File tree

2 files changed

+127
-2
lines changed

2 files changed

+127
-2
lines changed

IRremote.cpp

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks
7272
// Debugging versions are in IRremote.cpp
7373
#endif
7474

75+
#ifdef IRsendNEC
7576
void IRsend::sendNEC(unsigned long data, int nbits)
7677
{
7778
enableIROut(38);
@@ -91,7 +92,9 @@ void IRsend::sendNEC(unsigned long data, int nbits)
9192
mark(NEC_BIT_MARK);
9293
space(0);
9394
}
95+
#endif
9496

97+
#ifdef IRsendSONY
9598
void IRsend::sendSony(unsigned long data, int nbits) {
9699
enableIROut(40);
97100
mark(SONY_HDR_MARK);
@@ -109,7 +112,9 @@ void IRsend::sendSony(unsigned long data, int nbits) {
109112
data <<= 1;
110113
}
111114
}
115+
#endif
112116

117+
#ifdef IRsendRAW
113118
void IRsend::sendRaw(unsigned int buf[], int len, int hz)
114119
{
115120
enableIROut(hz);
@@ -123,7 +128,9 @@ void IRsend::sendRaw(unsigned int buf[], int len, int hz)
123128
}
124129
space(0); // Just to be sure
125130
}
131+
#endif
126132

133+
#ifdef IRsendRC5
127134
// Note: first bit must be a one (start bit)
128135
void IRsend::sendRC5(unsigned long data, int nbits)
129136
{
@@ -145,7 +152,9 @@ void IRsend::sendRC5(unsigned long data, int nbits)
145152
}
146153
space(0); // Turn off at end
147154
}
155+
#endif
148156

157+
#ifdef IRsendRC6
149158
// Caller needs to take care of flipping the toggle bit
150159
void IRsend::sendRC6(unsigned long data, int nbits)
151160
{
@@ -177,6 +186,9 @@ void IRsend::sendRC6(unsigned long data, int nbits)
177186
}
178187
space(0); // Turn off at end
179188
}
189+
#endif
190+
191+
#ifdef IRsendPANASONIC
180192
void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
181193
enableIROut(35);
182194
mark(PANASONIC_HDR_MARK);
@@ -204,6 +216,9 @@ void IRsend::sendPanasonic(unsigned int address, unsigned long data) {
204216
mark(PANASONIC_BIT_MARK);
205217
space(0);
206218
}
219+
#endif
220+
221+
#ifdef IRsendJVC
207222
void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
208223
{
209224
enableIROut(38);
@@ -226,7 +241,9 @@ void IRsend::sendJVC(unsigned long data, int nbits, int repeat)
226241
mark(JVC_BIT_MARK);
227242
space(0);
228243
}
244+
#endif
229245

246+
#ifdef IRsendSAMSUNG
230247
void IRsend::sendSAMSUNG(unsigned long data, int nbits)
231248
{
232249
enableIROut(38);
@@ -246,6 +263,7 @@ void IRsend::sendSAMSUNG(unsigned long data, int nbits)
246263
mark(SAMSUNG_BIT_MARK);
247264
space(0);
248265
}
266+
#endif
249267

250268
void IRsend::mark(int time) {
251269
// Sends an IR mark for the specified number of microseconds.
@@ -417,60 +435,87 @@ int IRrecv::decode(decode_results *results) {
417435
if (irparams.rcvstate != STATE_STOP) {
418436
return ERR;
419437
}
438+
#ifdef NEC
420439
#ifdef DEBUG
421440
Serial.println("Attempting NEC decode");
422441
#endif
423442
if (decodeNEC(results)) {
424443
return DECODED;
425444
}
445+
#endif
446+
447+
#ifdef SONY
426448
#ifdef DEBUG
427449
Serial.println("Attempting Sony decode");
428450
#endif
429451
if (decodeSony(results)) {
430452
return DECODED;
431453
}
454+
#endif
455+
456+
#ifdef SANYO
432457
#ifdef DEBUG
433458
Serial.println("Attempting Sanyo decode");
434459
#endif
435460
if (decodeSanyo(results)) {
436461
return DECODED;
437462
}
463+
#endif
464+
465+
#ifdef MITSUBISHI
438466
#ifdef DEBUG
439467
Serial.println("Attempting Mitsubishi decode");
440468
#endif
441469
if (decodeMitsubishi(results)) {
442470
return DECODED;
443471
}
472+
#endif
473+
474+
#ifdef RC5
444475
#ifdef DEBUG
445476
Serial.println("Attempting RC5 decode");
446477
#endif
447478
if (decodeRC5(results)) {
448479
return DECODED;
449480
}
481+
#endif
482+
483+
#ifdef RC6
450484
#ifdef DEBUG
451485
Serial.println("Attempting RC6 decode");
452486
#endif
453487
if (decodeRC6(results)) {
454488
return DECODED;
455489
}
490+
#endif
491+
492+
#ifdef PANASONIC
456493
#ifdef DEBUG
457494
Serial.println("Attempting Panasonic decode");
458495
#endif
459496
if (decodePanasonic(results)) {
460497
return DECODED;
461498
}
499+
#endif
500+
501+
#ifdef JVC
462502
#ifdef DEBUG
463503
Serial.println("Attempting JVC decode");
464504
#endif
465505
if (decodeJVC(results)) {
466506
return DECODED;
467507
}
508+
#endif
509+
510+
#ifdef SAMSUNG
468511
#ifdef DEBUG
469512
Serial.println("Attempting SAMSUNG decode");
470513
#endif
471514
if (decodeSAMSUNG(results)) {
472515
return DECODED;
473516
}
517+
#endif
518+
474519
// decodeHash returns a hash on any input.
475520
// Thus, it needs to be last in the list.
476521
// If you add any decodes, add them before this.
@@ -482,6 +527,7 @@ int IRrecv::decode(decode_results *results) {
482527
return ERR;
483528
}
484529

530+
#ifdef NEC
485531
// NECs have a repeat only 4 items long
486532
long IRrecv::decodeNEC(decode_results *results) {
487533
long data = 0;
@@ -530,7 +576,9 @@ long IRrecv::decodeNEC(decode_results *results) {
530576
results->decode_type = NEC;
531577
return DECODED;
532578
}
579+
#endif
533580

581+
#ifdef SONY
534582
long IRrecv::decodeSony(decode_results *results) {
535583
long data = 0;
536584
if (irparams.rawlen < 2 * SONY_BITS + 2) {
@@ -544,7 +592,11 @@ long IRrecv::decodeSony(decode_results *results) {
544592
// Serial.print("IR Gap found: ");
545593
results->bits = 0;
546594
results->value = REPEAT;
595+
#ifdef SANYO
547596
results->decode_type = SANYO;
597+
#else
598+
results->decode_type = UNKNOWN;
599+
#endif
548600
return DECODED;
549601
}
550602
offset++;
@@ -582,7 +634,9 @@ long IRrecv::decodeSony(decode_results *results) {
582634
results->decode_type = SONY;
583635
return DECODED;
584636
}
637+
#endif
585638

639+
#ifdef SANYO
586640
// I think this is a Sanyo decoder - serial = SA 8650B
587641
// Looks like Sony except for timings, 48 chars of data and time/space different
588642
long IRrecv::decodeSanyo(decode_results *results) {
@@ -646,7 +700,9 @@ long IRrecv::decodeSanyo(decode_results *results) {
646700
results->decode_type = SANYO;
647701
return DECODED;
648702
}
703+
#endif
649704

705+
#ifdef MITSUBISHI
650706
// Looks like Sony except for timings, 48 chars of data and time/space different
651707
long IRrecv::decodeMitsubishi(decode_results *results) {
652708
// Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
@@ -710,8 +766,9 @@ long IRrecv::decodeMitsubishi(decode_results *results) {
710766
results->decode_type = MITSUBISHI;
711767
return DECODED;
712768
}
769+
#endif
713770

714-
771+
#if defined(RC5) || defined(RC6)
715772
// Gets one undecoded level at a time from the raw buffer.
716773
// The RC5/6 decoding is easier if the data is broken into time intervals.
717774
// E.g. if the buffer has MARK for 2 time intervals and SPACE for 1,
@@ -757,7 +814,9 @@ int IRrecv::getRClevel(decode_results *results, int *offset, int *used, int t1)
757814
#endif
758815
return val;
759816
}
817+
#endif
760818

819+
#ifdef RC5
761820
long IRrecv::decodeRC5(decode_results *results) {
762821
if (irparams.rawlen < MIN_RC5_SAMPLES + 2) {
763822
return ERR;
@@ -792,7 +851,9 @@ long IRrecv::decodeRC5(decode_results *results) {
792851
results->decode_type = RC5;
793852
return DECODED;
794853
}
854+
#endif
795855

856+
#ifdef RC6
796857
long IRrecv::decodeRC6(decode_results *results) {
797858
if (results->rawlen < MIN_RC6_SAMPLES) {
798859
return ERR;
@@ -843,6 +904,9 @@ long IRrecv::decodeRC6(decode_results *results) {
843904
results->decode_type = RC6;
844905
return DECODED;
845906
}
907+
#endif
908+
909+
#ifdef PANASONIC
846910
long IRrecv::decodePanasonic(decode_results *results) {
847911
unsigned long long data = 0;
848912
int offset = 1;
@@ -876,6 +940,9 @@ long IRrecv::decodePanasonic(decode_results *results) {
876940
results->bits = PANASONIC_BITS;
877941
return DECODED;
878942
}
943+
#endif
944+
945+
#ifdef JVC
879946
long IRrecv::decodeJVC(decode_results *results) {
880947
long data = 0;
881948
int offset = 1; // Skip first space
@@ -927,7 +994,9 @@ long IRrecv::decodeJVC(decode_results *results) {
927994
results->decode_type = JVC;
928995
return DECODED;
929996
}
997+
#endif
930998

999+
#ifdef SAMSUNG
9311000
// SAMSUNGs have a repeat only 4 items long
9321001
long IRrecv::decodeSAMSUNG(decode_results *results) {
9331002
long data = 0;
@@ -976,6 +1045,7 @@ long IRrecv::decodeSAMSUNG(decode_results *results) {
9761045
results->decode_type = SAMSUNG;
9771046
return DECODED;
9781047
}
1048+
#endif
9791049

9801050
/* -----------------------------------------------------------------------
9811051
* hashdecode - decode an arbitrary IR code.
@@ -1052,7 +1122,7 @@ For the DISH codes, only send the last for characters of the hex.
10521122
i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the
10531123
linked LIRC file.
10541124
*/
1055-
1125+
#ifdef IRsendSHARP
10561126
void IRsend::sendSharp(unsigned long data, int nbits) {
10571127
unsigned long invertdata = data ^ SHARP_TOGGLE_MASK;
10581128
enableIROut(38);
@@ -1086,7 +1156,9 @@ void IRsend::sendSharp(unsigned long data, int nbits) {
10861156
space(SHARP_ZERO_SPACE);
10871157
delay(46);
10881158
}
1159+
#endif
10891160

1161+
#ifdef IRsendDISH
10901162
void IRsend::sendDISH(unsigned long data, int nbits)
10911163
{
10921164
enableIROut(56);
@@ -1104,3 +1176,4 @@ void IRsend::sendDISH(unsigned long data, int nbits)
11041176
data <<= 1;
11051177
}
11061178
}
1179+
#endif

0 commit comments

Comments
 (0)
0