Skip to content

Commit b962db8

Browse files
committed
Bumped version to 4.3.1. Fixed overflow bug for rawlen > 254. Removed deprecated sendPulseDistance... functions with parameter aSendStopBit.
1 parent 59f4ce4 commit b962db8

File tree

10 files changed

+58
-110
lines changed

10 files changed

+58
-110
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
The latest version may not be released!
33
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
44

5+
# 4.3.1
6+
- Fixed overflow bug for rawlen > 254.
7+
- Removed deprecated sendPulseDistance... functions with parameter aSendStopBit.
8+
59
# 4.3.0
610
- Removed default value USE_DEFAULT_FEEDBACK_LED_PIN for last parameter of IRsend::begin(bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin).
711
Therefore IrSender.begin(DISABLE_LED_FEEDBACK) will not longer work!

examples/AllProtocolsOnLCD/AllProtocolsOnLCD.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ void loop() {
241241
) {
242242
// 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
243243
IrReceiver.printIRSendUsage(&Serial);
244-
IrReceiver.printIRResultRawFormatted(&Serial, false); // print ticks, this is faster :-)
244+
// IrReceiver.printIRResultRawFormatted(&Serial, false); // print ticks, this is faster :-)
245+
IrReceiver.printIRResultRawFormatted(&Serial); // print us, this is better to compare :-)
245246
}
246247

247248
// Guarantee at least 5 millis for tone. decode starts 5 millis (RECORD_GAP_MICROS) after end of frame

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "git",
88
"url": "https://github.com/z3t0/Arduino-IRremote.git"
99
},
10-
"version": "4.3.0",
10+
"version": "4.3.1",
1111
"frameworks": "arduino",
1212
"platforms": ["atmelavr", "atmelmegaavr", "atmelsam", "espressif8266", "espressif32", "ststm32"],
1313
"authors" :

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=IRremote
2-
version=4.3.0
2+
version=4.3.1
33
author=shirriff, z3t0, ArminJo
44
maintainer=Armin Joachimsmeyer <[email protected]>
55
sentence=Send and receive infrared signals with multiple protocols

