M5Unit-INFRARED 0.3.0 git rev:2148adc
Loading...
Searching...
No Matches
m5::unit::ir::AutoDetectCodec Class Reference

Auto-detecting multi-protocol IR decoder. More...

#include <auto_detect_codec.hpp>

Inheritance diagram for m5::unit::ir::AutoDetectCodec:
m5::unit::ir::IRCodec

Public Member Functions

 AutoDetectCodec ()
 Constructor.
 
item_container_type encode (uint16_t address, uint16_t command, bool repeat) override
 Encode using the last detected protocol's codec (default: NEC)
 
bool decode (const gpio::m5_rmt_item_t *items, uint32_t num, DecodeResult &result) override
 Try decoding with each protocol codec in priority order.
 
uint32_t carrierFrequencyHz () const override
 Carrier frequency of the last detected protocol.
 
IRCodec * lastCodec ()
 Get the codec that last successfully decoded.
 
Access individual codecs
NecCodec & nec ()
 Get NEC codec instance.
 
SircCodec & sirc ()
 Get Sony SIRC codec instance.
 
Rc5Codec & rc5 ()
 Get Philips RC5 codec instance.
 
Rc6Codec & rc6 ()
 Get Philips RC6 codec instance.
 
PanasonicCodec & panasonic ()
 Get Panasonic / Kaseikyo codec instance.
 
MitsubishiCodec & mitsubishi ()
 Get Mitsubishi codec instance.
 
- Public Member Functions inherited from m5::unit::ir::IRCodec
 IRCodec (const CodecType t)
 Constructor.
 
virtual ~IRCodec ()=default
 Destructor.
 
CodecType type () const
 Get codec type for safe downcasting.
 
virtual float carrierDuty () const
 Carrier duty cycle (0.0 - 1.0)
 
virtual uint8_t minFrames () const
 Number of frames that should be transmitted per keypress for this protocol.
 
virtual uint16_t frameGapUs () const
 Inter-frame gap (microseconds) when transmitting multiple frames in one burst.
 
virtual bool decode (const m5::unit::gpio::m5_rmt_item_t *items, uint32_t num, DecodeResult &result)=0
 Try to decode RMT items into an IR command.
 

Detailed Description

Auto-detecting multi-protocol IR decoder.

Tries multiple IR protocols in order during decode(). Detection priority:

  1. NEC — 9 ms leader mark
  2. Panasonic — 3.5 ms leader mark
  3. RC6 — 2.67 ms leader mark
  4. SIRC — 2.4 ms leader mark
  5. Mitsubishi — no leader, short 300us bit mark
  6. RC5 — no leader, ~889us Manchester half-bit

For encode(), delegates to the codec matching the last successfully decoded protocol, defaulting to NEC.

Member Function Documentation

◆ carrierFrequencyHz()

uint32_t m5::unit::ir::AutoDetectCodec::carrierFrequencyHz ( ) const
inlineoverridevirtual

Carrier frequency of the last detected protocol.

Returns
Frequency in Hz (default NEC: 38 kHz)

Implements m5::unit::ir::IRCodec.

◆ decode()

bool m5::unit::ir::AutoDetectCodec::decode ( const gpio::m5_rmt_item_t * items,
uint32_t num,
DecodeResult & result )
override

Try decoding with each protocol codec in priority order.

Parameters
itemsRMT items from receiver
numNumber of items
[out]resultPopulated when a protocol matches
Returns
True on successful decode

◆ encode()

item_container_type m5::unit::ir::AutoDetectCodec::encode ( uint16_t address,
uint16_t command,
bool repeat )
inlineoverridevirtual

Encode using the last detected protocol's codec (default: NEC)

Parameters
addressDevice address for the target protocol
commandCommand code for the target protocol
repeatTrue to emit the repeat frame (only NEC has a dedicated one)
Returns
Encoded RMT items

Implements m5::unit::ir::IRCodec.

◆ lastCodec()

IRCodec * m5::unit::ir::AutoDetectCodec::lastCodec ( )
inline

Get the codec that last successfully decoded.

Returns
Pointer to the active codec (NecCodec on startup)