Page 1 of 1

MX product - program keypad in VB

Posted: Fri Sep 16, 2005 3:12 pm
by tphuynh
Hi,

I'm trying to program in VB one of the keypad "Enter" to display something like "Power On". For exampling, pressing the Enter button on the LCD pad - will display "Power ON" on the screen.

I know that pressing "enter" on the keypad will store a HEX value of 48 in
MSComm1.input. Somehow I can not get it to display on the screen.

Can someone give me a sample code on how to display some text after pressing one of the keypad.

Thanks.

Posted: Fri Sep 16, 2005 3:35 pm
by Tom
Hi tphuynh,

Thank you for posting at the forums.

Please refer to the link at http://www.lcdforums.com/forums/viewtopic.php?t=1961 to display text. What you may want to try after receiving the character is to use some type of if statement. Ex) If 0x48 is detected, then print a specific screen. What you need to make sure you are doing, when you are trying to receive a character is to put some delay in to give sufficient amount of time for the processor to process the information.

If you have anymore questions or concerns, please feel free to post them.

Best Regards,

Posted: Fri Sep 16, 2005 3:54 pm
by tphuynh
Tom wrote:Hi tphuynh,

Thank you for posting at the forums.

Please refer to the link at http://www.lcdforums.com/forums/viewtopic.php?t=1961 to display text. What you may want to try after receiving the character is to use some type of if statement. Ex) If 0x48 is detected, then print a specific screen. What you need to make sure you are doing, when you are trying to receive a character is to put some delay in to give sufficient amount of time for the processor to process the information.

If you have anymore questions or concerns, please feel free to post them.

Best Regards,
Hi Tom,

The link you sent me. I know all of that already. Somehow I can not get the Enter keypad to trigger any display on the screen.

THis is what I have:

If MSComm1.Input = Chr$(&H48) Then
Form1.MSComm1.Output = "Power On"
End If

It's not displaying to the screen. I think I'm missing something, but I can't figure it out. I want this code to fire once the "Enter" keypad is pressed on the MX product. Do I need to put this in a loop?

Another suggestions?

Posted: Fri Sep 16, 2005 5:11 pm
by Ray

Code: Select all

 
Private Sub Form_Load()
    MSComm1.Settings = "19200,N,8,1"
    MSComm1.CommPort = 3
    MSComm1.InputLen = 0
    MSComm1.RThreshold = 1
    MSComm1.PortOpen = True
End Sub

Private Sub SendText(text As String)
    MSComm1.Output = Chr$(&HFE) & Chr$(&H58)
    MSComm1.Output = text
End Sub

Private Sub MSComm1_OnComm()
    Dim strInput As String
    If MSComm1.CommEvent = comEvReceive Then
        While (MSComm1.InBufferCount > 0)
          strInput = Left(MSComm1.Input, 1) '<---- Evil code here discards all other data in buffer except the first byte
          Select Case strInput
            Case "D"
                SendText "Up"
            Case "E"
                SendText "Down"
            Case "K"
                SendText "Left"
            Case "C"
                SendText "Enter"
            Case "J"
                SendText "F1"
            Case "I"
                SendText "F2"
            Case Else
                SendText "Unknown (" & strInput & ")"
          End Select
        Wend
    End If
End Sub
This code should get you started.

Posted: Sat Sep 17, 2005 12:05 am
by tphuynh
Thank-you Ray! It worked.

Just had to modify some of the Case values to work with the MX product.

Thanks again! :D

Posted: Sun Sep 18, 2005 5:18 am
by Jeroen Vonk
Hi tphuynh,

You could also try the SDK I wrote (freeware) Should save you a lot of time :) You can find it at http://www.jvonk.info/mosdk Also works in VB...

Regards,
Jeroen