src/IRProtocol.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ struct IRData {
119119
uint8_t flags; ///< IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above
120120

121121
// These 2 variables allow to call resume() directly after decode, if no dump is required. Since 4.3.0.
122-
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
123-
uint_fast8_t rawlen; ///< counter of entries in rawbuf
124-
#else
125-
uint_fast16_t rawlen; ///< counter of entries in rawbuf
126-
#endif
122+
IRRawlenType rawlen; ///< counter of entries in rawbuf
127123
uint16_t initialGap; ///< rawbuf[0] contains the initial gap of the last frame.
128124

129125
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 {
141137
/*
142138
* Definitions for member PulseDistanceWidthProtocolConstants.Flags
143139
*/
144-
#define SUPPRESS_STOP_BIT_FOR_THIS_DATA 0x20
140+
#define SUPPRESS_STOP_BIT_FOR_THIS_DATA 0x20 // Stop bit is otherwise sent for all pulse distance protocols.
145141
#define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST
146142
#define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST
147-
// 2 definitions for deprecated parameter bool aSendStopBit
148-
#define SEND_STOP_BIT true
149-
#define SEND_NO_STOP_BIT false
150143

151144
/*
152145
* Carrier frequencies for various protocols

src/IRReceive.hpp

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ bool IRrecv::decode() {
700700
* @param aMSBfirst If true send Most Significant Bit first, else send Least Significant Bit (lowest bit) first.
701701
* @return true If decoding was successful
702702
*/
703-
bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, uint16_t aOneMarkMicros,
703+
bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset, uint16_t aOneMarkMicros,
704704
uint16_t aZeroMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroSpaceMicros, bool aMSBfirst) {
705705

706706
auto *tRawBufPointer = &decodedIRData.rawDataPtr->rawbuf[aStartOffset];
@@ -843,7 +843,7 @@ bool IRrecv::decodePulseDistanceWidthData(uint_fast8_t aNumberOfBits, uint_fast8
843843
* @return true if decoding was successful
844844
*/
845845
bool IRrecv::decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits,
846-
uint_fast8_t aStartOffset) {
846+
IRRawlenType aStartOffset) {
847847

848848
return decodePulseDistanceWidthData(aNumberOfBits, aStartOffset, aProtocolConstants->DistanceWidthTimingInfo.OneMarkMicros,
849849
aProtocolConstants->DistanceWidthTimingInfo.ZeroMarkMicros, aProtocolConstants->DistanceWidthTimingInfo.OneSpaceMicros,
@@ -967,12 +967,7 @@ bool IRrecv::decodeHash() {
967967
if (decodedIRData.rawlen < 6) {
968968
return false;
969969
}
970-
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
971-
uint_fast8_t i;
972-
#else
973-
unsigned int i;
974-
#endif
975-
for (i = 1; (i + 2) < decodedIRData.rawlen; i++) {
970+
for (IRRawlenType i = 1; (i + 2) < decodedIRData.rawlen; i++) {
976971
// Compare mark with mark and space with space
977972
uint_fast8_t value = compare(decodedIRData.rawDataPtr->rawbuf[i], decodedIRData.rawDataPtr->rawbuf[i + 2]);
978973
// Add value into the hash
@@ -1281,12 +1276,8 @@ void IRrecv::printDistanceWidthTimingInfo(Print *aSerial, DistanceWidthTimingInf
12811276

12821277
uint32_t IRrecv::getTotalDurationOfRawData() {
12831278
uint16_t tSumOfDurationTicks = 0;
1284-
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
1285-
uint_fast8_t i;
1286-
#else
1287-
unsigned int i;
1288-
#endif
1289-
for (i = 1; i < decodedIRData.rawlen; i++) {
1279+
1280+
for (IRRawlenType i = 1; i < decodedIRData.rawlen; i++) {
12901281
tSumOfDurationTicks += decodedIRData.rawDataPtr->rawbuf[i];
12911282
}
12921283
return tSumOfDurationTicks * (uint32_t) MICROS_PER_TICK;
@@ -1492,11 +1483,6 @@ void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsI
14921483
} else {
14931484
aSerial->println(decodedIRData.initialGap, DEC);
14941485
}
1495-
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
1496-
uint_fast8_t i;
1497-
#else
1498-
unsigned int i;
1499-
#endif
15001486

15011487
// Newline is printed every 8. value, if tCounterForNewline % 8 == 0
15021488
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
15171503

15181504
uint32_t tDuration;
15191505
uint16_t tSumOfDurationTicks = 0;
1520-
for (i = 1; i < decodedIRData.rawlen; i++) {
1506+
for (IRRawlenType i = 1; i < decodedIRData.rawlen; i++) {
15211507
auto tCurrentTicks = decodedIRData.rawDataPtr->rawbuf[i];
15221508
if (aOutputMicrosecondsInsteadOfTicks) {
15231509
tDuration = tCurrentTicks * MICROS_PER_TICK;
@@ -1586,12 +1572,7 @@ void IRrecv::compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicr
15861572
aSerial->print(F("] = {")); // Start declaration
15871573

15881574
// Dump data
1589-
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
1590-
uint_fast8_t i;
1591-
#else
1592-
unsigned int i;
1593-
#endif
1594-
for (i = 1; i < decodedIRData.rawlen; i++) {
1575+
for (IRRawlenType i = 1; i < decodedIRData.rawlen; i++) {
15951576
uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK;
15961577

15971578
if (i & 1) {
@@ -1638,11 +1619,7 @@ void IRrecv::compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicr
16381619
void IRrecv::compensateAndStoreIRResultInArray(uint8_t *aArrayPtr) {
16391620

16401621
// Store data, skip leading space#
1641-
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
1642-
uint_fast8_t i;
1643-
#else
1644-
unsigned int i;
1645-
#endif
1622+
IRRawlenType i;
16461623
for (i = 1; i < decodedIRData.rawlen; i++) {
16471624
uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK;
16481625
if (i & 1) {

src/IRSend.hpp

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -521,21 +521,8 @@ void IRsend::sendRaw_P(const uint8_t aBufferWithTicks[], uint_fast16_t aLengthOf
521521
* 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.
522522
* The output always ends with a space
523523
* Stop bit is always sent
524+
* @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.
524525
*/
525-
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
526-
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
527-
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit,
528-
uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats) {
529-
uint8_t tFlags = 0;
530-
if (aMSBFirst) {
531-
tFlags = PROTOCOL_IS_MSB_FIRST;
532-
}
533-
(void) aSendStopBit;
534-
535-
sendPulseDistanceWidthFromArray(aFrequencyKHz, aHeaderMarkMicros, aHeaderSpaceMicros, aOneMarkMicros, aOneSpaceMicros,
536-
aZeroMarkMicros, aZeroSpaceMicros, aDecodedRawDataArray, aNumberOfBits, tFlags, aRepeatPeriodMillis, aNumberOfRepeats);
537-
}
538-
539526
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, DistanceWidthTimingInfoStruct *aDistanceWidthTimingInfo,
540527
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
541528
int_fast8_t aNumberOfRepeats) {
@@ -545,7 +532,6 @@ void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, Distanc
545532
aDistanceWidthTimingInfo->ZeroSpaceMicros, aDecodedRawDataArray, aNumberOfBits, aFlags, aRepeatPeriodMillis,
546533
aNumberOfRepeats);
547534
}
548-
549535
void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
550536
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros,
551537
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis,
@@ -616,6 +602,9 @@ void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_
616602
* 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.
617603
* The output always ends with a space
618604
* Stop bit is always sent
605+
* @param aNumberOfBits Number of bits from aDecodedRawDataArray to be actually sent.
606+
* @param aNumberOfRepeats If < 0 and a aProtocolConstants->SpecialSendRepeatFunction() is specified
607+
* then it is called without leading and trailing space.
619608
*/
620609
void IRsend::sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants *aProtocolConstants,
621610
IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, int_fast8_t aNumberOfRepeats) {
@@ -692,7 +681,7 @@ void IRsend::sendPulseDistanceWidthFromArray(PulseDistanceWidthProtocolConstants
692681
}
693682

694683
/**
695-
* Sends PulseDistance frames and repeats and enables receiver again
684+
* Sends PulseDistance frames and repeats
696685
* @param aProtocolConstants The constants to use for sending this protocol.
697686
* @param aData uint32 or uint64 holding the bits to be sent.
698687
* @param aNumberOfBits Number of bits from aData to be actually sent.
@@ -761,23 +750,11 @@ void IRsend::sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtoc
761750
* @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.
762751
* @param aData uint32 or uint64 holding the bits to be sent.
763752
* @param aNumberOfBits Number of bits from aData to be actually sent.
753+
* @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.
764754
* @param aNumberOfRepeats If < 0 and a aProtocolConstants->SpecialSendRepeatFunction() is specified
765755
* then it is called without leading and trailing space.
766756
* @param aSpecialSendRepeatFunction If NULL, the first frame is repeated completely, otherwise this function is used for sending the repeat frame.
767757
*/
768-
void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
769-
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, IRRawDataType aData,
770-
uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit, uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats,
771-
void (*aSpecialSendRepeatFunction)()) {
772-
uint8_t tFlags = 0;
773-
if (aMSBFirst) {
774-
tFlags = PROTOCOL_IS_MSB_FIRST;
775-
}
776-
(void) aSendStopBit;
777-
sendPulseDistanceWidth(aFrequencyKHz, aHeaderMarkMicros, aHeaderSpaceMicros, aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros,
778-
aZeroSpaceMicros, aData, aNumberOfBits, tFlags, aRepeatPeriodMillis, aNumberOfRepeats, aSpecialSendRepeatFunction);
779-
780-
}
781758
void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros,
782759
uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, IRRawDataType aData,
783760
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
825802
}
826803

827804
/**
828-
* Sends PulseDistance data
805+
* Sends PulseDistance from data contained in parameter using ProtocolConstants structure for timing etc.
829806
* The output always ends with a space
830807
* Each additional call costs 16 bytes program memory
808+
* @param aProtocolConstants The constants to use for sending this protocol.
809+
* @param aData uint32 or uint64 holding the bits to be sent.
810+
* @param aNumberOfBits Number of bits from aData to be actually sent.
831811
*/
832812
void IRsend::sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData,
833813
uint_fast8_t aNumberOfBits) {
@@ -838,18 +818,13 @@ void IRsend::sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aPr
838818
}
839819

840820
/**
841-
* Sends PulseDistance data
821+
* Sends PulseDistance data with timing parameters and flag parameters.
842822
* The output always ends with a space
823+
* @param aOneMarkMicros Timing for sending this protocol.
824+
* @param aData uint32 or uint64 holding the bits to be sent.
825+
* @param aNumberOfBits Number of bits from aData to be actually sent.
826+
* @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.
843827
*/
844-
void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
845-
uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, bool aMSBFirst, bool aSendStopBit) {
846-
uint8_t tFlags = 0;
847-
if (aMSBFirst) {
848-
tFlags = PROTOCOL_IS_MSB_FIRST;
849-
}
850-
(void) aSendStopBit;
851-
sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aData, aNumberOfBits, tFlags);
852-
}
853828
void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
854829
uint16_t aZeroSpaceMicros, IRRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags) {
855830

@@ -885,6 +860,7 @@ void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSp
885860
/*
886861
* Stop bit is sent for all pulse distance protocols i.e. aOneMarkMicros == aZeroMarkMicros.
887862
* Therefore it is not sent for Sony and Magiquest :-)
863+
* For sending from an array, no intermediate stop bit must be sent for first data chunk.
888864
*/
889865
if (!(aFlags & SUPPRESS_STOP_BIT_FOR_THIS_DATA) && aOneMarkMicros == aZeroMarkMicros) {
890866
// Send stop bit here
@@ -905,6 +881,8 @@ void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSp
905881
* 1 -> space+mark
906882
* The output always ends with a space
907883
* can only send 31 bit data, since we put the start bit as 32th bit on front
884+
* @param aData uint32 or uint64 holding the bits to be sent.
885+
* @param aNumberOfBits Number of bits from aData to be actually sent.
908886
*/
909887
void IRsend::sendBiphaseData(uint16_t aBiphaseTimeUnit, uint32_t aData, uint_fast8_t aNumberOfBits) {
910888

src/IRVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
#ifndef _IR_VERSION_HPP
3737
#define _IR_VERSION_HPP
3838

39-
#define VERSION_IRREMOTE "4.3.0"
39+
#define VERSION_IRREMOTE "4.3.1"
4040
#define VERSION_IRREMOTE_MAJOR 4
4141
#define VERSION_IRREMOTE_MINOR 3
42-
#define VERSION_IRREMOTE_PATCH 0
42+
#define VERSION_IRREMOTE_PATCH 1
4343

4444
/*
4545
* Macro to convert 3 version parts into an integer

0 commit comments

Comments
 (0)