| 737 | } |
| 738 | |
| 739 | void IRsend::sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros, |
| 740 | uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, |
| 741 | IRDecodedRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, |
| 742 | int_fast8_t aNumberOfRepeats) { |
| 743 | |
| 744 | // Set IR carrier frequency |
| 745 | enableIROut(aFrequencyKHz); |
| 746 | |
| 747 | uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; |
| 748 | uint_fast8_t tNumberOf32Or64BitChunks = ((aNumberOfBits - 1) / BITS_IN_DECODED_RAW_DATA_TYPE) + 1; |
| 749 | |
| 750 | #if defined(LOCAL_DEBUG) |
| 751 | // fist data |
| 752 | Serial.print(F("Data[0]=0x")); |
| 753 | Serial.print(aDecodedRawDataArray[0], HEX); |
| 754 | if (tNumberOf32Or64BitChunks > 1) { |
| 755 | Serial.print(F(" Data[1]=0x")); |
| 756 | Serial.print(aDecodedRawDataArray[1], HEX); |
| 757 | } |
| 758 | Serial.print(F(" #=")); |
| 759 | Serial.println(aNumberOfBits); |
| 760 | Serial.flush(); |
| 761 | #endif |
| 762 | |
| 763 | while (tNumberOfCommands > 0) { |
| 764 | unsigned long tStartOfFrameMillis = millis(); |
| 765 | |
| 766 | // Header |
| 767 | mark(aHeaderMarkMicros); |
| 768 | space(aHeaderSpaceMicros); |
| 769 | |
| 770 | for (uint_fast8_t i = 0; i < tNumberOf32Or64BitChunks; ++i) { |
| 771 | uint8_t tNumberOfBitsForOneSend; |
| 772 | |
| 773 | // Manage stop bit |
| 774 | uint8_t tFlags; |
| 775 | if (i == (tNumberOf32Or64BitChunks - 1)) { |
| 776 | // End of data |
| 777 | tNumberOfBitsForOneSend = aNumberOfBits; |
| 778 | tFlags = aFlags; |
| 779 | } else { |
| 780 | // intermediate data |
| 781 | tNumberOfBitsForOneSend = BITS_IN_DECODED_RAW_DATA_TYPE; |
| 782 | tFlags = aFlags | SUPPRESS_STOP_BIT; // No stop bit for leading data |
| 783 | } |
| 784 | |
| 785 | sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aDecodedRawDataArray[i], |
| 786 | tNumberOfBitsForOneSend, tFlags); |
| 787 | aNumberOfBits -= BITS_IN_DECODED_RAW_DATA_TYPE; |
| 788 | } |
| 789 | |
| 790 | tNumberOfCommands--; |
| 791 | // skip last delay! |
| 792 | if (tNumberOfCommands > 0) { |
| 793 | /* |
| 794 | * Check and fallback for wrong RepeatPeriodMillis parameter. I.e the repeat period must be greater than each frame duration. |
| 795 | */ |
| 796 | auto tFrameDurationMillis = millis() - tStartOfFrameMillis; |
nothing calls this directly
no outgoing calls
no test coverage detected