diff --git a/Contributors.md b/Contributors.md index 7ca8054..349ccec 100644 --- a/Contributors.md +++ b/Contributors.md @@ -30,6 +30,6 @@ These are the active contributors of this project that you may contact if there - [Daniel Wallner](https://github.com/danielwallner) Bang & Olufsen protocol. - [slott](https://stackoverflow.com/users/11680056/sklott) Seeduino print(unsigned long long...) support. - [Joe Ostrander](https://github.com/joeostrander) Added support for attiny1614. -- [Buzzerb](https://github.com/Buzzerb) Added Extended NEC Protocol macro to TinyIR. +- [Buzzerb](https://github.com/Buzzerb) Added Extended NEC protocol to TinyIR and making it more consistent. Note: Please let [ArminJo](https://github.com/ArminJo) know if you have been missed. diff --git a/examples/TinySender/TinySender.ino b/examples/TinySender/TinySender.ino index 2d0fc16..4af4988 100644 --- a/examples/TinySender/TinySender.ino +++ b/examples/TinySender/TinySender.ino @@ -1,10 +1,10 @@ /* - * TinySender.ino + * TinySender.cpp * * Example for sending using TinyIR. By default sends simultaneously using all supported protocols * To use a single protocol, simply delete or comment out all unneeded protocols in the main loop * Program size is significantly reduced when using a single protocol - * For example, sending only 8 bit address and command NEC codes saves 780 bytes program memory and 26 bytes RAM compared to SimpleSender, + * For example, sending only 8 bit address and command NEC codes saves 780 bytes program memory and 26 bytes RAM compared to SimpleSender, * which does the same, but uses the IRRemote library (and is therefore much more flexible). * * @@ -23,7 +23,7 @@ ************************************************************************************ * MIT License * - * Copyright (c) 2022-2023 Armin Joachimsmeyer + * Copyright (c) 2022-2024 Armin Joachimsmeyer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -85,32 +85,32 @@ void loop() { Serial.print(F(" repeats=")); Serial.print(sRepeats); Serial.println(); - - // Send with FAST + + // Send with FAST // No address and only 16 bits of data, interpreted as 8 bit command and 8 bit inverted command for parity checking Serial.println(F("Send FAST with 8 bit command")); Serial.flush(); sendFAST(IR_SEND_PIN, sCommand, sRepeats); - - // Send with NEC + + // Send with NEC // NEC uses 8 bit address and 8 bit command each with 8 bit inverted parity checks // However, sendNEC will accept 16 bit address and commands too (but remove the parity checks) Serial.println(F("Send NEC with 8 bit address and command")); Serial.flush(); sendNEC(IR_SEND_PIN, sAddress, sCommand, sRepeats); - + // Send with Extended NEC - // Like NEC, but the address is forced 16 bits with no parity check + // Like NEC, but the address is forced 16 bits with no parity check Serial.println(F("Send ExtendedNEC with 16 bit address and 8 bit command")); Serial.flush(); sendExtendedNEC(IR_SEND_PIN, sAddress, sCommand, sRepeats); - + // Send with ONKYO // Like NEC, but both the address and command are forced 16 bits with no parity check Serial.println(F("Send ONKYO with 16 bit address and command")); Serial.flush(); sendONKYO(IR_SEND_PIN, sAddress, sCommand, sRepeats); - + // Send with NEC2 // Instead of sending the NEC special repeat code, sends the full original frame for repeats // Sending NEC2 is done by setting the optional bool NEC2Repeats argument to true (defaults to false) @@ -118,7 +118,7 @@ void loop() { Serial.println(F("Send NEC2 with 8 bit address and command and original frame repeats")); Serial.flush(); sendNEC(IR_SEND_PIN, sAddress, sCommand, sRepeats, true); - + /* * Increment send values * Also increment address just for demonstration, which normally makes no sense diff --git a/src/TinyIR.h b/src/TinyIR.h index f479f56..4f89fa2 100644 --- a/src/TinyIR.h +++ b/src/TinyIR.h @@ -34,9 +34,9 @@ * @{ */ -#define VERSION_TINYIR "2.0.0" +#define VERSION_TINYIR "2.1.0" #define VERSION_TINYIR_MAJOR 2 -#define VERSION_TINYIR_MINOR 0 +#define VERSION_TINYIR_MINOR 1 #define VERSION_TINYIR_PATCH 0 // The change log is at the bottom of the file @@ -256,13 +256,16 @@ void printTinyReceiverResultMinimal(Print *aSerial); void sendFAST(uint8_t aSendPin, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0); void sendFast8BitAndParity(uint8_t aSendPin, uint8_t aCommand, uint_fast8_t aNumberOfRepeats = 0); -void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool NEC2Repeats = false); // Send NEC with 16 bit command, even if aCommand < 0x100 +void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool aSendNEC2Repeats = false); // Send NEC with 16 bit command, even if aCommand < 0x100 void sendNECMinimal(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0) __attribute__ ((deprecated ("Renamed to sendNEC()."))); -void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool NEC2Repeats = false); -void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool NEC2Repeats = false); +void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool aSendNEC2Repeats = false); +void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats = 0, bool aSendNEC2Repeats = false); /* + * Version 2.1.0 - 2/2024 + * - New sendExtendedNEC() function and new parameter aSendNEC2Repeats. + * * Version 2.0.0 - 10/2023 * - New TinyIRReceiverData which is filled with address, command and flags. * - Removed parameters address, command and flags from callback handleReceivedTinyIRData() and printTinyReceiverResultMinimal(). diff --git a/src/TinyIRReceiver.hpp b/src/TinyIRReceiver.hpp index 2b5a75e..9f78743 100644 --- a/src/TinyIRReceiver.hpp +++ b/src/TinyIRReceiver.hpp @@ -28,7 +28,7 @@ ************************************************************************************ * MIT License * - * Copyright (c) 2022-2023 Armin Joachimsmeyer + * Copyright (c) 2022-2024 Armin Joachimsmeyer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/TinyIRSender.hpp b/src/TinyIRSender.hpp index a26593d..65a1fe1 100644 --- a/src/TinyIRSender.hpp +++ b/src/TinyIRSender.hpp @@ -19,7 +19,7 @@ ************************************************************************************ * MIT License * - * Copyright (c) 2022-2023 Armin Joachimsmeyer + * Copyright (c) 2022-2024 Armin Joachimsmeyer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -109,8 +109,9 @@ void sendMark(uint8_t aSendPin, unsigned int aMarkMicros) { * @param aAddress - The 16 bit address to send. * @param aCommand - The 16 bit command to send. * @param aNumberOfRepeats - Number of repeats send at a period of 110 ms. + * @param aSendNEC2Repeats - Instead of sending the NEC special repeat code, send the original frame for repeat. */ -void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool NEC2Repeats) { +void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendNEC2Repeats) { pinModeFast(aSendPin, OUTPUT); uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; @@ -118,7 +119,7 @@ void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast unsigned long tStartOfFrameMillis = millis(); sendMark(aSendPin, NEC_HEADER_MARK); - if ((!NEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) { + if ((!aSendNEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) { // send the NEC special repeat delayMicroseconds(NEC_REPEAT_HEADER_SPACE); // - 2250 } else { @@ -159,11 +160,12 @@ void sendONKYO(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast * @param aAddress - If aAddress < 0x100 send 8 bit address and 8 bit inverted address, else send 16 bit address. * @param aCommand - If aCommand < 0x100 send 8 bit command and 8 bit inverted command, else send 16 bit command. * @param aNumberOfRepeats - Number of repeats send at a period of 110 ms. + * @param aSendNEC2Repeats - Instead of sending the NEC special repeat code, send the original frame for repeat. */ void sendNECMinimal(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats) { sendNEC(aSendPin, aAddress, aCommand, aNumberOfRepeats); // sendNECMinimal() is deprecated } -void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool NEC2Repeats) { +void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendNEC2Repeats) { pinModeFast(aSendPin, OUTPUT); uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; @@ -171,7 +173,7 @@ void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_ unsigned long tStartOfFrameMillis = millis(); sendMark(aSendPin, NEC_HEADER_MARK); - if ((!NEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) { + if ((!aSendNEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) { // send the NEC special repeat delayMicroseconds(NEC_REPEAT_HEADER_SPACE); // - 2250 } else { @@ -227,8 +229,9 @@ void sendNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_ * @param aAddress - Send 16 bit address. * @param aCommand - If aCommand < 0x100 send 8 bit command and 8 bit inverted command, else send 16 bit command. * @param aNumberOfRepeats - Number of repeats send at a period of 110 ms. + * @param aSendNEC2Repeats - Instead of sending the NEC special repeat code, send the original frame for repeat. */ -void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool NEC2Repeats) { +void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendNEC2Repeats) { pinModeFast(aSendPin, OUTPUT); uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; @@ -236,7 +239,7 @@ void sendExtendedNEC(uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uin unsigned long tStartOfFrameMillis = millis(); sendMark(aSendPin, NEC_HEADER_MARK); - if ((!NEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) { + if ((!aSendNEC2Repeats) && (tNumberOfCommands < aNumberOfRepeats + 1)) { // send the NEC special repeat delayMicroseconds(NEC_REPEAT_HEADER_SPACE); // - 2250 } else {