📄 form10.frm
字号:
VERSION 5.00
Begin VB.Form Form10
Caption = "LCD Write"
ClientHeight = 3300
ClientLeft = 60
ClientTop = 345
ClientWidth = 8670
LinkTopic = "Form8"
ScaleHeight = 3300
ScaleWidth = 8670
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Clear Line"
Height = 375
Left = 7080
TabIndex = 13
Top = 2160
Width = 1215
End
Begin VB.CommandButton Disp_Btn
Caption = "Display Data"
Height = 375
Left = 5640
TabIndex = 12
Top = 2160
Width = 1215
End
Begin VB.CommandButton Exit_Btn
Caption = "Exit"
Height = 375
Left = 7080
TabIndex = 5
Top = 2760
Width = 1215
End
Begin VB.OptionButton Option4
Caption = "Option1"
Height = 195
Index = 3
Left = 1800
TabIndex = 4
Top = 2160
Width = 255
End
Begin VB.OptionButton Option3
Caption = "Option1"
Height = 195
Index = 2
Left = 1800
TabIndex = 3
Top = 1800
Width = 255
End
Begin VB.OptionButton Option2
Caption = "Option1"
Height = 195
Index = 1
Left = 1800
TabIndex = 2
Top = 1440
Width = 255
End
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 195
Index = 0
Left = 1800
TabIndex = 1
Top = 1080
Width = 255
End
Begin VB.TextBox Text1
Height = 495
Left = 3720
MaxLength = 20
TabIndex = 0
Top = 1320
Width = 3975
End
Begin VB.Frame Frame1
Caption = "Display Line"
Height = 1695
Left = 1080
TabIndex = 6
Top = 840
Width = 1815
Begin VB.Label Label3
Caption = "Line4"
Height = 255
Left = 120
TabIndex = 11
Top = 1320
Width = 615
End
Begin VB.Label Label2
Caption = "Line3"
Height = 255
Left = 120
TabIndex = 10
Top = 960
Width = 615
End
Begin VB.Label Label1
Caption = "Line2"
Height = 255
Left = 120
TabIndex = 9
Top = 600
Width = 495
End
Begin VB.Label Label4
Caption = "Line1"
Height = 255
Index = 0
Left = 120
TabIndex = 8
Top = 240
Width = 495
End
End
Begin VB.Frame Frame2
Caption = "LCD"
Height = 1095
Left = 3360
TabIndex = 7
Top = 960
Width = 4935
End
End
Attribute VB_Name = "Form10"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Response$
Const ResponseTime = 0.1
Const LCDType = "14"
Const Line1 = "01"
Const Line2 = "02"
Const Line3 = "03"
Const Line4 = "04"
Dim crc$
Dim LineNum$
Dim LCDData$
Option Explicit
Private Function GetResponse(Response$) As Boolean
'******************************************************************
'*Function: GetResponse() - Detects if a response arrived
'*Author : Sean Loving
'*Date : Mar 2003
'*Revised : May 2, 2003
'*
'*Description:
'*Detects response to a command
'*
'*Syntax detectReader()
'*
'*Parameters:
'*Response => passed by ref contains response if any
'*
'*Return Val:
'*True if response recieved else False
'*****************************************************************
Dim Start As Single
' wait to give the reader time to process the command before it responds
Start = Timer
Do
DoEvents
Loop Until (Timer - Start) > ResponseTime
Response$ = ""
Do While Form1.MSComm1.InBufferCount > 0
Response$ = Response$ & Form1.MSComm1.Input
If Right$(Response$, 2) = vbCrLf Then
Form1.MSComm1.InBufferCount = 0 ' clears the receive buffer
Exit Do
End If
Loop
If Response$ = "" Then
GetResponse = False
ElseIf Response = vbLf & "8195D" & vbCrLf Then 'C
GetResponse = False
Else
GetResponse = True
End If
End Function
Private Sub Command1_Click()
Text1.Text = ""
Disp_Btn_Click
End Sub
Private Sub Disp_Btn_Click()
Dim DataLen As Integer
If LineNum$ <> "00" Then
LCDData$ = "20420A01" & LCDType & LineNum$
DataLen = 1
While DataLen <= Len(Text1.Text)
LCDData$ = LCDData$ & Hex(Asc(Mid(Text1.Text, DataLen, 2)))
DataLen = DataLen + 1
Wend
crc$ = Form1.calculateCRC(LCDData$)
Do
Form1.MSComm1.Output = vbCr & LCDData$ & crc$ & vbCr
Loop Until (GetResponse(Response$) = True)
End If
End Sub
Private Sub Exit_Btn_Click()
Do
Form1.MSComm1.Output = vbCr & "20420A010025F2" & vbCr
Loop Until (GetResponse(Response$) = True)
Unload Form10
End Sub
Private Sub Form_Load()
'power lcd on
'20420A01FF2A8A
Do
Form1.MSComm1.Output = vbCr & "20410A01FF0F47" & vbCr
Loop Until (GetResponse(Response$) = True)
Do
Form1.MSComm1.Output = vbCr & "20420A01FF2A8A" & vbCr
Loop Until (GetResponse(Response$) = True)
LineNum$ = "00"
End Sub
Private Sub Option1_Click(Index As Integer)
'Get Data from the text box
'Form1.calculateCRC (writeCommand$)
'Dim DataLen As Integer
'LCDData$ = "20420A01" & LCDType & Line1
LineNum$ = Line1
'DataLen = 1
'While DataLen <= Len(Text1.Text)
' LCDData$ = LCDData$ & Hex(Asc(Mid(Text1.Text, DataLen, 2)))
' DataLen = DataLen + 1
'Wend
'crc$ = Form1.calculateCRC(LCDData$)
'Do
' Form1.MSComm1.Output = vbCr & LCDData$ & crc$ & vbCr
'Loop Until (GetResponse(Response$) = True)
End Sub
Private Sub Option2_Click(Index As Integer)
'LCDData$ = "20420A01" & LCDType & Line2
LineNum$ = Line2
End Sub
Private Sub Option3_Click(Index As Integer)
'LCDData$ = "20420A01" & LCDType & Line3
LineNum$ = Line3
End Sub
Private Sub Option4_Click(Index As Integer)
'LCDData$ = "20420A01" & LCDType & Line4
LineNum$ = Line4
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -