1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
'Code
....
Private Sub CmdMain_Click(Index As Integer)
Dim Test As Long
Select Case Index
' Go to the absolute position
Case BtnAbsPos
Test = TabGoto(1000, 1000)
' Close and reset the handle, btnClose = 6
Case BtnClose
CloseHandle
Case Else
Exit Sub
End Select
End Sub
Function TabGoto(ByVal X As Long, ByVal Y As Long) As Long
'X move
lngBytesToWrite = Len("X" & X) + 1
strWriteBuffer = "X" & (X) & vbCrLf
WriteHandle
' Y move
lngBytesToWrite = Len("Y" & Y) + 1
strWriteBuffer = "Y" & (Y) & vbCrLf
WriteHandle
TabGoto = 0
Exit Function
End Function
'Procedure to close the handle and "reset"
Private Sub CloseHandle()
Status = FT_Close(lngHandle)
If Status <> FT_OK Then
Exit Sub
End If
Status = FT_ResetDevice(lngHandle)
If Status <> FT_OK Then
Exit Sub
End If
End Sub
'Procedure to write character in writting buffer, srtWriteBuffer in string
Private Sub WriteHandle()
lngBytesWritten = 0
Status = FT_Write(lngHandle, strWriteBuffer, lngBytesToWrite, lngBytesWriten)
If Status <> FT_OK Then
Exit Sub
End If
End Sub
'Procedure to read character put in the buffer reading
Private Sub ReadHandle()
Sleep (250) ' Use to wait the buffer reading is full before go to read
'Read the buffer from driver motors
lpszBuffer = ""
Status = FT_GetQueueStatus(lngHandle, amountInRxQueue)
If Status <> FT_OK Then
read = MsgBox(Error, ok & vbOKOnly, "False")
Else
Status = FT_Read(lngHandle, lpszBuffer, amountInRxQueue, lngBytesReturned)
If Status <> FT_OK Then
Exit Sub
End If
End If
Disp1.Text = Disp1.Text & "rcvd < " & lpszBuffer & ""
Sleep (250)
End Sub |
Partager