From 7f4fcdecc00174c47136715258897bdd3e5b1183 Mon Sep 17 00:00:00 2001 From: Michal Skuta Date: Wed, 11 Dec 2024 09:01:06 +0100 Subject: [PATCH] Testing experimental NEC-48 support --- src/libraries/Arduino-IRremote-mod/src/IRSend.hpp | 6 +++++- .../Arduino-IRremote-mod/src/IRremoteInt.h | 1 + src/libraries/Arduino-IRremote-mod/src/ir_NEC.hpp | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libraries/Arduino-IRremote-mod/src/IRSend.hpp b/src/libraries/Arduino-IRremote-mod/src/IRSend.hpp index 89265bd39..c77efeae5 100644 --- a/src/libraries/Arduino-IRremote-mod/src/IRSend.hpp +++ b/src/libraries/Arduino-IRremote-mod/src/IRSend.hpp @@ -194,7 +194,11 @@ size_t IRsend::write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats) { * Order of protocols is in guessed relevance :-) */ if (tProtocol == NEC) { - sendNEC(tAddress, tCommand, aNumberOfRepeats); + if (aIRSendData->numberOfBits == 48) { + sendNEC48(tAddress, tCommand, aNumberOfRepeats); + } else { + sendNEC(tAddress, tCommand, aNumberOfRepeats); + } } else if (tProtocol == SAMSUNG) { sendSamsung(tAddress, tCommand, aNumberOfRepeats); diff --git a/src/libraries/Arduino-IRremote-mod/src/IRremoteInt.h b/src/libraries/Arduino-IRremote-mod/src/IRremoteInt.h index 5590c6bf4..f7b7c2364 100644 --- a/src/libraries/Arduino-IRremote-mod/src/IRremoteInt.h +++ b/src/libraries/Arduino-IRremote-mod/src/IRremoteInt.h @@ -522,6 +522,7 @@ class IRsend { void sendNEC2(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats); void sendNECRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats = NO_REPEATS); // NEC variants + void sendNEC48(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats); void sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats); void sendApple(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats); diff --git a/src/libraries/Arduino-IRremote-mod/src/ir_NEC.hpp b/src/libraries/Arduino-IRremote-mod/src/ir_NEC.hpp index d927be638..4205deafd 100644 --- a/src/libraries/Arduino-IRremote-mod/src/ir_NEC.hpp +++ b/src/libraries/Arduino-IRremote-mod/src/ir_NEC.hpp @@ -152,6 +152,19 @@ void IRsend::sendNEC2(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOf sendPulseDistanceWidth(&NEC2ProtocolConstants, computeNECRawDataAndChecksum(aAddress, aCommand), NEC_BITS, aNumberOfRepeats); } +/* + * Experimental nec48 protocol based by: + * aCommand contains command and E variable + */ +void IRsend::sendNEC48(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) { + + uint32_t necRawArray[2]; + necRawArray[0] = computeNECRawDataAndChecksum(aAddress, aCommand >> 8); + uint8_t eValue = aCommand & 0x00FF; + necRawArray[1] = (uint32_t) ((~eValue) << 8) | eValue; + sendPulseDistanceWidthFromArray(&NECProtocolConstants, (uint32_t *) &necRawArray, NEC_BITS + 16, aNumberOfRepeats); +} + /* * Repeat commands should be sent in a 110 ms raster. * There is NO delay after the last sent repeat!