ripyl.protocol.infrared package

Submodules

ripyl.protocol.infrared.ir_common module

Infrared decoder common utilities

class ripyl.protocol.infrared.ir_common.IRConfig

Bases: ripyl.util.enum.Enum

Enumeration of configuration settings

IdleHigh = 1
IdleLow = 2
ripyl.protocol.infrared.ir_common.demodulate(edges, carrier_freq, polarity=2)

Demodulate an edge stream

This is a generator function.

You can safely pass an unmodulated stream through this function without alteration

Parameters:
  • edges (edge stream) – The edge stream to modulate
  • carrier_freq (float) – The modulation frequency
  • polarity (infrared.IRConfig) – Set the polarity (idle state high or low)
Returns:

An iterator yielding an edge stream.

ripyl.protocol.infrared.ir_common.modulate(edges, carrier_freq, duty_cycle=0.5, polarity=2)

Modulate an edge stream

This is a generator function.

Parameters:
  • edges (edge stream) – The edge stream to modulate
  • carrier_freq (float) – The modulation frequency
  • duty_cycle (float) – The duty cycle of the modulation
  • polarity (infrared.IRConfig) – Set the polarity (idle state high or low)
Returns:

An iterator yielding an edge stream.

ripyl.protocol.infrared.ir_common.time_is_at_least(time, expected_value, epsilon)

Check if a time value is greater than another

Parameters:
  • time (float) – The time to test
  • expected_value (float) – The value time should be greater than
  • epsilon (float) – The allowed difference between the time values
Returns:

Bool

ripyl.protocol.infrared.ir_common.time_is_nearly(time, expected_value, epsilon)

Check if a time value is approximately equal another

Parameters:
  • time (float) – The time to test
  • expected_value (float) – The value time should be equal to
  • epsilon (float) – The allowed difference between the time values
Returns:

Bool

ripyl.protocol.infrared.nec module

NEC IR protocol decoder

class ripyl.protocol.infrared.nec.NECMessage(cmd, addr_low, addr_high=None, cmd_inv=None)

Bases: object

NEC infrared message

__init__(cmd, addr_low, addr_high=None, cmd_inv=None)
is_valid()

Return True if the command check byte is correct

class ripyl.protocol.infrared.nec.NECRepeat

Bases: ripyl.protocol.infrared.nec.NECMessage

NEC infrared repeat command

__init__()
is_valid()
class ripyl.protocol.infrared.nec.NECStreamMessage(bounds, data=None, status=0)

Bases: ripyl.streaming.StreamSegment

Message object for NEC data

__init__(bounds, data=None, status=0)
ripyl.protocol.infrared.nec.nec_decode(ir_stream, carrier_freq=38000.0, polarity=2, logic_levels=None, stream_type=1)

Decode NEC infrared protocol

This is a generator function that can be used in a pipeline of waveform procesing operations.

Parameters:
  • ir_stream (iterable of SampleChunk objects or (float, int) pairs) – A sample stream or edge stream of IR pulses. The type of stream is identified by the stream_type parameter. When this is a sample stream, an initial block of data is consumed to determine the most likely logic levels in the signal. This signal can be either modulated or demodulated.
  • carrier_freq (float) – The carrier frequency for modulation.
  • polarity (infrared.IRConfig) – Set the polarity (idle state high or low).
  • logic_levels ((float, float) or None) – Optional pair that indicates (low, high) logic levels of the sample stream. When present, auto level detection is disabled. This has no effect on edge streams.
  • stream_type (streaming.StreamType) – A StreamType value indicating that the ir_stream parameter represents either Samples or Edges.

:param : :returns: An iterator yielding a series of NECStreamMessage objects.

Raises:AutoLevelError if stream_type = Samples and the logic levels cannot be determined.
ripyl.protocol.infrared.nec.nec_synth(messages, idle_start=0.0, message_interval=0.0425, idle_end=0.001)

Generate synthesized NEC Infrared waveforms

This function simulates NEC IR pulses.

Parameters:
  • messages (sequence of NECMessage) – Commands to be synthesized.
  • idle_start (float) – The amount of idle time before the transmission of messages begins.
  • message_interval (float) – The amount of time between messages.
  • idle_end (float) – The amount of idle time after the last message.
Returns:

An iterator yielding an edge stream of (float, int) pairs. The first element in the iterator is the initial state of the stream.

ripyl.protocol.infrared.rc5 module

Philips RC-5 IR protocol decoder

class ripyl.protocol.infrared.rc5.RC5Message(cmd, addr, toggle)

Bases: object

RC-5 infrared message

__init__(cmd, addr, toggle)
class ripyl.protocol.infrared.rc5.RC5StreamMessage(bounds, data=None, status=0)

Bases: ripyl.streaming.StreamSegment

Message object for RC-5 data

__init__(bounds, data=None, status=0)
ripyl.protocol.infrared.rc5.rc5_decode(ir_stream, carrier_freq=36000.0, polarity=2, logic_levels=None, stream_type=1)

Decode RC5 infrared protocol

This is a generator function that can be used in a pipeline of waveform procesing operations.

Parameters:
  • ir_stream (iterable of SampleChunk objects or (float, int) pairs) – A sample stream or edge stream of IR pulses. The type of stream is identified by the stream_type parameter. When this is a sample stream, an initial block of data is consumed to determine the most likely logic levels in the signal. This signal can be either modulated or demodulated.
  • carrier_freq (float) – The carrier frequency for modulation.
  • polarity (infrared.IRConfig) – Set the polarity (idle state high or low).
  • logic_levels ((float, float) or None) – Optional pair that indicates (low, high) logic levels of the sample stream. When present, auto level detection is disabled. This has no effect on edge streams.
  • stream_type (streaming.StreamType) – A StreamType value indicating that the ir_stream parameter represents either Samples or Edges.

