rem usbevent2video.brs rem only usb events this script Sub Main() Development = False 'Development = True If Development ? "This is usb2video.brs" Endif '*********************************************************************** 'creating the message port mp=CreateObject("roMessagePort") '*********************************************************************** 'creating the USB-Serial port USB_Serial=CreateObject("roSerialPort",2,38400) USB_Serial.SetLineEventPort(mp) 'attach USB messages to the message port 'NOW CREATING THE RECTANGLE TO HOLD THE CANVAS WIDGETS RECT1 = CreateObject("roRectangle",0,0,1920,1080) cw1 = CreateObject("roCanvasWidget",rect1) rem this next line causes a runtime errro rem cw1.SetbackgroundColor("#808080") aa1 = CreateObject("roAssociativeArray") aa1["text"] = "HMS Electronics 'USB Event' Script" aa2 = CreateObject("roAssociativeArray") aa2["text"] = "Waiting on USB Event" aa3 = CreateObject("roAssociativeArray") aa3["text"] = "Waiting on USB Event" aa1["targetRect"] = { x: 280, 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: 280, y:380, w:1000, h:200 } aa2["textAttrs"] = { Color:"#ffffff", font:"Large", HAlign:"Center" , vAlign: "Top" } aa3["targetRect"] = { x: 280, 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 '********************************************************** 'this is a forever loop if development ? "waiting for a USB 'LineEvent'" endif 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) rem aa3["text"] = "Message Value = "+str(val(msg)) aa3["text"] = "Message Value = "+msg cw1.SetLayer(aa3,3) cw1.EnableAutoRedraw(1) endwhile End Sub