Skip to content

Commit ec94757

Browse files
committed
UnitTest tested for Digispark and ATTiny core
1 parent 38f4eb6 commit ec94757

File tree

17 files changed

+111
-35
lines changed

17 files changed

+111
-35
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
- arduino:avr:uno|DEBUG
4747
- arduino:avr:uno|USE_NO_SEND_PWM
4848
- arduino:avr:uno|USE_OLD_DECODE
49+
- arduino:avr:uno|NO_LEGACY_COMPATIBILITY
4950
- arduino:avr:uno|SEND_PWM_BY_TIMER
5051
- arduino:avr:leonardo
5152
- arduino:megaavr:nona4809:mode=off
@@ -83,6 +84,11 @@ jobs:
8384
build-properties: # the flags were put in compiler.cpp.extra_flags
8485
All: -DUSE_OLD_DECODE
8586

87+
- arduino-boards-fqbn: arduino:avr:uno|NO_LEGACY_COMPATIBILITY
88+
sketches-exclude: IR2Keyboard
89+
build-properties: # the flags were put in compiler.cpp.extra_flags
90+
All: -DNO_LEGACY_COMPATIBILITY
91+
8692
- arduino-boards-fqbn: arduino:avr:uno|SEND_PWM_BY_TIMER
8793
sketches-exclude: IR2Keyboard
8894
build-properties: # the flags were put in compiler.cpp.extra_flags

