'------------------------------------------------------------------------------- ' LCD Contrl Library Author: Gary G. Herbst '------------------------------------------------------------------------------- Const SERPIN As Byte = 10 ' Change based on connection Const ASCII_BKL_ON As Byte = 14 Const ASCII_BKL_OFF As Byte = 15 Const ASCII_NULL As Byte = 0 Const ASCII_HOME As Byte = 1 Const ASCII_HIDE As Byte = 4 Const ASCII_SHOW_UNDERLINE As Byte = 5 Const ASCII_SHOW_BLINK_BLOCK As Byte = 6 Const ASCII_BELL As Byte = 7 Const ASCII_BACKSPACE As Byte = 8 Const ASCII_HTAB As Byte = 9 Const ASCII_SMART_LINEFEED As Byte = 10 Const ASCII_VTAB As Byte = 11 Const ASCII_CLEAR As Byte = 12 Const ASCII_CF As Byte = 13 Const ASCII_CUR_POS As Byte = 16 Const ASCII_RIGHT_ALIGN As Byte = 18 Const ASCII_ESCAPE As Byte = 27 '------------------------------------------------------------------------------- Dim OutBuffer(1 To 30) As Byte Dim InBuffer(1 To 15) As Byte '------------------------------------------------------------------------------- Sub Main() ' Turn on Back Light Call LCDBackLight(true) ' Clear display and home cursor Call LCDSendASCII(ASCII_HOME) Call LCDSendASCII(ASCII_CLEAR) Call LCDSendString(" Test Line 1") Call LCDSendASCII(ASCII_CF) Call LCDSendString(" Test Line 2") Sleep 4000 ' Turn on Back Light Call LCDBackLight(false) ' Clear display and home cursor Call LCDSendASCII(ASCII_HOME) Call LCDSendASCII(ASCII_CLEAR) End Sub '-------------------------------------------------------------- '- Turn LCD backlight on/off '-------------------------------------------------------------- Sub LCDBackLight( ByVal Param1 As Boolean) if (Param1) then ' Turn on Back Light Call PutQueueStr(OutBuffer, Chr(ASCII_BKL_ON)) Else ' Turn off Back Light Call PutQueueStr(OutBuffer, Chr(ASCII_BKL_OFF)) End if End Sub '-------------------------------------------------------------- '- Send ASCII '-------------------------------------------------------------- Sub LCDSendASCII( ByVal Param1 As Byte) Call PutQueueStr(OutBuffer, Chr(Param1)) End Sub '-------------------------------------------------------------- '- Send String '-------------------------------------------------------------- Sub LCDSendString( ByVal Param1 As String) Call PutQueueStr(OutBuffer, Param1) End Sub '-------------------------------------------------------------- '- Configure LCD Commuications '-------------------------------------------------------------- Sub LCDSendString( ByVal Param1 As String) Call OpenQueue(OutBuffer, 30) Call OpenQueue(InBuffer, 15) Call DefineCom3(0, SERPIN, bx1000_1000) ' Inverted, no parity 8 data bits Call OpenCom(3,2400,InBuffer, OutBuffer) Call Delay(0.5) End Sub