Brightsign BrightScript 2 Reference Guide Manual do Utilizador Página 20

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 59
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 19
20
Events
Events in BrightScript center around an event loop and the “roMessagePort” Roku object.
Any RokuObject can be posted to a message port. Typically these will be Objects that
are designed to post events. For example, the “roTimer” class posts events of type
“roTimerEvent”.
Example:
print "BrightSign Button-LED Test Running"
p = CreateObject("roMessagePort")
gpio = CreateObject("roGpioControlPort")
gpio.SetPort(p)
while true
msg=wait(0, p)
if type(msg)="roGpioButton" then
butn = msg.GetInt()
if butn <=5 then
gpio.SetOutputState(butn+17,1)
print "Button Pressed: ";butn
sleep(500)
gpio.SetOutputState(butn+17,0)
end if
end if
REM ignore buttons pressed while flashing led above
while p.GetMessage()<>invalid
end while
end while
Note that the following two lines:
while true
msg=wait(0, p)
Could be replaced with:
For each msg in p
And then the last “end while” would become a “next”.
Vista de página 19
1 2 ... 15 16 17 18 19 20 21 22 23 24 25 ... 58 59

Comentários a estes Manuais

Sem comentários