Player APIs (BrightScript & Ja...
BrightScript-JavaScript Object...
BSControlPort
9min
this object provides support for the bp200/bp900 usb button boards and gpio ports button presses are returned as oncontroldown and oncontrolup 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 bscontrolport(in domstring portname) 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) methods see the hardware interfaces section for your player in hardware docid\ uyyjyej6qojy1hksbrlpu for a table of pins and corresponding buttons for the onboard gpio connector boolean configureasinput (unsigned button) marks the specified button as an input if an invalid button number is passed, false will be returned if successful, the function returns true input buttons are tri stated and can be driven high or low externally boolean configureasoutput (unsigned button) 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 boolean setpinvalue(unsigned button, unsigned output) configures the output of the specified button, which can be either low (0) or high (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 rocontrolport docid 8exdhgmohqig7j uvfce1 boolean getpinvalue(unsigned button) returns the output of the specified button void close() shuts down the bscontrolport instance, preventing it from further consuming resources if this method is not called, garbage collection determines when the instance will be destroyed boolean setoutputvalue(unsigned param) 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 the parameter is an 8 bit integer and each bit represents an output boolean setoutputvalues(unsigned param1, unsigned param2, unsigned param3, unsigned param4) configures buttons on a bp200/bp900 button board this method can only be used when the bscontrolport object is instantiated with the touchboard \<n> led setup or touchboard \<n> led parameter the parameters are integer values events the following events are available on the bscontrolport object each event can receive a controlportevent event oncontroldown oncontrolup oncontrolevent controlportevent – attributes readonly attribute unsigned long code examples the following example code configures four gpio outputs var gpio = new bscontrolport("brightsign"); // set outputs gpio configureasoutput(0); gpio configureasoutput(1); gpio configureasoutput(2); gpio configureasoutput(3); // set desired states gpio setpinvalue(0, 1); gpio setpinvalue(1, 1); gpio setpinvalue(2, 0); gpio setpinvalue(3, 0); the following example causes the leds on a bp900 button board to twinkle var bp900 gpio; function myfunction() { var bp900 setup = new bscontrolport("touchboard 0 led setup"); bp900 setup setpinvalue(0, 11) var bp900 = new bscontrolport("touchboard 0 led"); bp900 setpinvalue(0, 0x07fe) bp900 setpinvalue(1, 0x07fd) bp900 setpinvalue(2, 0x07fb) bp900 setpinvalue(3, 0x07f7) bp900 setpinvalue(4, 0x07ef) bp900 setpinvalue(5, 0x07df) bp900 setpinvalue(6, 0x07bf) bp900 setpinvalue(7, 0x077f) bp900 setpinvalue(8, 0x06ff) bp900 setpinvalue(9, 0x05ff) bp900 setpinvalue(10, 0x03ff) bp900 gpio = new bscontrolport("touchboard 0 gpio"); bp900 gpio oncontroldown = function(e) { console log('###### oncontroldown' + e code); } } the following example displays events from a gpio expander board note that using the equivalent rogpiocontrolport object in brightscript at the same time will result in unpredictable i/o behavior \<html> \<head> \<script> var bp900 gpio = new bscontrolport("brightsign"); bp900 gpio oncontroldown = function(e){ console log('### oncontroldown ' + e code); newtext = " down " + e code + "\n"; document myform outputtext value += newtext; document myform outputtext scrolltop = document myform outputtext scrollheight; } bp900 gpio oncontrolup = function(e){ console log('### oncontrolup ' + e code); newtext = " up " + e code + "\n"; document myform outputtext value += newtext; document myform outputtext scrolltop = document myform outputtext scrollheight; } bp900 gpio oncontrolevent = function(e){ console log('### oncontrolevent ' + e code); newtext = "event " + e code + "\n"; document myform outputtext value += newtext; document myform outputtext scrolltop = document myform outputtext scrollheight; } function ledon(output index) { bp900 gpio configureasoutput(output index); newtext = " led " + output index + "\n"; document myform outputtext value += newtext; document myform outputtext scrolltop = document myform outputtext scrollheight; } function buttonon(output index) { bp900 gpio configureasinput(output index); newtext = "input " + output index + "\n"; document myform outputtext value += newtext; document myform outputtext scrolltop = document myform outputtext scrollheight; } \</script> \</head> \<body bgcolor="#e6e6fa"> \<h1>gpio/expander test page\</h1> note this does not play well with \<em>rogpiocontrolport\</em>!!\<br>\<br> \<input type="button" onclick="ledon(0)" value="led0"> \<input type="button" onclick="ledon(1)" value="led1"> \<input type="button" onclick="ledon(2)" value="led2"> \<input type="button" onclick="ledon(3)" value="led3"> \<input type="button" onclick="ledon(4)" value="led4"> \<input type="button" onclick="ledon(5)" value="led5"> \<input type="button" onclick="ledon(6)" value="led6"> \<input type="button" onclick="ledon(7)" value="led7"> \<br> \<input type="button" onclick="buttonon(0)" value="button0"> \<input type="button" onclick="buttonon(1)" value="button1"> \<input type="button" onclick="buttonon(2)" value="button2"> \<input type="button" onclick="buttonon(3)" value="button3"> \<input type="button" onclick="buttonon(4)" value="button4"> \<input type="button" onclick="buttonon(5)" value="button5"> \<input type="button" onclick="buttonon(6)" value="button6"> \<input type="button" onclick="buttonon(7)" value="button7"> \<br> \<form name="myform"> \<textarea readonly rows="50" cols="100" name="outputtext" style="font family\ monospace">\</textarea> \</form> \</body> \</html>