IRremote
IRremote.hpp
Go to the documentation of this file.
1 
43 /*
44  * This library can be configured at compile time by the following options / macros:
45  * For more details see: https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
46  *
47  * - RAW_BUFFER_LENGTH Buffer size of raw input buffer. Must be even! 100 is sufficient for *regular* protocols of up to 48 bits.
48  * - IR_SEND_PIN If specified (as constant), reduces program size and improves send timing for AVR.
49  * - SEND_PWM_BY_TIMER Disable carrier PWM generation in software and use (restricted) hardware PWM.
50  * - USE_NO_SEND_PWM Use no carrier PWM, just simulate an **active low** receiver signal. Overrides SEND_PWM_BY_TIMER definition.
51  * - USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN 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!
52  * - EXCLUDE_EXOTIC_PROTOCOLS If activated, BANG_OLUFSEN, BOSEWAVE, WHYNTER, FAST and LEGO_PF are excluded in decode() and in sending with IrSender.write().
53  * - EXCLUDE_UNIVERSAL_PROTOCOLS If activated, the universal decoder for pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in decode().
54  * - DECODE_* Selection of individual protocols to be decoded. See below.
55  * - MARK_EXCESS_MICROS Value is subtracted from all marks and added to all spaces before decoding, to compensate for the signal forming of different IR receiver modules.
56  * - RECORD_GAP_MICROS Minimum gap between IR transmissions, to detect the end of a protocol.
57  * - FEEDBACK_LED_IS_ACTIVE_LOW Required on some boards (like my BluePill and my ESP8266 board), where the feedback LED is active low.
58  * - NO_LED_FEEDBACK_CODE This completely disables the LED feedback code for send and receive.
59  * - IR_INPUT_IS_ACTIVE_HIGH Enable it if you use a RF receiver, which has an active HIGH output signal.
60  * - IR_SEND_DUTY_CYCLE_PERCENT Duty cycle of IR send signal.
61  * - MICROS_PER_TICK Resolution of the raw input buffer data. Corresponds to 2 pulses of each 26.3 us at 38 kHz.
62  * - IR_USE_AVR_TIMER* Selection of timer to be used for generating IR receiving sample interval.
63  */
64 
65 #ifndef _IR_REMOTE_HPP
66 #define _IR_REMOTE_HPP
67 
68 #include "IRVersion.h"
69 
70 // activate it for all cores that does not use the -flto flag, if you get false error messages regarding begin() during compilation.
71 //#define SUPPRESS_ERROR_MESSAGE_FOR_BEGIN
72 
73 /*
74  * If activated, BANG_OLUFSEN, BOSEWAVE, MAGIQUEST, WHYNTER, FAST and LEGO_PF are excluded in decoding and in sending with IrSender.write
75  */
76 //#define EXCLUDE_EXOTIC_PROTOCOLS
77 /****************************************************
78  * PROTOCOLS
79  ****************************************************/
80 /*
81  * Supported IR protocols
82  * Each protocol you include costs memory and, during decode, costs time
83  * Copy the lines with the protocols you need in your program before the #include <IRremote.hpp> line
84  * See also SimpleReceiver example
85  */
86 
87 #if !defined(NO_DECODER) // for sending raw only
88 # if (!(defined(DECODE_DENON) || defined(DECODE_JVC) || defined(DECODE_KASEIKYO) \
89 || defined(DECODE_PANASONIC) || defined(DECODE_LG) || defined(DECODE_NEC) || defined(DECODE_ONKYO) || defined(DECODE_SAMSUNG) \
90 || defined(DECODE_SONY) || defined(DECODE_RC5) || defined(DECODE_RC6) \
91 || defined(DECODE_DISTANCE_WIDTH) || defined(DECODE_HASH) || defined(DECODE_BOSEWAVE) \
92 || defined(DECODE_LEGO_PF) || defined(DECODE_MAGIQUEST) || defined(DECODE_FAST) || defined(DECODE_WHYNTER)))
93 /*
94  * If no protocol is explicitly enabled, we enable all protocols
95  */
96 #define DECODE_DENON // Includes Sharp
97 #define DECODE_JVC
98 #define DECODE_KASEIKYO
99 #define DECODE_PANASONIC // alias for DECODE_KASEIKYO
100 #define DECODE_LG
101 #define DECODE_NEC // Includes Apple and Onkyo
102 #define DECODE_SAMSUNG
103 #define DECODE_SONY
104 #define DECODE_RC5
105 #define DECODE_RC6
106 
107 # if !defined(EXCLUDE_EXOTIC_PROTOCOLS) // saves around 2000 bytes program memory
108 #define DECODE_BOSEWAVE
109 #define DECODE_LEGO_PF
110 #define DECODE_MAGIQUEST // It modifies the RAW_BUFFER_LENGTH from 100 to 112
111 #define DECODE_WHYNTER
112 #define DECODE_FAST
113 # endif
114 
115 # if !defined(EXCLUDE_UNIVERSAL_PROTOCOLS)
116 #define DECODE_DISTANCE_WIDTH // universal decoder for pulse distance width protocols - requires up to 750 bytes additional program memory
117 #define DECODE_HASH // special decoder for all protocols - requires up to 250 bytes additional program memory
118 # endif
119 # endif
120 #endif // !defined(NO_DECODER)
121 
122 //#define DECODE_BEO // Bang & Olufsen protocol always must be enabled explicitly. It prevents decoding of SONY!
123 
124 #if defined(DECODE_NEC) && !(~(~DECODE_NEC + 0) == 0 && ~(~DECODE_NEC + 1) == 1)
125 #warning "The macros DECODE_XXX no longer require a value. Decoding is now switched by defining / non defining the macro."
126 #endif
127 
128 //#define DEBUG // Activate this for lots of lovely debug output from the IRremote core.
129 
130 /****************************************************
131  * RECEIVING
132  ****************************************************/
148 #if !defined(MARK_EXCESS_MICROS)
149 // To change this value, you simply can add a line #define "MARK_EXCESS_MICROS <My_new_value>" in your ino file before the line "#include <IRremote.hpp>"
150 #define MARK_EXCESS_MICROS 20
151 #endif
152 
159 #if !defined(RECORD_GAP_MICROS)
160 // To change this value, you simply can add a line #define "RECORD_GAP_MICROS <My_new_value>" in your ino file before the line "#include <IRremote.hpp>"
161 #define RECORD_GAP_MICROS 8000 // RECS80 (https://www.mikrocontroller.net/articles/IRMP#RECS80) 1 bit space is 7500µs , NEC header space is 4500
162 #endif
163 
166 #if !defined(RECORD_GAP_MICROS_WARNING_THRESHOLD)
167 // To change this value, you simply can add a line #define "RECORD_GAP_MICROS_WARNING_THRESHOLD <My_new_value>" in your ino file before the line "#include <IRremote.hpp>"
168 #define RECORD_GAP_MICROS_WARNING_THRESHOLD 15000
169 #endif
170 
172 #define RECORD_GAP_TICKS (RECORD_GAP_MICROS / MICROS_PER_TICK) // 100
173 
174 /*
175  * Activate this line if your receiver has an external output driver transistor / "inverted" output
176  */
177 //#define IR_INPUT_IS_ACTIVE_HIGH
178 #if defined(IR_INPUT_IS_ACTIVE_HIGH)
179 // IR detector output is active high
180 #define INPUT_MARK 1
181 #else
182 // IR detector output is active low
183 #define INPUT_MARK 0
184 #endif
185 /****************************************************
186  * SENDING
187  ****************************************************/
191 //#define SEND_PWM_BY_TIMER // restricts send pin on many platforms to fixed pin numbers
192 #if (defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(PARTICLE)) || defined(ARDUINO_ARCH_MBED)
193 # if !defined(SEND_PWM_BY_TIMER)
194 #define SEND_PWM_BY_TIMER // the best and default method for ESP32 etc.
195 #warning INFO: For ESP32, RP2040, mbed and particle boards SEND_PWM_BY_TIMER is enabled by default, since we have the resources and timing is more exact than the software generated one. If this is not intended, deactivate the line in IRremote.hpp over this warning message in file IRremote.hpp.
196 # endif
197 #else
198 # if defined(SEND_PWM_BY_TIMER)
199 # if defined(IR_SEND_PIN)
200 #undef IR_SEND_PIN // to avoid warning 3 lines later
201 #warning Since SEND_PWM_BY_TIMER is defined, the existing value of IR_SEND_PIN is discarded and replaced by the value determined by timer used for PWM generation
202 # endif
203 #define IR_SEND_PIN DeterminedByTimer // must be set here, since it is evaluated at IRremoteInt.h, before the include of private/IRTimer.hpp
204 # endif
205 #endif
206 
210 //#define USE_NO_SEND_PWM
211 #if defined(SEND_PWM_BY_TIMER) && defined(USE_NO_SEND_PWM)
212 #warning "SEND_PWM_BY_TIMER and USE_NO_SEND_PWM are both defined -> undefine SEND_PWM_BY_TIMER now!"
213 #undef SEND_PWM_BY_TIMER // USE_NO_SEND_PWM overrides SEND_PWM_BY_TIMER
214 #endif
215 
220 //#define USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN
221 #if defined(USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN) && !defined(OUTPUT_OPEN_DRAIN)
222 #warning Pin mode OUTPUT_OPEN_DRAIN is not supported on this platform -> mimick open drain mode by switching between INPUT and OUTPUT mode.
223 #endif
224 
229 #if !defined(PULSE_CORRECTION_NANOS)
230 # if defined(F_CPU)
231 // To change this value, you simply can add a line #define "PULSE_CORRECTION_NANOS <My_new_value>" in your ino file before the line "#include <IRremote.hpp>"
232 #define PULSE_CORRECTION_NANOS (48000L / (F_CPU/MICROS_IN_ONE_SECOND)) // 3000 @16MHz, 666 @72MHz
233 # else
234 #define PULSE_CORRECTION_NANOS 600
235 # endif
236 #endif
237 
241 #if ! defined(IR_SEND_DUTY_CYCLE_PERCENT)
242 #define IR_SEND_DUTY_CYCLE_PERCENT 30 // 30 saves power and is compatible to the old existing code
243 #endif
244 
248 #if ! defined(MICROS_PER_TICK)
249 #define MICROS_PER_TICK 50L // must be with L to get 32 bit results if multiplied with rawbuf[] content.
250 #endif
251 
252 #define MILLIS_IN_ONE_SECOND 1000L
253 #define MICROS_IN_ONE_SECOND 1000000L
254 #define MICROS_IN_ONE_MILLI 1000L
255 
256 #include "IRremoteInt.h"
257 /*
258  * We always use digitalWriteFast() and digitalReadFast() functions to have a consistent mapping for pins.
259  * For most non AVR cpu's, it is just a mapping to digitalWrite() and digitalRead() functions.
260  */
261 #include "digitalWriteFast.h"
262 
263 #if !defined(USE_IRREMOTE_HPP_AS_PLAIN_INCLUDE)
264 #include "private/IRTimer.hpp" // defines IR_SEND_PIN for AVR and SEND_PWM_BY_TIMER
265 
266 # if !defined(NO_LED_FEEDBACK_CODE)
267 # if !defined(LED_BUILTIN)
268 /*
269  * print a warning
270  */
271 #warning INFO: No definition for LED_BUILTIN found -> default LED feedback is disabled.
272 # endif
273 #include "IRFeedbackLED.hpp"
274 # else
275 void disableLEDFeedback() {}; // dummy function for examples
276 # endif
277 
278 #include "LongUnion.h" // used in most decoders
279 
280 /*
281  * Include the sources here to enable compilation with macro values set by user program.
282  */
283 #include "IRProtocol.hpp" // must be first, it includes definition for PrintULL (unsigned long long)
284 #if !defined(DISABLE_CODE_FOR_RECEIVER)
285 #include "IRReceive.hpp"
286 #endif
287 #include "IRSend.hpp"
288 
289 /*
290  * Include the sources of all decoders here to enable compilation with macro values set by user program.
291  */
292 #include "ir_BangOlufsen.hpp"
293 #include "ir_BoseWave.hpp"
294 #include "ir_Denon.hpp"
295 #include "ir_JVC.hpp"
296 #include "ir_Kaseikyo.hpp"
297 #include "ir_Lego.hpp"
298 #include "ir_LG.hpp"
299 #include "ir_MagiQuest.hpp"
300 #include "ir_NEC.hpp"
301 #include "ir_RC5_RC6.hpp"
302 #include "ir_Samsung.hpp"
303 #include "ir_Sony.hpp"
304 #include "ir_FAST.hpp"
305 #include "ir_Others.hpp"
306 #include "ir_Pronto.hpp" // pronto is an universal decoder and encoder
307 # if defined(DECODE_DISTANCE_WIDTH) // universal decoder for pulse distance width protocols - requires up to 750 bytes additional program memory
309 # endif
310 #endif // #if !defined(USE_IRREMOTE_HPP_AS_PLAIN_INCLUDE)
311 
315 #define RAWBUF 101 // Maximum length of raw duration buffer
316 #define REPEAT 0xFFFFFFFF
317 #define USECPERTICK MICROS_PER_TICK
318 #define MARK_EXCESS MARK_EXCESS_MICROS
319 
320 #endif // _IR_REMOTE_HPP
IRSend.hpp
IRTimer.hpp
All timer specific definitions are contained in this file. Sets IR_SEND_PIN if required,...
ir_Samsung.hpp
ir_Sony.hpp
ir_MagiQuest.hpp
ir_FAST.hpp
ir_RC5_RC6.hpp
ir_NEC.hpp
ir_BangOlufsen.hpp
ir_Lego.hpp
digitalWriteFast.h
ir_DistanceWidthProtocol.hpp
ir_Others.hpp
ir_LG.hpp
disableLEDFeedback
void disableLEDFeedback()
Definition: IRFeedbackLED.hpp:89
IRProtocol.hpp
LongUnion.h
IRFeedbackLED.hpp
All Feedback LED specific functions are contained in this file.
ir_Denon.hpp
ir_Kaseikyo.hpp
ir_JVC.hpp
IRReceive.hpp
IRVersion.h
ir_BoseWave.hpp
ir_Pronto.hpp
IRremoteInt.h
Contains all declarations required for the interface to IRremote. Could not be named IRremote....