README.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,33 @@ Click on the LibraryManager badge above to see the [instructions](https://www.ar
1919

2020
# Supported IR Protocols
2121
Denon / Sharp, JVC, LG, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BoseWave, Lego, Whynter, MagiQuest.<br/>
22-
Protocols can be switched off and on by definining macros before the line `#incude <IRremote.h>` like [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/SimpleReceiver/SimpleReceiver.ino#L14):
22+
Protocols can be switched off and on by defining macros before the line `#include <IRremote.h>` like [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/SimpleReceiver/SimpleReceiver.ino#L14):
2323

2424
```
2525
#define DECODE_NEC
2626
//#define DECODE_DENON
27-
#incude <IRremote.h>
27+
#include <IRremote.h>
2828
```
2929

3030
# [Wiki](https://github.com/Arduino-IRremote/Arduino-IRremote/wiki)
3131
This is a quite old but maybe useful wiki for this library.
3232

33+
# Features of the 3.x version
34+
- You can use any pin for sending now, like you are used with receiving.
35+
- Simultaneous sending and receiving. See the [UnitTest](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/UnitTest/UnitTest.ino#L165-L166) example.
36+
- No more need to use 32 bit hex values in your code. Instead a (8 bit) command value is provided for decoding (as well as an 16 bit address and a protocol number).
37+
- Protocol values comply to protocol standards, i.e. NEC, Panasonic, Sony, Samsung and JVC decode and send LSB first.
38+
- Supports more protocols, since adding a protocol is quite easy now.
39+
- Better documentation and more examples :-).
40+
- Compatible with tone() library, see [ReceiveDemo](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/ReceiveDemo/ReceiveDemo.ino#L150-L153).
41+
- Supports more platforms, since the new structure allows to easily add a new platform.
42+
- Feedback LED also for sending.
43+
- Ability to generate a non PWM signal to just simulate an active low receiver signal for direct connect to existent receiving devices without using IR.
44+
- Easy configuration of protocols required, directly in your [source code[(https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/SimpleReceiver/SimpleReceiver.ino#L18-L34). This reduces the memory footprint and increases decoding time.
45+
3346
# Converting your program to the 3.1 version
3447
This must be done also for all versions > 3.0.1 if `USE_NO_SEND_PWM` is defined.<br/>
35-
Starting with this version, **the generation of PWM is done by software**, thus saving the hardware timer and **enabling abitrary output pins**.<br/>
48+
Starting with this version, **the generation of PWM is done by software**, thus saving the hardware timer and **enabling arbitrary output pins**.<br/>
3649
Therefore you must change all `IrSender.begin(true);` by `IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK);`.
3750
If you use a core that does not use the `-flto` flag for compile, you can activate the line `#define SUPPRESS_ERROR_MESSAGE_FOR_BEGIN` in IRRemote.h, if you get false error messages regarding begin() during compilation.
3851

@@ -47,12 +60,33 @@ If you use a core that does not use the `-flto` flag for compile, you can activa
4760
- Seldom used: `results.rawbuf` and `results.rawlen` must be replaced by `IrReceiver.decodedIRData.rawDataPtr->rawbuf` and `IrReceiver.decodedIRData.rawDataPtr->rawlen`.
4861

4962
# 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.
63+
If you program is of style:
64+
```
65+
IRrecv irrecv(RECV_PIN);
66+
decode_results results;
67+
68+
void setup()
69+
{
70+
...
71+
irrecv.enableIRIn(); // Start the receiver
72+
}
73+
74+
void loop() {
75+
if (irrecv.decode(&results)) {
76+
Serial.println(results.value, HEX);
77+
...
78+
irrecv.resume(); // Receive the next value
79+
}
80+
...
81+
}
82+
```
83+
it should run on the 3.1.1 version as before. The following decoders are available: Denon, JVC, LG, NEC, Panasonic, RC5, RC6, Samsung, Sony.
84+
The `results.value` is set by the decoders for **NEC, Panasonic, Sony, Samsung and JVC** as MSB first like in 2.x.<br/>
5285
- 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**.
5386
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.
5487

5588
# Convert old MSB first 32 bit IR data codes to new LSB first 32 bit IR data codes
89+
The new decoders for **NEC, Panasonic, Sony, Samsung and JVC** `IrReceiver.decodedIRData.decodedRawData` is now LSB-first, as the definition of these protocols suggests!
5690
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/>
5791
Example:<br/>
5892
0xCB340102 byte reverse -> 02 01 34 CB bit reverse-> 40 80 2C D3.<br/>
@@ -97,7 +131,7 @@ If you do not know which protocol your IR transmitter uses, you have several cho
97131
since one IR diode requires only 1.5 volt.
98132
- The line \#include "ATtinySerialOut.h" in PinDefinitionsAndMore.h (requires the library to be installed) saves 370 bytes program space and 38 bytes RAM for **Digispark boards** as well as enables serial output at 8MHz.
99133
- The default software generated PWM has **problems on ATtinies running with 8 MHz**. The PWM frequency is around 30 instead of 38 kHz and RC6 is not reliable. You can switch to timer PWM generation by `#define SEND_PWM_BY_TIMER`.
100-
- Minimal CPU frequency for receiving is 4 MHz, sive the 50 us timer ISR takes around 12 us on a 16 MHz ATmega.
134+
- Minimal CPU frequency for receiving is 4 MHz, since the 50 us timer ISR takes around 12 us on a 16 MHz ATmega.
101135

102136
# Examples
103137
In order to fit the examples to the 8K flash of ATtiny85 and ATtiny88, the [Arduino library ATtinySerialOut](https://github.com/ArminJo/ATtinySerialOut) is required for this CPU's.
@@ -129,13 +163,13 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
129163

130164
| Name | File | Default value | Description |
131165
|-|-|-|-|
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`. |
166+
| `SEND_PWM_BY_TIMER` | Before `#include <IRremote.h>` | disabled | Disable carrier PWM generation in software and use (restricted) hardware PWM except for ESP32 where both modes are using the flexible `hw_timer_t`. |
133167
| `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. |
134168
| `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. |
135169
| `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. |
136170
| `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. |
137171
| `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. |
138-
| `DISABLE_LED_FEEDBACK_FOR_RECEIVE` | Before `#include <IRremote.h>` | disabled | This disables the LED feedback code for receive, thus saving around 108 bytes program space and halving the receiver ISR processing time. |
172+
| `DISABLE_LED_FEEDBACK_FOR_RECEIVE` | Before `#include <IRremote.h>` | disabled | This completely disables the LED feedback code for receive, thus saving around 108 bytes program space and halving the receiver ISR processing time. |
139173
| `IR_INPUT_IS_ACTIVE_HIGH` | Before `#include <IRremote.h>` | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
140174
| `RAW_BUFFER_LENGTH` | IRremoteInt.h | 101 | Buffer size of raw input buffer. Must be odd! |
141175
| `DEBUG` | IRremoteInt.h | disabled | Enables lots of lovely debug output. |
@@ -180,7 +214,7 @@ The send PWM signal is by default generated by software. **Therefore every pin c
180214

181215
| Software generated PWM showing small jitter because of the limited resolution of 4 us of the Arduino core `micros()` function for an ATmega328 | Detail (ATmega328 generated) showing 33% Duty cycle |
182216
|-|-|
183-
| ![Software PWM](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/pictures/IR_PWM_by_software_jitter.png) | ![Software PWM detail](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/pictures/IR_PWM_by_software_detail.png) |
217+
| ![Software PWM](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/pictures/IR_PWM_by_software_jitter.png) | ![Software PWM detail](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/pictures/IR_PWM_by_software_detail.png) |
184218

185219
## Hardware-PWM signal generation for sending
186220
If you define `SEND_PWM_BY_TIMER`, the send PWM signal is generated by a hardware timer. The same timer as for the receiver is used.

changelog.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The latest version may not be released!
3939
- Fixed JVC repeat error.
4040

4141
## 3.0.0 + 3.0.1 2021/02
42+
- New LSB first decoders are default.
4243
- Added SendRaw with byte data.
4344
- Fixed resume bug if irparams.rawlen >= RAW_BUFFER_LENGTH. Thanks to Iosif Peterfi
4445
- Added `dumpPronto(String *aString, unsigned int frequency)` with String object as argument. Thanks to Iosif Peterfi
@@ -60,10 +61,9 @@ The latest version may not be released!
6061
- Changed License to MIT see https://github.com/Arduino-IRremote/Arduino-IRremote/issues/397.
6162
- Added ATtiny timer 1 support.
6263
- Changed wrong return code signature of decodePulseDistanceData() and its handling.
63-
- Removed Mitsubishi protocol, since the implementation is in contradiction with all documentation I could found and therefore supposed to be wrong.
64-
- Removed AIWA implementation, since it is only for 1 device and at least sending implemented wrong.
64+
- Removed Mitsubishi protocol, since the implementation is in contradiction with all documentation I found and therefore supposed to be wrong.
65+
- Removed AIWA implementation, since it is only for 1 device and at least the sending was implemented wrong.
6566
- Added Lego_PF decode.
66-
- Added new example IR2Keyboard.
6767
- Changed internal usage of custom_delay_usec.
6868
- Moved dump/print functions from example to irReceiver.
6969
- irPronto.cpp: Using Print instead of Stream saves 1020 bytes program memory. Changed from & to * parameter type to be more transparent and consistent with other code of IRremote.

examples/ControlRelay/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#define IR_TIMING_TEST_PIN PA5
7070

7171
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
72-
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM
72+
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM for digistump core
7373
#define IR_RECEIVE_PIN 0
7474
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
7575
#define TONE_PIN 3

examples/ReceiveAndSend/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#define IR_TIMING_TEST_PIN PA5
7070

7171
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
72-
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM
72+
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM for digistump core
7373
#define IR_RECEIVE_PIN 0
7474
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
7575
#define TONE_PIN 3

examples/ReceiveDemo/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#define IR_TIMING_TEST_PIN PA5
7070

7171
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
72-
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM
72+
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM for digistump core
7373
#define IR_RECEIVE_PIN 0
7474
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
7575
#define TONE_PIN 3

examples/ReceiveDump/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#define IR_TIMING_TEST_PIN PA5
7070

7171
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
72-
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM
72+
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM for digistump core
7373
#define IR_RECEIVE_PIN 0
7474
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
7575
#define TONE_PIN 3

examples/SendBoseWaveDemo/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#define IR_TIMING_TEST_PIN PA5
7070

7171
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
72-
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM
72+
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM for digistump core
7373
#define IR_RECEIVE_PIN 0
7474
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
7575
#define TONE_PIN 3

examples/SendDemo/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#define IR_TIMING_TEST_PIN PA5
7070

7171
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
72-
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM
72+
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM for digistump core
7373
#define IR_RECEIVE_PIN 0
7474
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
7575
#define TONE_PIN 3

examples/SendLGAirConditionerDemo/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#define IR_TIMING_TEST_PIN PA5
7070

7171
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
72-
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM
72+
#include "ATtinySerialOut.h" // Available as Arduino library. saves 370 bytes program space and 38 bytes RAM for digistump core
7373
#define IR_RECEIVE_PIN 0
7474
#define IR_SEND_PIN 4 // Pin 2 is serial output with ATtinySerialOut. Pin 1 is internal LED and Pin3 is USB+ with pullup on Digispark board.
7575
#define TONE_PIN 3

0 commit comments

Comments
 (0)