-
Notifications
You must be signed in to change notification settings - Fork 835
Upgrading to v2.0
v2.x is a significant change in the IRremoteESP8266 library from versions v1.x & earlier. Almost all the code in the library has been re-written. Due to that there are now some substantial differences to prior versions.
To update your code to use the new version of the library, you will need to make a few changes. First, you will need to add or change the main library #include file. e.g.
#include <IRremoteESP8266.h>
#include <IRsend.h> // Needed if you want to send IR commands.
#include <IRrecv.h> // Needed if you want to receive IR commands.
Almost all arguments of the procedures and functions in the library have been changed to c99 types and to unsigned variables. e.g.
#include <IRremoteESP8266.h>
long data = 0x12345678;
int bits = 32;
irsend.sendNEC(data, bits);
#include <IRremoteESP8266.h>
#include <IRsend.h>
// Simple upgrade
unsigned long data = 0x12345678;
unsigned int bits = 32;
irsend.sendNEC(data, bits);
or
#include <IRremoteESP8266.h>
#include <IRsend.h>
// Better upgrade
uint64_t data = 0x12345678ULL; // unsigned long long
uint16_t bits = 32U; // unsigned int
irsend.sendNEC(data, bits);
The main code of the library has moved to the src/ subdirectory. Under which, all the protocols and major functions have been split into individual files. e.g. NEC-related routines are located in src/ir_NEC.cpp, etc.
The test/ directory stores the unit tests for this library. It is used for testing the library. It is not for use on the ESP chips. The tests are designed to run on Travis or unix machines.
The lib/ directory stores external libraries used by this library. Namely, the Google Unit Test framework.
- All suitable protocols now handle 64-bit data messages. (e.g. unsigned long long or uint64_t)
- All suitable protocols can be sent repeatedly via an optional argument.
- Most protocols now have reasonable default argument settings.
e.g.- Default number of bits.
Old:sendNEC(0x12345678, 32);
-> New:sendNEC(0x12345678);
- Default number of repeats.
Old:sendSony(0x1234, 20, 2);
-> New:sendSony(0x1234, 20);
- Default number of bits.
- Most protocols now add an appropriate post-message gap.
- Protocols that require a message is repeatedly sent to be correctly received by an external device now do so by default.
e.g. sendSony() now sends a command a total of 3 times by default with the appropriate gaps. - Unit tests for all protocols. When ever possible, real examples of IR messages are used to ensure better protocol decoding and sending.
- Far better and stricter decoding for most protocols.
- Address & command encoding & decoding for protocols where that information is available.
- Numerous bug fixes.
- Much more precise timing for generation of signals sent, plus the ability to self-calibrate if required.
- Support for and use of lower duty-cycles for some protocols. Default is still 50%.
- Several new protocols added, and some new sending and decoding routines for existing ones.
e.g.- Gree heat pumps
- Phillips RC-5X, RC-MM, & RC-6 36 bit (i.e. Xbox-360)
- Sanyo
- Aiwa
- Coolix (decoding)
- Ability to optionally choose which protocols are included, enabling faster decoding and smaller code footprints if desired.
- Option for inverting the signal to the GPIO pin, if required.
- Support for far larger capture buffers. (e.g. RAWLEN > 256)
- Support for the PlatformIO build environment & IDE.
- The code-base is now cpplint free and tries to comply with the Google C++ Style Guide.