Skip to content

Commit 2ccae65

Browse files
committed
Implemented feedback for send. Removed decode_results results. Added unit test and fixed LG send bug. MATCH_MARK() etc. now available as matchMark(). Added PinDefinitionsAndMore.h.
1 parent 0bd9f46 commit 2ccae65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2411
-1592
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ jobs:
104104

105105
- arduino-boards-fqbn: digistump:avr:digispark-tiny:clock=clock1
106106
platform-url: https://raw.githubusercontent.com/ArminJo/DigistumpArduino/master/package_digistump_index.json
107-
sketches-exclude: IR2Keyboard,IRUnitTest,IRrelay,ReceiveAndSend,IRreceiveDump,IRsendProntoDemo,MicroGirs,IRDispatcherDemo,LGAirConditionerSendDemo,ReceiverTimingAnalysis # Does not fit in FLASH or RAM, missing digitalPinToInterrupt
107+
sketches-exclude: IR2Keyboard,UnitTest,ControlRelay,ReceiveAndSend,ReceiveDump,SendProntoDemo,MicroGirs,IRDispatcherDemo,SendLGAirConditionerDemo,ReceiverTimingAnalysis # Does not fit in FLASH or RAM, missing digitalPinToInterrupt
108108
build-properties: # the flags were put in compiler.cpp.extra_flags
109109
All: -DEXCLUDE_EXOTIC_PROTOCOLS
110110

111111
- arduino-boards-fqbn: ATTinyCore:avr:attinyx5:chip=85,clock=1internal
112112
platform-url: http://drazzy.com/package_drazzy.com_index.json
113-
sketches-exclude: IR2Keyboard,IRUnitTest,IRrelay,ReceiveAndSend,IRreceiveDump,IRsendProntoDemo,MicroGirs,IRDispatcherDemo,LGAirConditionerSendDemo,ReceiverTimingAnalysis # Does not fit in FLASH or RAM
113+
sketches-exclude: IR2Keyboard,UnitTest,ReceiveAndSend,ReceiveDump,SendProntoDemo,MicroGirs,IRDispatcherDemo,SendLGAirConditionerDemo,ReceiverTimingAnalysis # Does not fit in FLASH or RAM
114114
build-properties: # the flags were put in compiler.cpp.extra_flags
115115
All: -DEXCLUDE_EXOTIC_PROTOCOLS
116116

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ This is a quite old but maybe useful wiki for this library.
3232
# Converting your program to the 3.1 version
3333
This must be done also for all versions > 3.0.1 if `USE_NO_SEND_PWM` is defined.<br/>
3434
Starting with this version, **the generation of PWM is done by software**, thus saving the hardware timer and **enabling abitrary output pins**.<br/>
35-
Therefore you must change all `IrSender.begin(true);` by `IrSender.begin(IR_SEND_PIN, true);`.
35+
Therefore you must change all `IrSender.begin(true);` by `IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK);`.
3636

