Reading Keypad under VB6

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
unstabl1
LCD?
Posts: 7
Joined: Thu Aug 29, 2002 6:00 pm
Location: ON, Canada

Post by unstabl1 »

Hey all. Need a little guidance please. I need a code example to read the keypad from the BVK202A using VB6. I have no problems sending to it (displaying text, controlling GPOs, etc.) but my brain seems to have turned into mush (too much work, not enough sleep/food), you know how it is. Thanks

babber
LCD!
Posts: 19
Joined: Tue Jan 15, 2002 4:00 pm
Location: Gloucester UK

Post by babber »

This is pretty easy. When you intialise MScomm, you need to set the RThreshold to 1 and InputLen to 1. You can then use the OnComm event. Read up on this in the VB help file. When data is received by the port, OnComm is fired and you can then react and find out what "key" was pressed.This code is taken direct from my project. I use XMComm control rather than MSComm but they are the same.

Private Sub XMComm2_OnComm()
Static LastKeyPress As String
XMComm2.Output = Chr$(&HFE) & Chr$(&H42) & Chr$(&H1) 'backlight on
bufferLCD = XMComm2.Input
If LastKeyPress = "D" Then
If bufferLCD = "I" Then
vol = True
lcdVolControl (bufferLCD)
WinAMP_PressPlay
Exit Sub
End If
End If

Select Case bufferLCD
Case "C"
If vol = True Then
vol = False
LCDOutPut
winampTimer = True
Exit Sub
End If
WinAMP_PressPlay
Text4.Text = "Play"
Case "E"
If vol = True Then
vol = False
LCDOutPut
winampTimer = True
Exit Sub
End If
WinAMP_PressStop
Text4.Text = "Stop"
Case "B"
If vol = True Then
vol = False
LCDOutPut
winampTimer = True
Exit Sub
End If
WinAMP_PressFFWD
Text4.Text = "Fast Forward"
Case "G"
If vol = True Then
vol = False
LCDOutPut
winampTimer = True
Exit Sub
End If
WinAMP_PressRWD
Text4.Text = "Rewind"
Case "J"
If vol = False Then
UpAnAlbum
Text4.Text = "Up An Album"
End If
If vol = True Then
lcdVolControl (bufferLCD)
elapsedsecs = 0
LastKeyPress = ""
End If
Case "H"
If vol = False Then
DownAnAlbum
Text4.Text = "Down An Album"
End If
If vol = True Then
lcdVolControl (bufferLCD)
elapsedsec = 0
LastKeyPress = ""
End If
Case "I"
If vol = True Then
vol = False
LCDOutPut
winampTimer = True
Exit Sub
End If
AlbumSelected
Text4.Text = "Album Selected"
Case "D"
If vol = True Then
vol = False
LCDOutPut
winampTimer = True
Exit Sub
End If
WinAMP_Pause
Text4.Text = "Paused"
Case "9"
InitialiseLCD
End Select
LastKeyPress = bufferLCD
buffer1 = ""
bufferLCD = ""
XMComm2.InBufferCount = 0

End Sub

This should help. If you are still stuck, post again.

Babber

Post Reply