Bumped version to 4.3.1. Fixed overflow bug for rawlen > 254. Removed deprecated sendPulseDistance... functions with parameter aSendStopBit.

This commit is contained in:
Armin 2024-03-16 01:15:06 +01:00
parent 59f4ce4a7f
commit b962db8f4e
10 changed files with 58 additions and 110 deletions

View File

@ -2,6 +2,10 @@
The latest version may not be released! The latest version may not be released!
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
# 4.3.1
- Fixed overflow bug for rawlen > 254.
- Removed deprecated sendPulseDistance... functions with parameter aSendStopBit.
# 4.3.0 # 4.3.0
- Removed default value USE_DEFAULT_FEEDBACK_LED_PIN for last parameter of IRsend::begin(bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin). - Removed default value USE_DEFAULT_FEEDBACK_LED_PIN for last parameter of IRsend::begin(bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin).
Therefore IrSender.begin(DISABLE_LED_FEEDBACK) will not longer work! Therefore IrSender.begin(DISABLE_LED_FEEDBACK) will not longer work!

View File

@ -241,7 +241,8 @@ void loop() {
) { ) {
// Print more info, but only if we are connected to USB, i.e. VCC is > 4300 mV, because this may take to long to detect some fast repeats // Print more info, but only if we are connected to USB, i.e. VCC is > 4300 mV, because this may take to long to detect some fast repeats
IrReceiver.printIRSendUsage(&Serial); IrReceiver.printIRSendUsage(&Serial);
IrReceiver.printIRResultRawFormatted(&Serial, false); // print ticks, this is faster :-) // IrReceiver.printIRResultRawFormatted(&Serial, false); // print ticks, this is faster :-)
IrReceiver.printIRResultRawFormatted(&Serial); // print us, this is better to compare :-)
} }
// Guarantee at least 5 millis for tone. decode starts 5 millis (RECORD_GAP_MICROS) after end of frame // Guarantee at least 5 millis for tone. decode starts 5 millis (RECORD_GAP_MICROS) after end of frame

View File

@ -7,7 +7,7 @@
"type": "git", "type": "git",
"url": "https://github.com/z3t0/Arduino-IRremote.git" "url": "https://github.com/z3t0/Arduino-IRremote.git"
}, },
"version": "4.3.0", "version": "4.3.1",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": ["atmelavr", "atmelmegaavr", "atmelsam", "espressif8266", "espressif32", "ststm32"], "platforms": ["atmelavr", "atmelmegaavr", "atmelsam", "espressif8266", "espressif32", "ststm32"],
"authors" : "authors" :

View File

@ -1,5 +1,5 @@
name=IRremote name=IRremote
version=4.3.0 version=4.3.1
author=shirriff, z3t0, ArminJo author=shirriff, z3t0, ArminJo
maintainer=Armin Joachimsmeyer <armin.arduino@gmail.com> maintainer=Armin Joachimsmeyer <armin.arduino@gmail.com>
sentence=Send and receive infrared signals with multiple protocols sentence=Send and receive infrared signals with multiple protocols

View File

