|
Arduino PulseWire Transceiver Library
|
Abstract base class for IR protocol encoding and decoding. More...
#include <Codec.h>


Public Member Functions | |
| Codec (Preamble &preambleDetector) | |
| virtual void | init (Preamble &detector, uint32_t shortPulseUs=600, uint32_t longPulseUs=1200, uint32_t toleranceUs=200) |
| virtual bool | begin (uint16_t bitFrequencyHz) |
| initialization method for codecs that require setup before use (e.g., loading PIO programs, configuring state machines). | |
| virtual void | reset () |
| Preamble & | getPreamble () |
| Get the preamble detector associated with this codec. | |
| void | setPreamble (Preamble &preamble) |
| Set the Preamble Detector object. | |
| virtual size_t | getEdgeCount () const =0 |
| Get the number of protocol symbols (bits, pulses, etc.) per encoded byte. | |
| virtual bool | decodeEdge (uint32_t durationUs, bool level, uint8_t &result) |
| Edge-based decoding for protocol-agnostic RX drivers. | |
| size_t | encodePreamble (Vector< OutputEdge > &output) |
| virtual size_t | encode (uint8_t byte, Vector< OutputEdge > &output) |
| Fill output vector with protocol-specific OutputSpec(s) for a byte. | |
| void | setFrameSize (uint16_t size) |
| virtual size_t | encodeBit (bool bit, Vector< OutputEdge > &output) |
| Fill output vector with protocol-specific OutputSpec(s) for a bit. | |
| 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. | |
| virtual bool | decodeByte (Vector< OutputEdge > &edges, uint8_t &result)=0 |
| Decode edges into a byte. | |
| virtual int | getEndOfFrameDelayUs ()=0 |
| Provide the end of frame delay in microseconds for this protocol, used by RX driver to. | |
| virtual bool | getIdleLevel () const |
| Provides the initial ldle state (low or hith) | |
| virtual CodecEnum | getCodecType () const =0 |
| instance. | |
| const char * | name () const |
| Get the name of the codec type as a string (e.g., "PulseDistance", "Manchester"). | |
Protected Attributes | |
| CustomPreambleUs | _defaultPreamble |
| Preamble * | _preamble = &_defaultPreamble |
| uint16_t | _bitFrequencyHz = 0 |
| uint32_t | _bitPeriodUs = 0 |
| Vector< OutputEdge > | _decodeEdgeStream |
| volatile bool | _inFrame = false |
Abstract base class for IR protocol encoding and decoding.
Provides a unified interface for encoding bytes to protocol-specific bitstreams, edge-based decoding for protocol-agnostic drivers, and protocol symbol count. Derived classes implement protocol-specific logic (e.g., Manchester, pulse-distance).
|
inline |
initialization method for codecs that require setup before use (e.g., loading PIO programs, configuring state machines).
Reimplemented in pulsewire::RecorderCodec, pulsewire::DifferentialManchesterCodec, pulsewire::ManchesterCodec, pulsewire::NRZCodec, pulsewire::PulseDistanceCodec, and pulsewire::PulseWidthCodec.
|
pure virtual |
Decode edges into a byte.
Implemented in pulsewire::DifferentialManchesterCodec, pulsewire::ManchesterCodec, pulsewire::NRZCodec, pulsewire::PulseDistanceCodec, pulsewire::PulseWidthCodec, and pulsewire::RecorderCodec.
|
inlinevirtual |
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. |
Reimplemented in pulsewire::ManchesterCodec, pulsewire::NRZCodec, and pulsewire::RecorderCodec.
|
inlinevirtual |
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). |
Reimplemented in pulsewire::NRZCodec.
|
inlinevirtual |
Fill output vector with protocol-specific OutputSpec(s) for a bit.
| bit | The bit to encode (true/false). |
| output | Vector to append OutputSpec(s). |
Reimplemented in pulsewire::RecorderCodec, pulsewire::DifferentialManchesterCodec, pulsewire::ManchesterCodec, pulsewire::PulseDistanceCodec, and pulsewire::PulseWidthCodec.
|
inlinevirtual |
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). |
Reimplemented in pulsewire::RecorderCodec.
|
inline |
|
pure virtual |
instance.
Get the codec type (e.g., PulseDistance, Manchester) for this Codec
Implemented in pulsewire::DifferentialManchesterCodec, pulsewire::ManchesterCodec, pulsewire::NRZCodec, pulsewire::PulseDistanceCodec, pulsewire::PulseWidthCodec, and pulsewire::RecorderCodec.
Get the number of protocol symbols (bits, pulses, etc.) per encoded byte.
Implemented in pulsewire::RecorderCodec, pulsewire::ManchesterCodec, pulsewire::NRZCodec, pulsewire::PulseDistanceCodec, and pulsewire::PulseWidthCodec.
Provide the end of frame delay in microseconds for this protocol, used by RX driver to.
Implemented in pulsewire::ManchesterCodec, pulsewire::NRZCodec, pulsewire::PulseDistanceCodec, pulsewire::PulseWidthCodec, and pulsewire::RecorderCodec.
Provides the initial ldle state (low or hith)
Reimplemented in pulsewire::DifferentialManchesterCodec.
|
inline |
|
inlinevirtual |
Used by IRTransceiver to initialize codec with protocol-specific parameters
Reimplemented in pulsewire::PulseWidthCodec, pulsewire::PulseDistanceCodec, and pulsewire::RecorderCodec.
|
protected |
|
protected |
|
protected |