|
Arduino PulseWire Transceiver Library
|
Miller (Delay Modulation) encoding/decoding utility class. More...
#include <MillerCodec.h>


Public Member Functions | |
| MillerCodec (Preamble &preamble) | |
| CodecEnum | getCodecType () const override |
| size_t | getEdgeCount () const override |
| Get the number of protocol symbols (bits, pulses, etc.) per encoded byte. | |
| int | getEndOfFrameDelayUs () override |
| bool | getIdleLevel () const override |
| Provides the initial ldle state (low or hith) | |
| void | reset () override |
| Reset the internal state of the codec. | |
| size_t | encode (uint8_t byte, Vector< OutputEdge > &output) override |
| Encode a byte using Miller encoding (byte-aligned). | |
| size_t | flushEncoder (Vector< OutputEdge > &output) override |
| Add termination edge at end of frame. | |
| bool | decodeEdge (uint32_t durationUs, bool level, uint8_t &result) override |
| Decode Miller encoding edge by edge. | |
| virtual void | init (Preamble &detector, uint32_t shortPulseUs=600, uint32_t longPulseUs=1200, uint32_t toleranceUs=200) |
| virtual bool | begin (uint32_t bitFrequencyHz) |
| initialization method for codecs that require setup before use (e.g., loading PIO programs, configuring state machines). | |
| 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. | |
| const char * | name () const |
| Get the name of the codec type as a string (e.g., "PulseDistance", "Manchester"). | |
| size_t | encodePreamble (Vector< OutputEdge > &output) |
Protected Member Functions | |
| bool | handleIdleGap (uint32_t durationUs, bool level, uint8_t &result) |
| Handle idle gap detection and end-of-frame processing. | |
| bool | handlePreamble (uint32_t durationUs, bool level) |
| Handle preamble detection. | |
| int | durationToHalfPeriods (uint32_t durationUs) |
| Convert duration to half-periods (rounded to nearest). | |
| void | decodeMiller (int hp, bool level) |
| Decode Miller half-periods into bits. | |
| void | decodeWhileExpectingMid (int hp) |
| Decode when expecting mid-transition of a '1' bit. | |
| void | decodeAtBoundary (int hp) |
| Decode when at bit boundary (not expecting mid-transition). | |
| bool | checkByteComplete (uint8_t &result) |
| Check if a complete byte has been assembled. | |
| void | pushBit (bool bit) |
| Push a decoded bit into the receive buffer. | |
| 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 | |
| bool | _encLevel = true |
| uint8_t | _rxByte = 0 |
| uint8_t | _rxBitPos = 0 |
| bool | _rxExpectingMidTransition = false |
| CustomPreambleUs | _defaultPreamble |
| Preamble * | _preamble = &_defaultPreamble |
| uint16_t | _bitFrequencyHz = 0 |
| uint32_t | _bitPeriodUs = 0 |
| Vector< OutputEdge > | _decodeEdgeStream |
| volatile bool | _inFrame = false |
| uint16_t | _frameSize = 0 |
Miller (Delay Modulation) encoding/decoding utility class.
Miller encoding rules (bit period = T):
This implementation uses BYTE-ALIGNED encoding where each byte is encoded independently. State is reset at byte boundaries to ensure clean decoding.
Definition at line 17 of file MillerCodec.h.
|
inline |
Definition at line 20 of file MillerCodec.h.
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::PulseDistanceCodec, and pulsewire::PulseWidthCodec.
Check if a complete byte has been assembled.
Definition at line 301 of file MillerCodec.h.
Decode when at bit boundary (not expecting mid-transition).
Definition at line 275 of file MillerCodec.h.
|
inlineoverridevirtual |
Decode Miller encoding edge by edge.
Handles preamble detection using the base Codec's preamble logic, then interprets edge durations in terms of half-periods (hp):
State machine tracks whether we're expecting the mid-transition of a '1'.
Implements pulsewire::Codec.
Definition at line 146 of file MillerCodec.h.
Decode Miller half-periods into bits.
Definition at line 232 of file MillerCodec.h.
Decode when expecting mid-transition of a '1' bit.
Definition at line 246 of file MillerCodec.h.
Convert duration to half-periods (rounded to nearest).
Definition at line 221 of file MillerCodec.h.
|
inlineoverridevirtual |
Encode a byte using Miller encoding (byte-aligned).
Miller encoding rules:
Each byte is encoded independently with state reset at boundaries. The encoder accumulates "pending" time at the current level and outputs edges when transitions occur.
Implements pulsewire::Codec.
Definition at line 50 of file MillerCodec.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 |
|
inlineoverridevirtual |
Add termination edge at end of frame.
Adds a 2T pulse to ensure the receiver sees a final transition and can complete decoding any pending bits before timeout.
Reimplemented from pulsewire::Codec.
Definition at line 119 of file MillerCodec.h.
|
inlineoverridevirtual |
Get the codec type (e.g., PulseDistance, Manchester) for this Codec instance.
Implements pulsewire::Codec.
Definition at line 22 of file MillerCodec.h.
|
inlineoverridevirtual |
Get the number of protocol symbols (bits, pulses, etc.) per encoded byte.
Implements pulsewire::Codec.
Definition at line 24 of file MillerCodec.h.
|
inlineoverridevirtual |
Provide the end of frame delay in microseconds for this protocol, used by RX driver to
Implements pulsewire::Codec.
Definition at line 26 of file MillerCodec.h.
|
inlineinherited |
|
inlineoverridevirtual |
Provides the initial ldle state (low or hith)
Reimplemented from pulsewire::Codec.
Definition at line 28 of file MillerCodec.h.
|
inlineinherited |
|
inlineprotected |
Handle idle gap detection and end-of-frame processing.
Definition at line 170 of file MillerCodec.h.
Handle preamble detection.
Definition at line 194 of file MillerCodec.h.
|
inlinevirtualinherited |
Used by IRTransceiver to initialize codec with protocol-specific parameters
Reimplemented in pulsewire::PulseWidthCodec, pulsewire::PulseDistanceCodec, and pulsewire::RecorderCodec.
Push a decoded bit into the receive buffer.
Shifts the bit into _rxByte from the right (MSB first order). Ignores bits if byte is already complete (overflow protection).
Definition at line 318 of file MillerCodec.h.
|
inlineoverridevirtual |
Reset the internal state of the codec.
Reimplemented from pulsewire::Codec.
Definition at line 30 of file MillerCodec.h.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Definition at line 330 of file MillerCodec.h.
|
protectedinherited |
|
protectedinherited |
|
protected |
Definition at line 334 of file MillerCodec.h.
|
protected |
Definition at line 333 of file MillerCodec.h.
Definition at line 335 of file MillerCodec.h.