You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support for old 2.x code by backwards compatible decode(decode_results *aResults) function. Removed USE_OLD_DECODE macro and added NO_LEGACY_COMPATIBILITY macro
Copy file name to clipboardExpand all lines: README.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,18 +42,23 @@ If you use a core that does not use the `-flto` flag for compile, you can activa
42
42
- Since the decoded values are now in `IrReceiver.decodedIRData` and not in `results` any more, remove the line `decode_results results` or similar.
43
43
- Like for the Serial object, call [`IrReceiver.begin(IR_RECEIVE_PIN, ENABE_ED_FEEDBACK);`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/ReceiveDemo/ReceiveDemo.ino#L38) or `IrReceiver.begin(IR_RECEIVE_PIN, DISABLE_LED_FEEDBACK);` instead of the `IrReceiver.enableIRIn();` or `irrecv.enableIRIn();` in setup().
44
44
- Old `decode(decode_results *aResults)` function is replaced by simple `decode()`. So if you have a statement `if(irrecv.decode(&results))` replace it with `if (IrReceiver.decode())`.
45
-
- The decoded result is now in in `IrReceiver.decodedIRData` and not in `results` any more, therefore replace any occurrences of `results.value`and / or `results.decode_type` (and similar) to `IrReceiver.decodedIRData.decodedRawData` and / or `IrReceiver.decodedIRData.decodedRawData`.
45
+
- The decoded result is now in in `IrReceiver.decodedIRData` and not in `results` any more, therefore replace any occurrences of `results.value` and `results.decode_type` (and similar) to `IrReceiver.decodedIRData.decodedRawData` and `IrReceiver.decodedIRData.protocol`.
46
46
- Overflow, Repeat and other flags are now in [`IrReceiver.receivedIRData.flags`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.h#L126).
47
47
- Seldom used: `results.rawbuf` and `results.rawlen` must be replaced by `IrReceiver.decodedIRData.rawDataPtr->rawbuf` and `IrReceiver.decodedIRData.rawDataPtr->rawlen`.
48
-
- For **NEC, Panasonic, Sony, Samsung and JVC** the `IrReceiver.decodedIRData.decodedRawData` is now LSB-first, as the definition of these protocols suggests! To use your **old MSB-first 32 bit IR data codes**, you must activate the line `#define USE_OLD_DECODE` in IRremoteInt.h.<br/>
49
-
To convert one into the other, you must reverse the byte positions and then reverse all bit positions of each byte or write it as one binary string and reverse/mirror it.
48
+
49
+
# Running your 2.x program with the 3.x library version
50
+
- The `results.value` is not set by the new decoders and for **NEC, Panasonic, Sony, Samsung and JVC** the `IrReceiver.decodedIRData.decodedRawData` is now LSB-first, as the definition of these protocols suggests!<br/>
51
+
To use your **old MSB-first 32 bit IR data codes**, you must have `decode_results results` and call `decode(&results)` as in most old sources.
52
+
- The old functions `sendNEC()` and `sendJVC()` are deprecated and renamed to `sendNECMSB()` and `sendJVCMSB()` to make it clearer that they send data with MSB first, which is not the standard for NEC and JVC. Use them to send your **old MSB-first 32 bit IR data codes**.
53
+
In the new version you will send NEC commands not by 32 bit codes but by a (constant) 8 bit address and an 8 bit command.
54
+
55
+
# Convert old MSB first 32 bit IR data codes to new LSB first 32 bit IR data codes
56
+
To convert one into the other, you must reverse the byte positions and then reverse all bit positions of each byte or write it as one binary string and reverse/mirror it.<br/>
0xCB340102 is binary 11001011001101000000000100000010.<br/>
53
60
0x40802CD3 is binary 01000000100000000010110011010011.<br/>
54
61
If you read the first binary sequence backwards (right to left), you get the second sequence.
55
-
- The old functions `sendNEC()` and `sendJVC()` are deprecated and renamed to `sendNECMSB()` and `sendJVCMSB()` to make it clearer that they send data with MSB first, which is not the standard for NEC and JVC. Use them to send your **old MSB-first 32 bit IR data codes**.
56
-
In the new version you will send NEC commands not by 32 bit codes but by a (constant) 8 bit address and an 8 bit command.
57
62
58
63
# FAQ
59
64
- IR does not work right when I use Neopixels (aka WS2811/WS2812/WS2812B) or other libraries blocking interrupts for a longer time (> 50 us).<br/>
@@ -126,7 +131,7 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
126
131
|-|-|-|-|
127
132
|`SEND_PWM_BY_TIMER`| Before `#include <IRremote.h>`| disabled | Disable carrier PWM generation in software and use (restricted) hardware PWM ecxept for ESP32 where both modes are using the flexible `hw_timer_t`. |
128
133
|`USE_NO_SEND_PWM`| Before `#include <IRremote.h>`| disabled | Use no carrier PWM, just simulate an active low receiver signal. Overrides `SEND_PWM_BY_TIMER` definition. |
129
-
|`USE_OLD_DECODE`| IRremoteInt.h | disabled |Enables the old decoder in order to be version 2.x compatible, where all protocols -especially NEC, Panasonic, Sony, Samsung and JVC- were MSB first. |
134
+
|`NO_LEGACY_COMPATIBILITY`| IRremoteInt.h | disabled |Disables the old decoder for version 2.x compatibility, where all protocols -especially NEC, Panasonic, Sony, Samsung and JVC- were MSB first. Saves around 60 bytes program space and 14 bytes RAM. |
130
135
|`EXCLUDE_EXOTIC_PROTOCOLS`| Before `#include <IRremote.h>`| disabled | If activated, BOSEWAVE, MAGIQUEST,WHYNTER and LEGO_PF are excluded in `decode()` and in sending with `IrSender.write()`. Saves up to 900 bytes program space. |
131
136
|`MARK_EXCESS_MICROS`| Before `#include <IRremote.h>`| 20 | MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding, to compensate for the signal forming of different IR receiver modules. |
132
137
|`FEEDBACK_LED_IS_ACTIVE_LOW`| Before `#include <IRremote.h>`| disabled | Required on some boards (like my BluePill and my ESP8266 board), where the feedback LED is active low. |
"The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter.");
1360
-
(void) aResults;
1361
-
returndecode();
1325
+
staticboolsDeprecationMessageSent= false;
1326
+
1327
+
if (irparams.StateForISR!=IR_REC_STATE_STOP) {
1328
+
return false;
1329
+
}
1330
+
1331
+
if (!sDeprecationMessageSent) {
1332
+
Serial.println(
1333
+
"The function decode(&results)) is deprecated and may not work as expected! Just use decode() without a parameter and IrReceiver.decodedIRData.<fieldname> .");
1334
+
sDeprecationMessageSent= true;
1335
+
}
1336
+
1337
+
// copy for usage by legacy programs
1338
+
aResults->rawbuf=irparams.rawbuf;
1339
+
aResults->rawlen=irparams.rawlen;
1340
+
if (irparams.OverflowFlag) {
1341
+
// Copy overflow flag to decodedIRData.flags
1342
+
irparams.OverflowFlag= false;
1343
+
irparams.rawlen=0; // otherwise we have OverflowFlag again at next ISR call
1344
+
DBG_PRINTLN("Overflow happened");
1345
+
}
1346
+
aResults->overflow=irparams.OverflowFlag;
1347
+
aResults->value=0;
1348
+
1349
+
decodedIRData.rawDataPtr=&irparams; // for decodePulseDistanceData() etc.
1350
+
decodedIRData.flags=IRDATA_FLAGS_IS_MSB_FIRST; // for print
1351
+
1352
+
#if defined(DECODE_NEC)
1353
+
DBG_PRINTLN("Attempting old NEC decode");
1354
+
if (decodeNECMSB(aResults)) {
1355
+
return true ;
1356
+
}
1357
+
#endif
1358
+
1359
+
#if defined(DECODE_SONY)
1360
+
DBG_PRINTLN("Attempting old Sony decode");
1361
+
if (decodeSonyMSB(aResults)) {
1362
+
return true ;
1363
+
}
1364
+
#endif
1365
+
1366
+
//#if defined(DECODE_MITSUBISHI)
1367
+
// DBG_PRINTLN("Attempting Mitsubishi decode");
1368
+
// if (decodeMitsubishi(results)) return true ;
1369
+
//#endif
1370
+
1371
+
#if defined(DECODE_RC5)
1372
+
DBG_PRINTLN("Attempting RC5 decode");
1373
+
if (decodeRC5()) {
1374
+
aResults->bits=decodedIRData.numberOfBits;
1375
+
aResults->value=decodedIRData.decodedRawData;
1376
+
aResults->decode_type=RC5;
1377
+
1378
+
return true ;
1379
+
}
1380
+
#endif
1381
+
1382
+
#if defined(DECODE_RC6)
1383
+
DBG_PRINTLN("Attempting RC6 decode");
1384
+
if (decodeRC6()) {
1385
+
aResults->bits=decodedIRData.numberOfBits;
1386
+
aResults->value=decodedIRData.decodedRawData;
1387
+
aResults->decode_type=RC6;
1388
+
return true ;
1389
+
}
1390
+
#endif
1391
+
1392
+
#if defined( DECODE_PANASONIC)
1393
+
DBG_PRINTLN("Attempting old Panasonic decode");
1394
+
if (decodePanasonicMSB(aResults)) {
1395
+
return true ;
1396
+
}
1397
+
#endif
1398
+
1399
+
#if defined(DECODE_LG)
1400
+
DBG_PRINTLN("Attempting old LG decode");
1401
+
if (decodeLGMSB(aResults)) { return true ;}
1402
+
#endif
1403
+
1404
+
#if defined(DECODE_JVC)
1405
+
DBG_PRINTLN("Attempting old JVC decode");
1406
+
if (decodeJVCMSB(aResults)) {
1407
+
return true ;
1408
+
}
1409
+
#endif
1410
+
1411
+
#if defined(DECODE_SAMSUNG)
1412
+
DBG_PRINTLN("Attempting old SAMSUNG decode");
1413
+
if (decodeSAMSUNG(aResults)) {
1414
+
return true ;
1415
+
}
1416
+
#endif
1417
+
1418
+
//#if defined(DECODE_WHYNTER)
1419
+
// DBG_PRINTLN("Attempting Whynter decode");
1420
+
// if (decodeWhynter(results)) return true ;
1421
+
//#endif
1422
+
1423
+
#if defined(DECODE_DENON)
1424
+
DBG_PRINTLN("Attempting old Denon decode");
1425
+
if (decodeDenonOld(aResults)) {
1426
+
return true ;
1427
+
}
1428
+
#endif
1429
+
1430
+
//#if defined(DECODE_LEGO_PF)
1431
+
// DBG_PRINTLN("Attempting Lego Power Functions");
1432
+
// if (decodeLegoPowerFunctions(results)) return true ;
0 commit comments