Player APIs (BrightScript & Ja...
...
Object Reference
Input/Output Objects
roControlPort
24min
this object provides support for the bp200/bp900 usb button boards, gpio ports, and side buttons on the brightsign player button presses are returned as rocontrolup and rocontroldown events the object is used to configure output levels on the i/o connector and monitor inputs typically, leds and buttons are attached to the gpio connector on the brightsign player or the brightsign expansion module the javascript equivalent is controlport docid\ n8yocsdagogqcp1oyuolw object creation the rocontrolport object is created with a single parameter that specifies the port being used createobject("rocontrolport", port as string) the port parameter can be one of the following brightsign specifies the onboard gpio connector (including the svc (gpio12) button) expander gpio specifies the db 25 connector on the brightsign expansion module if no brightsign expansion module is attached, then object creation will fail and invalid will be returned expander \<n> gpio specifies a usb to gpio device https //www brightsign biz/digital signage products/accessories/usb c cables connected to the player multiple usb to gpio devices can be controlled using separate rocontrolport instances the first device corresponds to "expander 0 gpio" , the second to "expander 1 gpio" , etc expander dip specifies the eight dip switches on the brightsign expansion module if no brightsign expansion module is attached, then object creation will fail and invalid will be returned hot plugging the brightsign expansion module is not supported touchboard \<n> gpio retrieves events from the specified bp200/bp900 button board events are handled in the same manner as events from the brightsign port touchboard \<n> led setup sets various led output options for the specified bp200/bp900 button board touchboard \<n> led sets the bits for each button on the specified bp200/bp900 button board the bits indicate whether the associated led should be on or off since multiple bp200/bp900 button boards can be connected to a player simultaneously, the \<n> value specifies the port enumeration of each board this value corresponds to the \<raw> or \<fid> value returned by the docid\ utkdmpos1ulxaoylx1ns6 method an unspecified enumeration value is synonymous with a button board with an enumeration value of 0 (e g touchboard gpio and touchboard 0 gpio are identical) ifcontrolport the "button" numbers described below are not the same as gpio "pin" numbers some pins act as power supply or ground, so they are not included in the button numbering scheme see the hardware docid\ uyyjyej6qojy1hksbrlpu associated with your player model to view a mapping of buttons to pins getversion() as string returns the version number of the firmware (either the main brightsign firmware or the brightsign expansion module firmware) responsible for the control port enableoutput(button as integer) as boolean marks the specified button as an output if an invalid button number is passed, false will be returned if successful, the function returns true the output will be driven high or low depending on the current output state of the pin enableinput(button as integer) as boolean marks the specified button as an input if an invalid button number is passed, false will be returned if successful, the function returns true the button will be tri stated and can be driven high or low externally enablealternatefunction(button as integer, pin function as string) as boolean enables an alternate function on a gpio button this method applies to the onboard gpio connector and is currently supported on the xtx44, xtx43, xdx34, xdx33, hdx24, hdx23, and ho523 models the first argument specifies the gpio button number (between 0 and 7) the second argument specifies the alternate function setting; the following table outlines the possible alternate setting for each pin gpio pin button number alternate function 3 0 "serial1" (rx) 4 1 "irin1" 5 2 "irout" (hdx23, ho523 only) 6 3 n/a 9 4 "serial0" (rx console port) 10 5 "serial0" (tx) 11 6 "serial1" (tx) 12 7 n/a models that do not have a 3 5mm serial port (e g hd223, xd233) do not support serial port 0 to revert a gpio button to its primary function, specify the pin function as "gpio" getwholestate() as integer returns the state of all the inputs attached to the control port as bits in an integer individual buttons can be checked using binary operations, although it is normally easier to call isinputactive() instead isinputactive(button as integer) as boolean returns the state of the specified input if the button is not configured as an input, then the result is undefined setwholestate(state as integer) as boolean specifies the desired state of all outputs attached to the control port as bits in an integer the individual buttons can be set using binary operations, although it is normally easier to call setoutputstate() instead example port = createobject("rocontrolport", "brightsign") gpio1 = 2 '2^1 gpio3 = 8 '2^3 gpio5 = 32 '2^5 gpio7 = 128 '2^7 port setwholestate(gpio1 + gpio2 + gpio5 + gpio7) 'turns on ports 1, 3, 5, and 7 setoutputstate(button as integer, level as boolean) as boolean configures the output of the specified pin, which can be either "off" (0) or "on" (1) if the button is not configured as an output, the resulting level is undefined this method can also be used to configure led output behavior on bp200/b900 button boards; see the rocontrolport docid 8exdhgmohqig7j uvfce1 section below for more details setoutputvalue(offset as integer, bit mask as integer) as boolean configures a button on a bp200/bp900 button board this method can only be used when the rocontrolport object is instantiated with the touchboard \<n> led setup or touchboard \<n> led parameter see the rocontrolport docid 8exdhgmohqig7j uvfce1 section below for more details setoutputvalues(values as roassociativearray) as boolean configures buttons on a bp200/bp900 button board this method can only be used when the rocontrolport object is instantiated with the touchboard \<n> led setup or touchboard \<n> led parameter see the rocontrolport docid 8exdhgmohqig7j uvfce1 section below for more details getproperties() as roassociativearray returns an associative array of values related to the attached bp200/bp900 button board, including hardware, header, and revision this method can only be used with an rocontrolport instantiated with the touchboard \<n> gpio parameter setpulseparams(parameters as roassociativearray) as boolean specifies a period of time, as well as the time slices within that period, for pulsing gpio leds these properties are applied to all gpio outputs this method is passed an associative array with the following parameters milliseconds an integer specifying the time period (in ms) for pulsing slices an integer specifying the number of divisions within the milliseconds time period for example, a 500ms time period with slices 2 is divided into two 250ms slices setpulse(button as integer, bit field as integer) as boolean sets the off/on bit field for a particular gpio use the slices parameter of the setpulseparams() method to determine the number of bits in the bit field for example, specifying milliseconds 500, slices 2 , and a bit field of 10 will cause the button to turn on every other 250 millisecond period removepulse(button as integer) as boolean removes the specified gpio from the set affected by the pulse ifmessageport setport(port as object) posts messages of type and docid 58tkuomyod8urhrp3uqy to the attached message port ifuserdata setuserdata(user data as object) sets the user data that will be returned when events are raised getuserdata() as object returns the user data that has previously been set via setuserdata() it will return invalid if no data has been set ifidentity getidentity() as integer returns an identity value that can be used to associate rocontrolup and rocontroldown events with this control port the ifidentity interface has been deprecated we recommend using the ifuserdata interface instead examples this example script applies timed pulses to a set of gpios ' set up button 2 and 3 to flash at 2hz (i e on & off twice in a second) in an alternating ' fashion gpioport = createobject("rocontrolport", "brightsign") gpioport enableoutput(2) gpioport setoutputstate(2, true) gpioport enableoutput(3) gpioport setoutputstate(3, true) ' set up pulse to have two time slices of 250ms each gpioport setpulseparams({ milliseconds 500, slices 2 }) ' button 2 will have slice 1 on and slice 2 off gpioport setpulse(2, \&h01) ' button 3 will have the reverse of button 2 gpioport setpulse(3, \&h02) ' wait for a bit sleep(10000) ' stop pulsing on button 2 gpioport removepulse(2) this example script enables various alternate functions on the gpio c = createobject("rocontrolport", "brightsign") 'enable serial port 1 on the gpio c enablealternatefunction(0, "serial1") c enablealternatefunction(6, "serial1") s1 = createobject("roserialport", 1, 115200) s1 sendline("this is serial port 1") mp = createobject("romessageport") s1 setlineeventport(mp) ? wait(10000, mp) 'switch serial port 0 from the 3 5mm serial port to the gpio '\[note it is advised use telnet/ssh or a script when testing this] c enablealternatefunction(4, "serial0") c enablealternatefunction(5, "serial0") s = createobject("roserialport", 0, 115200) s sendline("hello on the console?") mp = createobject("romessageport") s setlineeventport(mp) ? wait(10000, mp) 'restore normal operation on serial port 0 c enablealternatefunction(4, "gpio") c enablealternatefunction(5, "gpio") 'enable ir input on the gpio c = createobject("rocontrolport", "brightsign") ? c enablealternatefunction(1, "irin1") nexus encodings = \[ "nec", "nec32" ] ir gpio = createobject("roirreceiver", { source "gpio", encodings nexus encodings }) mp = createobject("romessageport") ir gpio setport(mp) m = wait(10000, mp) 'enable ir output on the gpio (hdx23, ho523 only the xt/xd models have a dedicated 3 5mm ir socket) c enablealternatefunction(2, "irout") ir = createobject("roirtransmitter", { destination "gpio"} ) ir send("nec32", \&h12345) bp200/bp900 setup to send a configuration to the bp200/bp900 button board, instantiate rocontrolport with the touchboard \<n> led setup parameter and call the setoutputvalue() method this method accepts two integers the first integer specifies one of three command types (offsets); the second integer is a bit field consisting of 32 bits offset 0 configures the button board using a bit field that is split into four bytes of eight bits each each byte is a separate part of the configuration in the script, these bytes need to be listed from right to left in hex value (i e byte 1 + byte 2 + byte 3 + byte 4) byte 1 specifies the configuration type for the button board currently, the only configuration type is for led output, which is specified with the value \&ha0 byte 2 the button number(s) that will be configured buttons are numbered beginning from 1 the value is set to 0 (\&h00) if this command is not required byte 3 the led bit field configuration this value specifies how many on/off bits should be used (up to 32 bits) when setoutputvalue() is called on a touchboard \<n> led instance (see the bp200/bp900 led output section below for details) set the value to 0 (\&h00) if this command is not required (the bit field will be set to eight bits by default) byte 4 this value is currently always set to 0 (\&h00) offset 1 disables buttons on the button board according to values in the bit field each button is disabled individually by setting bits 0 10 for example, passing the hex value \&h00000008 will disable button 4 only offset 2 disables leds on the button board according to values in the bit field each led is disabled individually by setting bits 0 10 for example, passing the hex value \&h00000080 will disable the led on button 8 only disabling a button led will not automatically disable the button itself (and vice versa) to disable both the button and the led, make separate setoutputvalue() calls for offset 1 and offset 2 bp200/bp900 led output to control the behavior of individual button leds, instantiate rocontrolport with the touchboard \<n> led parameter, then pass per led bit fields to the setoutputvalue() method this method accepts two integers the first integer specifies the button number (0 11), while the second integer uses a bit field to specify the on/off behavior of the button led the size of the bit field (up to 32 bits) is determined with the offset 0 – byte 3 value described in the section above each bit specifies the on/off behavior of a single cycle, and the bp200/bp900 button boards run at approximately 11hz for example, if you want an led to cycle on every other second, you would set the offset 0 – byte 3 value to \&h16 (22 bits) and the bit field itself to \&h3ff800 (0000000000011111111111) this example script sets a bp900 to “twinkle” by turning off each button led at a different point in the cycle led=createobject("rocontrolport", "touchboard 0 led") led setup=createobject("rocontrolport", "touchboard 0 led setup") led setup setoutputvalue(0, \&h000b00a0) led setoutputvalue(0, \&h07fe) led setoutputvalue(1, \&h07fd) led setoutputvalue(2, \&h07fb) led setoutputvalue(3, \&h07f7) led setoutputvalue(4, \&h07ef) led setoutputvalue(5, \&h07df) led setoutputvalue(6, \&h07bf) led setoutputvalue(7, \&h077f) led setoutputvalue(8, \&h06ff) led setoutputvalue(9, \&h05ff) led setoutputvalue(10, \&h03ff) see controlport docid\ n8yocsdagogqcp1oyuolw for the equivalent example (setting a bp900 to twinkle) in javascript