Skip to content

Commit 2baa90a

Browse files
committed
Bug fix for USE_OLD_DECODE
1 parent 9a43cf7 commit 2baa90a

File tree

6 files changed

+46
-9
lines changed

6 files changed

+46
-9
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
- arduino:avr:uno
5050
- arduino:avr:uno|DEBUG
5151
- arduino:avr:uno|USE_NO_SEND_PWM
52+
- arduino:avr:uno|USE_OLD_DECODE
5253
- arduino:avr:leonardo
5354
- arduino:megaavr:nona4809:mode=off
5455
- digistump:avr:digispark-tiny:clock=clock1
@@ -77,6 +78,11 @@ jobs:
7778
build-properties: # the flags were put in compiler.cpp.extra_flags
7879
All: -DUSE_NO_SEND_PWM
7980

81+
- arduino-boards-fqbn: arduino:avr:uno|USE_OLD_DECODE
82+
sketches-exclude: IR2Keyboard
83+
build-properties: # the flags were put in compiler.cpp.extra_flags
84+
All: -DUSE_OLD_DECODE
85+
8086
- arduino-boards-fqbn: arduino:megaavr:nona4809:mode=off
8187
sketches-exclude: IR2Keyboard,MinimalReceiver,IRDispatcherDemo
8288

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# IRremote Arduino Library
22
Available as Arduino library "IRremote"
33

4-
### [Version 3.0.0](https://github.com/z3t0/Arduino-IRremote/archive/master.zip) - work in progress
4+
### [Version 3.0.2](https://github.com/z3t0/Arduino-IRremote/archive/master.zip) - work in progress
55

