rem serial2video.brs rem TTL-serial or GPIO events this script Sub Main() 'NOTE:SERIES_3 MACHINES REQUIRE 'INVERTED' TO WORK WITH THE HMS 'USB-S3' BOARDS 'SERIES_3 = TRUE SERIES_3 = FALSE Development = False 'Development = True If Development ? "This is serial2video.brs" Endif '*********************************************************************** 'creating the message port mp=CreateObject("roMessagePort") '*********************************************************************** 'creating the Serial port Serial=CreateObject("roSerialPort",0,38400) Serial.SetLineEventPort(mp) 'attach USB messages to the message port 'this next line required for Series 3 BrightSigns 'this set the 'tip' of the 3.5mm stereo connector to a positive state IF SERIES_3 Serial.SetInverted(True) ENDIF '*********************************************************************** 'creating the gpio contol port gpio = CreateObject("roGpioControlPort") gpio.SetPort(mp) 'tie port changes to the message object '*********************************************************************** 'NOW CREATING THE RECTANGLE TO HOLD THE CANVAS WIDGETS RECT1 = CreateObject("roRectangle",0,0,1920,1080) cw1 = CreateObject("roCanvasWidget",rect1) aa1 = CreateObject("roAssociativeArray") aa1["text"] = "HMS Electronics 'Serial/GPIO Event' Script" aa2 = CreateObject("roAssociativeArray") aa2["text"] = "Waiting on Serial/GPIO Event" aa3 = CreateObject("roAssociativeArray") aa3["text"] = "Waiting on Serial/GPIO Event" aa1["targetRect"] = { x: 300, y:180, w:1000, h:200 } aa1["textAttrs"] = { Color:"#ffffff", font:"Huge", HAlign:"Center" , vAlign: "Top" } '******************************************************************************* 'Dick:can't seem to set the color of the rectangle of the canvas widget rem aa1["backgroundColor"] = { Color: "#808080"} rem aa1.AddReplace("backgroundColor", &h10ff10) this does nothing '******************************************************************************* aa2["targetRect"] = { x: 300, y:380, w:1000, h:200 } aa2["textAttrs"] = { Color:"#ffffff", font:"Large", HAlign:"Center" , vAlign: "Top" } aa3["targetRect"] = { x: 300, y:580, w:1000, h:200 } aa3["textAttrs"] = { Color:"#ffffff", font:"Large", HAlign:"Center" , vAlign: "Top" } 'now show the rectangle?? ok = cw1.Show() if Development ? "just did show ";ok sleep(10000) endif cw1.Setlayer(aa1, 1) cw1.Setlayer(aa2, 2) cw1.Setlayer(aa3, 3) cw1.EnableAutoRedraw(1) if development ? "should have a multiple canvas widgets on the screen with text" endif '********************************************************** if development ? "waiting for a Serial 'LineEvent' or GPIO Event" endif 'this is a forever loop while true 'wait for a message msg = wait(0,mp) if development ? "Got a message" ? "type message =";type(msg) endif cw1.EnableAutoRedraw(0) aa2["text"]="Message Type = "+type(msg) cw1.SetLayer(aa2,2) if type(msg)="roStreamLineEvent" aa3["text"] = "Serial Value = "+msg endif if type(msg)="roGpioButton" aa3["text"] = "Button Number = "+str(msg.getInt()) endif cw1.SetLayer(aa3,3) cw1.EnableAutoRedraw(1) endwhile End Sub