* Sends PulseDistance frames and repeats. * @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. *
| 691 | * @param aSpecialSendRepeatFunction If nullptr, the first frame is repeated completely, otherwise this function is used for sending the repeat frame. |
| 692 | */ |
| 693 | void IRsend::sendPulseDistanceWidth(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros, |
| 694 | uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, |
| 695 | IRDecodedRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, |
| 696 | int_fast8_t aNumberOfRepeats, void (*aSpecialSendRepeatFunction)()) { |
| 697 | |
| 698 | if (aNumberOfRepeats < 0) { |
| 699 | if (aSpecialSendRepeatFunction != nullptr) { |
| 700 | aSpecialSendRepeatFunction(); |
| 701 | return; |
| 702 | } else { |
| 703 | aNumberOfRepeats = 0; // send a plain frame as repeat |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | // Set IR carrier frequency |
| 708 | enableIROut(aFrequencyKHz); |
| 709 | |
| 710 | uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; |
| 711 | while (tNumberOfCommands > 0) { |
| 712 | unsigned long tStartOfFrameMillis = millis(); |
| 713 | |
| 714 | if (tNumberOfCommands < ((uint_fast8_t) aNumberOfRepeats + 1) && aSpecialSendRepeatFunction != nullptr) { |
| 715 | // send special repeat |
| 716 | aSpecialSendRepeatFunction(); |
| 717 | } else { |
| 718 | // Header and regular frame |
| 719 | mark(aHeaderMarkMicros); |
| 720 | space(aHeaderSpaceMicros); |
| 721 | sendPulseDistanceWidthData(aOneMarkMicros, aOneSpaceMicros, aZeroMarkMicros, aZeroSpaceMicros, aData, aNumberOfBits, |
| 722 | aFlags); |
| 723 | } |
| 724 | |
| 725 | tNumberOfCommands--; |
| 726 | // skip last delay! |
| 727 | if (tNumberOfCommands > 0) { |
| 728 | /* |
| 729 | * Check and fallback for wrong RepeatPeriodMillis parameter. I.e the repeat period must be greater than each frame duration. |
| 730 | */ |
| 731 | auto tFrameDurationMillis = millis() - tStartOfFrameMillis; |
| 732 | if (aRepeatPeriodMillis > tFrameDurationMillis) { |
| 733 | delay(aRepeatPeriodMillis - tFrameDurationMillis); |
| 734 | } |
| 735 | } |
| 736 | } |
| 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, |
nothing calls this directly
no outgoing calls
no test coverage detected