Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following script sets the destination message port using the SetPort() method, waits for an event in the form of an roGpioButton object, and then processes the event.

 

Code Block
linenumberstrue
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 these two lines 6-7 can be replaced using the following (and substituting end while with end for):

...

Code Block
For each msg in p