'------------------------------------------------------------------------------- ' WCSPrismV22.BAS, for QB64 compiler for Windows ' Example code for sending messages to the USB BetaBrite Prism by allocating ' memory and using STRING and TEXT file commands. ' Copyright 2012, provided courtesy of Walker Consulting Solutions ' ' Based on PRISMMES.BAS - Gary Peek - IndustroLogic, Inc. ' ' Requires betabriteusb.dll in the same folder as QB64 exe. ' betabriteusb.dll copyright Adaptive Micro Systems. ' ' See SEGGER Microcontroller Systemes GmbH USB Bulk Stack documentation for info ' on USBBULK_ functions. '------------------------------------------------------------------------------- DECLARE DYNAMIC LIBRARY "betabriteusb" FUNCTION USBBULK_Open () FUNCTION USBBULK_Close () FUNCTION USBBULK_Write (msg AS STRING, BYVAL SIZE AS LONG) END DECLARE DIM bbMode AS STRING DIM bbColor AS STRING DIM bbText AS STRING DIM bbString AS STRING DIM returnval AS INTEGER DIM autobaud AS STRING autobaud = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) ' autobaud NULL characters bbMode = "a" ' mode = rotate bbColor = CHR$(28) + "Z" + "40FFFF" ' extended RGB color (whitish blue) 'This program can be run from the command line by typing the name of the executable to display 'the default text or a custom message can be included after the executable name. bbText = "Betabrite Prism Example v2.2 by Walker Consulting Solutions www.WalkerConsulting.net" IF LEN(COMMAND$) > 0 THEN bbText = COMMAND$ ELSE PRINT "Type your custom message after the command line call to this program" END IF PRINT "DISPLAY PROPERTIES" PRINT "Display Mode = " + bbMode PRINT "Display Color = " + bbColor PRINT "Display Text = " + bbText PRINT "" PRINT "Attempting to open USB" IF USBBULK_Open = 0 THEN PRINT "There was a problem opening the USB connection" returnval = USBBULK_Close ELSE PRINT "USB Connection Successful" END IF PRINT "" 'Compose Alpha transmission packet to write memory configuration for a text file and 'a string file (Letters in parens reference Alpha protocol document) bbString = autobaud 'autobaud NULL characters (A) bbString = bbString + CHR$(1) 'SOH character (B) bbString = bbString + "Z" 'Type Code: All Signs (C) bbString = bbString + "00" 'Sign Address: Broadcast (D) bbString = bbString + CHR$(2) 'STX Character (E) bbString = bbString + "E" 'Command Code E: SPECIAL FUNCTION (F) bbString = bbString + "$" 'Spcl Func Lbl $: Clear/Set Memory (G-B-1) bbString = bbString + "A" 'File Label: A (G1-B-2F) bbString = bbString + "A" 'File Type A: TEXT File (G1-B-2T) bbString = bbString + "U" 'Keyboard Unlocked (G1-B-2P) bbString = bbString + "0400" 'TEXT file size 0400h = 1024 bytes (G1-B-2SIZE) bbString = bbString + "FF" 'Start Time: FF = always on (G1-B-2QQ) bbString = bbString + "00" 'Stop Time: 00 Ignored (G1-B-2QQ) bbString = bbString + "1" 'File Label: 1 (G2-B-2F) bbString = bbString + "B" 'File Type A: STRING File (G2-B-2T) bbString = bbString + "L" 'Keyboard Locked (G2-B-2P) bbString = bbString + "4096" 'STRING file size 4096h = 16534 bytes (G2-B-2SIZE) bbString = bbString + "0000" 'NA for STRING file (G2-B-2QQQQ) bbString = bbString + CHR$(4) 'EOT Character (H) PRINT "Write bbString = " + bbString returnval = USBBULK_Write(bbString, LEN(bbString)) 'Compose Alpha transmission packet to send message file (with string file in it) bbString = autobaud 'autobauding NULL characters (A) bbString = bbString + CHR$(1) 'SOH character (B) bbString = bbString + "Z" 'Type Code: All Signs (C) bbString = bbString + "00" 'Sign Address: Broadcast (D) bbString = bbString + CHR$(2) 'STX Character (E) bbString = bbString + "A" 'Command Code: A = TEXT file (F) bbString = bbString + "A" 'File Label: A (G-B) bbString = bbString + CHR$(27) 'ESC Character (G-C) bbString = bbString + " " 'Display Position (ignored on 1line sign) (G-D) bbString = bbString + bbMode 'Display mode (from var above) (G-E) bbString = bbString + CHR$(16) 'Special Specifier (ignored?) (G-F) bbString = bbString + "1" 'ASCII Message (G-G) bbString = bbString + CHR$(4) 'EOT Character (H) PRINT "Write bbString = " + bbString returnval = USBBULK_Write(bbString, LEN(bbString)) 'Compose Alpha transmission packet to send message to fill string file bbString = autobaud 'autobauding NULL characters (A) bbString = bbString + CHR$(1) 'SOH character (B) bbString = bbString + "Z" 'Type Code: All Signs (C) bbString = bbString + "00" 'Sign Address: Broadcast (D) bbString = bbString + CHR$(2) 'STX Character (E) bbString = bbString + "G" 'Command Code: G = STRING file (F) bbString = bbString + "1" 'File Label: 1 (G-B) bbString = bbString + bbColor + bbText 'STRING file data (G-C) bbString = bbString + CHR$(4) 'EOT Character (H) PRINT "Write bbString = " + bbString returnval = USBBULK_Write(bbString, LEN(bbString)) PRINT "Close USBBulk Device" returnval = USBBULK_Close 'Uncomment the SYSTEM call to automatically close the window after the message has been sent 'Leave it commented to show debugging information 'SYSTEM