Skip to content

Commit c64b1c5

Browse files
committed
Documentation for adding new protocol
1 parent 56c6e66 commit c64b1c5

39 files changed

+200
-229
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ There are some other solutions to this on more powerful processors,
236236
- The **minimal CPU frequency** for receiving is 4 MHz, since the 50 µs timer ISR takes around 12 µs on a 16 MHz ATmega.
237237
- To **increase strength of sent output signal** you can increase the current through the send diode, and/or use 2 diodes in series,
238238
since one IR diode requires only 1.5 volt.
239-
- 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.
239+
- 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.
240240
- 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`.
241241
242242
@@ -274,7 +274,7 @@ If you do not know which protocol your IR transmitter uses, you have several cho
274274
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).
275275
- The [IRMP AllProtocol example](https://github.com/ukw100/IRMP#allprotocol-example) prints the protocol and data for one of the **40 supported protocols**.
276276
The same library can be used to send this codes.
277-
- If you have a bigger Arduino board at hand (> 100 kByte program space) you can try the
277+
- If you have a bigger Arduino board at hand (> 100 kByte program memory) you can try the
278278
[IRremoteDecode example](https://github.com/bengtmartensson/Arduino-DecodeIR/blob/master/examples/IRremoteDecode/IRremoteDecode.ino) of the Arduino library [DecodeIR](https://github.com/bengtmartensson/Arduino-DecodeIR).
279279
- Use [IrScrutinizer](http://www.harctoolbox.org/IrScrutinizer.html).
280280
It can automatically generate a send sketch for your protocol by exporting as "Arduino Raw". It supports IRremote,
@@ -352,13 +352,13 @@ Modify them by enabling / disabling them, or change the values if applicable.
352352
| `SEND_PWM_BY_TIMER` | disabled | Disable carrier PWM generation in software and use (restricted) hardware PWM. Enabled for ESP32 and RP2040 in all examples. |
353353
| `USE_NO_SEND_PWM` | disabled | Use no carrier PWM, just simulate an **active low** receiver signal. Overrides `SEND_PWM_BY_TIMER` definition. |
354354
| `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. |
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 memory. |
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 memory. |
357357
| `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) |
358358
| `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. |
359359
| `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. |
360360
| `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. |
361+
| `NO_LED_FEEDBACK_CODE` | disabled | This completely disables the LED feedback code for send and receive, thus saving around 100 bytes program memory for receiving, around 500 bytes for sending and halving the receiver ISR processing time. |
362362
| `IR_INPUT_IS_ACTIVE_HIGH` | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
363363
| `IR_SEND_DUTY_CYCLE_PERCENT` | 30 | Duty cycle of IR send signal. |
364364
| `MICROS_PER_TICK` | 50 | Resolution of the raw input buffer data. Corresponds to 2 pulses of each 26.3 µs at 38 kHz. |
@@ -371,7 +371,7 @@ These next macros for **TinyIRReceiver** must be defined in your program before
371371
|-|-|-|
372372
| `IR_INPUT_PIN` | 2 | The pin number for TinyIRReceiver IR input, which gets compiled in. |
373373
| `IR_FEEDBACK_LED_PIN` | `LED_BUILTIN` | The pin number for TinyIRReceiver feedback LED, which gets compiled in. |
374-
| `NO_LED_FEEDBACK_CODE` | disabled | Enable it to disable the feedback LED function. Saves 14 bytes program space. |
374+
| `NO_LED_FEEDBACK_CODE` | disabled | Enable it to disable the feedback LED function. Saves 14 bytes program memory. |
375375
376376
### Changing include (*.h) files with Arduino IDE
377377
First, use *Sketch > Show Sketch Folder (Ctrl+K)*.<br/>

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22
The latest version may not be released!
33
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
4+
## 3.6.2
5+
- Changed TOLERANCE to TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING and documented it.
46

