2#include "ManchesterCodec.h"
19 bool begin(uint32_t bitFrequencyHz)
override {
25 return CodecEnum::DifferentialManchester;
36 first.level = _lastLevelEncode;
37 first.pulseUs = _bitPeriodUs / 2;
38 _lastLevelEncode = !_lastLevelEncode;
39 second.level = _lastLevelEncode;
40 second.pulseUs = _bitPeriodUs / 2;
43 _lastLevelEncode = !_lastLevelEncode;
44 first.level = _lastLevelEncode;
45 first.pulseUs = _bitPeriodUs / 2;
46 _lastLevelEncode = !_lastLevelEncode;
47 second.level = _lastLevelEncode;
48 second.pulseUs = _bitPeriodUs / 2;
58 uint8_t&
byte = result;
62 for (
int i = 0; i < 8; ++i) {
63 bool b0 = edges[i * 2].level;
64 bool b1 = edges[i * 2 + 1].level;
67 bool transitionAtStart = (b0 != _lastLevelDecode);
68 if (!transitionAtStart) {
69 byte |= (1 << (7 - i));
72 _lastLevelDecode = b1;
78 void reset()
override {
79 ManchesterCodec::reset();
89 bool _lastLevelEncode =
false;
90 bool _lastLevelDecode =
false;
Differential Manchester encoding/decoding utility class for IR communication.
size_t encodeBit(bool bit, Vector< OutputEdge > &output) override
Fill output vector with protocol-specific OutputSpec(s) for a bit.
bool getIdleLevel() const override
Provides the initial ldle state (low or hith)
bool decodeByte(Vector< OutputEdge > &edges, uint8_t &result) override
Decode edges into a byte.
CodecEnum getCodecType() const override
instance.
bool begin(uint32_t bitFrequencyHz) override
initialization method for codecs that require setup before use (e.g., loading PIO programs,...
Manchester encoding/decoding utility class for IR communication.
size_t getEdgeCount() const override
Get the number of edges used to encode a byte (16 for Manchester).
bool begin(uint32_t bitFrequencyHz) override
initialization method for codecs that require setup before use (e.g., loading PIO programs,...
Abstract base class for preamble detection and generation.
Small, header-only vector replacement for non-STL environments.
void push_back(const T &value)
Add element to end of vector.
size_t size() const
Number of elements in vector.
Specifies a single IR signal segment for protocol-agnostic transmission.