:param : :returns: An iterator yielding a series of RC5StreamMessage objects.

Raises:AutoLevelError if stream_type = Samples and the logic levels cannot be determined.
ripyl.protocol.infrared.rc5.rc5_synth(messages, idle_start=0.0, message_interval=0.089, idle_end=0.001)

Generate synthesized RC5 infrared waveforms

This function simulates Philips RC5 IR pulses.

Parameters:
  • messages (sequence of RC5Message) – Commands to be synthesized.
  • idle_start (float) – The amount of idle time before the transmission of messages begins.
  • message_interval (float) – The amount of time between messages.
  • idle_end (float) – The amount of idle time after the last message.
Returns:

An iterator yielding an edge stream of (float, int) pairs. The first element in the iterator is the initial state of the stream.

ripyl.protocol.infrared.rc6 module

Philips RC-6 IR protocol decoder

NOTE: There are no publicly available RC-6 documents describing the complete message format. Only mode-0 and mode-6 (RC6A) is properly supported by this decoder.

class ripyl.protocol.infrared.rc6.RC6Message(cmd, addr, toggle, mode=0, customer=None)

Bases: object

RC-6 infrared message

__init__(cmd, addr, toggle, mode=0, customer=None)
class ripyl.protocol.infrared.rc6.RC6StreamMessage(bounds, data=None, status=0)

Bases: ripyl.streaming.StreamSegment

Message object for RC-6 data

__init__(bounds, data=None, status=0)
ripyl.protocol.infrared.rc6.rc6_decode(ir_stream, carrier_freq=36000.0, polarity=2, logic_levels=None, stream_type=1)

Decode RC6 infrared protocol

This is a generator function that can be used in a pipeline of waveform procesing operations.

Parameters:
  • ir_stream (iterable of SampleChunk objects or (float, int) pairs) – A sample stream or edge stream of IR pulses. The type of stream is identified by the stream_type parameter. When this is a sample stream, an initial block of data is consumed to determine the most likely logic levels in the signal. This signal can be either modulated or demodulated.
  • carrier_freq (float) – The carrier frequency for modulation.
  • polarity (infrared.IRConfig) – Set the polarity (idle state high or low).
  • logic_levels ((float, float) or None) – Optional pair that indicates (low, high) logic levels of the sample stream. When present, auto level detection is disabled. This has no effect on edge streams.
  • stream_type (streaming.StreamType) – A StreamType value indicating that the ir_stream parameter represents either Samples or Edges.

:param : :returns: An iterator yielding a series of RC6StreamMessage objects.

Raises:AutoLevelError if stream_type = Samples and the logic levels cannot be determined.
ripyl.protocol.infrared.rc6.rc6_synth(messages, idle_start=0.0, message_interval=0.089, idle_end=0.001)

Generate synthesized RC6 infrared waveforms

This function simulates Philips RC6 IR pulses.

Parameters:
  • messages (sequence of RC6Message) – Commands to be synthesized.
  • idle_start (float) – The amount of idle time before the transmission of messages begins.
  • message_interval (float) – The amount of time between messages.
  • idle_end (float) – The amount of idle time after the last message.
Returns:

An iterator yielding an edge stream of (float, int) pairs. The first element in the iterator is the initial state of the stream.

ripyl.protocol.infrared.sirc module

Sony SIRC IR protocol decoder

class ripyl.protocol.infrared.sirc.SIRCMessage(cmd, device, extended=None)

Bases: object

SIRC infrared message

__init__(cmd, device, extended=None)
class ripyl.protocol.infrared.sirc.SIRCStreamMessage(bounds, data=None, status=0)

Bases: ripyl.streaming.StreamSegment

Stream message object for SIRC data

__init__(bounds, data=None, status=0)
ripyl.protocol.infrared.sirc.sirc_decode(ir_stream, carrier_freq=40000.0, polarity=2, logic_levels=None, stream_type=1)

Decode Sony SIRC infrared protocol

This is a generator function that can be used in a pipeline of waveform procesing operations.

Parameters:
  • ir_stream (iterable of SampleChunk objects or (float, int) pairs) – A sample stream or edge stream of IR pulses. The type of stream is identified by the stream_type parameter. When this is a sample stream, an initial block of data is consumed to determine the most likely logic levels in the signal. This signal can be either modulated or demodulated.
  • carrier_freq (float) – The carrier frequency for modulation.
  • polarity (infrared.IRConfig) – Set the polarity (idle state high or low).
  • logic_levels ((float, float) or None) – Optional pair that indicates (low, high) logic levels of the sample stream. When present, auto level detection is disabled. This has no effect on edge streams.
  • stream_type (streaming.StreamType) – A StreamType value indicating that the ir_stream parameter represents either Samples or Edges.

:param : :returns: An iterator yielding a series of SIRCStreamMessage objects.

Raises:AutoLevelError if stream_type = Samples and the logic levels cannot be determined.
ripyl.protocol.infrared.sirc.sirc_synth(messages, idle_start=0.0, message_interval=0.0425, idle_end=0.001)

Generate synthesized Sony SIRC Infrared waveforms

This function simulates SIRC IR pulses.

Parameters:
  • messages (sequence of SIRCMessage) – Commands to be synthesized.
  • idle_start (float) – The amount of idle time before the transmission of messages begins.
  • message_interval (float) – The amount of time between messages.
  • idle_end (float) – The amount of idle time after the last message.
Returns:

An iterator yielding an edge stream of (float, int) pairs. The first element in the iterator is the initial state of the stream.

Module contents

Infrared protocol package