3737
# Converting your 2.x program to the 3.x version
3838
- Now there is an **IRreceiver** and **IRsender** object like the well known Arduino **Serial** object.
3939
- Just remove the line `IRrecv IrReceiver(IR_RECEIVE_PIN);` and/or `IRsend IrSender;` in your program, and replace all occurrences of `IRrecv.` or `irrecv.` with `IrReceiver`.
4040
- Since the decoded values are now in `IrReceiver.decodedIRData` and not in `results` any more, remove the line `decode_results results` or similar.
41-
- Like for the Serial object, call [`IrReceiver.begin(IR_RECEIVE_PIN, ENABE_ED_FEEDBACK);`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/IRreceiveDemo/IRreceiveDemo.ino#L38) or `IrReceiver.begin(IR_RECEIVE_PIN, DISABLE_LED_FEEDBACK);` instead of the `IrReceiver.enableIRIn();` or `irrecv.enableIRIn();` in setup().
41+
- 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().
4242
- 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())`.
4343
- 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`.
4444
- Overflow, Repeat and other flags are now in [`IrReceiver.receivedIRData.flags`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.h#L126).
@@ -69,8 +69,8 @@ The main reason is, that it was designed to fit inside MCUs with relatively low
6969

7070
## Hints
7171
If you do not know which protocol your IR transmitter uses, you have several choices.
72-
- Use the [IRreceiveDump example](examples/IRreceiveDump) to dump out the IR timing.
73-
You can then reproduce/send this timing with the [IRsendRawDemo example](examples/IRsendRawDemo).
72+
- Use the [IRreceiveDump example](examples/ReceiveDump) to dump out the IR timing.
73+
You can then reproduce/send this timing with the [SendRawDemo example](examples/SendRawDemo).
7474
For **long codes** with more than 48 bits like from air conditioners, you can **change the length of the input buffer** in [IRremote.h](src/IRremoteInt.h#L36).
7575
- The [IRMP AllProtocol example](https://github.com/ukw100/IRMP#allprotocol-example) prints the protocol and data for one of the **40 supported protocols**.
7676
The same library can be used to send this codes.
@@ -86,7 +86,7 @@ If you do not know which protocol your IR transmitter uses, you have several cho
8686
### SimpleReceiver + SimpleSender
8787
This examples are a good starting point.
8888

89-
### IRReceiveDemo + IRSendDemo
89+
### ReceiveDemo + SendDemo
9090
More complete examples for the advanced user.
9191

9292
### ReceiveAndSend
@@ -95,7 +95,7 @@ Like the name states...
9595
### MinimalReceiver + SmallReceiver
9696
If code size matters look at these examples.
9797

98-
### DispatcherDemo
98+
### IRDispatcherDemo
9999
Framework for calling different functions for different IR codes.
100100

101101
### IRrelay
@@ -113,11 +113,12 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
113113
| `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. |
114114
| `USE_NO_SEND_PWM` | Before `#include <IRremote.h>` | disabled | Use no carrier PWM, just simulate an active low receiver signal. |
115115
| `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. |
116+
| `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. |
116117
| `IR_INPUT_IS_ACTIVE_HIGH` | IRremoteInt.h | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
117118
| `RAW_BUFFER_LENGTH` | IRremoteint.h | 101 | Buffer size of raw input buffer. Must be odd! |
118119
| `DEBUG` | IRremoteInt.h | disabled | Enables lots of lovely debug output. |
119-
| `IR_SEND_DUTY_CYCLE` | IRremoteBoardDefs.h | 30 | Duty cycle of IR send signal. |
120-
| `MICROS_PER_TICK` | IRremoteBoardDefs.h | 50 | Resolution of the raw input buffer data. |
120+
| `IR_SEND_DUTY_CYCLE` | IRBoardDefs.h | 30 | Duty cycle of IR send signal. |
121+
| `MICROS_PER_TICK` | IRBoardDefs.h | 50 | Resolution of the raw input buffer data. |
121122
|-|-|-|-|
122123
| `IR_INPUT_PIN` | TinyIRReceiver.h | 2 | The pin number for TinyIRReceiver IR input, which gets compiled in. |
123124
| `IR_FEEDBACK_LED_PIN` | TinyIRReceiver.h | `LED_BUILTIN` | The pin number for TinyIRReceiver feedback LED, which gets compiled in. |
@@ -158,7 +159,7 @@ The send PWM signal is by default generated by software. **Therefore every pin c
158159
## Hardware-PWM signal generation for sending
159160
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.
160161
Since each hardware timer has its dedicated output pins, you must change timer to change PWN output.<br/>
161-
The timer and the pin usage can be adjusted in [IRremoteBoardDefs.h](src/private/IRremoteBoardDefs.h)
162+
The timer and the pin usage can be adjusted in [IRBoardDefs.h](src/private/IRBoardDefs.h)
162163

163164
| Board/CPU | Hardware-PWM Pin | Timers |
164165
|--------------------------------------------------------------------------|---------------------|-------------------|

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- Renamed most irparams_struct values.
1010
- Implemented feedback for send.
1111
- Removed decode_results results.
12+
- Added unit test and fixed LG send bug.
13+
- MATCH_MARK() etc. now available as matchMark().
1214

1315
## 3.0.2
1416
- Bug fix for USE_OLD_DECODE.

examples/IRrelay/IRrelay.ino renamed to examples/ControlRelay/ControlRelay.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* IRremote: IRrelay - demonstrates receiving IR codes with IRrecv
2+
* ControlRelay.cpp
3+
*
34
* Toggles an output pin at each command received
45
* An IR detector/demodulator must be connected to the input RECV_PIN.
56
* Initially coded 2009 Ken Shirriff http://www.righto.com
@@ -9,7 +10,7 @@
910
************************************************************************************
1011
* MIT License
1112
*
12-
* Copyright (c) 2020-2021 Armin Joachimsmeyer
13+
* Copyright (c) 2009-2021 Ken Shirriff, Armin Joachimsmeyer
1314
*
1415
* Permission is hereby granted, free of charge, to any person obtaining a copy
1516
* of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +40,11 @@
3940

4041
#include <IRremote.h>
4142

42-
int RELAY_PIN = 4; // is labeled D2 on the Chinese SAMD21 M0-Mini clone
43+
#if defined(APPLICATION_PIN)
44+
#define RELAY_PIN APPLICATION_PIN
45+
#else
46+
#define RELAY_PIN 5
47+
#endif
4348

4449
void setup() {
4550
pinMode(LED_BUILTIN, OUTPUT);

examples/IRreceiveDump/PinDefinitionsAndMore.h renamed to examples/ControlRelay/PinDefinitionsAndMore.h

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* This file is part of IRMP https://github.com/Arduino-IRremote/Arduino-IRremote.
1111
*
12-
* IRMP is free software: you can redistribute it and/or modify
12+
* Arduino-IRremote is free software: you can redistribute it and/or modify
1313
* it under the terms of the GNU General Public License as published by
1414
* the Free Software Foundation, either version 3 of the License, or
1515
* (at your option) any later version.
@@ -44,19 +44,19 @@
4444
//
4545
#if defined(ESP8266)
4646
#define FEEDBACK_LED_IS_ACTIVE_LOW // The LED on my board is active LOW
47-
#define IR_RECEIVE_PIN 14 // D5
48-
#define IR_SEND_PIN 12 // D6 - D4/2 is internal LED
49-
#define tone(a,b) void() // tone() inhibits receive timer
47+
#define IR_RECEIVE_PIN 14 // D5
48+
#define IR_SEND_PIN 12 // D6 - D4/2 is internal LED
49+
#define tone(a,b) void() // tone() inhibits receive timer
5050
#define noTone(a) void()
51-
#define TONE_PIN 42 // Dummy for examples using it
52-
#define IR_TIMING_TEST_PIN 13 // D7
51+
#define TONE_PIN 42 // Dummy for examples using it
52+
#define IR_TIMING_TEST_PIN 13 // D7
5353

5454
#elif defined(ESP32)
55-
#define IR_RECEIVE_PIN 15 // D15
56-
#define IR_SEND_PIN 4 // D4
57-
#define tone(a,b) void() // no tone() available on ESP32
55+
#define IR_RECEIVE_PIN 15 // D15
56+
#define IR_SEND_PIN 4 // D4
57+
#define tone(a,b) void() // no tone() available on ESP32
5858
#define noTone(a) void()
59-
#define TONE_PIN 42 // Dummy for examples using it
59+
#define TONE_PIN 42 // Dummy for examples using it
6060

6161
#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1)
6262
// BluePill in 2 flavors
@@ -101,34 +101,58 @@
101101
#define IR_SEND_PIN 11
102102
#define TONE_PIN 3
103103

104+
# elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \
105+
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
106+
|| defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \
107+
|| defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \
108+
|| defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \
109+
|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \
110+
|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) \
111+
|| defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) \
112+
|| defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__)
113+
#define IR_RECEIVE_PIN 2
114+
#define IR_SEND_PIN 13
115+
#define TONE_PIN 4
116+
#define APPLICATION_PIN 5
117+
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
118+
#define IR_TIMING_TEST_PIN 7
119+
104120
#elif defined(ARDUINO_ARCH_APOLLO3)
105121
#define IR_RECEIVE_PIN 11
106122
#define IR_SEND_PIN 12
107123
#define TONE_PIN 5
108124

109125
#elif defined(ARDUINO_ARCH_MBED) // Arduino Nano 33 BLE
110-
#define IR_RECEIVE_PIN 3
111-
#define IR_SEND_PIN 4
112-
#define TONE_PIN 5
113-
#define IR_TIMING_TEST_PIN 6
126+
#define IR_RECEIVE_PIN 2
127+
#define IR_SEND_PIN 3
128+
#define TONE_PIN 4
129+
#define APPLICATION_PIN 5
130+
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
131+
#define IR_TIMING_TEST_PIN 7
114132

115133
#elif defined(TEENSYDUINO)
116-
#define IR_RECEIVE_PIN 3
117-
#define IR_SEND_PIN 4
118-
#define TONE_PIN 5
119-
#define IR_TIMING_TEST_PIN 6
134+
#define IR_RECEIVE_PIN 2
135+
#define IR_SEND_PIN 3
136+
#define TONE_PIN 4
137+
#define APPLICATION_PIN 5
138+
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
139+
#define IR_TIMING_TEST_PIN 7
120140

121141
#elif defined(__AVR__)
122-
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
123-
#define IR_SEND_PIN 3
124-
#define TONE_PIN 4
125-
#define IR_TIMING_TEST_PIN 6
142+
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
143+
#define IR_SEND_PIN 3
144+
#define TONE_PIN 4
145+
#define APPLICATION_PIN 5
146+
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
147+
#define IR_TIMING_TEST_PIN 7
126148

127149
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
128-
#define IR_RECEIVE_PIN 2 // To be compatible with interrupt example, pin 2 is chosen here.
129-
#define IR_SEND_PIN 3
130-
#define TONE_PIN 4
131-
#define IR_TIMING_TEST_PIN 6
150+
#define IR_RECEIVE_PIN 2
151+
#define IR_SEND_PIN 3
152+
#define TONE_PIN 4
153+
#define APPLICATION_PIN 5
154+
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
155+
#define IR_TIMING_TEST_PIN 7
132156

133157
// On the Zero and others we switch explicitly to SerialUSB
134158
#define Serial SerialUSB
@@ -146,10 +170,12 @@
146170
#else
147171
#warning Board / CPU is not detected using pre-processor symbols -> using default values, which may not fit. Please extend PinDefinitionsAndMore.h.
148172
// Default valued for unidentified boards
149-
#define IR_RECEIVE_PIN 2
150-
#define IR_SEND_PIN 3
151-
#define TONE_PIN 4
152-
#define IR_TIMING_TEST_PIN 6
173+
#define IR_RECEIVE_PIN 2
174+
#define IR_SEND_PIN 3
175+
#define TONE_PIN 4
176+
#define APPLICATION_PIN 5
177+
#define ALTERNATIVE_IR_FEEDBACK_LED_PIN 6 // E.g. used for examples which use LED_BUILDIN for example output.
178+
#define IR_TIMING_TEST_PIN 7
153179
#endif // defined(ESP8266)
154180

155181
/*

examples/IRDispatcherDemo/IRDispatcherDemo.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464

6565
#include "PinDefinitionsAndMore.h"
6666
#define IR_RECEIVER_PIN IRMP_INPUT_PIN
67-
#if defined(ALTERNATIVE_IRMP_FEEDBACK_LED_PIN)
68-
#define FEEDBACK_LED_PIN ALTERNATIVE_IRMP_FEEDBACK_LED_PIN
67+
#if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN)
68+
#define FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN
6969
#endif
7070

7171
//#define IRMP_ENABLE_PIN_CHANGE_INTERRUPT // Enable interrupt functionality - requires around 376 additional bytes of program space
@@ -76,8 +76,8 @@
7676

7777
#define IRMP_SUPPORT_NEC_PROTOCOL 1 // this enables only one protocol
7878

79-
# ifdef ALTERNATIVE_IRMP_FEEDBACK_LED_PIN
80-
#define IRMP_FEEDBACK_LED_PIN ALTERNATIVE_IRMP_FEEDBACK_LED_PIN
79+
# ifdef ALTERNATIVE_IR_FEEDBACK_LED_PIN
80+
#define IRMP_FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN
8181
# endif
8282
/*
8383
* After setting the definitions we can include the code and compile it.
@@ -149,9 +149,9 @@ void setup()
149149
Serial.println(F("at pin " STR(IRMP_INPUT_PIN)));
150150
# endif
151151

152-
# ifdef ALTERNATIVE_IRMP_FEEDBACK_LED_PIN
153-
irmp_irsnd_LEDFeedback(true); // Enable receive signal feedback at ALTERNATIVE_IRMP_FEEDBACK_LED_PIN
154-
Serial.print(F("IR feedback pin is " STR(ALTERNATIVE_IRMP_FEEDBACK_LED_PIN)));
152+
# ifdef ALTERNATIVE_IR_FEEDBACK_LED_PIN
153+
irmp_irsnd_LEDFeedback(true); // Enable receive signal feedback at ALTERNATIVE_IR_FEEDBACK_LED_PIN
154+
Serial.print(F("IR feedback pin is " STR(ALTERNATIVE_IR_FEEDBACK_LED_PIN)));
155155
# endif
156156
#endif
157157

0 commit comments

Comments
 (0)