Panel | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
ON THIS PAGE
|
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Object Creation: The roIRReceiver object is created with an associative array.
Code Block |
---|
CreateObject("roIRReceiver", config As roAssociativeArray) |
The associative array can contain the following parameters:
source
: A string value indicating the source of the input.- "IR-in": The 3.5mm IR input/output connector (available on 4Kx42 and XDx32 models)
- "GPIO": Pin 1 of the GPIO connector
- "Iguana": The Iguanaworks IR transceiver. This source can support both NEC and RC5 encodings simultaneously.
encodings
: An array indicating the required encodings.- "NEC"
- "RC5" (supported on the Iguanaworks IR transceiver only)
NEC codes are expressed in 24 bits:
- Bits 0-7: Button code
- Bits 8-23: Manufacturer code
Note | ||
---|---|---|
| ||
If the manufacturer code is zero, then the code is considered to be intended for the Roku SoundBridge remote control. |
The roIRReceiver object can generate the following events:
- roIRDownEvent: Generates when a button is pressed.
- roIRRepeatEvent: Generates when a button repeats.
- roIRUpEvent (Iguanaworks IR transceiver only): Generates when a button is released.
ifUserData
SetUserData(user_data As Object)
Sets the user data that will be returned when events are raised.
GetUserData() As Object
Returns the user data that has previously been set via SetUserData()
. It will return Invalid if no data has been set.
ifMessagePort
SetPort(port As roMessagePort)
Specifies the port that will receive events generated by the roIRReceiver instance.
Example
To connect your USB-C port to an IR receiver:
Code Block |
---|
'12-53-23 - V1.x Test IR input, output to system log Sub Main() m.scriptlog = CreateObject("roSystemLog") 'display messages in system log m.Eventloop = Eventloop m.msgPort = CreateObject("roMessagePort") m.gpioPort = CreateObject("roGpioControlPort") m.gpioPort.SetPort(m.msgPort) m.configIR = CreateObject("roAssociativeArray") 'Built-in IR via usb c s.configIR.source = "TypeC" m.configIR.encodings = CreateObject("roArray", 1, false) m.configIR.encodings[0] = "NEC" m.IRRecep = CreateObject("roIRReceiver", m.configIR) if (type(m.IRRecep) = "roIRReceiver") then m. IRRecep.SetPort(m.msgPort) m. scriptlog.SendLine((" @@@@ Please press a button on remote control to display IR code... ") else if m.IRRecep = invalid then m.scriptlog.SendLine((" @@@@ IR receiver not detected, Please connect IR receiver and reboot player... ") end if m.Eventloop() End Sub Sub Eventloop() while true event = wait(0, m.msgPort) m. scriptlog.SendLine("@@@@ Received event ";type(event)) if (type(event) = "roIRDownEvent") then IrData$ = StripLeadingSpaces(stri(event)) m. scriptlog.SendLine((" @@@@ "+IrData$) end If End while end Sub |
Note that LS424 is the only platform where IR input is supported on the Type C connector. Also, a special cable is required: either an adapter (3.5mm plug to 3.5mm socket crossover), or custom all-in-one cable (LiteOn PN 306300009327).