' LCDModule.bas ' By C.D.Odom on 12.18.05 ' Initialization code for the 2x16 LCD screen sold by Netmedia Option Explicit ' Global Variables ' ////// LCD Constants ///// ' From LCD documentation Dim Com3In(1 to 15) as Byte Dim Com3Out(1 to 40) as Byte Const BackLite as Byte = 20 ' plug the backlight cable into any 5V power pin Const Contrast as Byte = 19 Const Clear_LCD as Byte = 12 Const Set_Cursor as Byte = 17 Const BackLiteBrightness as Byte = 100 ' 0 to 255 Const ContrastLevel as Byte = 70 ' 0 to 255 ' ///// Pin Constants /////// Const LCDOutPutPin as Byte = 20 ' RAMB 15 ' /////////// InitLCD ////////// Public Sub InitLCD() Call OpenQueue(Com3In, 15) Call OpenQueue(Com3Out, 40) Call DefineCom3(0,LCDOutPutPin, bx1000_1000) Call OpenCom(3, 9600, Com3In, Com3Out) End Sub ' /////////// Display ////////// Public Sub Display(ByVal MSG as String) Call PutQueueStr(Com3Out, Chr(BackLite) & Chr(BackLiteBrightness)) Call PutQueueStr(Com3Out, Chr(Contrast) & Chr(ContrastLevel)) Call PutQueueStr(Com3Out, Chr(Clear_LCD)) Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(0) & Chr(0)) Call PutQueueStr(Com3Out, MSG) End Sub ' /////////// Display2Lines ////////// Public Sub Display2Lines(ByVal MSG1 as String, ByVal MSG2 as String) Call PutQueueStr(Com3Out, Chr(BackLite) & Chr(BackLiteBrightness)) Call PutQueueStr(Com3Out, Chr(Contrast) & Chr(ContrastLevel)) Call PutQueueStr(Com3Out, Chr(Clear_LCD)) Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(0) & Chr(0)) Call PutQueueStr(Com3Out, MSG1) Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(1) & Chr(0)) Call PutQueueStr(Com3Out, MSG2) End Sub ' /////////// DisplayInt ////////// Public Sub DisplayInt(ByVal Value as Integer) Call PutQueueStr(Com3Out, Chr(BackLite)& Chr(BackLiteBrightness)) Call PutQueueStr(Com3Out, Chr(Contrast) & Chr(ContrastLevel)) Call PutQueueStr(Com3Out, Chr(Clear_LCD)) Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(0) & Chr(0)) Call PutQueueStr(Com3Out, "Value = ") Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(1) & Chr(0)) Call PutQueueStr(Com3Out, CStr(Value)) End Sub ' /////////// DisplaySng ////////// Public Sub DisplaySng(ByVal Value as Single) Call PutQueueStr(Com3Out, Chr(BackLite)& Chr(BackLiteBrightness)) Call PutQueueStr(Com3Out, Chr(Contrast) & Chr(ContrastLevel)) Call PutQueueStr(Com3Out, Chr(Clear_LCD)) Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(0) & Chr(0)) Call PutQueueStr(Com3Out, "Value = ") Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(1) & Chr(0)) Call PutQueueStr(Com3Out, CStr(Value)) End Sub ' /////////// Display2Sng ////////// Public Sub Display2Sng(ByVal Value1 as Single, ByVal Value2 as Single) Call PutQueueStr(Com3Out, Chr(BackLite)& Chr(BackLiteBrightness)) Call PutQueueStr(Com3Out, Chr(Contrast) & Chr(ContrastLevel)) Call PutQueueStr(Com3Out, Chr(Clear_LCD)) Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(0) & Chr(0)) Call PutQueueStr(Com3Out, "Value 1 = " & Fmt(Value1, 3)) Call PutQueueStr(Com3Out, Chr(Set_Cursor) & Chr(1) & Chr(0)) Call PutQueueStr(Com3Out, "Value 2 = " & Fmt(Value2, 3)) End Sub