Programming LCD screen with VB

akweb

New member
I don't quite get it. Where's the 'ScreenManager' sub? What's the 'ms_oncomm' subroutine?
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

Knight

New member
Sorry, maybe I should have made it more simplistic.

Here's teh code again, but in a more simplistic version....

I just copied and pasted from my program, so that's why you see the ScreenManager subroutine in there.



Public Sub PacketAnalyzer(Packet)
Dim SplitPacket() As String
SplitPacket = Split(Packet, " ")
If SplitPacket(0) = "128" Then
Select Case SplitPacket(2)
Case "1"
'Key Up Pressed
'Do this when key up is pressed
Case "2"
'Key Down Pressed
'Do this when key down is pressed
Case "3"
'Key Left Pressed
'Do this when key down is pressed
Case "4"
'Key Right Pressed
'Do this when key right is pressed
Case "5"
'Key Enter Pressed
'Do this when key enter is pressed
Case "6"
'Key Cancel Pressed
'Do this when Cancel key is pressed
Case "7"
'Key Up Released
'Do this when Key Up is released
Case "8"
'Key Down released
'Do this when key down is released
Case "9"
'Key left released
'Do this when key left is released
Case "10"
'Key right released
'Do this when key right is released
Case "11"
'Key Enter released
'Do this when enter key is released
Case "12"
'Key Cancel released
'Do this when Cancel key is released
End Select
End If



You have to understand that this is for the 633. The 631 doesn't have this many key's, so you'll have to modify it for that circumstance.

As for the OnComm this is the subroutine that is called by VB when it recieves something through the serial port, IE, a packet.

This is what my OnComm subrotuine looked like:

Private Sub MSComm1_OnComm()
Dim ComPortData as String
ComPortData = MSComm1.Input
If ComPortData <> "" Then
Call PacketAnalyzer(ComPortData)
End If
ComPortData = ""
End Sub
 

akweb

New member
Knight,

Excellent example, thanks! However, I'm unable to get it to work with the 631. Perhaps with the 631 there's a different way altogether to read key inputs(?) I'm unable to get the MSComm1_OnComm() subroutine to 'kick in' - nothing happens when key pressed.
Any ideas?

-akweb
 

Knight

New member
Is the name of your control for the input of the 631 called MSComm1_OnComm ?

In compatibilty issue's from the difference from 631 and 633's wouldn't have the same symptopms that you are describing. It just would either create a error, or the PacketAnalyzer wouldn't work. The MSComm1_OnComm should be called no matter what, assuming the MSComm1_OnComm control is working, and recieving data.

If you changed the name, you'll have to change the name in my example.
 

akweb

New member
Hmmm. I've got my control on my form called MSComm1 which I'm using to write output to the 631 fine, but for some reason the MSComm1_OnComm() routine isn't getting called when a button a pressed.
 

Knight

New member
Check the settings on the control.

The "Rthreshold" and "SThreshold" should be both set at 1 also make sure the "settings" propertie of hte control is correct for the 633 the correct setting is "19200,n,8,1" You'll only need to change the first number to the baud rate of the display.
 

akweb

New member
Knight,

You are the man! That worked! Took me a while to figure out the returned packet structure of the 631, but I think I've got it.

Thanks a bunch for your great expertise!

-akweb
 

Knight

New member
I wouldn't be suprised if it takes you a while to understand the Packet Structure. Sometimes it's confusing, and it's wrote with the expectation that you are using C+ and so the format is slightly different.


The RThreshold and SThreshold deteremines when to initiate the OnComm routine.

If it's set to 1 then EVERY charator that is sent to the computer causes the computer to call the OnComm subrotuine.

If you ever program for a device that always sends the same information, such as a scale that always sends the weight in punds, and sends it in the format of "000000lbs" then you should set the rthreshold to 9, this would cause the Com control to call the oncomm every 9th charactor.

Basically you'll ALWAYS have it set to 1. I've programmed for about 30 different devices on the Serial port, and I can't think of once where I had it set to something other than 1.
 

akweb

New member
Scrolling Text using VB

Knight,

Have you had any luck using VB to scroll text on a display?

Thanks in advance,

-AK
 

Knight

New member
I havn't tried. Although with the problem with the inserting 0's into the string and the CRC comming out incorrect having been fixed then it should work without any hitches.

Just follow the manual I'm sure it'll explain, and I'm sure you can figure it out. If you just can't get it let me know and I'll see what I can do.
 

akweb

New member
At this point I'm just trying to figure out how to scroll using the Packet Debugger, then I can translate that into VB. I understand 'Command 22' must be used to do the call to the controller, but I'm not sure how to do the scrolling part of it.
I'm able to do certain 'low-level' commands like clear the screen, set the cursor home, blink on/off, etc. using Command 22, but not able to figure out scrolling yet.

Anyone had any experience with this?

-AK
 

CURTISBEEF

