Skip to content

MiP_Infrared

github-actions[bot] edited this page Aug 10, 2026 · 7 revisions

Class MiP_Infrared

Manages MiP's infrared subsystem for robot detection and remote control.

Table of Contents


Public Functions

enableMiPDetectionMode

Signature: void enableMiPDetectionMode(uint8_t id, uint8_t txPower)

Summary: Enables MiP detection mode (allows detecting other MiPs via IR).

Details:

Configures the robot to broadcast its unique ID over IR and listen for other nearby MiP robots.

Parameters:

Parameter Description
id Unique ID for this MiP (used in detection events broadcast to others).
txPower Transmit power level (1-120).

disableMiPDetectionMode

Signature: void disableMiPDetectionMode()

Summary: Disables MiP detection mode.

Details:

Stops broadcasting the robot's ID over IR.


isMiPDetectionModeEnabled

Signature: bool isMiPDetectionModeEnabled()

Summary: Checks if MiP detection mode is currently enabled.

Returns: true if detection mode is active (broadcast ID > 0), false otherwise.


readDetectedMiP

Signature: uint8_t readDetectedMiP()

Summary: Reads the next detected MiP event from the queue.

Details:

Processes pending serial data first. Pops the oldest detected MiP ID from the internal queue.

Returns: ID of the detected MiP (1-255), or 0 if no event is available.


availableDetectedMiPEvents

Signature: uint8_t availableDetectedMiPEvents()

Summary: Returns the number of unread detected MiP events in the queue.

Details:

Processes pending serial data first to update the queue before checking.

Returns: Number of available MiP detection events in the queue.


enableRemoteControl

Signature: void enableRemoteControl()

Summary: Enables IR remote control mode.

Details:

Verified operation: sends the enable command and reads back state with retry.


disableRemoteControl

Signature: void disableRemoteControl()

Summary: Disables IR remote control mode.

Details:

Verified operation: sends the disable command and reads back state with retry.


isRemoteControlEnabled

Signature: bool isRemoteControlEnabled()

Summary: Checks if IR remote control mode is currently enabled.

Returns: true if IR remote control mode is active, false otherwise.


sendDongleCode

Signature: void sendDongleCode(const MiPIRDongleCode &irCode, uint8_t transmitPower)

Summary: Transmits a 2-, 3-, or 4-byte IR dongle code using a struct (fire and forget).

Details:

Transmits the IR payload stored in irCode at the specified transmit power. No read-back verification is performed as there is no feedback mechanism over IR.

Parameters:

Parameter Description
irCode Struct containing code value and byte length (2, 3, or 4).
transmitPower Transmit power level (1-120).

sendDongleCode

Signature: void sendDongleCode(uint32_t code, uint8_t length, uint8_t transmitPower)

Summary: Transmits a variable-length IR dongle code using direct values (fire and forget).

Details:

Transmits the specified numerical code value at the given length and transmitPower. No read-back verification is performed as there is no feedback mechanism over IR.

Parameters:

Parameter Description
code Up to 32-bit numerical IR code value.
length Code length in bytes (2, 3, or 4).
transmitPower Transmit power level (1-120).

readDongleCode

Signature: MiPIRDongleCode readDongleCode()

Summary: Reads the next received IR dongle code from the queue.

Details:

Processes pending serial data first. Pops the oldest IR dongle code from the queue.

Returns: MiPIRDongleCode struct containing the code value and its byte length. Returns an empty/invalid struct (length = 0, code = 0xFFFFFFFF) if no event is available.


availableCodeEvents

Signature: uint8_t availableCodeEvents()

Summary: Returns the number of unread IR dongle code events in the queue.

Details:

Processes pending serial data first to update the queue before checking.

Returns: Number of available IR code events in the queue.


processEvent

Signature: void processEvent(uint8_t command, const uint8_t *payload, size_t length)

Summary: Handles incoming infrared OOB event notifications from the transport layer.

Details:

Called by MiP::dispatchEvent() when an IR detection or received dongle code event arrives over UART. Parses the payload and pushes the event into the appropriate queue.

Parameters:

Parameter Description
command Command byte indicating the specific IR notification type.
payload Pointer to the raw response buffer.
length Length of the payload in bytes.

Public Variables

MIP_CMD_RECEIVE_IR_DONGLE_CODE

Signature: constexpr uint8_t MIP_CMD_RECEIVE_IR_DONGLE_CODE

Summary: Protocol command byte received when an IR dongle code is detected.


MIP_CMD_GET_DETECTED_MIP

Signature: constexpr uint8_t MIP_CMD_GET_DETECTED_MIP

Summary: Protocol command byte received when a nearby MiP is detected via IR.


MIP_CMD_SET_DETECTION_MODE

Signature: constexpr uint8_t MIP_CMD_SET_DETECTION_MODE

Summary: Protocol command byte to configure MiP detection transmission and power.


MIP_CMD_SET_IR_REMOTE_CONTROL

Signature: constexpr uint8_t MIP_CMD_SET_IR_REMOTE_CONTROL

Summary: Protocol command byte to enable or disable IR remote control mode.


MIP_CMD_GET_IR_REMOTE_CONTROL

Signature: constexpr uint8_t MIP_CMD_GET_IR_REMOTE_CONTROL

Summary: Protocol command byte to query if IR remote control mode is active.


MIP_CMD_SEND_IR_DONGLE_CODE

Signature: constexpr uint8_t MIP_CMD_SEND_IR_DONGLE_CODE

Summary: Protocol command byte to transmit an IR dongle code.


MIP_IR_DETECTION_MODE_DISABLE

Signature: constexpr uint8_t MIP_IR_DETECTION_MODE_DISABLE

Summary: Special ID value used to disable MiP detection mode.


MIP_IR_REMOTE_CONTROL_DISABLE

Signature: constexpr uint8_t MIP_IR_REMOTE_CONTROL_DISABLE

Summary: State value representing disabled IR remote control mode.


MIP_IR_REMOTE_CONTROL_ENABLE

Signature: constexpr uint8_t MIP_IR_REMOTE_CONTROL_ENABLE

Summary: State value representing enabled IR remote control mode.


Clone this wiki locally