You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Protocols can be switched off and on by defining macros before the line `#include <IRremote.hpp>` like [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/SimpleReceiver/SimpleReceiver.ino#L14):
22
22
23
-
```
23
+
```c++
24
24
#defineDECODE_NEC
25
25
//#define DECODE_DENON
26
26
#include<IRremote.hpp>
@@ -58,11 +58,12 @@ If you use an (old) Arduino core that does not use the `-flto` flag for compile,
58
58
- Overflow, Repeat and other flags are now in [`IrReceiver.receivedIRData.flags`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.h#L126).
59
59
- Seldom used: `results.rawbuf` and `results.rawlen` must be replaced by `IrReceiver.decodedIRData.rawDataPtr->rawbuf` and `IrReceiver.decodedIRData.rawDataPtr->rawlen`.
60
60
61
-
# Do not want to convert your 2.x program and use the 3.x library version?
62
-
The 3.x versions try to be backwards compatible, so you can easily run your old examples. But some functions like e.g. `sendNEC()` -see below- could not made backwards compatible,
63
-
so in this cases you must revisit your code and adapt it to the 3.x library.<br/>
64
-
If you program look like:
65
-
```
61
+
## Example
62
+
### 2.x program:
63
+
64
+
```c++
65
+
#include<IRremote.h>
66
+
66
67
IRrecv irrecv(RECV_PIN);
67
68
decode_results results;
68
69
@@ -81,9 +82,38 @@ void loop() {
81
82
...
82
83
}
83
84
```
85
+
86
+
### 3.x program:
87
+
88
+
```c++
89
+
#include <IRremote.hpp>
90
+
91
+
void setup()
92
+
{
93
+
...
94
+
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver
IrReceiver.printIRResultShort(&Serial); // optional use new print version
101
+
...
102
+
IrReceiver.resume(); // Enable receiving of the next value
103
+
}
104
+
...
105
+
}
106
+
```
107
+
108
+
# Do not want to convert your 2.x program and use the 3.x library version?
109
+
The 3.x versions try to be backwards compatible, so you can easily run your old examples. But some functions like e.g. `sendNEC()` -see below- could not made backwards compatible,
110
+
so in this cases you must revisit your code and adapt it to the 3.x library.<br/>
111
+
If you program look like:
112
+
84
113
it runs on the 3.x version as before. But only the following decoders are available then: Denon, JVC, LG, NEC, Panasonic, RC5, RC6, Samsung, Sony.
85
114
The `results.value` is set by the decoders for **NEC, Panasonic, Sony, Samsung and JVC** as MSB first like in 2.x!<br/>
86
-
- The old functions `sendNEC()` and `sendJVC()` are deprecated and renamed to `sendNECMSB()` and `sendJVCMSB()` to make it clearer that they send data with MSB first,
115
+
116
+
The old functions `sendNEC()` and `sendJVC()` are deprecated and renamed to `sendNECMSB()` and `sendJVCMSB()` to make it clearer that they send data with MSB first,
87
117
which is not the standard for NEC and JVC. Use them to send your **old MSB-first 32 bit IR data codes**.
88
118
In the new version you will send NEC (and other) commands not by 32 bit codes but by a (constant) 8 bit address and an 8 bit command.
89
119
@@ -98,6 +128,27 @@ Example:
98
128
0x40802CD3 is binary 01000000100000000010110011010011.<br/>
99
129
If you read the first binary sequence backwards (right to left), you get the second sequence.
100
130
131
+
# Receiving IR codes
132
+
Check for **available data** can be done by `if (IrReceiver.decode()) {`. This also decodes the received data.
133
+
After successful decoding, the IR data is contained in the IRData structure, available as `IrReceiver.decodedIRData`.
uint16_t extra; // Used by MagiQuest and for Kaseikyo unknown vendor ID. Ticks used for decoding Distance protocol.
141
+
uint16_t numberOfBits; // Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
142
+
uint8_t flags; // See IRDATA_FLAGS_* definitions above
143
+
uint32_t decodedRawData; // Up to 32 bit decoded raw data, used for sendRaw functions.
144
+
irparams_struct *rawDataPtr; // Pointer of the raw timing data to be decoded. Mainly the data buffer filled by receiving ISR.
145
+
};
146
+
```
147
+
To access e.g. the **RAW data**, use `uint32_t myRawdata= IrReceiver.decodedIRData.decodedRawData;`.<br/>
148
+
The content of the `IrReceiver.decodedIRData.flags` is described [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremoteInt.h#L204-L212).<br/>
149
+
To **print all fields**, use `IrReceiver.printIRResultShort(&Serial);`.<br/>
150
+
To print the **raw timing data** received, use `IrReceiver.printIRResultRawFormatted(&Serial, true);`.
151
+
101
152
# Sending IR codes
102
153
Please do not use the old send*Raw() functions for sending like e.g. `IrSender.sendNECRaw(0xE61957A8,2)`,
103
154
even if this functions are used in a lot of **(old)** tutorials. They are only kept for backward compatibility and unsupported and error prone.<br/>
@@ -257,6 +308,8 @@ If you are using Sloeber as your IDE, you can easily define global symbols with
**Issues and discussions with the content "Is it possible to use this library with the ATTinyXYZ? / board XYZ" without any reasonable explanations will be immediately closed without further notice.**<br/>
312
+
<br/>
260
313
ATtiny and Digispark boards are only tested with the recommended [ATTinyCore](https://github.com/SpenceKonde/ATTinyCore) using `New Style` pin mapping for the pro board.
261
314
- Arduino Uno / Mega / Leonardo / Duemilanove / Diecimila / LilyPad / Mini / Fio / Nano etc.
@@ -293,7 +346,7 @@ The **send PWM signal** is by default generated by software. **Therefore every p
293
346
If you use a library which requires the same timer as IRremote, you have a problem, since **the timer resource cannot be shared simultaneously** by both libraries. The best approach is to change the timer used for IRremote, which can be accomplished by modifying the timer selection in [private/IRTimer.hpp](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/private/IRTimer.hpp).<br/>
294
347
For the AVR platform the code to modify looks like:
uint16_t extra; ///< Used by MagiQuest and for Kaseikyo unknown vendor ID. Ticks used for decoding Distance protocol.
223
200
uint16_t numberOfBits; ///< Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
224
-
uint8_t flags; ///< See IRDATA_FLAGS_* definitions above
225
-
uint32_t decodedRawData; ///< Up to 32 bit decoded raw data, used for sendRaw functions.
201
+
uint8_t flags; ///< See IRDATA_FLAGS_* definitions above
202
+
uint32_t decodedRawData; ///< Up to 32 bit decoded raw data, used for sendRaw functions.
226
203
irparams_struct *rawDataPtr; ///< Pointer of the raw timing data to be decoded. Mainly the data buffer filled by receiving ISR.
227
204
};
228
205
@@ -231,6 +208,29 @@ struct IRData {
231
208
*/
232
209
#defineUSE_DEFAULT_FEEDBACK_LED_PIN0
233
210
211
+
/*
212
+
* Activating this saves 60 bytes program space and 14 bytes RAM
213
+
*/
214
+
//#define NO_LEGACY_COMPATIBILITY
215
+
#if !defined(NO_LEGACY_COMPATIBILITY)
216
+
/**
217
+
* Results returned from old decoders !!!deprecated!!!
218
+
*/
219
+
structdecode_results {
220
+
decode_type_t decode_type; // deprecated, moved to decodedIRData.protocol ///< UNKNOWN, NEC, SONY, RC5, ...
221
+
uint16_t address; ///< Used by Panasonic & Sharp [16-bits]
222
+
uint32_t value; // deprecated, moved to decodedIRData.decodedRawData ///< Decoded value / command [max 32-bits]
223
+
uint8_t bits; // deprecated, moved to decodedIRData.numberOfBits ///< Number of bits in decoded value
224
+
uint16_t magnitude; // deprecated, moved to decodedIRData.extra ///< Used by MagiQuest [16-bits]
225
+
bool isRepeat; // deprecated, moved to decodedIRData.flags ///< True if repeat of value is detected
226
+
227
+
// next 3 values are copies of irparams values - see IRremoteint.h
228
+
uint16_t *rawbuf; // deprecated, moved to decodedIRData.rawDataPtr->rawbuf ///< Raw intervals in 50uS ticks
229
+
uint16_t rawlen; // deprecated, moved to decodedIRData.rawDataPtr->rawlen ///< Number of records in rawbuf
230
+
bool overflow; // deprecated, moved to decodedIRData.flags ///< true if IR raw code too long
0 commit comments