Skip to content

Commit 4fb32a6

Browse files
committed
disabled old results structure, added default receiver and sender objects, removed deprecated decoders with parameter, added Stram like API with begin() -like Arduino Serial-, LED feedback now also for send
1 parent b64165b commit 4fb32a6

38 files changed

+819
-647
lines changed

.github/issue_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Use [a gist](gist.github.com) if the code exceeds 30 lines
4343
**checklist:**
4444
- [] I have **read** the README.md file thoroughly
4545
- [] I have searched existing issues to see if there is anything I have missed.
46-
- [] The latest [release](https://github.com/z3t0/Arduino-IRremote/releases/latest) is used
46+
- [] The latest [repo version](https://github.com/Arduino-IRremote/Arduino-IRremote/archive/master.zip) is used
4747
- [] Any code referenced is provided and if over 30 lines a gist is linked INSTEAD of it being pasted in here
4848
- [] The title of the issue is helpful and relevant
4949

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ Protocols can be switched off and on by changing the lines in *IRremote.h*:
2727
# [Wiki](https://github.com/z3t0/Arduino-IRremote/wiki)
2828
This is a quite old but maybe useful wiki for this library.
2929

30+
# Converting your program to the 3.x version
31+
- Now there is an **IRreceiver** and **IRsender** object like the well known Arduino **Serial** object.
32+
- Just remove the line `IRrecv IrReceiver(IR_RECEIVE_PIN);` and/or `IRsend IrSender;`in your program.
33+
- Like for the Serial object, call `[IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);](https://github.com/Arduino-IRremote/Arduino-IRremote/examples/IRreceiveDemo/IRreceiveDemo.ino#L38)` or `IrReceiver.begin(IR_RECEIVE_PIN, DISABLE_LED_FEEDBACK);` instead of the `IrReceiver.enableIRIn();` in setup().
34+
- Old `decode(decode_results *aResults)` is replaced by simple `decode()`.
35+
- Overflow and many other flags are now in [IrReceiver.receivedIRData.flags](https://github.com/Arduino-IRremote/Arduino-IRremote/src/IRremote.h#L126).
36+
37+
If you discover more changes, which should be documented, please send me a mail to [email protected].
38+
3039
# FAQ
3140
- IR does not work right when I use Neopixels (aka WS2811/WS2812/WS2812B)<br/>
3241
Whether you use the Adafruit Neopixel lib, or FastLED, interrupts get disabled on many lower end CPUs like the basic Arduinos for longer than 50 µs.
@@ -76,6 +85,7 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
7685
| `USE_SOFT_SEND_PWM` | IRremote.h | disabled | Use carrier PWM generation in software, instead of hardware PWM. |
7786
| `PULSE_CORRECTION_MICROS` | IRremote.h | 3 | If USE_SOFT_SEND_PWM, this amount is subtracted from the on-time of the pulses. |
7887
| `USE_SPIN_WAIT` | IRremote.h | disabled | If USE_SOFT_SEND_PWM, use spin wait instead of delayMicros(). |
88+
| `SUPPORT_SEND_EXOTIC_PROTOCOLS` | IRremote.h | enabled | If activated, BOSEWAVE and LEGO_PF are supported in the write method. Costs around 500 bytes program space. |
7989
| `RAW_BUFFER_LENGTH` | IRremoteint.h | 101 | Buffer size of raw input buffer. Must be odd! |
8090
| `IR_SEND_DUTY_CYCLE` | IRremoteBoardDefs.h | 30 | Duty cycle of IR send signal. |
8191
| `MICROS_PER_TICK` | IRremoteBoardDefs.h | 50 | Resolution of the raw input buffer data. |
@@ -84,6 +94,7 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
8494
| `IR_FEEDBACK_LED_PIN` | TinyIRReceiver.h | `LED_BUILTIN` | The pin number for TinyIRReceiver feedback LED, which gets compiled in. |
8595
| `DO_NOT_USE_FEEDBACK_LED` | TinyIRReceiver.h | disabled | Enable it to disable the feedback LED function. |
8696

97+
8798
### Modifying compile options with Arduino IDE
8899
First use *Sketch > Show Sketch Folder (Ctrl+K)*.<br/>
89100
If you did not yet stored the example as your own sketch, then you are instantly in the right library folder.<br/>

changelog.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- Fixed bug in Sony decode introduced in 2.8.0.
1616

1717
## 2.8.0 2020/10
18-
- Changed License to MIT see https://github.com/z3t0/Arduino-IRremote/issues/397.
18+
- Changed License to MIT see https://github.com/Arduino-IRremote/Arduino-IRremote/issues/397.
1919
- Added ATtiny timer 1 support.
2020
- Changed wrong return code signature of decodePulseDistanceData() and its handling.
2121
- Removed Mitsubishi protocol, since the implementation is in contradiction with all documentation I could found and therefore supposed to be wrong.
@@ -58,7 +58,7 @@
5858
- Corrected keywords.txt.
5959
- BoseWave protocol added PR #690.
6060
- Formatting comply to the new stylesheet.
61-
- Renamed "boarddefs.h" [ISSUE #375](https://github.com/z3t0/Arduino-IRremote/issues/375).
61+
- Renamed "boarddefs.h" [ISSUE #375](https://github.com/Arduino-IRremote/Arduino-IRremote/issues/375).
6262
- Renamed `SEND_PIN` to `IR_SEND_PIN`.
6363
- Renamed state macros.
6464
- Enabled `DUTY_CYCLE` for send signal.
@@ -71,22 +71,22 @@ Changes from #268 by adamlhumphreys
7171
- Optimized by reducing floating point operations as suggested by @madmalkav (#193).
7272
- Optimized with macros when using default `MICROS_PER_TICK` and `TOLERANCE`.
7373
- Made decodeHash as a settable protocol defined by `DECODE_HASH`.
74-
- Added Philips Extended RC-5 protocol support [PR #522] (https://github.com/z3t0/Arduino-IRremote/pull/522)
74+
- Added Philips Extended RC-5 protocol support [PR #522] (https://github.com/Arduino-IRremote/Arduino-IRremote/pull/522)
7575

7676
## 2.4.0 - 2017/08/10
77-
- Cleanup of hardware dependencies. Merge in SAM support [PR #437](https://github.com/z3t0/Arduino-IRremote/pull/437)
77+
- Cleanup of hardware dependencies. Merge in SAM support [PR #437](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/437)
7878

7979
## 2.3.3 - 2017/03/31
80-
- Added ESP32 IR receive support [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/425)
80+
- Added ESP32 IR receive support [PR #427](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/425)
8181

8282
## 2.2.3 - 2017/03/27
83-
- Fix calculation of pause length in LEGO PF protocol [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/427)
83+
- Fix calculation of pause length in LEGO PF protocol [PR #427](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/427)
8484

8585
## 2.2.2 - 2017/01/20
86-
- Fixed naming bug [PR #398](https://github.com/z3t0/Arduino-IRremote/pull/398)
86+
- Fixed naming bug [PR #398](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/398)
8787

8888
## 2.2.1 - 2016/07/27
89-
- Added tests for Lego Power Functions Protocol [PR #336](https://github.com/z3t0/Arduino-IRremote/pull/336)
89+
- Added tests for Lego Power Functions Protocol [PR #336](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/336)
9090

9191
## 2.2.0 - 2016/06/28
9292
- Added support for ATmega8535
@@ -99,23 +99,23 @@ Changes from #268 by adamlhumphreys
9999
- Added support for ATmega64
100100
- Added support for ATmega128
101101

102-
[PR](https://github.com/z3t0/Arduino-IRremote/pull/324)
102+
[PR](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/324)
103103

104104
## 2.1.1 - 2016/05/04
105-
- Added Lego Power Functions Protocol [PR #309](https://github.com/z3t0/Arduino-IRremote/pull/309)
105+
- Added Lego Power Functions Protocol [PR #309](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/309)
106106

107107
## 2.1.0 - 2016/02/20
108-
- Improved Debugging [PR #258](https://github.com/z3t0/Arduino-IRremote/pull/258)
109-
- Display TIME instead of TICKS [PR #258](https://github.com/z3t0/Arduino-IRremote/pull/258)
108+
- Improved Debugging [PR #258](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/258)
109+
- Display TIME instead of TICKS [PR #258](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/258)
110110

111111
## 2.0.4 - 2016/02/20
112-
- Add Panasonic and JVC to IRrecord example [PR](https://github.com/z3t0/Arduino-IRremote/pull/54)
112+
- Add Panasonic and JVC to IRrecord example [PR](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/54)
113113

114114
## 2.0.3 - 2016/02/20
115-
- Change IRSend Raw parameter to const [PR](https://github.com/z3t0/Arduino-IRremote/pull/227)
115+
- Change IRSend Raw parameter to const [PR](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/227)
116116

117117
## 2.0.2 - 2015/12/02
118-
- Added IRremoteInfo Sketch - [PR](https://github.com/z3t0/Arduino-IRremote/pull/241)
118+
- Added IRremoteInfo Sketch - [PR](https://github.com/Arduino-IRremote/Arduino-IRremote/pull/241)
119119
- Enforcing changelog.md
120120

121121
## 2.0.1 - 2015/07/26 - [Release](https://github.com/shirriff/Arduino-IRremote/releases/tag/BETA)

examples/BoseWaveSendDemo/BoseWaveSendDemo.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#define BOSE_CMD_PRESET_4 0x10
3939
#define BOSE_CMD_PRESET_5 0x11
4040

41-
IRsend IrSender;
42-
4341
// On the Zero and others we switch explicitly to SerialUSB
4442
#if defined(ARDUINO_ARCH_SAMD)
4543
#define Serial SerialUSB
@@ -58,6 +56,8 @@ void setup() {
5856
// Just to know which program is running on my Arduino
5957
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
6058

59+
IrSender.begin(true); // Enable feedback LED,
60+
6161
prompt = true;
6262
}
6363

examples/IR2Keyboard/IR2Keyboard.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ int IR_RECEIVE_PIN = 10;
4040
#else
4141
int IR_RECEIVE_PIN = 11;
4242
#endif
43-
IRrecv IrReceiver(IR_RECEIVE_PIN);
4443

4544
// On the Zero and others we switch explicitly to SerialUSB
4645
#if defined(ARDUINO_ARCH_SAMD)
@@ -63,8 +62,8 @@ void setup() {
6362
// In case the interrupt driver crashes on setup, give a clue
6463
// to the user what's going on.
6564
Serial.println("Enabling IRin");
66-
IrReceiver.enableIRIn(); // Start the receiver
67-
IrReceiver.blink13(true); // Enable feedback LED
65+
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver, enable feedback LED, take LED feedback pin from the internal boards definition
66+
6867

6968
Serial.print(F("Ready to receive IR signals at pin "));
7069
Serial.println(IR_RECEIVE_PIN);

examples/IRUnitTest/IRUnitTest.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <IRremote.h>
1111

12-
IRrecv IrReceiver(0);
1312

1413
// Dumps out the decode_results structure.
1514
// Call this after IRrecv::decode()
@@ -104,7 +103,7 @@ void verify(unsigned long val, unsigned int bits, unsigned int type) {
104103
IrReceiver.decode();
105104
Serial.print("Testing ");
106105
Serial.print(val, HEX);
107-
if (IrReceiver.results.value == val && IrReceiver.decodedIRData.numberOfBits == bits && IrReceiver.decodedIRData.protocol == type) {
106+
if (IrReceiver.decodedIRData.decodedRawData == val && IrReceiver.decodedIRData.numberOfBits == bits && IrReceiver.decodedIRData.protocol == type) {
108107
Serial.println(": OK");
109108
} else {
110109
Serial.println(": Error");

examples/IRreceiveDemo/IRreceiveDemo.ino

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ int IR_RECEIVE_PIN = 10;
1616
#else
1717
int IR_RECEIVE_PIN = 11;
1818
#endif
19-
IRrecv IrReceiver(IR_RECEIVE_PIN);
2019

2120
// On the Zero and others we switch explicitly to SerialUSB
2221
#if defined(ARDUINO_ARCH_SAMD)
@@ -36,8 +35,7 @@ void setup() {
3635
// In case the interrupt driver crashes on setup, give a clue
3736
// to the user what's going on.
3837
Serial.println("Enabling IRin");
39-
IrReceiver.enableIRIn(); // Start the receiver
40-
IrReceiver.blink13(true); // Enable feedback LED
38+
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver, enable feedback LED, take LED feedback pin from the internal boards definition
4139

4240
Serial.print(F("Ready to receive IR signals at pin "));
4341
Serial.println(IR_RECEIVE_PIN);
@@ -49,21 +47,37 @@ void loop() {
4947
* Decoded result is in the IrReceiver.decodedIRData structure.
5048
*/
5149
if (IrReceiver.decode()) {
52-
// Print a short summary of received data
53-
IrReceiver.printIRResultShort(&Serial);
54-
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
55-
// We have an unknown protocol, print more info
56-
IrReceiver.printIRResultRawFormatted(&Serial, true);
50+
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
51+
IrReceiver.decodedIRData.flags = false; // yes we have recognized the flag :-)
52+
// no need to call resume, this is already done by decode()
53+
Serial.println(F("Overflow detected"));
54+
#if !defined(ESP32)
55+
/*
56+
* do double beep
57+
*/
58+
IrReceiver.stop();
59+
tone(5, 1100, 10);
60+
delay(50);
61+
#endif
62+
63+
} else {
64+
// Print a short summary of received data
65+
IrReceiver.printIRResultShort(&Serial);
66+
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
67+
// We have an unknown protocol, print more info
68+
IrReceiver.printIRResultRawFormatted(&Serial, true);
69+
}
5770
}
5871
Serial.println();
5972

6073
#if !defined(ESP32)
6174
/*
6275
* Play tone, wait and restore IR timer
6376
*/
77+
IrReceiver.stop();
6478
tone(5, 2200, 10);
6579
delay(11);
66-
IrReceiver.enableIRIn();
80+
IrReceiver.start();
6781
#endif
6882

6983
IrReceiver.resume(); // Enable receiving of the next value
@@ -73,9 +87,5 @@ void loop() {
7387
if (IrReceiver.decodedIRData.command == 0x11) {
7488
// do something
7589
}
76-
} else if (IrReceiver.results.overflow) {
77-
IrReceiver.results.overflow = false;
78-
// no need to call resume, this is already done by decode()
79-
Serial.println(F("Overflow detected"));
8090
}
8191
}

examples/IRreceiveDump/IRreceiveDump.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ int IR_RECEIVE_PIN = 15;
2323
#else
2424
int IR_RECEIVE_PIN = 11;
2525
#endif
26-
IRrecv IrReceiver(IR_RECEIVE_PIN);
2726

2827
//+=============================================================================
2928
// Configure the Arduino
@@ -38,8 +37,7 @@ void setup() {
3837
// Just to know which program is running on my Arduino
3938
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
4039

41-
IrReceiver.enableIRIn(); // Start the receiver
42-
IrReceiver.blink13(true); // Enable feedback LED
40+
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver, enable feedback LED, take LED feedback pin from the internal boards definition
4341

4442
Serial.print(F("Ready to receive IR signals at pin "));
4543
Serial.println(IR_RECEIVE_PIN);
@@ -64,9 +62,9 @@ void loop() {
6462
IrReceiver.printIRResultRawFormatted(&Serial, true); // Output the results in RAW format
6563
Serial.println(); // blank line between entries
6664
Serial.println(F("Result as internal ticks (50 us) array - compensated with MARK_EXCESS_MICROS"));
67-
IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, false); // Output the results as uint8_t source code array of ticks
65+
IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, false); // Output the results as uint8_t source code array of ticks
6866
Serial.println(F("Result as microseconds array - compensated with MARK_EXCESS_MICROS"));
69-
IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, true); // Output the results as uint16_t source code array of micros
67+
IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, true); // Output the results as uint16_t source code array of micros
7068
IrReceiver.printIRResultAsCVariables(&Serial); // Output address and data as source code variables
7169

7270
IrReceiver.compensateAndPrintIRResultAsPronto(&Serial);

0 commit comments

Comments
 (0)