Roku BrightSign Manual do Utilizador Página 5

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 26
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 4
5
BrightSign Object Library
This section specifies each of the Roku Objects that are included with BrigthScript.
Event Loops
When creating anything more than a very simple script, an Event Loop will need to be created. An Event
Loop typically has this structure:
1. wait for the event
2. process the event
3. jump back to 1
Events are things like a button press, a timer that has triggered, a video that has finished playing back, etc.
By convention, Roku Object (RO) events work as follows.
A RO of type “roMessagePort” is created. In BrightScript, by the user’s script.
ROs that can send events are instructed to send their events to this message port. You could set up
multiple message ports, and have each event go to its own message port, but it is usually simpler
to just create one message port, and have the events all go to this one port. To instruct the RO to
send events to a specific port, use the ifSetMessagePort Interface.
The script waits for an event. The actual function to do this is the ifMessagePort.WaitMessage(),
but if you are using BrightScript, the built-in statement WAIT makes this easy.
If multiple event types are possible, your script should determine which event that the wait
received, then process it. The script then jumps back to the Wait.
An “Event” can be generated by any Roku Object. For example, the class “roGpioControlPort” sends
events of type “roGpioButton”. The “roGpioButton” has one interface: ifInt. ifInt allows access to an
integer. An event loop needs to be aware of the possible events it can get, and process them.
Example
print "BrightSign Button-LED Test Running"
p = CreateObject("roMessagePort")
tmr = CreateObject("roMessagePort")
gpio = CreateObject("roGpioControlPort")
gpio.SetPort(p)
sw = CreateObject("roGpioControlPort") 'switch/led control port
sw.SetPort(p)
event_loop:
msg=wait(0, p)
if type(msg)<>"roGpioButton" then event_loop
butn = msg.GetInt()
if butn > 5 then event_loop
sw.SetOutputState(butn+17,1)
print "Button Pressed: ";butn
msg = wait (500, tmr)
sw.SetOutputState(butn+17,0)
clear_events:
msg=p.GetMessage():if type(msg)<>"rotINT32" then clear_events
goto event_loop
Classes
For each class a brief description is given, a list of interfaces, and the member functions in the interfaces.
Vista de página 4
1 2 3 4 5 6 7 8 9 10 ... 25 26

Comentários a estes Manuais

Sem comentários