Arduino PulseWire Transceiver Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes
pulsewire::IRMultiProtocol Class Reference

IRMultiProtocol: Handles detection and delegation for multiple IR protocols. More...

#include <IRProtocol.h>

Inheritance diagram for pulsewire::IRMultiProtocol:
Inheritance graph
[legend]
Collaboration diagram for pulsewire::IRMultiProtocol:
Collaboration graph
[legend]

Public Member Functions

 IRMultiProtocol (IRProtocol &defaultInfo)
 
IRProtocolEnum getProtocolID () const override
 Returns the protocol enum identifier for this IR protocol.
 
int getEdges (Vector< OutputEdge > &output) const override
 Returns the preamble edges for this protocol.
 
size_t preambleLength () const override
 Returns the number of edges in the preamble.
 
uint32_t frequency () const
 Returns the carrier frequency in Hz.
 
size_t dataLength () const
 Returns the expected data length in bytes (not including preamble)
 
uint32_t shortPulseUs () const
 Returns the duration of the short pulse in microseconds.
 
uint32_t longPulseUs () const
 Returns the duration of the long pulse in microseconds.
 
uint32_t toleranceUs () const
 Tolerance in microseconds for pulse duration matching during detection.
 
void copyFrom (const IRProtocol &other)
 
void begin (IRProtocolEnum proto, uint32_t frequency, size_t dataLength, uint32_t shortPulse, uint32_t longPulse, uint32_t tolerance, Vector< OutputEdge > edges)
 
bool detect (const OutputEdge &edge) override
 Detects if the incoming edge matches the expected preamble pattern.
 
void setCallback (void(*callback)(IRProtocolEnum, IRProtocol &, void *ref), void *ref)
 
IRProtocolgetProtocol () const
 Provides the active protocol.
 
IRProtocolgetProtocolByID (IRProtocolEnum proto) const
 Provides a protocol by its enum ID, or a default if not found.
 
void addProtocol (IRProtocol &protocol)
 
void setActualProtocol (IRProtocol &proto)
 
void begin (IRProtocolEnum proto, uint32_t frequency, size_t dataLength, uint32_t shortPulse, uint32_t longPulse, uint32_t tolerance, Vector< OutputEdge > edges, CodecEnum codecType=CodecEnum::PulseDistance)
 Set all fields for this IR protocol, including preamble edges.
 
virtual bool begin (uint16_t bitFrequencyHz)
 
const charname () const
 
virtual Codeccodec ()
 Provides the codec associated with this protocol.
 
void reset ()
 
bool inRange (uint32_t value, uint32_t target, uint32_t tolerance) const
 

Protected Attributes

IRProtocol_refInfo = &IRProtocolNEC
 
Vector< IRProtocol * > _preambles
 
void(* _callback )(IRProtocolEnum, IRProtocol &, void *ref) = nullptr
 
void_ref = nullptr
 
pulsewire::Vector< pulsewire::OutputEdge_history
 
pulsewire::Vector< pulsewire::OutputEdge_expected
 

Detailed Description

IRMultiProtocol: Handles detection and delegation for multiple IR protocols.

This class manages a collection of known IR protocol definitions and attempts to detect which protocol is present in an incoming signal. It delegates all IR protocol-specific method calls to a reference protocol instance (_refInfo), which is updated upon successful detection. This allows seamless switching and handling of multiple IR protocols within a single interface. The class also supports callback registration for protocol detection events.

Definition at line 316 of file IRProtocol.h.

Constructor & Destructor Documentation

◆ IRMultiProtocol() [1/2]

pulsewire::IRMultiProtocol::IRMultiProtocol ( )
inline

Definition at line 318 of file IRProtocol.h.

◆ IRMultiProtocol() [2/2]

pulsewire::IRMultiProtocol::IRMultiProtocol ( IRProtocol defaultInfo)
inline

Definition at line 340 of file IRProtocol.h.

Member Function Documentation

◆ addProtocol()

void pulsewire::IRMultiProtocol::addProtocol ( IRProtocol protocol)
inline

Definition at line 398 of file IRProtocol.h.

◆ begin() [1/3]

void pulsewire::IRMultiProtocol::begin ( IRProtocolEnum  proto,
uint32_t  frequency,
size_t  dataLength,
uint32_t  shortPulse,
uint32_t  longPulse,
uint32_t  tolerance,
Vector< OutputEdge edges 
)
inline

Definition at line 358 of file IRProtocol.h.

◆ begin() [2/3]

void pulsewire::IRProtocol::begin ( IRProtocolEnum  proto,
uint32_t  frequency,
size_t  dataLength,
uint32_t  shortPulse,
uint32_t  longPulse,
uint32_t  tolerance,
Vector< OutputEdge edges,
CodecEnum  codecType = CodecEnum::PulseDistance 
)
inlineinherited

Set all fields for this IR protocol, including preamble edges.

Definition at line 148 of file IRProtocol.h.

◆ begin() [3/3]

virtual bool pulsewire::Preamble::begin ( uint16_t  bitFrequencyHz)
inlinevirtualinherited

Definition at line 44 of file Preamble.h.

◆ codec()

virtual Codec & pulsewire::IRProtocol::codec ( )
inlinevirtualinherited

Provides the codec associated with this protocol.

