| 802 | } |
| 803 | |
| 804 | void IRsend::sendPulseDistanceWidthFromPGMArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros, |
| 805 | uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, |
| 806 | IRDecodedRawDataType const *aDecodedRawDataPGMArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, |
| 807 | int_fast8_t aNumberOfRepeats) { |
| 808 | |
| 809 | // Set IR carrier frequency |
| 810 | enableIROut(aFrequencyKHz); |
| 811 | |
| 812 | uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; |
| 813 | uint_fast8_t tNumberOf32Or64BitChunks = ((aNumberOfBits - 1) / BITS_IN_DECODED_RAW_DATA_TYPE) + 1; |
| 814 | |
| 815 | #if defined(LOCAL_DEBUG) |
| 816 | // fist data |
| 817 | Serial.print(F("Data[0]=0x")); |
| 818 | Serial.print(aDecodedRawDataPGMArray[0], HEX); |
| 819 | if (tNumberOf32Or64BitChunks > 1) { |
| 820 | Serial.print(F(" Data[1]=0x")); |
| 821 | Serial.print(aDecodedRawDataPGMArray[1], HEX); |
| 822 | } |
| 823 | Serial.print(F(" #=")); |
| 824 | Serial.println(aNumberOfBits); |
| 825 | Serial.flush(); |
| 826 | #endif |
| 827 | |
| 828 | while (tNumberOfCommands > 0) { |
| 829 | unsigned long tStartOfFrameMillis = millis(); |
| 830 | |
| 831 | // Header |
| 832 | mark(aHeaderMarkMicros); |
| 833 | space(aHeaderSpaceMicros); |
| 834 | |
| 835 | for (uint_fast8_t i = 0; i < tNumberOf32Or64BitChunks; ++i) { |
| 836 | uint8_t tNumberOfBitsForOneSend; |
| 837 | |
| 838 | // Manage stop bit |
| 839 | uint8_t tFlags; |
| 840 | if (i == (tNumberOf32Or64BitChunks - 1)) { |
| 841 | // End of data |
| 842 | tNumberOfBitsForOneSend = aNumberOfBits; |
| 843 | tFlags = aFlags; |
| 844 | } else { |
| 845 | // intermediate data |
| 846 | tNumberOfBitsForOneSend = BITS_IN_DECODED_RAW_DATA_TYPE; |
| 847 | tFlags = aFlags | SUPPRESS_STOP_BIT; // No stop bit for leading data |
| 848 | } |
| 849 | |
| 850 | IRDecodedRawDataType tDecodedRawData; |
| 851 | #if (__INT_WIDTH__ < 32) |
| 852 | tDecodedRawData = pgm_read_dword(&aDecodedRawDataPGMArray[i]); // pgm_read_dword reads 32 bit on AVR |
| 853 | #else |
| 854 | tDecodedRawData = aDecodedRawDataPGMArray[i]; // assume non Harvard architecture here |
| 855 | #endif |
| 856 | sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, tDecodedRawData, |
| 857 | tNumberOfBitsForOneSend, tFlags); |
| 858 | aNumberOfBits -= BITS_IN_DECODED_RAW_DATA_TYPE; |
| 859 | } |
| 860 | |
| 861 | tNumberOfCommands--; |
nothing calls this directly
no outgoing calls
no test coverage detected