M5Unit-INFRARED 0.2.0 git rev:76ad9e1
Loading...
Searching...
No Matches
m5::unit::ir::Rc5Codec Class Reference

Philips RC5 / RC5X IR protocol encoder/decoder. More...

#include <rc5_codec.hpp>

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

Public Member Functions

 Rc5Codec ()
 Constructor.
 
item_container_type encode (uint16_t address, uint16_t command, bool repeat) override
 Encode an RC5 or RC5X frame (S2 = ~Cmd[6] when command ≥ 64)
 
bool decode (const gpio::m5_rmt_item_t *items, uint32_t num, DecodeResult &result) override
 Decode an RC5 / RC5X Manchester frame (14 bits including S1/S2/T)
 
uint32_t carrierFrequencyHz () const override
 Carrier frequency for RC5 (36 kHz)
 
bool toggle () const
 Toggle bit state (flipped on each new key press)
 
void setToggle (bool t)
 Set toggle bit.
 
void flipToggle ()
 Flip toggle bit (call on each new key press)
 
- Public Member Functions inherited from m5::unit::ir::IRCodec
 IRCodec (CodecType t)
 
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

Philips RC5 / RC5X IR protocol encoder/decoder.

  • Carrier: 36 kHz, duty 1/3
  • Modulation: Manchester (bi-phase)
  • Bit order: MSB first
  • RC5: S1(1) + S2(1) + Toggle(1) + Address(5) + Command(6) = 14 bits
  • RC5X: S1(1) + S2=~Cmd6(1) + Toggle(1) + Address(5) + Command(6) = 14 bits, 128 commands
  • 1 bit = 1778us (64 cycles of 36kHz), half-bit = 889us
  • RC5 polarity: "0" = mark+space, "1" = space+mark

Member Function Documentation

◆ carrierFrequencyHz()

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

Carrier frequency for RC5 (36 kHz)

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

◆ encode()

item_container_type m5::unit::ir::Rc5Codec::encode ( uint16_t address,
uint16_t command,
bool repeat )
overridevirtual

Encode an RC5 or RC5X frame (S2 = ~Cmd[6] when command ≥ 64)

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

◆ setToggle()

void m5::unit::ir::Rc5Codec::setToggle ( bool t)
inline

Set toggle bit.

Parameters
tNew toggle value; the next encode() emits this bit verbatim

◆ toggle()

bool m5::unit::ir::Rc5Codec::toggle ( ) const
inline

Toggle bit state (flipped on each new key press)

Returns
Current toggle bit (false = 0, true = 1)