Definition at line 205 of file IRProtocol.h.

◆ copyFrom()

void pulsewire::IRMultiProtocol::copyFrom ( const IRProtocol other)
inline

Definition at line 357 of file IRProtocol.h.

◆ dataLength()

size_t pulsewire::IRMultiProtocol::dataLength ( ) const
inlinevirtual

Returns the expected data length in bytes (not including preamble)

Reimplemented from pulsewire::IRProtocol.

Definition at line 351 of file IRProtocol.h.

◆ detect()

bool pulsewire::IRMultiProtocol::detect ( const OutputEdge edge)
inlineoverridevirtual

Detects if the incoming edge matches the expected preamble pattern.

Reimplemented from pulsewire::Preamble.

Definition at line 365 of file IRProtocol.h.

◆ frequency()

uint32_t pulsewire::IRMultiProtocol::frequency ( ) const
inlinevirtual

Returns the carrier frequency in Hz.

Reimplemented from pulsewire::IRProtocol.

Definition at line 350 of file IRProtocol.h.

◆ getEdges()

int pulsewire::IRMultiProtocol::getEdges ( Vector< OutputEdge > &  output) const
inlineoverridevirtual

Returns the preamble edges for this protocol.

Reimplemented from pulsewire::IRProtocol.

Definition at line 346 of file IRProtocol.h.

◆ getProtocol()

IRProtocol & pulsewire::IRMultiProtocol::getProtocol ( ) const
inline

Provides the active protocol.

Definition at line 385 of file IRProtocol.h.

◆ getProtocolByID()

IRProtocol & pulsewire::IRMultiProtocol::getProtocolByID ( IRProtocolEnum  proto) const
inline

Provides a protocol by its enum ID, or a default if not found.

Definition at line 388 of file IRProtocol.h.

◆ getProtocolID()

IRProtocolEnum pulsewire::IRMultiProtocol::getProtocolID ( ) const
inlineoverridevirtual

Returns the protocol enum identifier for this IR protocol.

Reimplemented from pulsewire::IRProtocol.

Definition at line 343 of file IRProtocol.h.

◆ inRange()

bool pulsewire::Preamble::inRange ( uint32_t  value,
uint32_t  target,
uint32_t  tolerance 
) const
inlineinherited

Utility function to check if a value is within a specified tolerance range of a target

Definition at line 95 of file Preamble.h.

◆ longPulseUs()

uint32_t pulsewire::IRMultiProtocol::longPulseUs ( ) const
inlinevirtual

Returns the duration of the long pulse in microseconds.

Reimplemented from pulsewire::IRProtocol.

Definition at line 353 of file IRProtocol.h.

◆ name()

const char * pulsewire::IRProtocol::name ( ) const
inlineinherited

Definition at line 182 of file IRProtocol.h.

◆ preambleLength()

size_t pulsewire::IRMultiProtocol::preambleLength ( ) const
inlineoverridevirtual

Returns the number of edges in the preamble.

Reimplemented from pulsewire::IRProtocol.

Definition at line 349 of file IRProtocol.h.

◆ reset()

void pulsewire::Preamble::reset ( )
inlineinherited

Definition at line 49 of file Preamble.h.

◆ setActualProtocol()

void pulsewire::IRMultiProtocol::setActualProtocol ( IRProtocol proto)
inline

Definition at line 409 of file IRProtocol.h.

◆ setCallback()

void pulsewire::IRMultiProtocol::setCallback ( void(*)(IRProtocolEnum, IRProtocol &, void *ref callback,
void ref 
)
inline

You can registre a callback that will be executed when the protocol changes

Definition at line 378 of file IRProtocol.h.

◆ shortPulseUs()

uint32_t pulsewire::IRMultiProtocol::shortPulseUs ( ) const
inlinevirtual

Returns the duration of the short pulse in microseconds.

Reimplemented from pulsewire::IRProtocol.

Definition at line 352 of file IRProtocol.h.

◆ toleranceUs()

uint32_t pulsewire::IRMultiProtocol::toleranceUs ( ) const
inlinevirtual

Tolerance in microseconds for pulse duration matching during detection.

Reimplemented from pulsewire::IRProtocol.

Definition at line 354 of file IRProtocol.h.

Field Documentation

◆ _callback

void(* pulsewire::IRMultiProtocol::_callback) (IRProtocolEnum, IRProtocol &, void *ref) = nullptr
protected

Definition at line 419 of file IRProtocol.h.

◆ _expected

pulsewire::Vector<pulsewire::OutputEdge> pulsewire::Preamble::_expected
protectedinherited

Definition at line 102 of file Preamble.h.

◆ _history

pulsewire::Vector<pulsewire::OutputEdge> pulsewire::Preamble::_history
protectedinherited

Definition at line 101 of file Preamble.h.

◆ _preambles

Vector<IRProtocol*> pulsewire::IRMultiProtocol::_preambles
protected

Definition at line 418 of file IRProtocol.h.

◆ _ref

void* pulsewire::IRMultiProtocol::_ref = nullptr
protected

Definition at line 420 of file IRProtocol.h.

◆ _refInfo

IRProtocol* pulsewire::IRMultiProtocol::_refInfo = &IRProtocolNEC
protected

Definition at line 417 of file IRProtocol.h.


The documentation for this class was generated from the following file: