Skip to content

Commit

Permalink
Testing experimental NEC-48 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mintos5 committed Dec 12, 2024
1 parent 2c0b3cd commit 7f4fcde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libraries/Arduino-IRremote-mod/src/IRSend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/libraries/Arduino-IRremote-mod/src/IRremoteInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions src/libraries/Arduino-IRremote-mod/src/ir_NEC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit 7f4fcde

Please sign in to comment.