|
Arduino PulseWire Transceiver Library
|
Pulse-width encoding/decoding utility class for IR communication. More...
#include <PulseWidthCodec.h>


Public Member Functions | |
| PulseWidthCodec (Preamble &detector) | |
| virtual void | init (Preamble &detector, uint32_t shortPulseUs, uint32_t longPulseUs, uint32_t toleranceUs) |
| bool | begin (uint32_t bitFrequencyHz) override |
| initialization method for codecs that require setup before use (e.g., loading PIO programs, configuring state machines). | |
| CodecEnum | getCodecType () const override |
| int | getEndOfFrameDelayUs () override |
| size_t | getEdgeCount () const override |
| Get the number of protocol symbols (bits, pulses, etc.) per encoded byte. | |
| size_t | encode (uint8_t byte, Vector< OutputEdge > &output) override |
| Fill output vector with protocol-specific OutputSpec(s) for a byte. | |
| bool | decodeEdge (uint32_t durationUs, bool level, uint8_t &result) override |
| Edge-based decoding for protocol-agnostic RX drivers. | |
| virtual void | reset () |
| Reset the internal state of the codec. | |
| void | setPreamble (Preamble &preamble) |
| Set the Preamble Detector object. | |
| Preamble & | getPreamble () |
| Get the preamble detector associated with this codec. | |
| void | setFrameSize (uint16_t size) |
| Set the Frame Size. | |
| uint16_t | getFrameSize () const |
| Get the configured frame size. | |
| virtual bool | getIdleLevel () const |
| Provides the initial ldle state (low or hith) | |
| const char * | name () const |
| Get the name of the codec type as a string (e.g., "PulseDistance", "Manchester"). | |
| size_t | encodePreamble (Vector< OutputEdge > &output) |
| virtual size_t | flushEncoder (Vector< OutputEdge > &output) |
| Flush any pending encoder state at end of frame. | |
Protected Member Functions | |
| bool | bitMatch (uint32_t duration, bool bit) const |
| size_t | encodeBit (bool bit, Vector< OutputEdge > &output) |
| Fill output vector with PulseWidth OutputSpec(s) for a bit. | |
| bool | decodeByte (Vector< OutputEdge > &edges, uint8_t &result) |
| virtual void | encodeByte (uint8_t byte, std::vector< bool > &bits) const |
| Encode a byte to protocol bitstream. Default implementation encodes to raw bits (MSB first), but can be overridden by protocols that require different bit formatting (e.g., Manchester). The output bits are stored in. | |
Protected Attributes | |
| uint32_t | _shortPulseUs = 0 |
| uint32_t | _longPulseUs = 0 |
| uint32_t | _toleranceUs = 0 |
| CustomPreambleUs | _defaultPreamble |
| Preamble * | _preamble = &_defaultPreamble |
| uint16_t | _bitFrequencyHz = 0 |
| uint32_t | _bitPeriodUs = 0 |
| Vector< OutputEdge > | _decodeEdgeStream |
| volatile bool | _inFrame = false |
| uint16_t | _frameSize = 0 |
Pulse-width encoding/decoding utility class for IR communication.
Encodes bytes using pulse-width modulation (e.g., Sony SIRC, custom protocols). Decodes pulse-width bitstreams to bytes, with frame and checksum support.
Timing parameters are configurable.
Definition at line 23 of file PulseWidthCodec.h.
|
inline |
Definition at line 27 of file PulseWidthCodec.h.
initialization method for codecs that require setup before use (e.g., loading PIO programs, configuring state machines).
Reimplemented from pulsewire::Codec.
Definition at line 38 of file PulseWidthCodec.h.
Definition at line 111 of file PulseWidthCodec.h.
|
inlineprotected |
Definition at line 135 of file PulseWidthCodec.h.
|
inlineoverridevirtual |
Edge-based decoding for protocol-agnostic RX drivers.
Called on each signal edge (duration since last edge, new level, minUs, maxUs). The codec maintains its own state and assembles frames internally.
| durationUs | Time in microseconds since last edge. |
| level | New logic level after the edge (true = HIGH, false = LOW). |
| frameBuffer | Output buffer for decoded frame (if available). |
| frameBufferSize | Size of frameBuffer (bytes). |
| frameLen | Set to decoded frame length if a frame is available. |
Implements pulsewire::Codec.
Definition at line 66 of file PulseWidthCodec.h.
|
inlineoverridevirtual |
Fill output vector with protocol-specific OutputSpec(s) for a byte.
Encodes the byte to protocol bits and appends OutputSpec(s) for each bit.
| byte | The byte to encode. |
| output | Vector to append OutputSpec(s). |
Implements pulsewire::Codec.
Definition at line 55 of file PulseWidthCodec.h.
|
inlineprotected |
Fill output vector with PulseWidth OutputSpec(s) for a bit.
| bit | The bit to encode (true/false). |
| bitPeriod | The bit period in microseconds. |
| output | Vector to append OutputSpec(s). |
Definition at line 125 of file PulseWidthCodec.h.
|
inlineprotectedvirtualinherited |
Encode a byte to protocol bitstream. Default implementation encodes to raw bits (MSB first), but can be overridden by protocols that require different bit formatting (e.g., Manchester). The output bits are stored in.
| byte | The input byte to encode. |
| bits | Output buffer for encoded bits (protocol-specific format). |
|
inlineinherited |
|
inlinevirtualinherited |
Flush any pending encoder state at end of frame.
Some codecs (e.g., Miller) accumulate pending duration that must be output at the end of the frame. This method outputs any remaining pending state. Default implementation does nothing.
| output | Vector to append OutputSpec(s). |
Reimplemented in pulsewire::MillerCodec.
|
inlineoverridevirtual |
Get the codec type (e.g., PulseDistance, Manchester) for this Codec instance.
Implements pulsewire::Codec.
Definition at line 49 of file PulseWidthCodec.h.
|
inlineoverridevirtual |
Get the number of protocol symbols (bits, pulses, etc.) per encoded byte.
Implements pulsewire::Codec.
Definition at line 53 of file PulseWidthCodec.h.
|
inlineoverridevirtual |
Provide the end of frame delay in microseconds for this protocol, used by RX driver to
Implements pulsewire::Codec.
Definition at line 51 of file PulseWidthCodec.h.
|
inlineinherited |
Provides the initial ldle state (low or hith)
Reimplemented in pulsewire::DifferentialManchesterCodec, pulsewire::MillerCodec, pulsewire::NRZCodec, and pulsewire::RZCodec.
|
inlineinherited |
|
inlinevirtual |
Used by IRTransceiver to initialize codec with protocol-specific parameters
Reimplemented from pulsewire::Codec.
Definition at line 30 of file PulseWidthCodec.h.
Reset the internal state of the codec.
Reimplemented in pulsewire::DifferentialManchesterCodec, pulsewire::MillerCodec, pulsewire::NRZCodec, and pulsewire::RZCodec.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
Definition at line 108 of file PulseWidthCodec.h.
|
protectedinherited |
|
protected |
Definition at line 107 of file PulseWidthCodec.h.
|
protected |
Definition at line 109 of file PulseWidthCodec.h.