Skip to content

Commit 2a0c6b3

Browse files
committed
Documentation
1 parent 9dcf45d commit 2a0c6b3

Some content is hidden

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

50 files changed

+74
-68
lines changed

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ Available as [Arduino library "IRremote"](https://www.arduinolibraries.info/libr
2727
- [Sending IR codes](https://github.com/Arduino-IRremote/Arduino-IRremote#sending-ir-codes)
2828
+ [List of public IR code databases](https://github.com/Arduino-IRremote/Arduino-IRremote#list-of-public-ir-code-databases)
2929
- [FAQ and hints](https://github.com/Arduino-IRremote/Arduino-IRremote#faq-and-hints)
30+
* [Problems with Neopixels, FastLed etc.](https://github.com/Arduino-IRremote/Arduino-IRremote#problems-with-neopixels-fastled-etc)
31+
* [Does not work/compile with another library](https://github.com/Arduino-IRremote/Arduino-IRremote#does-not-workcompile-with-another-library)
32+
* [Multiple IR receiver](https://github.com/Arduino-IRremote/Arduino-IRremote#multiple-ir-receiver)
33+
* [Increase strength of sent output signal](https://github.com/Arduino-IRremote/Arduino-IRremote#increase-strength-of-sent-output-signal)
34+
* [Minimal CPU frequency](https://github.com/Arduino-IRremote/Arduino-IRremote#minimal-cpu-frequency)
3035
- [Handling unknown Protocols](https://github.com/Arduino-IRremote/Arduino-IRremote#handling-unknown-protocols)
3136
* [Disclaimer](https://github.com/Arduino-IRremote/Arduino-IRremote#disclaimer)
3237
* [Protocol=PULSE_DISTANCE](https://github.com/Arduino-IRremote/Arduino-IRremote#protocolpulse_distance)
@@ -226,22 +231,31 @@ You will discover that **the address is a constant** and the commands sometimes
226231
http://www.harctoolbox.org/IR-resources.html
227232
228233
# FAQ and hints
229-
- IR does not work right when I use **Neopixels** (aka WS2811/WS2812/WS2812B) or other libraries blocking interrupts for a longer time (> 50 µs).<br/>
230-
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.
234+
235+
## Problems with Neopixels, FastLed etc.
236+
IR will not work right when you use **Neopixels** (aka WS2811/WS2812/WS2812B) or other libraries blocking interrupts for a longer time (> 50 µs).<br/>
237+
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.
231238
In turn, this stops the IR interrupt handler from running when it needs to.<br/>
232239
You can try to wait for the IR receiver to be idle before you send the Neopixel data with `if (IrReceiver.isIdle()) { strip.show();}`. This prevents at least breaking a running IR transmission and -depending of the update rate of the Neopixel- may work quite well.<br/>
233240
There are some other solutions to this on more powerful processors,
234-
[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)
235-
- **Another library** is only working if I deactivate the line `IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);`. Please see [below](https://github.com/Arduino-IRremote/Arduino-IRremote#timer-and-pin-usage).
236-
- You can use **multiple IR receiver** by just connecting the output pins of several IR receivers together.
237-
The IR receivers use an NPN transistor as output device with just a 30k resistor to VCC.
238-
This is almost "open collector" and allows connecting of several output pins to one Arduino input pin.
239-
- The **minimal CPU frequency** for receiving is 4 MHz, since the 50 µs timer ISR takes around 12 µs on a 16 MHz ATmega.
240-
- To **increase strength of sent output signal** you can increase the current through the send diode, and/or use 2 diodes in series,
241+
[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)
242+
243+
## Does not work/compile with another library
244+
**Another library** is only working if you deactivate the line `IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);`.
245+
This is often due to resource conflicts with the other library. Please see [below](https://github.com/Arduino-IRremote/Arduino-IRremote#timer-and-pin-usage).
246+
247+
## Multiple IR receiver
248+
You can use **multiple IR receiver** by just connecting the output pins of several IR receivers together.
249+
The IR receivers use an NPN transistor as output device with just a 30k resistor to VCC.
250+
This is almost "open collector" and allows connecting of several output pins to one Arduino input pin.
251+
252+
## Increase strength of sent output signal
253+
To **increase strength of sent output signal** you can increase the current through the send diode, and/or use 2 diodes in series,
241254
since one IR diode requires only 1.5 volt.
242-
- The line \#include "ATtinySerialOut.h" in PinDefinitionsAndMore.h (requires the library to be installed) saves 370 bytes program memory and 38 bytes RAM for **Digispark boards** as well as enables serial output at 8MHz.
243-
- The default software generated PWM has **problems on AVR 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`.
244255
256+
## Minimal CPU frequency
257+
For receiving, the **minimal CPU frequency is 4 MHz**, since the 50 µs timer ISR takes around 12 µs on a 16 MHz ATmega.<br/>
258+
For sending, the **default software generated PWM has problems on AVR 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`.
245259
246260
# Handling unknown Protocols
247261
## Disclaimer
@@ -290,7 +304,7 @@ In order to fit the examples to the 8K flash of ATtiny85 and ATtiny88, the [Ardu
290304
This examples are a good starting point.
291305
292306
### ReceiveDemo
293-
Receives all protocols and play a beep on each packet received. By connecting pin 5 to ground, you can see the raw values for each packet.
307+
Receives all protocols and **generates a beep with the Arduino tone() function** on each packet received. By connecting pin 5 to ground, you can see the raw values for each packet. **Example how to use IRremote and tone() together**.
294308
295309
### ReceiveDump
296310
Receives all protocols and dumps the received signal in different flavors. Since the printing takes so much time, repeat signals may be skipped or interpreted as UNKNOWN.

examples/ControlRelay/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void noTone(uint8_t _pin){
236236
#define Serial SerialUSB
237237

238238
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
239-
// Attention!!! D2 and D4 are switched on these boards!!!
239+
// Attention!!! D2 and D4 are swapped on these boards!!!
240240
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
241241
//#undef LED_BUILTIN
242242
//#define LED_BUILTIN 24 // PB11

examples/IRDispatcherDemo/IRCommandDispatcher.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct IRDataForCommandDispatcherStruct {
5656
uint16_t address; // to distinguish between multiple senders
5757
uint16_t command;
5858
bool isRepeat;
59-
uint32_t MillisOfLastCode; // millis() of last IR command received - for timeouts etc.
59+
uint32_t MillisOfLastCode; // millis() of last IR command -including repeats!- received - for timeouts etc.
6060
volatile bool isAvailable; // flag for a polling interpreting function, that a new command has arrived.
6161
};
6262

@@ -75,7 +75,7 @@ class IRCommandDispatcher {
7575
void init();
7676

7777
bool checkAndRunNonBlockingCommands();
78-
void checkAndRunSuspendedBlockingCommands();
78+
bool checkAndRunSuspendedBlockingCommands();
7979
bool delayAndCheckForStop(uint16_t aDelayMillis);
8080

8181
// The main dispatcher function
@@ -90,6 +90,7 @@ class IRCommandDispatcher {
9090
uint8_t BlockingCommandToRunNext = COMMAND_INVALID; // Storage for command currently suspended to allow the current command to end, before it is called by main loop
9191
/*
9292
* Flag for running blocking commands to terminate. To check, you can use "if (requestToStopReceived) return;" (available as macro RETURN_IF_STOP).
93+
* Is reset by next IR command received. Can be reset by main loop, if command has stopped.
9394
*/
9495
volatile bool requestToStopReceived;
9596
/*

examples/IRDispatcherDemo/IRCommandDispatcher.hpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@
3838

3939
#include "IRCommandDispatcher.h"
4040

41-
//#define INFO // activate this out to see serial info output
42-
//#define DEBUG // activate this out to see serial info output
43-
#if defined(DEBUG) && !defined(INFO)
44-
// Propagate level
45-
#define INFO
41+
/*
42+
* Enable this to see information on each call.
43+
* Since there should be no library which uses Serial, it should only be enabled for development purposes.
44+
*/
45+
#if defined(INFO)
46+
#define LOCAL_INFO
47+
#else
48+
//#define LOCAL_INFO // This enables info output only for this file
49+
#endif
50+
#if defined(DEBUG)
51+
#define LOCAL_DEBUG
52+
// Propagate debug level
53+
#define LOCAL_INFO
54+
#else
55+
//#define LOCAL_DEBUG // This enables debug output only for this file
4656
#endif
4757

4858
IRCommandDispatcher IRDispatcher;
@@ -277,10 +287,11 @@ bool IRCommandDispatcher::delayAndCheckForStop(uint16_t aDelayMillis) {
277287

278288
/*
279289
* Intended to be called from main loop
290+
* @return true, if command was called
280291
*/
281-
void IRCommandDispatcher::checkAndRunSuspendedBlockingCommands() {
292+
bool IRCommandDispatcher::checkAndRunSuspendedBlockingCommands() {
282293
/*
283-
* search IR code or take last rejected command and call associated function
294+
* Take last rejected command and call associated function
284295
*/
285296
if (BlockingCommandToRunNext != COMMAND_INVALID) {
286297

@@ -291,7 +302,9 @@ void IRCommandDispatcher::checkAndRunSuspendedBlockingCommands() {
291302
BlockingCommandToRunNext = COMMAND_INVALID;
292303
IRReceivedData.isRepeat = false;
293304
checkAndCallCommand(true);
305+
return true;
294306
}
307+
return false;
295308
}
296309

297310
void IRCommandDispatcher::printIRCommandString(Print *aSerial) {
@@ -309,5 +322,10 @@ void IRCommandDispatcher::setRequestToStopReceived() {
309322
requestToStopReceived = true;
310323
}
311324

325+
#if defined(LOCAL_DEBUG)
326+
#undef LOCAL_DEBUG
327+
#endif
328+
#if defined(LOCAL_INFO)
329+
#undef LOCAL_INFO
330+
#endif
312331
#endif // _IR_COMMAND_DISPATCHER_HPP
313-
#pragma once

examples/IRDispatcherDemo/IRCommandMapping.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,3 @@ const struct IRToCommandMappingStruct IRMapping[] =
192192
{ COMMAND_DECREASE_BLINK, IR_COMMAND_FLAG_REPEATABLE_NON_BLOCKING, &doDecreaseBlinkFrequency, decreaseBlink } };
193193

194194
#endif / _IR_COMMAND_MAPPING_H
195-
#pragma once

examples/IRDispatcherDemo/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void noTone(uint8_t _pin){
236236
#define Serial SerialUSB
237237

238238
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
239-
// Attention!!! D2 and D4 are switched on these boards!!!
239+
// Attention!!! D2 and D4 are swapped on these boards!!!
240240
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
241241
//#undef LED_BUILTIN
242242
//#define LED_BUILTIN 24 // PB11

examples/IRremoteExtensionTest/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void noTone(uint8_t _pin){
236236
#define Serial SerialUSB
237237

238238
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
239-
// Attention!!! D2 and D4 are switched on these boards!!!
239+
// Attention!!! D2 and D4 are swapped on these boards!!!
240240
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
241241
//#undef LED_BUILTIN
242242
//#define LED_BUILTIN 24 // PB11

examples/MicroGirs/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void noTone(uint8_t _pin){
236236
#define Serial SerialUSB
237237

238238
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
239-
// Attention!!! D2 and D4 are switched on these boards!!!
239+
// Attention!!! D2 and D4 are swapped on these boards!!!
240240
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
241241
//#undef LED_BUILTIN
242242
//#define LED_BUILTIN 24 // PB11

examples/ReceiveAndSend/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void noTone(uint8_t _pin){
236236
#define Serial SerialUSB
237237

238238
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
239-
// Attention!!! D2 and D4 are switched on these boards!!!
239+
// Attention!!! D2 and D4 are swapped on these boards!!!
240240
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
241241
//#undef LED_BUILTIN
242242
//#define LED_BUILTIN 24 // PB11

examples/ReceiveDemo/PinDefinitionsAndMore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void noTone(uint8_t _pin){
236236
#define Serial SerialUSB
237237

238238
// Definitions for the Chinese SAMD21 M0-Mini clone, which has no led connected to D13/PA17.
239-
// Attention!!! D2 and D4 are switched on these boards!!!
239+
// Attention!!! D2 and D4 are swapped on these boards!!!
240240
// If you connect the LED, it is on pin 24/PB11. In this case activate the next two lines.
241241
//#undef LED_BUILTIN
242242
//#define LED_BUILTIN 24 // PB11

0 commit comments

Comments
 (0)