Skip to content

Commit 648fa78

Browse files
committed
Separated enable flag of send and receive feedback LED. Inspired by PR#970 from luvaihassanali.
1 parent 9da5df0 commit 648fa78

File tree

15 files changed

+144
-89
lines changed

15 files changed

+144
-89
lines changed

README.md

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This library enables you to send and receive using infra-red signals on an Ardui
88
[![Installation instructions](https://www.ardu-badge.com/badge/IRremote.svg?)](https://www.ardu-badge.com/IRremote)
99
[![LibraryBuild](https://github.com/Arduino-IRremote/Arduino-IRremote/workflows/LibraryBuild/badge.svg)](https://github.com/Arduino-IRremote/Arduino-IRremote/actions)
1010

11-
Available as Arduino library "IRremote"
11+
Available as [Arduino library "IRremote"](https://www.arduinolibraries.info/libraries/i-rremote).
1212

1313
# Table of content
1414
- [API](https://github.com/Arduino-IRremote/Arduino-IRremote#api)
@@ -263,7 +263,7 @@ If you see something like `Protocol=UNKNOWN Hash=0x13BD886C 35 bits received` as
263263
- If you have an **odd number of bits** received, it is likely, that your receiver circuit has problems. Maybe because the IR signal is too weak.
264264
- If you see timings like `+ 600,- 600 + 550,- 150 + 200,- 100 + 750,- 550` then one 450 µs space was split into two 150 and 100 µs spaces with a spike / error signal of 200 µs between. Maybe because of a defective receiver or a weak signal in conjunction with another light emitting source nearby.
265265
- If you see timings like `+ 500,- 550 + 450,- 550 + 500,- 500 + 500,-1550`, then marks are generally shorter than spaces and therefore `MARK_EXCESS_MICROS` (specified in your ino file) should be **negative** to compensate for this at decoding.
266-
- If you see `Protocol=UNKNOWN Hash=0x0 1 bits received` it may be that the space after the initial mark is longer than [`RECORD_GAP_MICROS`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.h#L124).
266+
- If you see `Protocol=UNKNOWN Hash=0x0 1 bits received` it may be that the space after the initial mark is longer than [`RECORD_GAP_MICROS`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.h#L124).
267267
This was observed for some LG air conditioner protocols. Try again with a line e.g. `#define RECORD_GAP_MICROS 12000` before the line `#include <IRremote.hpp>` in your ino file.
268268
- To see more info supporting you to find the reason for your UNKNOWN protocol, you must enable the line `//#define DEBUG` in IRremoteInt.h.
269269
@@ -342,32 +342,35 @@ Click on the receiver while simulation is running to specify individual NEC IR c
342342
343343
# Compile options / macros for this library
344344
To customize the library to different requirements, there are some compile options / macros available.<br/>
345-
Most macros must be defined in your program before the line `#include <IRremote.hpp>` to take effect.
345+
These macros must be defined in your program before the line `#include <IRremote.hpp>` to take effect.
346346
Modify them by enabling / disabling them, or change the values if applicable.
347347
348-
| Name | File | Default value | Description |
349-
|-|-|-|-|
350-
| `RAW_BUFFER_LENGTH` | Before `#include <IRremote.hpp>` | 100 | Buffer size of raw input buffer. Must be even! 100 is sufficient for *regular* protocols of up to 48 bits, but for most air conditioner protocols a value of up to 750 is required. Use the ReceiveDump example to find smallest value for your requirements. |
351-
| `IR_SEND_PIN` | Before `#include <IRremote.hpp>` | disabled | If specified (as constant), reduces program size and improves send timing for AVR. If you want to use a runtime variable send pin e.g. with `setSendPin(uint8_t aSendPinNumber)` , you must disable this macro. |
352-
| `SEND_PWM_BY_TIMER` | Before `#include <IRremote.hpp>` | disabled | Disable carrier PWM generation in software and use (restricted) hardware PWM. Enabled for ESP32 and RP2040 in all examples. |
353-
| `USE_NO_SEND_PWM` | Before `#include <IRremote.hpp>` | disabled | Use no carrier PWM, just simulate an **active low** receiver signal. Overrides `SEND_PWM_BY_TIMER` definition. |
354-
| `USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN` | Before `#include <IRremote.hpp>` | disabled | Use or simulate open drain output mode at send pin. **Attention, active state of open drain is LOW**, so connect the send LED between positive supply and send pin! |
355-
| `EXCLUDE_EXOTIC_PROTOCOLS` | Before `#include <IRremote.hpp>` | disabled | If activated, BOSEWAVE, WHYNTER and LEGO_PF are excluded in `decode()` and in sending with `IrSender.write()`. Saves up to 650 bytes program space. |
356-
| `EXCLUDE_UNIVERSAL_PROTOCOLS` | Before `#include <IRremote.hpp>` | disabled | If activated, the universal decoder for pulse width or pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in `decode()`. Saves up to 1000 bytes program space. |
357-
| `DECODE_<Protocol name>` | Before `#include <IRremote.hpp>` | all | Selection of individual protocol(s) to be decoded. You can specify multiple protocols. See [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.hpp#L98-L121) |
358-
| `MARK_EXCESS_MICROS` | Before `#include <IRremote.hpp>` | 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. |
359-
| `RECORD_GAP_MICROS` | Before `#include <IRremote.hpp>` | 5000 | Minimum gap between IR transmissions, to detect the end of a protocol.<br/>Must be greater than any space of a protocol e.g. the NEC header space of 4500 µs.<br/>Must be smaller than any gap between a command and a repeat; e.g. the retransmission gap for Sony is around 24 ms.<br/>Keep in mind, that this is the delay between the end of the received command and the start of decoding. |
360-
| `FEEDBACK_LED_IS_ACTIVE_LOW` | Before `#include <IRremote.hpp>` | disabled | Required on some boards (like my BluePill and my ESP8266 board), where the feedback LED is active low. |
361-
| `NO_LED_FEEDBACK_CODE` | Before `#include <IRremote.hpp>` | disabled | This completely disables the LED feedback code for send and receive, thus saving around 100 bytes program space for receiving, around 500 bytes for sending and halving the receiver ISR processing time. |
362-
| `IR_INPUT_IS_ACTIVE_HIGH` | Before `#include <IRremote.hpp>` | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
363-
| `IR_SEND_DUTY_CYCLE_PERCENT` | Before `#include <IRremote.hpp>` | 30 | Duty cycle of IR send signal. |
364-
| `MICROS_PER_TICK` | Before `#include <IRremote.hpp>` | 50 | Resolution of the raw input buffer data. Corresponds to 2 pulses of each 26.3 µs at 38 kHz. |
365-
| `DEBUG` | IRremoteInt.h | disabled | Enables lots of lovely debug output. |
366-
| `IR_USE_AVR_TIMER*` | private/IRTimer.hpp | | Selection of timer to be used for generating IR receiving sample interval. |
367-
|-|-|-|-|
368-
| `IR_INPUT_PIN` | Before `#include <TinyIRReceiver.hpp>` | 2 | The pin number for TinyIRReceiver IR input, which gets compiled in. |
369-
| `IR_FEEDBACK_LED_PIN` | Before `#include <TinyIRReceiver.hpp>` | `LED_BUILTIN` | The pin number for TinyIRReceiver feedback LED, which gets compiled in. |
370-
| `NO_LED_FEEDBACK_CODE` | Before `#include <TinyIRReceiver.hpp>` | disabled | Enable it to disable the feedback LED function. Saves 14 bytes program space. |
348+
| Name | Default value | Description |
349+
|-|-|-|
350+
| `RAW_BUFFER_LENGTH` | 100 | Buffer size of raw input buffer. Must be even! 100 is sufficient for *regular* protocols of up to 48 bits, but for most air conditioner protocols a value of up to 750 is required. Use the ReceiveDump example to find smallest value for your requirements. |
351+
| `IR_SEND_PIN` | disabled | If specified (as constant), reduces program size and improves send timing for AVR. If you want to use a runtime variable send pin e.g. with `setSendPin(uint8_t aSendPinNumber)` , you must disable this macro. |
352+
| `SEND_PWM_BY_TIMER` | disabled | Disable carrier PWM generation in software and use (restricted) hardware PWM. Enabled for ESP32 and RP2040 in all examples. |
353+
| `USE_NO_SEND_PWM` | disabled | Use no carrier PWM, just simulate an **active low** receiver signal. Overrides `SEND_PWM_BY_TIMER` definition. |
354+
| `USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN` | disabled | Use or simulate open drain output mode at send pin. **Attention, active state of open drain is LOW**, so connect the send LED between positive supply and send pin! |
355+
| `EXCLUDE_EXOTIC_PROTOCOLS` | disabled | If activated, BOSEWAVE, WHYNTER and LEGO_PF are excluded in `decode()` and in sending with `IrSender.write()`. Saves up to 650 bytes program space. |
356+
| `EXCLUDE_UNIVERSAL_PROTOCOLS` | disabled | If activated, the universal decoder for pulse width or pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in `decode()`. Saves up to 1000 bytes program space. |
357+
| `DECODE_<Protocol name>` | all | Selection of individual protocol(s) to be decoded. You can specify multiple protocols. See [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.hpp#L98-L121) |
358+
| `MARK_EXCESS_MICROS` | 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. |
359+
| `RECORD_GAP_MICROS` | 5000 | Minimum gap between IR transmissions, to detect the end of a protocol.<br/>Must be greater than any space of a protocol e.g. the NEC header space of 4500 µs.<br/>Must be smaller than any gap between a command and a repeat; e.g. the retransmission gap for Sony is around 24 ms.<br/>Keep in mind, that this is the delay between the end of the received command and the start of decoding. |
360+
| `FEEDBACK_LED_IS_ACTIVE_LOW` | disabled | Required on some boards (like my BluePill and my ESP8266 board), where the feedback LED is active low. |
361+
| `NO_LED_FEEDBACK_CODE` | disabled | This completely disables the LED feedback code for send and receive, thus saving around 100 bytes program space for receiving, around 500 bytes for sending and halving the receiver ISR processing time. |
362+
| `IR_INPUT_IS_ACTIVE_HIGH` | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
363+
| `IR_SEND_DUTY_CYCLE_PERCENT` | 30 | Duty cycle of IR send signal. |
364+
| `MICROS_PER_TICK` | 50 | Resolution of the raw input buffer data. Corresponds to 2 pulses of each 26.3 µs at 38 kHz. |
365+
| `DEBUG` | disabled | Enables lots of lovely debug output. |
366+
| `IR_USE_AVR_TIMER*` | | Selection of timer to be used for generating IR receiving sample interval. |
367+
368+
These next macros for **TinyIRReceiver** must be defined in your program before the line `#include <TinyIRReceiver.hpp>` to take effect.
369+
| Name | Default value | Description |
370+
|-|-|-|
371+
| `IR_INPUT_PIN` | 2 | The pin number for TinyIRReceiver IR input, which gets compiled in. |
372+
| `IR_FEEDBACK_LED_PIN` | `LED_BUILTIN` | The pin number for TinyIRReceiver feedback LED, which gets compiled in. |
373+
| `NO_LED_FEEDBACK_CODE` | disabled | Enable it to disable the feedback LED function. Saves 14 bytes program space. |
371374
372375
### Changing include (*.h) files with Arduino IDE
373376
First, use *Sketch > Show Sketch Folder (Ctrl+K)*.<br/>
@@ -497,8 +500,9 @@ Due to automatic gain control and other bias effects, high intensity of the 38 k
497500

498501
## Increase sending power
499502
**The best way to increase the IR power** is to use 2 or 3 IR diodes in series. One diode requires 1.1 to 1.5 volt so you can supply 3 diodes with a 5 volt output.<br/>
500-
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/>
501-
For 3 diodes it requires factor 2.5 e.g. from 150 ohm to 60 ohm.
503+
To keep the current for 2 diodes with 1.3 volt and 25 mA and a 5 volt supply, you must reduce the resistor by factor: (5V - 1.3V) / (5V - 2.6V) = 1.5 e.g. from 150 ohm to 100 ohm.<br/>
504+
For 3 diodes it requires factor 2.5 e.g. from 150 ohm to 60 ohm.<br/>
505+
Or compute it directly with the **U = R * I formula**. Here U is (5V - <number_of_diodes> * 1.3V) at moderate current, at higher currents you must choose more than 1.3 volt. If you want to be exact, you must check the datasheet of your diode for the appropriate **forward voltage fo a given current**.
502506

503507
# How we decode signals
504508
The IR signal is sampled at a **50 µs interval**. For a constant 525 µs pulse or pause we therefore get 10 or 11 samples, each with 50% probability.<br/>

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ The latest version may not be released!
33
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
44

55
## 3.5.3
6+
- Separated enable flag of send and receive feedback LED. Inspired by PR#970 from luvaihassanali.
67
- RP2040 support added.
78
- Refactored IRTimer.hpp.
89
- Refactored IR_SEND_PIN and IrSender.sendPin handling.

examples/IRDispatcherDemo/IRDispatcherDemo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Choose the library to be used for IR receiving
3131
*/
3232
#define USE_TINY_IR_RECEIVER // Recommended, but only for NEC protocol!!! If disabled and IRMP_INPUT_PIN is defined, the IRMP library is used for decoding
33-
//#define TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT // costs 112 bytes FLASH + 4bytes RAM
33+
//#define TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT // costs 112 bytes program space + 4 bytes RAM
3434

3535
#include "PinDefinitionsAndMore.h"
3636
// Some kind of auto detect library if USE_TINY_IR_RECEIVER is deactivated

examples/ReceiveDump/ReceiveDump.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void loop() {
108108
/*
109109
* Example for using the compensateAndStorePronto() function.
110110
* Creating this String requires 2210 bytes program memory and 10 bytes RAM for the String class.
111-
* The String object itself requires additional 440 Bytes RAM from the heap.
111+
* The String object itself requires additional 440 bytes RAM from the heap.
112112
* This values are for an Arduino UNO.
113113
*/
114114
// Serial.println(); // blank line between entries

examples/SendAndReceive/SendAndReceive.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void setup() {
7272
#if defined(IR_SEND_PIN)
7373
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
7474
#else
75-
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
75+
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
7676
#endif
7777

7878
Serial.print(F("Ready to receive IR signals of protocols: "));

examples/SendLGAirConditionerDemo/SendLGAirConditionerDemo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ delay(4000); // To be able to connect Serial monitor after reset or power up and
8383
#if defined(IR_SEND_PIN)
8484
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
8585
#else
86-
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
86+
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
8787
#endif
8888

8989
Serial.print(F("Ready to send IR signals at pin "));

examples/SendProntoDemo/SendProntoDemo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void setup() {
6565
#if defined(IR_SEND_PIN)
6666
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
6767
#else
68-
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
68+
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
6969
#endif
7070

7171
Serial.print(F("Ready to send IR signals at pin "));

examples/SendRawDemo/SendRawDemo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void setup() {
6262
#if defined(IR_SEND_PIN)
6363
IrSender.begin(); // Start with IR_SEND_PIN as send pin and enable feedback LED at default feedback LED pin
6464
#else
65-
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
65+
IrSender.begin(3, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
6666
#endif
6767

6868
Serial.print(F("Ready to send IR signals at pin "));

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ decodedIRData KEYWORD1
1919

2020
setFeedbackLED KEYWORD2
2121
enableLEDFeedback KEYWORD2
22+
enableLEDFeedbackForSend KEYWORD2
2223
disableLEDFeedback KEYWORD2
24+
disableLEDFeedbackForSend KEYWORD2
2325
printIRResultShort KEYWORD2
2426
begin KEYWORD2
2527
start KEYWORD2

0 commit comments

Comments
 (0)