Option Explicit '======================================================================================== 'Module Title: BetaBrite_R2.Bas '======================================================================================== 'Author: ZbasicAndy '======================================================================================== 'Date: '======================================================================================== 'Operating System: XP '======================================================================================== 'ZBasic IDE Version: 1.0.4 / ZBasic Compiler version 1-1-18 / ZX-40 Firmware v1.1.6 '======================================================================================== 'Target: ZX-40 '======================================================================================== 'Hardware: "Super Comm Z R1" ([4 software serial & 1 Hardware] RS232 ports with ZX-40 PCB) 'Main/Support Modules Needed: ComSupport_R1.bas - for basic serial communications subroutines. ' Super_Comm_Z_R1.bas - "Sub Main" basic project module '======================================================================================== 'Comport used: ZX-40 comport 3 @ 9600 7 E 1 - DO NOT CHANGE THE COMMUNICATION PARAMETERS! '======================================================================================== 'Bugs fixes and updates: ' ' ' ' ' ' ' ' '======================================================================================== ' Module Description: ' ' This program demostrates the "basic commands" needed to display information on the ' BetaBrite 5 x 7 dot multicolor LED message display using the "Super Comm Z" ' Note: BetaBrite 2" high 5 x 7 dot single line LED message display sign - obtained from ' Sam's Club $158.00 plus tax. ' Please hook up the cable first to your PC and run the test demo supplied on the CD. ' ' This software ONLY writes to file "A" to display text. If you need to display and sequence ' multi-line text and special dot displays please obtain the protocol manual from ' http://www.ams-i.com/ and find doc led97088061 (word doc). ' Also, go to the following website and get a better BetaBrite primer ' http://dens-site.net/betabrite/betabrite.htm ' ' To test - just plug in to J2 (Comm3) on the "Super Comm Z board" ' Run the test routines e.g. "call BBTest?()" "once" and do not loop without a time delay. ' ' '========================================================================================= ' ' '========================================================================================= 'Program Definitions: '========================================================================================= '========================================================================================= 'Constants '[Public | Private] Const As = (default private) '========================================================================================= ' Betabrite protocol constants Private Const NUL as byte = 0 ' null Private Const SOH as byte = 1 ' start of header Private Const ALL_SIGNS_TYPE as byte = 90 ' all betabrite signs "Z" Private Const STX as byte = 2 ' start of text Private Const FILE_LABLE as byte = 65 ' which betabrite file to write to "A" Private Const ESC as byte = 27 ' escape char Private Const TOP_LINE as byte = 34 ' top line on a multi-line display Private Const MIDDLE_LINE as byte = 32 ' middle line - works best on betabrite '[Command Codes] Private Const WRITE_Txt_File as byte = 65 ' Write TEXT file Private Const READ_Txt_File as byte = 66 ' Read TEXT file Private Const WRITE_SPEC as byte = 69 ' Write SPECIAL Function file Private Const READ_SPEC as byte = 70 ' Read SPECIAL Function file Private Const WRITE_STRING as byte = 71 ' Write String file Private Const READ_STRING as byte = 72 ' Read String file Private Const WRITE_DOT as byte = 73 ' Write DOT file Private Const READ_DOT as byte = 74 ' Read DOT file '[Modes] Private Const ROTATE_MODE as byte = 97 ' message travels right to left Private Const HOLD_MODE as byte = 98 ' message stays stationary Private Const FLASH_MODE as byte = 99 ' message stays stationary and flashes Private Const ROLL_UP_MODE as byte = 101 ' message is pushed up by new message Private Const ROLL_DOWN_MODE as byte = 102 ' message is pushed down by new message Private Const ROLL_LEFT_MODE as byte = 103 ' message is pushed left by new message Private Const ROLL_RIGHT_MODE as byte = 104 ' message is pushed right by new message Private Const WIPE_UP_MODE as byte = 105 ' message is wiped from bttom to top Private Const WIPE_DOWN_MODE as byte = 106 ' message is wiped from top to bottom Private Const WIPE_LEFT_MODE as byte = 107 ' message is wiped from right ot left Private Const WIPE_RIGHT_MODE as byte = 108 ' message is wiped from left to right Private Const SCROLL_MODE as byte = 109 ' message pushed bottom line to top on 2-line signs Private Const AUTO_MODE as byte = 111 ' messages are displayed with various modes automatically Private Const ROLL_IN_MODE as byte = 112 ' message is pushed toward center Private Const ROLL_OUT_MODE as byte = 113 ' message is pushed outward Private Const WIPE_IN_MODE as byte = 114 ' message is wiped inward Private Const WIPE_OUT_MODE as byte = 115 ' message is wiped from center outward Private Const COMP_ROT_MODE as byte = 116 ' compressed text rotate mode Private Const SPECIAL_MODE as byte = 110 ' special mode - must be followed by special mode code 'Special Modes Private Const TWINKLE_SPMODE as byte = 48 ' message will twinkle on display Private Const SPARKLE_SPMODE as byte = 49 ' message will sparkle over old message Private Const SNOW_SPMODE as byte = 50 ' message will snow fall onto display Private Const INTERLOCK_SPMODE as byte = 51 ' message will interlock over old message Private Const SWITCH_SPMODE as byte = 52 ' message will switch onto display Private Const SLIDE_SPMODE as byte = 53 ' message will slide onto display Private Const SPRAY_SPMODE as byte = 54 ' message is sprayed onto display Private Const STARBURST_SPMODE as byte = 55 ' message will explodes onto display 'Graphics Private Const WELCOME_GRAPHICS as byte = 56 ' displays a welcome message Private Const SLOT_GRAPHICS as byte = 57 ' displays slot machine symbols across the display Private Const NEWS_GRAPHICS as byte = 65 ' news flash animation Private Const TRUMPET_GRAPHICS as byte = 66 ' Trumpet Animation Private Const THANK_GRAPHICS as byte = 83 ' displays thank you Private Const NO_SMOKE_GRAPHICS as byte = 85 ' displays no smoking animation Private Const DONT_DRNK_GRAHICS as byte = 86 ' displays don't drink & drive animation Private Const FISH_GRAPHICS as byte = 87 ' displays a running animal animation Private Const FIREWORK_GRAPHICS as byte = 88 ' displays fireworks animation Private Const BALLONS_GRAPHICS as byte = 89 ' displays a car driving animation Private Const BOMB_GRAPHICS as byte = 90 ' displays a bomb explosion animation 'Colors Private Const SELECT_COLOR as byte = 28 ' color selection char Private Const RED_COLOR as byte = 49 ' red display Private Const GREEN_COLOR as byte = 50 ' green display Private Const AMBER_COLOR as byte = 51 ' amber display Private Const RAINBOW1_COLOR as byte = 57 ' rainbow color display Private Const RAINBOW2_COLOR as byte = 65 ' rainbow color display Private Const MIXED_COLOR as byte = 66 ' mixed color display Private Const AUTO_COLOR as byte = 67 ' auto color display Private Const EOT as byte = 4 ' end of transmission Private Const ETX as byte = 3 ' end of text Private Const BB_DLy AS SINGLE = 10.0 '========================================================================================= 'Variables '{Public | Private | Dim} As (default private) '========================================================================================= 'BetaBrite Variables Private color_BB as Byte ' select color to display Private mode as Byte ' select mode Private spmode as Byte ' special mode code modifier Private startAddr as Integer ' used to point to eeprom data Private char as Byte ' used to hold eeprom data '========================================================================================= 'Subroutines '========================================================================================= 'BetaBrite Subroutines 'Displays CID information '========================================================================================= ' Application specific subroutine for CID '========================================================================================= Public Sub Display_CID(Byref CID_Time as string, Byref CID_Date as string, _ Byref CID_NMBR as string, Byref CID_Name as string, Byref CID_Alt_Name as string, _ Byref location as string, Byref color as byte,Byref Display_Mode as byte) 'For CID display dim BB_Color as byte dim Display_Text as string dim i as integer dim BB_Dly1 as single BB_Dly1 = 1.0 For i = 1 To 10 Debug.Print CStr(i) Next i Select Case Display_Mode Case 1 'no number found - no location and number - CID_NMBR & CID_Name - color (red) For i = 1 To 3 Display_Text = CID_NMBR BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Display_Text = CID_Name BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Next i Case 2 'telemarketer - location ,CID_alt_name, CID_NMBR - color (red) For i = 1 To 3 Display_Text = location BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Display_Text = CID_Alt_Name BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Display_Text = CID_NMBR BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Next i Case 3 'number found - use location, CID_NMBR, CID_Name - do not use CID_alt_name - color (x) For i = 1 To 3 Display_Text = location BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Display_Text = CID_NMBR BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Display_Text = CID_Name BB_Color = color Call Output_BetaBrite(BB_Color,Display_Text) CALL delay(BB_DLy1) Next i End Select End Sub '========================================================================================= ' Application specific subroutine for Test Routines '========================================================================================= Public Sub Display_BB_Message(ByRef BB_Message as string, ByVal Color as BYTE) '13 chars max Color_BB = Color mode = HOLD_MODE ' then select mode (see constants above for options) Call SendHeader() ' next, send the header info Call PutStr_3(BB_Message) 'Do not exceed display characters or the sign will roll. Call SendEot() ' end by sending the end of text message 'CALL delay(BB_DLy) ' display it for a while End Sub '========================================================================================= ' Application specific subroutine for CID '========================================================================================= Private Sub Output_BetaBrite(Byref BB_Color as byte, Byref Display_Text as string) 'CID display Color_BB = BB_Color ' start by selecting color (see constants above for options) mode = HOLD_MODE ' then select mode (see constants above for options) Call SendHeader() ' next, send the header info Call PutStr_3(Display_Text) ' Do not exceed display characters or the sign will roll. Call SendEot() ' end by sending the end of text message End Sub '============================================================================================ ' BetaBrite Test Subs '============================================================================================ Public Sub BBTest1() 'Example using text in program (hard-coded) dim tx as string tx = "ZBasic ZX-40" Color_BB = MIXED_COLOR ' start by selecting color (see constants above for options) mode = HOLD_MODE ' then select mode (see constants above for options) Call SendHeader() ' next, send the header info Call PutStr_3(Tx) ' Do not exceed display characters or the sign will roll. Call SendEot() ' end by sending the end of text message CALL delay(BB_DLy) ' display it for a while End Sub ' '================================================================================================================= ' Example using text in program with special mode Public Sub BBTest2() dim tx as string tx = "Super Comm Z" Color_BB = GREEN_COLOR ' select color mode = SPECIAL_MODE ' SPECIAL_MODE requires a special mode code spmode = SNOW_SPMODE ' special mode code Call SendHeader() ' next, send the header info Call PutStr_3(Tx) 'Do not exceed display characters or the sign will roll. Call SendEot() ' end by sending the end of text message CALL delay(BB_DLy) ' display it for a while End Sub ' '================================================================================================================= ' Example using graphics mode Public Sub BBTest3() dim tx as string tx = "BetaBrite" Color_BB = AMBER_COLOR ' select color mode = SPECIAL_MODE ' SPECIAL_MODE requires a special mode code spmode = FIREWORK_GRAPHICS ' special mode code Call SendHeader() ' next, send the header info Call PutStr_3(Tx) 'Do not exceed display characters or the sign will roll. Call SendEot() ' end by sending the end of text message CALL delay(BB_DLy) ' display it for a while End Sub ' '================================================================================================================= Public Sub BBTest4() 'Example using text in program (hard-coded) to clear the BetaBrite screen. dim tx as string tx = " " Color_BB = MIXED_COLOR ' start by selecting color (see constants above for options) mode = HOLD_MODE ' then select mode (see constants above for options) Call SendHeader() ' next, send the header info Call PutStr_3(Tx) 'Do not exceed display characters or the sign will roll. Call SendEot() ' end by sending the end of text message CALL delay(BB_DLy) ' display it for a while End Sub '================================================================================================================= 'Example using text in program (hard-coded) Public Sub BBTest5() dim tx as string tx = "123456789ABCD" Color_BB = MIXED_COLOR ' start by selecting color (see constants above for options) mode = HOLD_MODE ' then select mode (see constants above for options) Call SendHeader() ' next, send the header info Call PutStr_3(Tx) 'Do not exceed display characters or the sign will roll. Call SendEot() ' end by sending the end of text message CALL delay(BB_DLy) ' display it for a while End Sub '================================================================================================ 'Standard Transmission Frame '[ NULs ][ SOH ][ Type Code ][ Sign Address ][ STX ] [ Command Code ][ Data Field ] [ EOT ] 'The [ Command Code ][ Data Field ] can be broken down into the following parts for a WRITE TEXT frame '[COMMAND CODE][FILE LABEL] [Display Position][Mode Code] Special Specifier [ASCII MESSAGE] '------------------------------------------------------------------------ Private sub SendHeader() ' Send 6 nulls 'was 5 CALL PutByte_3(NUL) CALL PutByte_3(NUL) CALL PutByte_3(NUL) CALL PutByte_3(NUL) CALL PutByte_3(NUL) CALL PutByte_3(NUL) ' Start of header CALL PutByte_3(SOH) '1 ' Sign code CALL PutByte_3(ALL_SIGNS_TYPE) 'Z - sign code - all signs ' Sign address CALL PutByte_3(48) '0 - sign address CALL PutByte_3(48) '0 - sign address ' Start of text char CALL PutByte_3(STX) '2 - start of text ' Command Code CALL PutByte_3(WRITE_TXT_FILE)'A - Command code - write ' File label CALL PutByte_3(FILE_LABLE) 'A ' Escape CALL PutByte_3(ESC) '27 ' Display position CALL PutByte_3(TOP_LINE) '34 ' Mode code CALL PutByte_3(MODE) ' Special mode If mode = SPECIAL_MODE Then Call SendSpecialModeCode() Else Call SelectColor() End If End Sub '================================================================================================================ Private Sub SelectColor() 'Select color CALL PutByte_3(SELECT_COLOR) CALL PutByte_3(COLOR_BB) End Sub ' '================================================================================================================= Private Sub SendEOT() 'End of transmission char CALL PutByte_3(EOT) End Sub ' '================================================================================================================ ' Private Sub SendSpecialModeCode() 'Sends a special mode code. Use only with mode code of SPECIAL_MODE CALL PutByte_3(SPMODE) CALL SelectColor() End Sub ' '==============================================================================================