From 1154607b690aca0ec2d6822e10ce53be3f1c5f1b Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Mon, 4 Sep 2017 20:48:37 -0700 Subject: [PATCH 1/4] Fix minor compiler warnings in examples --- examples/IRrecord/IRrecord.ino | 2 +- examples/IRtest2/IRtest2.ino | 6 +++--- examples/LGACSendDemo/LGACSendDemo.ino | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/IRrecord/IRrecord.ino b/examples/IRrecord/IRrecord.ino index 7fc5cfd..a121e59 100644 --- a/examples/IRrecord/IRrecord.ino +++ b/examples/IRrecord/IRrecord.ino @@ -45,7 +45,7 @@ int toggle = 0; // The RC5/6 toggle state // Most of this code is just logging void storeCode(decode_results *results) { codeType = results->decode_type; - int count = results->rawlen; + //int count = results->rawlen; if (codeType == UNKNOWN) { Serial.println("Received unknown code, saving as raw"); codeLen = results->rawlen - 1; diff --git a/examples/IRtest2/IRtest2.ino b/examples/IRtest2/IRtest2.ino index 56b8a4d..22a8fa2 100644 --- a/examples/IRtest2/IRtest2.ino +++ b/examples/IRtest2/IRtest2.ino @@ -61,7 +61,7 @@ void setup() // Wait for the gap between tests, to synchronize with // the sender. // Specifically, wait for a signal followed by a gap of at last gap ms. -void waitForGap(int gap) { +void waitForGap(unsigned long gap) { Serial.println("Waiting for gap"); while (1) { while (digitalRead(RECV_PIN) == LOW) { @@ -125,7 +125,7 @@ void dump(decode_results *results) { // The motivation behind this method is that the sender and the receiver // can do the same test calls, and the mode variable indicates whether // to send or receive. -void test(char *label, int type, unsigned long value, int bits) { +void test(const char *label, int type, unsigned long value, int bits) { if (mode == SENDER) { Serial.println(label); if (type == NEC) { @@ -175,7 +175,7 @@ void test(char *label, int type, unsigned long value, int bits) { // Test raw send or receive. This is similar to the test method, // except it send/receives raw data. -void testRaw(char *label, unsigned int *rawbuf, int rawlen) { +void testRaw(const char *label, unsigned int *rawbuf, int rawlen) { if (mode == SENDER) { Serial.println(label); irsend.sendRaw(rawbuf, rawlen, 38 /* kHz */); diff --git a/examples/LGACSendDemo/LGACSendDemo.ino b/examples/LGACSendDemo/LGACSendDemo.ino index da5db37..e3c7dfa 100644 --- a/examples/LGACSendDemo/LGACSendDemo.ino +++ b/examples/LGACSendDemo/LGACSendDemo.ino @@ -192,12 +192,12 @@ void loop() ac_activate(AC_TEMPERATURE, AC_FLOW); break; case 2: - if ( b == 0 | b == 1 ) { + if ( b == 0 || b == 1 ) { ac_change_air_swing(b); } break; case 3: // 1 : clean on, power on - if ( b == 0 | b == 1 ) { + if ( b == 0 || b == 1 ) { ac_air_clean(b); } break; From d719c27f95fa374a44a8c022ab4afe7b3ce1fbe3 Mon Sep 17 00:00:00 2001 From: Rafi Khan Date: Thu, 14 Sep 2017 21:52:37 -0400 Subject: [PATCH 2/4] Changed default send pin on ATmega32u4 from 13 to 9 The reason for this change is that I was informed by a community member that the Pro Micro board does not have the default pin 13. This causes many issues for beginners that are not familiar with the inner workings of the library. However, I am concerned about this being a breaking change. If there are serious issues I may just end up adding a tutorial in the FAQ for beginners, informing them how they may change the default pins. --- README.md | 2 +- boarddefs.h | 4 ++-- changelog.md | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 00a4b03..9a6bac8 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ We are open to suggestions for adding support to new boards, however we highly r | [ATtiny84](https://github.com/SpenceKonde/ATTinyCore) | **6** | **1** | | [ATtiny85](https://github.com/SpenceKonde/ATTinyCore) | **1** | **TINY0** | | [ATmega8](https://github.com/MCUdude/MiniCore) | **9** | **1** | -| Atmega32u4 | 5, 9, **13** | 1, 3, **4** | +| Atmega32u4 | 5, **9**, 13 | 1, 3, **4** | | [ATmega48, ATmega88, ATmega168, ATmega328](https://github.com/MCUdude/MiniCore) | **3**, 9 | 1, **2** | | [ATmega1284](https://github.com/MCUdude/MightyCore) | 13, 14, 6 | 1, **2**, 3 | | [ATmega164, ATmega324, ATmega644](https://github.com/MCUdude/MightyCore) | 13, **14** | 1, **2** | diff --git a/boarddefs.h b/boarddefs.h index 17e2551..9ac9491 100644 --- a/boarddefs.h +++ b/boarddefs.h @@ -85,8 +85,8 @@ // Teensy 2.0 #elif defined(__AVR_ATmega32U4__) //#define IR_USE_TIMER1 // tx = pin 14 - //#define IR_USE_TIMER3 // tx = pin 9 - #define IR_USE_TIMER4_HS // tx = pin 10 + #define IR_USE_TIMER3 // tx = pin 9 + //#define IR_USE_TIMER4_HS // tx = pin 10 // Teensy 3.0 / Teensy 3.1 #elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) diff --git a/changelog.md b/changelog.md index 81339f2..a3adbfe 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +## 3.0.0 - 2017/09/14 +- Changed default send pin on ATmega32u4 from 13 to 9. + Note: this is a non-backwards compatible change as the behaviour of existing programs using this board for receiving WILL be affected. If you would like to use pin 13 as before then please search src/boarddefs.h for "32u4" and comment the line for pin 9 while uncommenting the line for pin 13 + + + ## 2.3.3 - 2017/03/31 - Added ESP32 IR receive support [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/425) From 71f6daca4f756983422b17bf227aa5e952552990 Mon Sep 17 00:00:00 2001 From: Rafi Khan Date: Thu, 14 Sep 2017 22:13:50 -0400 Subject: [PATCH 3/4] Revert "Merge pull request #519 from PaulStoffregen/master" This reverts commit 20a4d97f6178efdfcf421e92b3a4ca668d741d9e, reversing changes made to 47aadf559d359d7e270eb4b5451ee68cd6d1d464. --- examples/IRrecord/IRrecord.ino | 2 +- examples/IRtest2/IRtest2.ino | 6 +++--- examples/LGACSendDemo/LGACSendDemo.ino | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/IRrecord/IRrecord.ino b/examples/IRrecord/IRrecord.ino index a121e59..7fc5cfd 100644 --- a/examples/IRrecord/IRrecord.ino +++ b/examples/IRrecord/IRrecord.ino @@ -45,7 +45,7 @@ int toggle = 0; // The RC5/6 toggle state // Most of this code is just logging void storeCode(decode_results *results) { codeType = results->decode_type; - //int count = results->rawlen; + int count = results->rawlen; if (codeType == UNKNOWN) { Serial.println("Received unknown code, saving as raw"); codeLen = results->rawlen - 1; diff --git a/examples/IRtest2/IRtest2.ino b/examples/IRtest2/IRtest2.ino index 22a8fa2..56b8a4d 100644 --- a/examples/IRtest2/IRtest2.ino +++ b/examples/IRtest2/IRtest2.ino @@ -61,7 +61,7 @@ void setup() // Wait for the gap between tests, to synchronize with // the sender. // Specifically, wait for a signal followed by a gap of at last gap ms. -void waitForGap(unsigned long gap) { +void waitForGap(int gap) { Serial.println("Waiting for gap"); while (1) { while (digitalRead(RECV_PIN) == LOW) { @@ -125,7 +125,7 @@ void dump(decode_results *results) { // The motivation behind this method is that the sender and the receiver // can do the same test calls, and the mode variable indicates whether // to send or receive. -void test(const char *label, int type, unsigned long value, int bits) { +void test(char *label, int type, unsigned long value, int bits) { if (mode == SENDER) { Serial.println(label); if (type == NEC) { @@ -175,7 +175,7 @@ void test(const char *label, int type, unsigned long value, int bits) { // Test raw send or receive. This is similar to the test method, // except it send/receives raw data. -void testRaw(const char *label, unsigned int *rawbuf, int rawlen) { +void testRaw(char *label, unsigned int *rawbuf, int rawlen) { if (mode == SENDER) { Serial.println(label); irsend.sendRaw(rawbuf, rawlen, 38 /* kHz */); diff --git a/examples/LGACSendDemo/LGACSendDemo.ino b/examples/LGACSendDemo/LGACSendDemo.ino index e3c7dfa..da5db37 100644 --- a/examples/LGACSendDemo/LGACSendDemo.ino +++ b/examples/LGACSendDemo/LGACSendDemo.ino @@ -192,12 +192,12 @@ void loop() ac_activate(AC_TEMPERATURE, AC_FLOW); break; case 2: - if ( b == 0 || b == 1 ) { + if ( b == 0 | b == 1 ) { ac_change_air_swing(b); } break; case 3: // 1 : clean on, power on - if ( b == 0 || b == 1 ) { + if ( b == 0 | b == 1 ) { ac_air_clean(b); } break; From bdb9f1c1f58436b241d05f4f13ecb1dcc491373e Mon Sep 17 00:00:00 2001 From: Rafi Khan Date: Sat, 23 Sep 2017 21:03:07 -0400 Subject: [PATCH 4/4] Added support for RC5 extended Credits: https://github.com/LarsWH Excerpt from PR: ``` Hi, I added support for 'RC5 extended' in order to make this project: https://www.instructables.com/id/Remote-Control-for-Lava-mMotion-Swing-Mounting-Bra/ The modification is working nicely in this single application. It has not been tested elsewhere. (I am new to Git and this is my first pull request ever. So please excuse me if I have messed something up) Kind regards, Lars ``` Merged #522 --- IRremote.h | 1 + changelog.md | 7 ++---- ir_RC5_RC6.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/IRremote.h b/IRremote.h index fe1a870..4ce810e 100644 --- a/IRremote.h +++ b/IRremote.h @@ -270,6 +270,7 @@ class IRsend //...................................................................... # if SEND_RC5 void sendRC5 (unsigned long data, int nbits) ; + void sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle); # endif # if SEND_RC6 void sendRC6 (unsigned long data, int nbits) ; diff --git a/changelog.md b/changelog.md index a3adbfe..3435389 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,5 @@ -## 3.0.0 - 2017/09/14 -- Changed default send pin on ATmega32u4 from 13 to 9. - Note: this is a non-backwards compatible change as the behaviour of existing programs using this board for receiving WILL be affected. If you would like to use pin 13 as before then please search src/boarddefs.h for "32u4" and comment the line for pin 9 while uncommenting the line for pin 13 - - +## 2.4.3 +- Added Philips Extended RC-5 protocol support [PR #522] (https://github.com/z3t0/Arduino-IRremote/pull/522) ## 2.3.3 - 2017/03/31 - Added ESP32 IR receive support [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/425) diff --git a/ir_RC5_RC6.cpp b/ir_RC5_RC6.cpp index 10e7927..e16a334 100644 --- a/ir_RC5_RC6.cpp +++ b/ir_RC5_RC6.cpp @@ -78,6 +78,73 @@ void IRsend::sendRC5 (unsigned long data, int nbits) space(0); // Always end with the LED off } + +void IRsend::sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle) +{ + // Set IR carrier frequency + enableIROut(36); + + unsigned long addressBits = 5; + unsigned long commandBits = 7; + unsigned long nbits = addressBits + commandBits; + + // Start + mark(RC5_T1); + + // Bit #6 of the command part, but inverted! + unsigned long cmdBit6 = (1UL << (commandBits-1)) & cmd; + if (cmdBit6) { + // Inverted (1 -> 0 = mark-to-space) + mark(RC5_T1); + space(RC5_T1); + } else { + space(RC5_T1); + mark(RC5_T1); + } + commandBits--; + + // Toggle bit + static int toggleBit = 1; + if (toggle) { + if (toggleBit == 0) { + toggleBit = 1; + } else { + toggleBit = 0; + } + } + if (toggleBit) { + space(RC5_T1); + mark(RC5_T1); + } else { + mark(RC5_T1); + space(RC5_T1); + } + + // Address + for (unsigned long mask = 1UL << (addressBits - 1); mask; mask >>= 1) { + if (addr & mask) { + space(RC5_T1); // 1 is space, then mark + mark(RC5_T1); + } else { + mark(RC5_T1); + space(RC5_T1); + } + } + + // Command + for (unsigned long mask = 1UL << (commandBits - 1); mask; mask >>= 1) { + if (cmd & mask) { + space(RC5_T1); // 1 is space, then mark + mark(RC5_T1); + } else { + mark(RC5_T1); + space(RC5_T1); + } + } + + space(0); // Always end with the LED off +} + #endif //+=============================================================================