Professional Documents
Culture Documents
Dim i As Integer
Dim c As Long
Dim d As Integer
hexstr = UCase(hexstr)
c=0
For i = 1 To Len(hexstr)
c = c * 16
d = Asc(Mid(hexstr, i, 1))
If d >= &H30 And d <= &H39 Then
d = d - &H30
Else
d = d - &H41 + 10
End If
c=c+d
Next
Hex2Long = c
End Function
Private Sub LCDInit()
RS_Low
LCDStrobe &H38 '8 bit interface. for 4 bit interface, use &H28
Sleep 1
LCDStrobe &H8 ' Display off
Sleep 1
LCDStrobe &H1 'clear screen
Sleep 1
LCDStrobe &H6 'Increment, no shift
Sleep 1
LCDStrobe &HE 'display on, show cursor, no blink
RS_Low
If (ctrl Mod 2) = 0 Then
ctrl = ctrl + 1 'E=0, or ctrl.0 = 1
End If
End Sub
Dim i As Integer
End Sub
Private Sub LCDWrite(ByVal dbyte As Integer, ByVal line As Integer, ByVal pos As Integer)
'dbyte is ascii char to be shown
'line is 1 or 2
'pos is 1 to 16
If line = 1 Then
addr = &H80 + pos
ElseIf line = 2 Then
addr = &HC0 + pos
Else
addr = &H80 + pos
End If
End Sub
Dim i As Integer
Dim j As Integer
Dim c As Integer
If n <= 0 Then
n=1
ElseIf n > 1000 Then
n = 1000
End If
For i = 1 To n
For j = 1 To 100
'change this 100 to higher value if your system is very fast
'100 was ok on a Celeron 1.8GHz CPU
'You may need to change only if LCD does not function well.
c = c 'dummy.
Next
Next
End Sub
'RS-x-x-E: 1-0-0-0
ctrl = ctrl Mod 8 'make bit four zero (inverted)
End Sub
'RS-x-x-E: 0-0-0-0
'keep other bits unchanged
ctrl = ctrl Mod 8
'make control.3 high
ctrl = ctrl + 8
End Sub
Dim i As Integer
Dim c As Integer
Dim s As String
LCDInit
Sleep 10
s = "Welcome"
For i = 1 To Len(s)
c = Asc(Mid(s, i, 1))
LCDWrite c, 1, i
Next
Text1 = s
s = ""
c = &H41 'Ascii A
For i = 1 To 16
LCDWrite c, 2, i
s = s & Chr(c)
c=c+1
Next
Text2.Text = s
End Sub
For i = 1 To Len(s)
c = Asc(Mid(s, i, 1))
LCDWrite c, 1, i
Next
s = Text2.Text
s = Left(s, 16)
If Len(s) < 16 Then
s = s & Space(16 - Len(s))
End If
For i = 1 To Len(s)
c = Asc(Mid(s, i, 1))
LCDWrite c, 2, i
Next
End Sub
End Sub
Dim i As Integer
s = Left(Text1.Text, 16)
If Len(s) < 16 Then
s = s & Space(16 - Len(s))
End If
For i = 1 To Len(s)
LCDWrite Asc(Mid(s, i, 1)), 1, i
Sleep 10
Next
End Sub
End Sub
Dim i As Integer
s = Left(Text2.Text, 16)
If Len(s) < 16 Then
s = s & Space(16 - Len(s))
End If
For i = 1 To Len(s)
LCDWrite Asc(Mid(s, i, 1)), 2, i
Sleep 10
Next
End Sub
BasePort = Hex2Long(Text3.Text)
SaveSetting "C-Quad", "LCD", "BasePort", Text3.Text
End Sub