Roku objects, Examples, Gpio control port – Roku BrightSign User Manual

Page 10

Advertising
background image

10

Roku Objects

Take a look at the section of this manual titled “Auto Playing a Video Upon PowerUp”.
It shows a simple five line script to autoplay a video, looping. You’ll see it uses the
CreateObject() function. This creates a Roku Object. These “objects” provide access to
all of BrightSign’s features: playing video, playing images, etc.

There are two other manuals that you’ll need to refer to when writing scripts:

• BrightSign HD600 BrightScript Reference -- this describes the actual scripting

language

• BrightSign HD600 Object Reference -- this describes the Roku Objects, such as

“roVideoPlayer”

Examples

A good way to learn BrightScript is to look at or modify existing scripts. You can find
links to example scripts at www.rokulabs.com/brightsign.

GPIO Control Port

The BrightSign has a DB25 General Purpose Input Output (GPIO) Port. This port has
12 inputs that can be directly connected to buttons or switches, and 6 outputs that can
directly drive LEDs. To use this port you must create a simple but custom cable that
connects a DB25 connector to your buttons or LEDs. See the BrightSign Hardware
Manual for more information and example circuits. Roku has a test button/LED board
that you can purchase to evaluate the GPIO port and test your scripts that read the buttons
or set the LEDs.

Here is an example script that will flash an LED for half a second each time a button is
pressed on the BrightSign button/led board. Note: line numbers are optional, but are
included here to label each line.

100 print "BrightSign Button-LED Test Running"
110 p = CreateObject("roMessagePort")
120 tmr = CreateObject("roMessagePort")
130 gpio = CreateObject("roGpioControlPort")
140 gpio.SetPort(p)
142 sw = CreateObject("roGpioControlPort")

147 sw.SetPort(p)
150 LED1=2 ^ 17
160 LED2=2 ^ 18
170 LED3=2 ^ 19
180 LED4=2 ^ 20
190 LED5=2 ^ 21
200 LED6=2 ^ 22
210

dim

idx(5):idx(0)=LED1:idx(1)=LED2:idx(2)=LED3:idx(4)=LED5:idx(5)=LED6

220 msg=wait(0, p)

230

if

type(msg)<>"roGpioButton"

then

220

240 butn = msg.GetInt()
250

if

butn > 5

then

220

255 sw.SetOutputState(butn+17,1)
260 print "Button Pressed: ";butn

Advertising