Brightsign BrightScript 2 Reference Guide Instrukcja Użytkownika Strona 20

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 59
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 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”.
Przeglądanie stron 19
1 2 ... 15 16 17 18 19 20 21 22 23 24 25 ... 58 59

Komentarze do niniejszej Instrukcji

Brak uwag