@ -119,11 +119,7 @@ struct IRData {
uint8_t flags; ///< IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above uint8_t flags; ///< IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above
// These 2 variables allow to call resume() directly after decode, if no dump is required. Since 4.3.0. // These 2 variables allow to call resume() directly after decode, if no dump is required. Since 4.3.0.
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR IRRawlenType rawlen; ///< counter of entries in rawbuf
uint_fast8_t rawlen; ///< counter of entries in rawbuf
#else
uint_fast16_t rawlen; ///< counter of entries in rawbuf
#endif
uint16_t initialGap; ///< rawbuf[0] contains the initial gap of the last frame. uint16_t initialGap; ///< rawbuf[0] contains the initial gap of the last frame.
irparams_struct *rawDataPtr; ///< Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by receiving ISR. irparams_struct *rawDataPtr; ///< Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by receiving ISR.
@ -141,12 +137,9 @@ struct PulseDistanceWidthProtocolConstants {
/* /*
* Definitions for member PulseDistanceWidthProtocolConstants.Flags * Definitions for member PulseDistanceWidthProtocolConstants.Flags
*/ */
#define SUPPRESS_STOP_BIT_FOR_THIS_DATA 0x20 #define SUPPRESS_STOP_BIT_FOR_THIS_DATA 0x20 // Stop bit is otherwise sent for all pulse distance protocols.
#define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST #define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST
#define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST #define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST
// 2 definitions for deprecated parameter bool aSendStopBit
#define SEND_STOP_BIT true
#define SEND_NO_STOP_BIT false
/* /*
* Carrier frequencies for various protocols * Carrier frequencies for various protocols

View File

@ -700,7 +700,7 @@ bool IRrecv::decode() {
* @param aMSBfirst If true send Most Significant Bit first, else send Least Significant Bit (lowest bit) first. * @param aMSBfirst If true send Most Significant Bit first, else send Least Significant Bit (lowest bit) first.
* @return true If decoding was successful * @return true If decoding was successful
*/ */
bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, uint16_t aOneMarkMicros, bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset, uint16_t aOneMarkMicros,
uint16_t aZeroMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroSpaceMicros, bool aMSBfirst) { uint16_t aZeroMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroSpaceMicros, bool aMSBfirst) {
auto *tRawBufPointer = &decodedIRData.rawDataPtr->rawbuf[aStartOffset]; auto *tRawBufPointer = &decodedIRData.rawDataPtr->rawbuf[aStartOffset];
@ -843,7 +843,7 @@ bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, uint_fast8
* @return true if decoding was successful * @return true if decoding was successful
*/ */
bool IRrecv::decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, bool IRrecv::decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits,
uint_fast8_t aStartOffset) { IRRawlenType aStartOffset) {
return decodePulseDistanceWidthData(aNumberOfBits, aStartOffset, aProtocolConstants->DistanceWidthTimingInfo.OneMarkMicros, return decodePulseDistanceWidthData(aNumberOfBits, aStartOffset, aProtocolConstants->DistanceWidthTimingInfo.OneMarkMicros,
aProtocolConstants->DistanceWidthTimingInfo.ZeroMarkMicros, aProtocolConstants->DistanceWidthTimingInfo.OneSpaceMicros, aProtocolConstants->DistanceWidthTimingInfo.ZeroMarkMicros, aProtocolConstants->DistanceWidthTimingInfo.OneSpaceMicros,
@ -967,12 +967,7 @@ bool IRrecv::decodeHash() {
if (decodedIRData.rawlen < 6) { if (decodedIRData.rawlen < 6) {
return false; return false;
} }
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR for (IRRawlenType i = 1; (i + 2) < decodedIRData.rawlen; i++) {
uint_fast8_t i;
#else
unsigned int i;
#endif
for (i = 1; (i + 2) < decodedIRData.rawlen; i++) {
// Compare mark with mark and space with space // Compare mark with mark and space with space
uint_fast8_t value = compare(decodedIRData.rawDataPtr->rawbuf[i], decodedIRData.rawDataPtr->rawbuf[i + 2]); uint_fast8_t value = compare(decodedIRData.rawDataPtr->rawbuf[i], decodedIRData.rawDataPtr->rawbuf[i + 2]);
// Add value into the hash // Add value into the hash
@ -1281,12 +1276,8 @@ void IRrecv::printDistanceWidthTimingInfo(Print *aSerial, DistanceWidthTimingInf
uint32_t IRrecv::getTotalDurationOfRawData() { uint32_t IRrecv::getTotalDurationOfRawData() {
uint16_t tSumOfDurationTicks = 0; uint16_t tSumOfDurationTicks = 0;
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
uint_fast8_t i; for (IRRawlenType i = 1; i < decodedIRData.rawlen; i++) {
#else
unsigned int i;
#endif
for (i = 1; i < decodedIRData.rawlen; i++) {
tSumOfDurationTicks += decodedIRData.rawDataPtr->rawbuf[i]; tSumOfDurationTicks += decodedIRData.rawDataPtr->rawbuf[i];
} }
return tSumOfDurationTicks * (uint32_t) MICROS_PER_TICK; return tSumOfDurationTicks * (uint32_t) MICROS_PER_TICK;
@ -1492,11 +1483,6 @@ void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsI
} else { } else {
aSerial->println(decodedIRData.initialGap, DEC); aSerial->println(decodedIRData.initialGap, DEC);
} }
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
uint_fast8_t i;
#else
unsigned int i;
#endif
// Newline is printed every 8. value, if tCounterForNewline % 8 == 0 // Newline is printed every 8. value, if tCounterForNewline % 8 == 0
uint_fast8_t tCounterForNewline = 6; // first newline is after the 2 values of the start bit uint_fast8_t tCounterForNewline = 6; // first newline is after the 2 values of the start bit
@ -1517,7 +1503,7 @@ void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsI
uint32_t tDuration; uint32_t tDuration;
uint16_t tSumOfDurationTicks = 0; uint16_t tSumOfDurationTicks = 0;
for (i = 1; i < decodedIRData.rawlen; i++) { for (IRRawlenType i = 1; i < decodedIRData.rawlen; i++) {
auto tCurrentTicks = decodedIRData.rawDataPtr->rawbuf[i]; auto tCurrentTicks = decodedIRData.rawDataPtr->rawbuf[i];
if (aOutputMicrosecondsInsteadOfTicks) { if (aOutputMicrosecondsInsteadOfTicks) {
tDuration = tCurrentTicks * MICROS_PER_TICK; tDuration = tCurrentTicks * MICROS_PER_TICK;
@ -1586,12 +1572,7 @@ void IRrecv::compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicr
aSerial->print(F("] = {")); // Start declaration aSerial->print(F("] = {")); // Start declaration
// Dump data // Dump data
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR for (IRRawlenType i = 1; i < decodedIRData.rawlen; i++) {
uint_fast8_t i;
#else
unsigned int i;
#endif
for (i = 1; i < decodedIRData.rawlen; i++) {
uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK; uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK;
if (i & 1) { if (i & 1) {
@ -1638,11 +1619,7 @@ void IRrecv::compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicr
void IRrecv::compensateAndStoreIRResultInArray(uint8_t *aArrayPtr) { void IRrecv::compensateAndStoreIRResultInArray(uint8_t *aArrayPtr) {
// Store data, skip leading space# // Store data, skip leading space#
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR IRRawlenType i;
uint_fast8_t i;
#else
unsigned int i;
#endif
for (i = 1; i < decodedIRData.rawlen; i++) { for (i = 1; i < decodedIRData.rawlen; i++) {
uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK; uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK;
if (i & 1) { if (i & 1) {

View File

@ -521,21 +521,8 @@ void IRsend::sendRaw_P(const uint8_t aBufferWithTicks[], uint_fast16_t aLengthOf
* For LSB First the LSB of array[0] is sent first then all bits until MSB of array[0]. Next is LSB of array[1] and so on. * For LSB First the LSB of array[0] is sent first then all bits until MSB of array[0]. Next is LSB of array[1] and so on.
* The output always ends with a space * The output always ends with a space
* Stop bit is always sent * Stop bit is always sent
* @param aFlags Evaluated flags are PROTOCOL_IS_MSB_FIRST and SUPPRESS_STOP_BIT_FOR_THIS_DATA. Stop bit is otherwise sent for all pulse distance protocols.
*/ */
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit,
uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats) {
uint8_t tFlags = 0;
if (aMSBFirst) {
tFlags = PROTOCOL_IS_MSB_FIRST;
}
(void) aSendStopBit;
sendPulseDistanceWidthFromArray(aFrequencyKHz, aHeaderMarkMicros, aHeaderSpaceMicros, aOneMarkMicros, aOneSpaceMicros,
aZeroMarkMicros, aZeroSpaceMicros, aDecodedRawDataArray, aNumberOfBits, tFlags, aRepeatPeriodMillis, aNumberOfRepeats);
}
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, DistanceWidthTimingInfoStruct *aDistanceWidthTimingInfo, void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, DistanceWidthTimingInfoStruct *aDistanceWidthTimingInfo,
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
int_fast8_t aNumberOfRepeats) { int_fast8_t aNumberOfRepeats) {
@ -545,7 +532,6 @@ void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, Distanc
aDistanceWidthTimingInfo->ZeroSpaceMicros, aDecodedRawDataArray, aNumberOfBits, aFlags, aRepeatPeriodMillis, aDistanceWidthTimingInfo->ZeroSpaceMicros, aDecodedRawDataArray, aNumberOfBits, aFlags, aRepeatPeriodMillis,
aNumberOfRepeats); aNumberOfRepeats);
} }
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros, void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
@ -616,6 +602,9 @@ void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_
* For LSB First the LSB of array[0] is sent first then all bits until MSB of array[0]. Next is LSB of array[1] and so on. * For LSB First the LSB of array[0] is sent first then all bits until MSB of array[0]. Next is LSB of array[1] and so on.
* The output always ends with a space * The output always ends with a space
* Stop bit is always sent * Stop bit is always sent
* @param aNumberOfBits Number of bits from aDecodedRawDataArray to be actually sent.
* @param aNumberOfRepeats If < 0 and a aProtocolConstants->SpecialSendRepeatFunction() is specified
* then it is called without leading and trailing space.
*/ */
void IRsend::sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants *aProtocolConstants, void IRsend::sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants *aProtocolConstants,
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, int_fast8_t aNumberOfRepeats) { IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, int_fast8_t aNumberOfRepeats) {
@ -692,7 +681,7 @@ void IRsend::sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants
} }
/** /**
* Sends PulseDistance frames and repeats and enables receiver again * Sends PulseDistance frames and repeats
* @param aProtocolConstants The constants to use for sending this protocol. * @param aProtocolConstants The constants to use for sending this protocol.
* @param aData uint32 or uint64 holding the bits to be sent. * @param aData uint32 or uint64 holding the bits to be sent.
* @param aNumberOfBits Number of bits from aData to be actually sent. * @param aNumberOfBits Number of bits from aData to be actually sent.
@ -761,23 +750,11 @@ void IRsend::sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtoc
* @param aFrequencyKHz, aHeaderMarkMicros, aHeaderSpaceMicros, aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aFlags, aRepeatPeriodMillis Values to use for sending this protocol, also contained in the PulseDistanceWidthProtocolConstants of this protocol. * @param aFrequencyKHz, aHeaderMarkMicros, aHeaderSpaceMicros, aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aFlags, aRepeatPeriodMillis Values to use for sending this protocol, also contained in the PulseDistanceWidthProtocolConstants of this protocol.
* @param aData uint32 or uint64 holding the bits to be sent. * @param aData uint32 or uint64 holding the bits to be sent.
* @param aNumberOfBits Number of bits from aData to be actually sent. * @param aNumberOfBits Number of bits from aData to be actually sent.
* @param aFlags Evaluated flags are PROTOCOL_IS_MSB_FIRST and SUPPRESS_STOP_BIT_FOR_THIS_DATA. Stop bit is otherwise sent for all pulse distance protocols.
* @param aNumberOfRepeats If < 0 and a aProtocolConstants->SpecialSendRepeatFunction() is specified * @param aNumberOfRepeats If < 0 and a aProtocolConstants->SpecialSendRepeatFunction() is specified
* then it is called without leading and trailing space. * then it is called without leading and trailing space.
* @param aSpecialSendRepeatFunction If NULL, the first frame is repeated completely, otherwise this function is used for sending the repeat frame. * @param aSpecialSendRepeatFunction If NULL, the first frame is repeated completely, otherwise this function is used for sending the repeat frame.
*/ */
void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, IRRawDataType aData,
uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit, uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats,
void (*aSpecialSendRepeatFunction)()) {
uint8_t tFlags = 0;
if (aMSBFirst) {
tFlags = PROTOCOL_IS_MSB_FIRST;
}
(void) aSendStopBit;
sendPulseDistanceWidth(aFrequencyKHz, aHeaderMarkMicros, aHeaderSpaceMicros, aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros,
aZeroSpaceMicros, aData, aNumberOfBits, tFlags, aRepeatPeriodMillis, aNumberOfRepeats, aSpecialSendRepeatFunction);
}
void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros, void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, IRRawDataType aData, uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, IRRawDataType aData,
uint_fast8_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats, uint_fast8_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats,
@ -825,9 +802,12 @@ void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeader
} }
/** /**
* Sends PulseDistance data * Sends PulseDistance from data contained in parameter using ProtocolConstants structure for timing etc.
* The output always ends with a space * The output always ends with a space
* Each additional call costs 16 bytes program memory * Each additional call costs 16 bytes program memory
* @param aProtocolConstants The constants to use for sending this protocol.
* @param aData uint32 or uint64 holding the bits to be sent.
* @param aNumberOfBits Number of bits from aData to be actually sent.
*/ */
void IRsend::sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, void IRsend::sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData,
uint_fast8_t aNumberOfBits) { uint_fast8_t aNumberOfBits) {
@ -838,18 +818,13 @@ void IRsend::sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aPr
} }
/** /**
* Sends PulseDistance data * Sends PulseDistance data with timing parameters and flag parameters.
* The output always ends with a space * The output always ends with a space
* @param aOneMarkMicros Timing for sending this protocol.
* @param aData uint32 or uint64 holding the bits to be sent.
* @param aNumberOfBits Number of bits from aData to be actually sent.
* @param aFlags Evaluated flags are PROTOCOL_IS_MSB_FIRST and SUPPRESS_STOP_BIT_FOR_THIS_DATA. Stop bit is otherwise sent for all pulse distance protocols.
*/ */
void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit) {
uint8_t tFlags = 0;
if (aMSBFirst) {
tFlags = PROTOCOL_IS_MSB_FIRST;
}
(void) aSendStopBit;
sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aData, aNumberOfBits, tFlags);
}
void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags) { uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags) {
@ -885,6 +860,7 @@ void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSp
/* /*
* Stop bit is sent for all pulse distance protocols i.e. aOneMarkMicros == aZeroMarkMicros. * Stop bit is sent for all pulse distance protocols i.e. aOneMarkMicros == aZeroMarkMicros.
* Therefore it is not sent for Sony and Magiquest :-) * Therefore it is not sent for Sony and Magiquest :-)
* For sending from an array, no intermediate stop bit must be sent for first data chunk.
*/ */
if (!(aFlags & SUPPRESS_STOP_BIT_FOR_THIS_DATA) && aOneMarkMicros == aZeroMarkMicros) { if (!(aFlags & SUPPRESS_STOP_BIT_FOR_THIS_DATA) && aOneMarkMicros == aZeroMarkMicros) {
// Send stop bit here // Send stop bit here
@ -905,6 +881,8 @@ void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSp
* 1 -> space+mark * 1 -> space+mark
* The output always ends with a space * The output always ends with a space
* can only send 31 bit data, since we put the start bit as 32th bit on front * can only send 31 bit data, since we put the start bit as 32th bit on front
* @param aData uint32 or uint64 holding the bits to be sent.
* @param aNumberOfBits Number of bits from aData to be actually sent.
*/ */
void IRsend::sendBiphaseData(uint16_t aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits) { void IRsend::sendBiphaseData(uint16_t aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits) {

View File

@ -36,10 +36,10 @@
#ifndef _IR_VERSION_HPP #ifndef _IR_VERSION_HPP
#define _IR_VERSION_HPP #define _IR_VERSION_HPP
#define VERSION_IRREMOTE "4.3.0" #define VERSION_IRREMOTE "4.3.1"
#define VERSION_IRREMOTE_MAJOR 4 #define VERSION_IRREMOTE_MAJOR 4
#define VERSION_IRREMOTE_MINOR 3 #define VERSION_IRREMOTE_MINOR 3
#define VERSION_IRREMOTE_PATCH 0 #define VERSION_IRREMOTE_PATCH 1
/* /*
* Macro to convert 3 version parts into an integer * Macro to convert 3 version parts into an integer

View File

@ -79,6 +79,11 @@
#error RAW_BUFFER_LENGTH must be even, since the array consists of space / mark pairs. #error RAW_BUFFER_LENGTH must be even, since the array consists of space / mark pairs.
#endif #endif
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
typedef uint_fast8_t IRRawlenType;
#else
typedef unsigned int IRRawlenType;
#endif
/**************************************************** /****************************************************
* Declarations for the receiver Interrupt Service Routine * Declarations for the receiver Interrupt Service Routine
****************************************************/ ****************************************************/
@ -105,11 +110,7 @@ struct irparams_struct {
void (*ReceiveCompleteCallbackFunction)(void); ///< The function to call if a protocol message has arrived, i.e. StateForISR changed to IR_REC_STATE_STOP void (*ReceiveCompleteCallbackFunction)(void); ///< The function to call if a protocol message has arrived, i.e. StateForISR changed to IR_REC_STATE_STOP
#endif #endif
bool OverflowFlag; ///< Raw buffer OverflowFlag occurred bool OverflowFlag; ///< Raw buffer OverflowFlag occurred
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR IRRawlenType rawlen; ///< counter of entries in rawbuf
uint_fast8_t rawlen; ///< counter of entries in rawbuf
#else
uint_fast16_t rawlen; ///< counter of entries in rawbuf
#endif
uint16_t rawbuf[RAW_BUFFER_LENGTH]; ///< raw data / tick counts per mark/space, first entry is the length of the gap between previous and current command uint16_t rawbuf[RAW_BUFFER_LENGTH]; ///< raw data / tick counts per mark/space, first entry is the length of the gap between previous and current command
}; };
@ -249,12 +250,12 @@ public:
* The main decoding functions used by the individual decoders * The main decoding functions used by the individual decoders
*/ */
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits,
uint_fast8_t aStartOffset = 3); IRRawlenType aStartOffset = 3);
bool decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, uint16_t aOneMarkMicros, bool decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset, uint16_t aOneMarkMicros,
uint16_t aZeroMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroSpaceMicros, bool aMSBfirst); uint16_t aZeroMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroSpaceMicros, bool aMSBfirst);
bool decodeBiPhaseData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, uint_fast8_t aStartClockCount, bool decodeBiPhaseData(uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset, uint_fast8_t aStartClockCount,
uint_fast8_t aValueOfSpaceToMarkTransition, uint16_t aBiphaseTimeUnit); uint_fast8_t aValueOfSpaceToMarkTransition, uint16_t aBiphaseTimeUnit);
void initBiphaselevel(uint_fast8_t aRCDecodeRawbuffOffset, uint16_t aBiphaseTimeUnit); void initBiphaselevel(uint_fast8_t aRCDecodeRawbuffOffset, uint16_t aBiphaseTimeUnit);
@ -458,11 +459,6 @@ public:
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
int_fast8_t aNumberOfRepeats); int_fast8_t aNumberOfRepeats);
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit,
uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats)
__attribute__ ((deprecated ("Since version 4.1.0 parameter aSendStopBit is not longer required.")));
void sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants *aProtocolConstants, void sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants *aProtocolConstants,
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, int_fast8_t aNumberOfRepeats); IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, int_fast8_t aNumberOfRepeats);
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, DistanceWidthTimingInfoStruct *aDistanceWidthTimingInfo, void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, DistanceWidthTimingInfoStruct *aDistanceWidthTimingInfo,
@ -484,9 +480,6 @@ public:
__attribute__ ((deprecated ("Since version 4.1.0 parameter aSendStopBit is not longer required."))); __attribute__ ((deprecated ("Since version 4.1.0 parameter aSendStopBit is not longer required.")));
void sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, void sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags); uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags);
void sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit)
__attribute__ ((deprecated ("Since version 4.1.0 last parameter aSendStopBit is not longer required.")));
void sendBiphaseData(uint16_t aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits); void sendBiphaseData(uint16_t aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits);
void mark(uint16_t aMarkMicros); void mark(uint16_t aMarkMicros);