66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77
[![Commits since latest](https://img.shields.io/github/commits-since/z3t0/Arduino-IRremote/latest)](https://github.com/z3t0/Arduino-IRremote/commits/master)
@@ -17,7 +17,7 @@ Tutorials and more information will be made available on [the official homepage]
1717
Click on the LibraryManager badge above to see the [instructions](https://www.ardu-badge.com/IRremote/zip).
1818

1919
# Supported IR Protocols
20-
Denon, JVC, LG, NEC, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sharp, Sony, (Pronto), BoseWave, Lego, Whynter, MagiQuest.<br/>
20+
Denon, JVC, LG, NEC / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sharp, Sony, (Pronto), BoseWave, Lego, Whynter, MagiQuest.<br/>
2121
Protocols can be switched off and on by changing the lines in *IRremote.h*:
2222

2323
```
@@ -41,7 +41,7 @@ In the new version you will send NEC commands not by 32 bit codes but by a (cons
4141

4242
# FAQ
4343
- IR does not work right when I use Neopixels (aka WS2811/WS2812/WS2812B)<br/>
44-
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.
44+
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.
4545
In turn, this stops the IR interrupt handler from running when it needs to. There are some solutions to this on some processors,
4646
[see this page from Marc MERLIN](http://marc.merlins.org/perso/arduino/post_2017-04-03_Arduino-328P-Uno-Teensy3_1-ESP8266-ESP32-IR-and-Neopixels.html)
4747
- The default IR timer on AVR's is timer 2. Since the **Arduino Tone library** as well as **analogWrite() for pin 3 and pin 11** requires timer 2,
@@ -81,6 +81,7 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
8181

8282
| Name | File | Default value | Description |
8383
|-|-|-|-|
84+
| `USE_OLD_DECODE` | IRremoteint.h | disabled | Enables the old decoder in order to be version 2.x compatible, where all protocols were MSB first. |
8485
| `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. |
8586
| `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. |
8687
| `IR_INPUT_IS_ACTIVE_HIGH` | IRremoteInt.h | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
@@ -170,7 +171,7 @@ The **durations** you receive are likely to be longer for marks and shorter for
170171
but this depends on the receiver circuit in use. Most protocols use multiples of one time-unit for marks and spaces like e.g. [NEC](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/ir_NEC.cpp#L50). It's easy to be off-by-one with the last bit, since the last space is not recorded by IRremote.
171172

172173
Try to make use of the template functions `decodePulseDistanceData()` and `sendPulseDistanceData()`.
173-
If your protocol supports address and code fields, try to reflect this in your api like it is done in [`sendNEC(uint16_t aAddress, uint8_t aCommand, uint8_t aNumberOfRepeats, bool aIsRepeat)`](https://github.com/z3t0/Arduino-IRremote/blob/master/src/ir_NEC.cpp#L86) and [`decodeNEC()`](https://github.com/z3t0/Arduino-IRremote/blob/master/src/ir_NEC.cpp#L145).<br/>
174+
If your protocol supports address and code fields, try to reflect this in your api like it is done in [`sendNEC(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aIsRepeat)`](https://github.com/z3t0/Arduino-IRremote/blob/master/src/ir_NEC.cpp#L86) and [`decodeNEC()`](https://github.com/z3t0/Arduino-IRremote/blob/master/src/ir_NEC.cpp#L145).<br/>
174175

175176
### Integration
176177
To integrate your protocol, you need to extend the two functions `decode()` and `getProtocolString()` in *IRreceice.cpp*,
@@ -205,6 +206,32 @@ BTW, **the best way to increase the IR power** is to use 2 or 3 IR diodes in ser
205206
To keep the current, you must reduce the resistor by (5 - 1.3) / (5 - 2.6) = 1.5 e.g. from 150 ohm to 100 ohm for 25 mA and 2 diodes with 1.3 volt and a 5 volt supply.<br/>
206207
For 3 diodes it requires factor 2.5 e.g. from 150 ohm to 60 ohm.
207208

209+
# Quick comparison of 4 Arduino IR receiving libraries
210+
## This is a short comparison and may not be complete or correct
211+
I created this comparison matrix for [myself](https://github.com/ArminJo) in order to choose a small IR lib for my project and to have a quick overview, when to choose which library.<br/>
212+
It is dated from **03.02.2021**. If you have complains about the data or request for extensions, please send a PM or open a discussion.
213+
214+
| Subject | [IRMP](https://github.com/ukw100/IRMP) | [IRLremote](https://github.com/NicoHood/IRLremote) | [IRLib2](https://github.com/cyborg5/IRLib2)<br/>**mostly unmaintained** | [IRremote](https://github.com/Arduino-IRremote/Arduino-IRremote) | [Minimal NEC](https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master/examples/MinimalReceiver) |
215+
|---------|------|-----------|--------|----------|----------|
216+
| Number of protocols | **50** | Nec + Panasonic + Hash \* | 12 + Hash \* | 17 + Hash \* | NEC |
217+
| 3.Party libs needed| % | PinChangeInterrupt if not pin 2 or 3 | % | % | % |
218+
| Timing method receive | Timer2 or interrupt for pin 2 or 3 | **Interrupt** | Timer2 or interrupt for pin 2 or 3 | Timer2 or interrupt for NEC | **Interrupt** |
219+
| Timing method send | PWM and timing with Timer2 interrupts | Timer2 interrupts | Timer2 and blocking wait | PWM with Timer2 and blocking wait with delayMicroseconds() | % |
220+
| Send pins| All | All | All ? | Timer dependent | % |
221+
| Decode method | OnTheFly | OnTheFly | RAM | RAM | OnTheFly |
222+
| Encode method | OnTheFly | OnTheFly | OnTheFly | OnTheFly or RAM | % |
223+
| Callback suppport | x | % | % | % | x |
224+
| Repeat handling | Receive + Send (partially) | % | ? | Receive + Send | x |
225+
| LED feedback | x | % | x | x | x |
226+
| FLASH usage (simple NEC example with 5 prints) | 1820<br/>(4300 for 15 main / 8000 for all 40 protocols)<br/>(+200 for callback)<br/>(+80 for interrupt at pin 2+3)| 1270<br/>(1400 for pin 2+3) | 4830 | 1770 | **900** |
227+
| RAM usage | 52<br/>(73 / 100 for 15 (main) / 40 protocols) | 62 | 334 | 227 | **19** |
228+
| Supported platforms | **avr, megaAVR, attiny, Digispark (Pro), esp8266, ESP32, STM32, SAMD 21, Apollo3<br/>(plus arm and pic for non Arduino IDE)** | avr, esp8266 | avr, SAMD 21, SAMD 51 | avr, attiny, [esp8266](https://github.com/crankyoldgit/IRremoteESP8266), esp32, SAM, SAMD | **All platforms with attachInterrupt()** |
229+
| Last library update | 2/2021 | 4/2018 | 9/2019 | 2/2021 | 2/2021 |
230+
| Remarks | Decodes 40 protocols concurrently.<br/>39 Protocols to send.<br/>Work in progress. | Only one protocol at a time. | Consists of 5 libraries. **Project containing bugs - 45 issues, no reaction for at least one year.** | Decoding and sending are easy to extend.<br/>Supports **Pronto** codes. | Requires no timer. |
231+
232+
\* The Hash protocol gives you a hash as code, which may be sufficient to distinguish your keys on the remote, but may not work with some protocols like Mitsubishi
233+
234+
208235
# Contributing
209236
If you want to contribute to this project:
210237
- Report bugs and errors
@@ -219,7 +246,7 @@ Check [here](https://github.com/z3t0/Arduino-IRremote/blob/master/Contributing.m
219246
Check [here](https://github.com/z3t0/Arduino-IRremote/blob/master/Contributors.md)
220247

221248
# Contact
222-
249+
223250
Please only email me if it is more appropriate than creating an Issue / PR. I **will** not respond to requests for adding support for particular boards, unless of course you are the creator of the board and would like to cooperate on the project. I will also **ignore** any emails asking me to tell you how to implement your ideas. However, if you have a private inquiry that you would only apply to you and you would prefer it to be via email, by all means.
224251

225252
# License

src/irReceive.cpp.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,16 @@ void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, uint16_t aLeadingSpa
809809
aSerial->print(aIRDataPtr->numberOfBits, DEC);
810810
aSerial->print(F(" bits)"));
811811

812+
#if !defined(USE_OLD_DECODE)
812813
if (aIRDataPtr->flags & IRDATA_FLAGS_IS_MSB_FIRST) {
813814
aSerial->println(F(" MSB first"));
814815
} else {
815816
aSerial->println(F(" LSB first"));
816-
817817
}
818+
#else
819+
aSerial->println();
820+
#endif
821+
818822
} else {
819823
aSerial->println();
820824
}

src/ir_JVC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ bool IRrecv::decodeJVC() {
164164
if ((results.rawlen - 1 == 33) && MATCH_MARK(results.rawbuf[offset], JVC_BIT_MARK)
165165
&& MATCH_MARK(results.rawbuf[results.rawlen - 1], JVC_BIT_MARK)) {
166166
results.bits = 0;
167-
results.value = REPEAT;
167+
results.value = 0xFFFFFFFF;
168168
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT;
169169
decodedIRData.protocol = JVC;
170170
return true;

src/ir_RC5_RC6.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool sLastSendToggleValue = false;
4646
// see: https://www.sbprojects.net/knowledge/ir/rc5.php
4747
// 0 -> mark+space
4848
// 1 -> space+mark
49-
// MSB first 1 start bit, 1 field bit, 1 toggle bit + 5 bit address + 6 bit command, no stop bit
49+
// MSB first 1 start bit, 1 field bit, 1 toggle bit + 5 bit address + 6 bit command (6 bit command + field bit for RC5X), no stop bit
5050
// duty factor is 25%,
5151
//
5252
#define RC5_ADDRESS_BITS 5

src/ir_Sony.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ bool IRrecv::decodeSony() {
169169
if (results.rawbuf[0] < (SONY_DOUBLE_SPACE_USECS / MICROS_PER_TICK)) {
170170
DBG_PRINTLN("IR Gap found");
171171
results.bits = 0;
172-
results.value = REPEAT;
172+
results.value = 0xFFFFFFFF;
173173
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT;
174174
decodedIRData.protocol = UNKNOWN;
175175
return true;

0 commit comments

Comments
 (0)