MCPcopy Create free account
hub / github.com/Arduino-IRremote/Arduino-IRremote / sendPulseDistanceWidthData

Method sendPulseDistanceWidthData

src/IRSend.hpp:611–648  ·  view source on GitHub ↗

* Core send function **********************************************************************************************************************/ * Sends PulseDistance data with timing parameters and flag parameters. * 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 aN

Source from the content-addressed store, hash-verified

609 * @param aFlags Evaluated flags are PROTOCOL_IS_MSB_FIRST and SUPPRESS_STOP_BIT. Stop bit is otherwise sent for all pulse distance protocols.
610 */
611void IRsend::sendPulseDistanceWidthData(uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros,
612 uint16_t aZeroSpaceMicros, IRDecodedRawDataType aData, uint_fast8_t aNumberOfBits, uint8_t aFlags) {
613
614 DEBUG_PRINT(aData, HEX);
615 DEBUG_PRINT('|');
616 DEBUG_PRINTLN(aNumberOfBits);
617 DEBUG_FLUSH();
618
619 // For MSBFirst, send data from MSB to LSB until mask bit is shifted out
620 IRDecodedRawDataType tMask = 1ULL << (aNumberOfBits - 1);
621 for (uint_fast8_t i = aNumberOfBits; i > 0; i--) {
622 if (((aFlags & PROTOCOL_IS_MSB_MASK) && (aData & tMask)) || (!(aFlags & PROTOCOL_IS_MSB_MASK) && (aData & 1))) {
623 TRACE_PRINT('1');
624 mark(aOneMarkMicros);
625 space(aOneSpaceMicros);
626 } else {
627 TRACE_PRINT('0');
628 mark(aZeroMarkMicros);
629 space(aZeroSpaceMicros);
630 }
631 if (aFlags & PROTOCOL_IS_MSB_MASK) {
632 tMask >>= 1;
633 } else {
634 aData >>= 1;
635 }
636 }
637 /*
638 * Stop bit is sent for all pulse distance protocols i.e. aOneSpaceMicros != aZeroSpaceMicros.
639 * Therefore it is not sent for Sony :-)
640 * For sending from an array, no intermediate stop bit must be sent for all but last data chunk.
641 */
642 if ((!(aFlags & SUPPRESS_STOP_BIT)) && (uintDifferenceAbs(aOneSpaceMicros, aZeroSpaceMicros) > (aOneSpaceMicros / 4))) {
643 // Send stop bit here
644 TRACE_PRINT('S');
645 mark(aOneMarkMicros); // Use aOneMarkMicros for stop bits. This seems to be correct for all protocols :-)
646 }
647 TRACE_PRINTLN();
648}
649
650/**********************************************************************************************************************
651 * Stubs for core send function with PulseDistanceWidthProtocolConstants parameter

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected