6#include "pulse/Codec.h"
7#include "pulse/TxDriverCommon.h"
8#include "pulse/TxProtocol.h"
9#include "pulse/Vector.h"
21 void setFrameSize(
uint16_t size)
override {
30 if (!_codec->
begin()) {
39 offset = pio.add_program(ir_tx_pio_program);
47 bool pin_ok = pio.set_pin_direction(_txPin,
true);
48 bool sm_ok = pio.set_sm_config(sm, offset, _txPin);
57 void sendPreamble()
override {
58 if (is_frame_closed) {
62 is_frame_closed =
false;
82 if (is_frame_closed)
return;
95 is_frame_closed =
true;
98 bool isFrameClosed()
const override {
return is_frame_closed; }
101 Codec* _codec =
nullptr;
106 bool is_frame_closed =
true;
113 pio.sm_set_enabled(sm,
true);
140 static const char* ir_tx_pio_program;
143const char* TxProtocolRP2040::ir_tx_pio_program = R
"(
158 nop [carrier_half_period]
160 nop [carrier_half_period]
184 if (!protocol.begin(&codec, pin)) {
194 void sendPreamble() { protocol.sendPreamble(); }
197 protocol.sendData(data,
len, _bitPeriod);
200 void sendEnd() { protocol.sendEnd(_useChecksum,
true, _bitPeriod); }
Abstract base class for IR protocol encoding and decoding.
virtual size_t encode(uint8_t byte, Vector< OutputEdge > &output)
Fill output vector with protocol-specific OutputSpec(s) for a byte.
virtual bool begin(uint32_t bitFrequencyHz)
initialization method for codecs that require setup before use (e.g., loading PIO programs,...
Preamble & getPreamble()
Get the preamble detector associated with this codec.
static void error(const char *format,...)
Log an error message with formatting.
virtual int getEdges(pulsewire::Vector< pulsewire::OutputEdge > &output) const =0
Returns the expected preamble edges for this protocol.
Provides common logic for transmitting signals using various framing modes.
RP2040-specific TxDriver implementation that uses TxProtocolRP2040 for transmission.
RP2040-specific TxProtocol implementation using PIO and DMA for precise timing.
Abstract base class for defining transmission protocols.
Small, header-only vector replacement for non-STL environments.
void resize(size_t n)
Resize vector to n elements.
void clear()
Remove all elements.
void push_back(const T &value)
Add element to end of vector.
T * data()
Pointer to underlying data.
size_t size() const
Number of elements in vector.
Specifies a single IR signal segment for protocol-agnostic transmission.