New member
ya there is not pixel by pixel scrolling on the 633/631 models :(

so you have to do it Character by Character :(

Edit: Corection only the 633 cant do pixel scrolling
 
Last edited:

akweb

New member
At first I was trying to write some code in VB that would write a character, move the character, write another character, etc. No luck. So I tried using the 'Command 22' to enable scrolling, but no luck either. What's the best way to accomplish it?

Thanks to all!

-ak
 

robo85045

New member
Knight said:
Code:
Public Sub PacketAnalyzer(Packet)
Dim SplitPacket() As String
SplitPacket = Split(Packet, " ")
If SplitPacket(0) = "128" Then
    Select Case SplitPacket(2)
        Case "1"
            'Key Up Pressed
            'Do this when key up is pressed
        Case "2"
            'Key Down Pressed
            'Do this when key down is pressed
        Case "3"
            'Key Left Pressed
            'Do this when key down is pressed
        Case "4"
            'Key Right Pressed
            'Do this when key right is pressed
        Case "5"
            'Key Enter Pressed
            'Do this when key enter is pressed
        Case "6"
            'Key Cancel Pressed
            'Do this when Cancel key is pressed
        Case "7"
            'Key Up Released
            'Do this when Key Up is released
        Case "8"
            'Key Down released
            'Do this when key down is released
        Case "9"
            'Key left released
            'Do this when key left is released
        Case "10"
            'Key right released
            'Do this when key right is released
        Case "11"
            'Key Enter released
            'Do this when enter key is released
        Case "12"
            'Key Cancel released
            'Do this when Cancel key is released
    End Select
End If
it not working. the if statement keeps skiping the If statement....
is the Packet variable really suppost to equal "€cá"?
im using the 633 btw

i found out whats wrong...the msComm returns the data as a string... at least i think so... if i place at the begining of the PacketAnalyzer:
Packet = Asc(Packet) then Packet becomes 128, exactly what the if statement is looking for.
The problum now:
SplitPacket(2) = subscript out of range
im pritty sure this means that SplitPacket(2) doesnt exist...and, since i have never seen the "Split" command before and MSDN's help on it makes no sence...i dont know how to fix it.

any help?
 
Last edited:

Knight

New member
You'll have to bear with me. I can't remember much about this system, it's been quite a while. However, the packet analyzier is pretty solid. It's most likely what is coming into it that is the problem. Not trying to be cocky or anything. ;)


> is the Packet variable really suppost to equal "€cá"?

This is a truly possible thing, and it be correct. The packet is changed to Ascii, and that could be why.


i found out whats wrong...the msComm returns the data as a string... at least i think so... if i place at the begining of the PacketAnalyzer:
Packet = Asc(Packet) then Packet becomes 128, exactly what the if statement is looking for
the problum now:
SplitPacket(2) = subscript out of range
im pritty sure this means that SplitPacket(2) doesnt exist...and, since i have never seen the "Split" command before and MSDN's help on it makes no sence...i dont know how to fix it.
The way the packet analyzier works is the following:


The first line defines the subroutine, and takes the packet into the variable named packet.

Dim SplitPacket() As String
causes VB to make the variable of "SplitPacket", the extra parenthesis tell's VB that it's an array, if you knew at runtime how many items you wanted in the array then you would put the number of items inside the parenthesis. Since hte packet size is different, then it can be different number, hence we dont specify.

SplitPacket = Split(Packet, " ")
This line tells VB to take the "Packet" variable, and split it up whever there is a " ". So, for every space it places it into a new array item of SplitPacket.

So, if "Packet" equaled "128 3 3 4 1"
Then the following would be true:
SplitPacket(0) = "128"
SplitPacket(1) = "3"
SplitPacket(2) = "3"
SplitPacket(3) = "4"
SplitPacket(4) = "1"

SplitPacket(2) is the third piece in the packet. I'm not near a CF book, and can't look up what this piece is.



I'm not really able to figure out why the packet that is incoming is not a key press packet. Is it possible that this is a fan reporting packet or something else similar?

If that's not it, then zip up the project and e-mail it to me. My e-mail address is my first name at my last name dot com.

Knight,
David Bussanmas.
 

Dexter

New member
I'm just trying this out with my 633 also, and it seems the problem is that the entire packet is not being fed into the system. I put a
MsgBox (Asc(ComPortData))
right when the data gets in and all thats there is 128.
 

CF Tech

Administrator
> . . . all thats there is 128. . .

Which is correct for the first character. What happens if you put in multiple "MsgBox (Asc(ComPortData))" ?
 

Dexter

New member
CF Tech said:
> . . . all thats there is 128. . .

Which is correct for the first character. What happens if you put in multiple "MsgBox (Asc(ComPortData))" ?

Right, but shouldnt there be a whole bunch of data. This is before the 'Split' function even comes into play. If i put multiple
MsgBox (Asc(ComPortData)), it just keeps saying 128, over and over.

Maybe it has to do with some setting of the MS Com control?
 
Top