diff --git a/.github/workflows/LibraryBuild.yml b/.github/workflows/LibraryBuild.yml index fb7638a..50b55a0 100644 --- a/.github/workflows/LibraryBuild.yml +++ b/.github/workflows/LibraryBuild.yml @@ -99,6 +99,7 @@ jobs: sketches-exclude: UnitTest build-properties: # the flags were put in compiler.cpp.extra_flags IRremoteExtensionTest: -DRAW_BUFFER_LENGTH=100 -DIR_SEND_PIN=3 -DSEND_PWM_BY_TIMER + ReceiveDemo: -DDECODE_ONKYO TinyReceiver: -DUSE_ONKYO_PROTOCOL TinySender: -DUSE_ONKYO_PROTOCOL All: -DSEND_PWM_BY_TIMER diff --git a/changelog.md b/changelog.md index ce6f556..8b1515b 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-I # 4.2.0 - The old decode function is renamed to decode_old(decode_results *aResults). decode (decode_results *aResults) is only available in IRremote.h and prints a message. +- Added DECODE_ONKYO, to force 16 bit command and data decoding. ## 4.1.2 - Workaround for ESP32 RTOS delay() timing bug influencing the mark() function. diff --git a/examples/ReceiveDemo/ReceiveDemo.ino b/examples/ReceiveDemo/ReceiveDemo.ino index cb53d92..e2659de 100644 --- a/examples/ReceiveDemo/ReceiveDemo.ino +++ b/examples/ReceiveDemo/ReceiveDemo.ino @@ -48,6 +48,7 @@ //#define DECODE_KASEIKYO //#define DECODE_PANASONIC // alias for DECODE_KASEIKYO //#define DECODE_LG +//#define DECODE_ONKYO // Decodes only Onkyo and not NEC or Apple //#define DECODE_NEC // Includes Apple and Onkyo //#define DECODE_SAMSUNG //#define DECODE_SONY diff --git a/src/IRReceive.hpp b/src/IRReceive.hpp index d0ee7fe..a1bf0b4 100644 --- a/src/IRReceive.hpp +++ b/src/IRReceive.hpp @@ -487,8 +487,8 @@ bool IRrecv::decode() { return true; } -#if defined(DECODE_NEC) - IR_TRACE_PRINTLN(F("Attempting NEC decode")); +#if defined(DECODE_NEC) || defined(DECODE_ONKYO) + IR_TRACE_PRINTLN(F("Attempting NEC/Onkyo decode")); if (decodeNEC()) { return true; } @@ -1143,7 +1143,9 @@ void IRrecv::printActiveIRProtocols(Print *aSerial) { ::printActiveIRProtocols(aSerial); } void printActiveIRProtocols(Print *aSerial) { -#if defined(DECODE_NEC) +#if defined(DECODE_ONKYO) + aSerial->print(F("Onkyo, ")); +#elif defined(DECODE_NEC) aSerial->print(F("NEC/NEC2/Onkyo/Apple, ")); #endif #if defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO) diff --git a/src/IRremote.hpp b/src/IRremote.hpp index 39a63fa..7baa0bf 100644 --- a/src/IRremote.hpp +++ b/src/IRremote.hpp @@ -96,7 +96,7 @@ #if !defined(NO_DECODER) // for sending raw only # if (!(defined(DECODE_DENON) || defined(DECODE_JVC) || defined(DECODE_KASEIKYO) \ -|| defined(DECODE_PANASONIC) || defined(DECODE_LG) || defined(DECODE_NEC) || defined(DECODE_SAMSUNG) \ +|| defined(DECODE_PANASONIC) || defined(DECODE_LG) || defined(DECODE_NEC) || defined(DECODE_ONKYO) || defined(DECODE_SAMSUNG) \ || defined(DECODE_SONY) || defined(DECODE_RC5) || defined(DECODE_RC6) \ || defined(DECODE_DISTANCE_WIDTH) || defined(DECODE_HASH) || defined(DECODE_BOSEWAVE) \ || defined(DECODE_LEGO_PF) || defined(DECODE_MAGIQUEST) || defined(DECODE_FAST) || defined(DECODE_WHYNTER))) diff --git a/src/ir_NEC.hpp b/src/ir_NEC.hpp index 8f856c9..55b426a 100644 --- a/src/ir_NEC.hpp +++ b/src/ir_NEC.hpp @@ -72,7 +72,7 @@ // http://www.hifi-remote.com/wiki/index.php/NEC // https://www.sbprojects.net/knowledge/ir/nec.php // for Apple see https://en.wikipedia.org/wiki/Apple_Remote - Fixed address 0x87EE, 8 bit device ID, 7 bit command, 1 bit parity - untested! -// ONKYO like NEC but 16 independent command bits +// ONKYO like NEC but 16 independent address and command bits // PIONEER (not implemented) is NEC2 with 40 kHz // LSB first, 1 start bit + 16 bit address (or 8 bit address and 8 bit inverted address) + 8 bit command + 8 bit inverted command + 1 stop bit. // Standard NEC sends a special fixed repeat frame. @@ -283,6 +283,13 @@ bool IRrecv::decodeNEC() { LongUnion tValue; tValue.ULong = decodedIRData.decodedRawData; decodedIRData.command = tValue.UByte.MidHighByte; // 8 bit + +#if defined(DECODE_ONKYO) + // Here only Onkyo protocol -> force 16 bit address and command decoding + decodedIRData.address = tValue.UWord.LowWord; // first 16 bit + decodedIRData.protocol = ONKYO; + decodedIRData.command = tValue.UWord.HighWord; // 16 bit command +#else // Address if (tValue.UWord.LowWord == APPLE_ADDRESS) { /* @@ -310,6 +317,8 @@ bool IRrecv::decodeNEC() { decodedIRData.command = tValue.UWord.HighWord; // 16 bit command } } +#endif + decodedIRData.numberOfBits = NEC_BITS; // check for NEC2 repeat, do not check for same content ;-) diff --git a/src/private/IRTimer.hpp b/src/private/IRTimer.hpp index 07f6a4d..e4f4522 100644 --- a/src/private/IRTimer.hpp +++ b/src/private/IRTimer.hpp @@ -1376,20 +1376,20 @@ void timerEnableReceiveInterrupt() { #if !defined(ESP_ARDUINO_VERSION_VAL) #define ESP_ARDUINO_VERSION_VAL(major, minor, patch) 202 #endif -# if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(2, 0, 2) +#if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(2, 0, 2) void timerDisableReceiveInterrupt() { if (s50usTimer != NULL) { timerEnd(s50usTimer); timerDetachInterrupt(s50usTimer); } } -# else +#else void timerDisableReceiveInterrupt() { if (s50usTimer != NULL) { timerAlarmDisable (s50usTimer); } } -# endif +#endif // Undefine ISR, because we register/call the plain function IRReceiveTimerInterruptHandler() # if defined(ISR)