exception adafruit_irremote.FailedToDecode[source]

Raised by decode_bits. Error argument is UnparseableIRMessage

class adafruit_irremote.GenericDecode[source]

Generic decoding of infrared signals

bin_data(pulses: List) List[List][source]

Wraps the top-level function bin_data for backward-compatibility.

decode_bits(pulses: List) Tuple[source]

Wraps the top-level function decode_bits for backward-compatibility.

read_pulses(input_pulses: list, *, max_pulse: int = 10000, blocking: bool = True, pulse_window: float = 0.1, blocking_delay: float = 0.1) List | None[source]

Read out a burst of pulses until pulses stop for a specified period (pulse_window), pruning pulses after a pulse longer than max_pulse.

  • input_pulses (PulseIn) – Object to read pulses from

  • max_pulse (int) – Pulse duration to end a burst

  • blocking (bool) – If True, will block until pulses found. If False, will return None if no pulses. Defaults to True for backwards compatibility

  • pulse_window (float) – pulses are collected for this period of time

  • blocking_delay (float) – delay between pulse checks when blocking

class adafruit_irremote.GenericTransmit(header: int, one: int, zero: int, trail: int, *, debug: bool = False)[source]

Generic infrared transmit class that handles encoding.

  • header (int) – The length of header in microseconds

  • one (int) – The length of a one in microseconds

  • zero (int) – The length of a zero in microseconds

  • trail (int) – The length of the trail in microseconds, set to None to disable

  • debug (bool) – Enable debug output, default False

transmit(pulseout: PulseOut, data: bytearray, *, repeat: int = 0, delay: float = 0.0, nbits: int | None = None) None[source]

Transmit the data using the pulseout.

  • pulseout (pulseio.PulseOut) – PulseOut to transmit on

  • data (bytearray) – Data to transmit

  • repeat (int) – Number of additional retransmissions of the data, default 0

  • delay (float) – Delay between any retransmissions, default 0.0

  • nbits (int) – Optional number of bits to send, useful to send fewer bits than in the data bytes

exception adafruit_irremote.IRDecodeException[source]

Generic decode exception

class adafruit_irremote.IRMessage(pulses, code)

Pulses and the code they were parsed into


Alias for field number 1


Alias for field number 0

exception adafruit_irremote.IRNECRepeatException[source]

Exception when a NEC repeat is decoded

class adafruit_irremote.NECRepeatIRMessage(pulses)

Pulses interpreted as an NEC repeat code


Alias for field number 0

class adafruit_irremote.NonblockingGenericDecode(pulses: List, max_pulse: int = 10000)[source]

Decode pulses into bytes in a non-blocking fashion.

  • input_pulses (PulseIn) – Object to read pulses from

  • max_pulse (int) – Pulse duration to end a burst. Units are microseconds.

>>> pulses = PulseIn(...)
>>> decoder = NonblockingGenericDecoder(pulses)
>>> for message in decoder.read():
...     if isinstance(message, IRMessage):
...         message.code  # TA-DA! Do something with this in your application.
...     else:
...         # message is either NECRepeatIRMessage or
...         # UnparseableIRMessage. You may decide to ignore it, raise
...         # an error, or log the issue to a file. If you raise or log,
...         # it may be helpful to include message.pulses in the error message.
...         ...
read() None[source]

Consume all pulses from PulseIn. Yield decoded messages, if any.

If a partial message is received, this does not block to wait for the rest. It stashes the partial message, to be continued the next time it is called.


Pulses and the reason that they could not be parsed into a code

adafruit_irremote.bin_data(pulses: List) List[List][source]

Compute bins of pulse lengths where pulses are +-25% of the average.


pulses (list) – Input pulse lengths

adafruit_irremote.decode_bits(pulses: List) NamedTuple[source]

Decode the pulses into bits.