57
## 3.6.1
68
- Switched Bose internal protocol timing for 0 and 1 -> old 1 timing is now 0 and vice versa.

examples/IRDispatcherDemo/IRCommandDispatcher.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* You should have received a copy of the GNU General Public License
3232
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
3333
*/
34-
#ifndef IR_COMMAND_DISPATCHER_HPP
35-
#define IR_COMMAND_DISPATCHER_HPP
34+
#ifndef _IR_COMMAND_DISPATCHER_HPP
35+
#define _IR_COMMAND_DISPATCHER_HPP
3636

3737
#include <Arduino.h>
3838

@@ -139,7 +139,7 @@ void handleReceivedIRData()
139139

140140
if (IRDispatcher.IRReceivedData.address == IR_ADDRESS) {
141141
IRDispatcher.checkAndCallCommand(true);
142-
#ifdef INFO
142+
#if defined(INFO)
143143
} else {
144144
CD_INFO_PRINT(F("Wrong address. Expected 0x"));
145145
CD_INFO_PRINTLN(IR_ADDRESS, HEX);
@@ -165,14 +165,14 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallAlsoBlockingCommands) {
165165
/*
166166
* Command found
167167
*/
168-
#ifdef INFO
168+
#if defined(INFO)
169169
const __FlashStringHelper *tCommandName = reinterpret_cast<const __FlashStringHelper*>(IRMapping[i].CommandString);
170170
#endif
171171
/*
172172
* Check for repeat and if it is allowed for the current command
173173
*/
174174
if (IRReceivedData.isRepeat && !(IRMapping[i].Flags & IR_COMMAND_FLAG_REPEATABLE)) {
175-
#ifdef DEBUG
175+
#if defined(DEBUG)
176176
Serial.print(F("Repeats of command \""));
177177
Serial.print(tCommandName);
178178
Serial.println("\" not accepted");
@@ -184,7 +184,7 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallAlsoBlockingCommands) {
184184
* Do not accept recursive call of the same command
185185
*/
186186
if (currentBlockingCommandCalled == IRReceivedData.command) {
187-
#ifdef DEBUG
187+
#if defined(DEBUG)
188188
Serial.print(F("Recursive command \""));
189189
Serial.print(tCommandName);
190190
Serial.println("\" not accepted");
@@ -246,7 +246,7 @@ void IRCommandDispatcher::checkAndCallCommand(bool aCallAlsoBlockingCommands) {
246246
CD_INFO_PRINTLN (tCommandName);
247247

248248
IRMapping[i].CommandToCall();
249-
#ifdef TRACE
249+
#if defined(TRACE)
250250
Serial.println(F("End of blocking command"));
251251
#endif
252252
executingBlockingCommand = false;
@@ -309,5 +309,5 @@ void IRCommandDispatcher::setRequestToStopReceived() {
309309
requestToStopReceived = true;
310310
}
311311

312-
#endif // #ifndef IR_COMMAND_DISPATCHER_HPP
312+
#endif // _IR_COMMAND_DISPATCHER_HPP
313313
#pragma once

examples/IRDispatcherDemo/IRDispatcherDemo.ino

Lines changed: 9 additions & 7 deletions
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 program space + 4 bytes RAM
33+
//#define TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT // costs 112 bytes program memory + 4 bytes RAM
3434

3535
#include "PinDefinitionsAndMore.h"
3636
// Some kind of auto detect library if USE_TINY_IR_RECEIVER is deactivated
@@ -57,20 +57,22 @@
5757
#endif
5858

5959
#elif defined(USE_IRMP_LIBRARY)
60-
#define IRMP_USE_COMPLETE_CALLBACK 1 // Enable callback functionality is required if IRMP library is used
61-
60+
/*
61+
* IRMP version
62+
*/
63+
#define IRMP_USE_COMPLETE_CALLBACK 1 // Enable callback functionality. It is required if IRMP library is used.
6264
#if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN)
6365
#define FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN
6466
#endif
6567

66-
//#define IRMP_ENABLE_PIN_CHANGE_INTERRUPT // Enable interrupt functionality (not for all protocols) - requires around 376 additional bytes of program space
68+
//#define IRMP_ENABLE_PIN_CHANGE_INTERRUPT // Enable interrupt functionality (not for all protocols) - requires around 376 additional bytes of program memory
6769

68-
#define IRMP_PROTOCOL_NAMES 1 // Enable protocol number mapping to protocol strings - requires some program space. Must before #include <irmp*>
70+
#define IRMP_PROTOCOL_NAMES 1 // Enable protocol number mapping to protocol strings - requires some program memory. Must before #include <irmp*>
6971

7072
#define IRMP_SUPPORT_NEC_PROTOCOL 1 // this enables only one protocol
7173
//#define IRMP_SUPPORT_KASEIKYO_PROTOCOL 1
7274

73-
# ifdef ALTERNATIVE_IR_FEEDBACK_LED_PIN
75+
# if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN)
7476
#define IRMP_FEEDBACK_LED_PIN ALTERNATIVE_IR_FEEDBACK_LED_PIN
7577
# endif
7678
/*
@@ -150,7 +152,7 @@ void setup() {
150152
Serial.println(F("at pin " STR(IRMP_INPUT_PIN)));
151153
# endif
152154

153-
# ifdef ALTERNATIVE_IR_FEEDBACK_LED_PIN
155+
# if defined(ALTERNATIVE_IR_FEEDBACK_LED_PIN)
154156
irmp_irsnd_LEDFeedback(true); // Enable receive signal feedback at ALTERNATIVE_IR_FEEDBACK_LED_PIN
155157
Serial.println(F("IR feedback pin is " STR(ALTERNATIVE_IR_FEEDBACK_LED_PIN)));
156158
# endif

examples/IRremoteInfo/IRremoteInfo.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,35 @@ void dumpRAW_BUFFER_LENGTH() {
6161

6262
void dumpTIMER() {
6363
bool flag = false;
64-
#ifdef IR_USE_TIMER1
64+
#if defined(IR_USE_TIMER1)
6565
Serial.print(F("Timer defined for use: "));
6666
Serial.println(F("Timer1"));
6767
flag = true;
6868
#endif
69-
#ifdef IR_USE_TIMER2
69+
#if defined(IR_USE_TIMER2)
7070
Serial.print(F("Timer defined for use: "));
7171
Serial.println(F("Timer2"));
7272
flag = true;
7373
#endif
74-
#ifdef IR_USE_TIMER3
74+
#if defined(IR_USE_TIMER3)
7575
Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer3")); flag = true;
7676
#endif
77-
#ifdef IR_USE_TIMER4
77+
#if defined(IR_USE_TIMER4)
7878
Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer4")); flag = true;
7979
#endif
80-
#ifdef IR_USE_TIMER5
80+
#if defined(IR_USE_TIMER5)
8181
Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer5")); flag = true;
8282
#endif
83-
#ifdef IR_USE_TIMER4_HS
83+
#if defined(IR_USE_TIMER4_HS)
8484
Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer4_HS")); flag = true;
8585
#endif
86-
#ifdef IR_USE_TIMER_CMT
86+
#if defined(IR_USE_TIMER_CMT)
8787
Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_CMT")); flag = true;
8888
#endif
89-
#ifdef IR_USE_TIMER_TPM1
89+
#if defined(IR_USE_TIMER_TPM1)
9090
Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_TPM1")); flag = true;
9191
#endif
92-
#ifdef IR_USE_TIMER_TINY0
92+
#if defined(IR_USE_TIMER_TINY0)
9393
Serial.print(F("Timer defined for use: ")); Serial.println(F("Timer_TINY0")); flag = true;
9494
#endif
9595

@@ -289,7 +289,7 @@ void dumpProtocols() {
289289
Serial.println(F("Disabled"));
290290
#endif
291291

292-
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS) // saves around 2000 bytes program space
292+
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS) // saves around 2000 bytes program memory
293293

294294
Serial.print(F("BOSEWAVE: "));
295295
#if defined(DECODE_BOSEWAVE)

examples/ReceiveAndSend/ReceiveAndSend.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
*/
5050
#include "PinDefinitionsAndMore.h"
5151

52-
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 900 bytes program space
52+
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 900 bytes program memory
5353

5454
#include <IRremote.hpp>
5555

examples/ReceiveDump/ReceiveDump.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,17 @@ void setup() {
7272
Serial.print(F("Ready to receive IR signals of protocols: "));
7373
printActiveIRProtocols(&Serial);
7474
Serial.print(F("at pin "));
75+
#if defined(ARDUINO_ARCH_STM32) || defined(ESP8266)
76+
Serial.println(IR_RECEIVE_PIN_STRING);
77+
#else
7578
Serial.println(IR_RECEIVE_PIN);
79+
#endif
80+
81+
// infos for receive
82+
Serial.print(RECORD_GAP_MICROS);
83+
Serial.println(F(" us is the (minimum) gap, after which the start of a new IR packet is assumed"));
84+
Serial.print(MARK_EXCESS_MICROS);
85+
Serial.println(F(" us are subtracted from all marks and added to all spaces for decoding"));
7686
}
7787

7888
//+=============================================================================

examples/ReceiveOneAndSendMultiple/ReceiveOneAndSendMultiple.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void sendSamsungSmartHubMacro(bool aDoSelect) {
160160
IrReceiver.stop(); // ESP32 uses another timer for tone()
161161
# endif
162162
if (millis() < tWaitTimeAfterBoot) {
163-
// division by 1000 and printing requires much (8%) program space
163+
// division by 1000 and printing requires much (8%) program memory
164164
Serial.print(F("It is "));
165165
Serial.print(millis() / 1000);
166166
Serial.print(F(" seconds after boot, Samsung H5273 TV requires "));

examples/SendAndReceive/SendAndReceive.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
*/
4242
#include "PinDefinitionsAndMore.h"
4343

44-
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program space.
44+
//#define EXCLUDE_UNIVERSAL_PROTOCOLS // Saves up to 1000 bytes program memory.
4545
//#define EXCLUDE_EXOTIC_PROTOCOLS
4646
//#define SEND_PWM_BY_TIMER
4747
//#define USE_NO_SEND_PWM
48-
//#define NO_LED_FEEDBACK_CODE // saves 500 bytes program space
48+
//#define NO_LED_FEEDBACK_CODE // saves 500 bytes program memory
4949
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
5050
#define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
5151

examples/SendDemo/SendDemo.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
*/
3838
#include "PinDefinitionsAndMore.h"
3939

40-
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 240 bytes program space if IrSender.write is used
40+
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 240 bytes program memory if IrSender.write is used
4141
//#define SEND_PWM_BY_TIMER
4242
//#define USE_NO_SEND_PWM
43-
//#define NO_LED_FEEDBACK_CODE // saves 566 bytes program space
43+
//#define NO_LED_FEEDBACK_CODE // saves 566 bytes program memory
4444

4545
#include <IRremote.hpp>
4646

@@ -124,7 +124,7 @@ void loop() {
124124
delay(DELAY_AFTER_SEND);
125125

126126
if (sRepeats == 0) {
127-
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program space of ATtiny85 etc.
127+
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
128128
/*
129129
* Send constant values only once in this demo
130130
*/
@@ -242,7 +242,7 @@ void loop() {
242242
IrSender.sendRC6(sAddress, sCommand, sRepeats, true);
243243
delay(DELAY_AFTER_SEND);
244244

245-
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program space of ATtiny85 etc.
245+
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
246246
/*
247247
* Next example how to use the IrSender.write function
248248
*/

0 commit comments

Comments
 (0)