infrared – Send and Receive Messages via IR Light

Codex infrared transmitter/receiver

class infrared.Infrared(power, max_payload=16)[source]

Create an Infrared (IR) send/receive driver.

Parameters
  • power (codex.Power) – Power object from codex module

  • max_payload (int) – Maximum number of rx bytes “in-flight” or queued.

flush()[source]

Clear and discard the receive buffer, without decoding it. Can be used after ‘send()’ to avoid receiving “loopback” data.

receive()[source]

Get the last string (if any) received by the IR receiver

Returns

the text received or None if nothing has been received

Return type

str

receive_queue()[source]

Get the queue of messages received by the IR receiver

Returns

a list of string messages received (may be empty). Index 0 is oldest.

Return type

list

send(message)[source]

Send a message string over infrared.

Size limit in a single message is max_payload defined in __init__() above, but due to AGC we recommend limiting to max 4 characters per message string.

Parameters

message (str) – the string to send

Download Source