View File

@ -23,8 +23,8 @@
* https://github.com/Arduino-IRremote/Arduino-IRremote/blob/d51b540cb2ddf1424888d2d9e6b62fe1ef46859d/examples/SendDemo/SendDemo.ino#L175 * https://github.com/Arduino-IRremote/Arduino-IRremote/blob/d51b540cb2ddf1424888d2d9e6b62fe1ef46859d/examples/SendDemo/SendDemo.ino#L175
* sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros, * sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, unsigned int aHeaderMarkMicros,
* unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros, * unsigned int aHeaderSpaceMicros, unsigned int aOneMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroMarkMicros,
* unsigned int aZeroSpaceMicros, uint32_t *aDecodedRawDataArray, unsigned int aNumberOfBits, bool aMSBFirst, * unsigned int aZeroSpaceMicros, uint32_t *aDecodedRawDataArray, unsigned int aNumberOfBits, uint8_t aFlags,
* bool aSendStopBit, unsigned int aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats) * unsigned int aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats)
* *
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote. * This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
* *
@ -163,8 +163,6 @@ bool IRrecv::decodeDistanceWidth() {
return false; return false;
} }
uint_fast8_t i;
// Reset duration array // Reset duration array
memset(tDurationArray, 0, DURATION_ARRAY_SIZE); memset(tDurationArray, 0, DURATION_ARRAY_SIZE);
@ -172,7 +170,7 @@ bool IRrecv::decodeDistanceWidth() {
/* /*
* Count number of mark durations up to 49 ticks. Skip leading start and trailing stop bit. * Count number of mark durations up to 49 ticks. Skip leading start and trailing stop bit.
*/ */
for (i = 3; i < (uint_fast8_t) decodedIRData.rawlen - 2; i += 2) { for (IRRawlenType i = 3; i < decodedIRData.rawlen - 2; i += 2) {
auto tDurationTicks = decodedIRData.rawDataPtr->rawbuf[i]; auto tDurationTicks = decodedIRData.rawDataPtr->rawbuf[i];
if (tDurationTicks < DURATION_ARRAY_SIZE) { if (tDurationTicks < DURATION_ARRAY_SIZE) {
tDurationArray[tDurationTicks]++; // count duration if less than DURATION_ARRAY_SIZE (50) tDurationArray[tDurationTicks]++; // count duration if less than DURATION_ARRAY_SIZE (50)
@ -219,7 +217,7 @@ bool IRrecv::decodeDistanceWidth() {
* Count number of space durations. Skip leading start and trailing stop bit. * Count number of space durations. Skip leading start and trailing stop bit.
*/ */
tIndexOfMaxDuration = 0; tIndexOfMaxDuration = 0;
for (i = 4; i < (uint_fast8_t) decodedIRData.rawlen - 2; i += 2) { for (IRRawlenType i = 4; i < decodedIRData.rawlen - 2; i += 2) {
auto tDurationTicks = decodedIRData.rawDataPtr->rawbuf[i]; auto tDurationTicks = decodedIRData.rawDataPtr->rawbuf[i];
if (tDurationTicks < DURATION_ARRAY_SIZE) { if (tDurationTicks < DURATION_ARRAY_SIZE) {
tDurationArray[tDurationTicks]++; tDurationArray[tDurationTicks]++;
@ -284,9 +282,12 @@ bool IRrecv::decodeDistanceWidth() {
Serial.print(F(", ")); Serial.print(F(", "));
Serial.println(tSpaceTicksShort * MICROS_PER_TICK); Serial.println(tSpaceTicksShort * MICROS_PER_TICK);
#endif #endif
uint8_t tStartIndex = 3; #if RAW_BUFFER_LENGTH <= 508
// skip leading start bit for decoding. uint_fast8_t tNumberOfBits;
uint16_t tNumberOfBits = (decodedIRData.rawlen / 2) - 1; #else
uint16_t tNumberOfBits;
#endif
tNumberOfBits = (decodedIRData.rawlen / 2) - 1;
if (tSpaceTicksLong > 0 && tMarkTicksLong == 0) { if (tSpaceTicksLong > 0 && tMarkTicksLong == 0) {
// For PULSE_DISTANCE a stop bit is mandatory, for PULSE_WIDTH it is not required! // For PULSE_DISTANCE a stop bit is mandatory, for PULSE_WIDTH it is not required!
tNumberOfBits--; // Correct for stop bit tNumberOfBits--; // Correct for stop bit
@ -320,6 +321,7 @@ bool IRrecv::decodeDistanceWidth() {
unsigned int tMarkMicrosShort = tMarkTicksShort * MICROS_PER_TICK; unsigned int tMarkMicrosShort = tMarkTicksShort * MICROS_PER_TICK;
unsigned int tMarkMicrosLong = tMarkTicksLong * MICROS_PER_TICK; unsigned int tMarkMicrosLong = tMarkTicksLong * MICROS_PER_TICK;
unsigned int tSpaceMicrosLong = tSpaceTicksLong * MICROS_PER_TICK; unsigned int tSpaceMicrosLong = tSpaceTicksLong * MICROS_PER_TICK;
IRRawlenType tStartIndex = 3; // skip leading start bit for decoding.
for (uint_fast8_t i = 0; i <= tNumberOfAdditionalArrayValues; ++i) { for (uint_fast8_t i = 0; i <= tNumberOfAdditionalArrayValues; ++i) {
uint8_t tNumberOfBitsForOneDecode = tNumberOfBits; uint8_t tNumberOfBitsForOneDecode = tNumberOfBits;