2#include "ManchesterCodec.h"
19 bool begin(uint32_t bitFrequencyHz)
override {
25 return CodecEnum::DifferentialManchester;
29 bool _lastLevelEncode =
false;
30 bool _lastLevelDecode =
false;
39 first.level = _lastLevelEncode;
40 first.pulseUs = _bitPeriodUs / 2;
41 _lastLevelEncode = !_lastLevelEncode;
42 second.level = _lastLevelEncode;
43 second.pulseUs = _bitPeriodUs / 2;
46 _lastLevelEncode = !_lastLevelEncode;
47 first.level = _lastLevelEncode;
48 first.pulseUs = _bitPeriodUs / 2;
49 _lastLevelEncode = !_lastLevelEncode;
50 second.level = _lastLevelEncode;
51 second.pulseUs = _bitPeriodUs / 2;
58 bool decodeByte(Vector<OutputEdge>& edges, uint8_t& result) {
61 uint8_t&
byte = result;
65 for (
int i = 0; i < 8; ++i) {
66 bool b0 = edges[i * 2].level;
67 bool b1 = edges[i * 2 + 1].level;
70 bool transitionAtStart = (b0 != _lastLevelDecode);
71 if (!transitionAtStart) {
72 byte |= (1 << (7 - i));
75 _lastLevelDecode = b1;
virtual void reset()
Reset the internal state of the codec.
Differential Manchester encoding/decoding utility class for IR communication.
bool begin(uint32_t bitFrequencyHz) override
initialization method for codecs that require setup before use (e.g., loading PIO programs,...
void reset() override
Reset the internal state of the codec.
bool getIdleLevel() const override
Provides the initial ldle state (low or hith)
CodecEnum getCodecType() const override
Manchester encoding/decoding utility class for IR communication.
bool begin(uint32_t bitFrequencyHz) override
initialization method for codecs that require setup before use (e.g., loading PIO programs,...
size_t getEdgeCount() const override
Get the number of edges used to encode a byte (16 for Manchester).
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.
Specifies a single IR signal segment for protocol-agnostic transmission.