Please help? LCD+ with Keypad

Started by Conrad A***** October 25, 2006
I am completely stuck on a project and have looked everywhere and found
nothing. I have a keypad plugged into a LCD+ display which is
connected to the BX24. Now I want to let the BX24 know that a key has
been pressed. Either by a debug.print or anything of that sort, just
to let me know it recognizes that I am pushing a button. Can anyone
please help me? Just a snippit of code or any advice? I am completely
stuck and can't go much futher until I figure this out.
What error do you get? Are you certain that the keyboard is connected
correctly? Did you add LCDXlib or similar library to your project?

First call LCDinitialize and then call the following routine:

Public Sub KeyboardCheck()
dim keyIn as byte
keyIn = GetKeypad()
if (keyIn<>255) then
debug.print cstr(keyin);" received from the keyboard"
call delay(0.1)
Do while (GetKeypad()=keyIn)
' spin until key released
Loop
end if
end Sub 'KeyboardCheck

> -----Original Message-----
> From: b... [mailto:b...] On Behalf Of
> Conrad A*****
> Sent: Wednesday, October 25, 2006 5:14 PM
> To: b...
> Subject: [BasicX] Please help? LCD+ with Keypad
>
> I am completely stuck on a project and have looked everywhere and found
> nothing. I have a keypad plugged into a LCD+ display which is
> connected to the BX24. Now I want to let the BX24 know that a key has
> been pressed. Either by a debug.print or anything of that sort, just
> to let me know it recognizes that I am pushing a button. Can anyone
> please help me? Just a snippit of code or any advice? I am completely
> stuck and can't go much futher until I figure this out.
Conrad,
Have you tried the "Reading buttons and switches" example from the
basicx site?

http://www.basicx.com/Products/BX-24/Code_Examples/Buttons_BX24.zip
Found under this link:
http://www.basicx.com/codeexamples/examplecode.htm

-Ben
Hello Conrad. I assume you have the user manual for the LCD+, if not
you can find it here: http://www.basicx.com/Products/LCD+/LCD%2Btech.htm

There is an example for sending data to the LCD in the back of the
manual.

I took a quick read through the manual, and what you need to do is read
the serial data coming back from the keypad - it gets sent out the TX
line on the LCD+ when you press a key. You must first set the com port
up to have the correct line speed (9600 is the default), then call
OpenCom on that comm port (Com1 or Com3).

In the OpenCOmm call you provide two queues, one for input from the
device, and one for output to it.

With the comm port open, you can then read the input queue by calling
GetQueue, and send data back to the LCD with PutQueue or PutQueueStr.

-steve
--- In b..., "Conrad A*****" wrote:
>
> I am completely stuck on a project and have looked everywhere and
found
> nothing. I have a keypad plugged into a LCD+ display which is
> connected to the BX24. Now I want to let the BX24 know that a key
has
> been pressed. Either by a debug.print or anything of that sort, just
> to let me know it recognizes that I am pushing a button. Can anyone
> please help me? Just a snippit of code or any advice? I am
completely
> stuck and can't go much futher until I figure this out.
>
Thanks for the replies!

Ken, after reading your email, you are correct the code for the LCDx
is different than the LCD+. I found out in fact mine is LCD+2 (not
that it really matters), so the code you provided won't work in my
case. Although I did read the LCDx manual and it is far more
descriptive and understanding than the tidbit given for the LCD+/+2
variant. Kinda makes me want to buy an LCDx. Haha.

Benoit, I am familiar with buttons and switches, I've had a BX24 for
a few years nowbut I am not sure how to capture a serial input from
the LCD since the keypad is connected to it.

Steve, I have read the manual many times and picked up some things
from it. I just haven't been able to see any sample code or anything
that shows how to debug.print a keypad press or use it to select
something. I don't have my code in front of me but I do believe I
have set the OpenCom port setup for input and output of the LCD. I
am just not sure what command I need to debug.print what key has been
pressed. Once I learn how to do that then I am sure I can figure out
how to get it to change variables, select or tab through menus. Till
then I'm stuck!

If anyone is interested I can upload my whole code and allow you to
poke holes in it and make things work. I always struggle the first
time before I try somethingthen after that it's not bad at all.
I've never used a keypad input for anything and I have been
struggling/waiting for quite some time to get it to work.

Conrad
--- In b..., "mr_tentacle_too"
wrote:
>
> Hello Conrad. I assume you have the user manual for the LCD+, if
not
> you can find it here: http://www.basicx.com/Products/LCD+/LCD%
2Btech.htm
>
> There is an example for sending data to the LCD in the back of the
> manual.
>
> I took a quick read through the manual, and what you need to do is
read
> the serial data coming back from the keypad - it gets sent out the
TX
> line on the LCD+ when you press a key. You must first set the com
port
> up to have the correct line speed (9600 is the default), then call
> OpenCom on that comm port (Com1 or Com3).
>
> In the OpenCOmm call you provide two queues, one for input from the
> device, and one for output to it.
>
> With the comm port open, you can then read the input queue by
calling
> GetQueue, and send data back to the LCD with PutQueue or
PutQueueStr.
>
> -steve
>
>
> --- In b..., "Conrad A*****" wrote:
> >
> > I am completely stuck on a project and have looked everywhere and
> found
> > nothing. I have a keypad plugged into a LCD+ display which is
> > connected to the BX24. Now I want to let the BX24 know that a
key
> has
> > been pressed. Either by a debug.print or anything of that sort,
just
> > to let me know it recognizes that I am pushing a button. Can
anyone
> > please help me? Just a snippit of code or any advice? I am
> completely
> > stuck and can't go much futher until I figure this out.
>



Hi Conrad. According to the docs the keypad sends a 1-byte "tag" for
each of the keys immediately upon a key press. I could not find what
the default values are, but this should be easy to determine. You
can send your own table of values for the tags, too.

Assuming you want to display the returned value with a debug.print,
you would do something like this (assuming you use COM3 for the
LCD+2):

dim byte_recv as byte

call definecom3(...)

call openqueue(in_q,15)
call openqueue(out_q,15)

call opencom(3,9600,in_q,out_q)

do
call getqueue(in_q,byte_recv,1)
debug.print "Key value:"; cstr(byte_recv)
loop

Note that the loop will be blocked for input at the "getqueue" until
a character is received.
--- In b..., "Conrad A*****" wrote:
>
> Thanks for the replies!
>
> Ken, after reading your email, you are correct the code for the
LCDx
> is different than the LCD+. I found out in fact mine is LCD+2 (not
> that it really matters), so the code you provided won't work in my
> case. Although I did read the LCDx manual and it is far more
> descriptive and understanding than the tidbit given for the LCD+/+2
> variant. Kinda makes me want to buy an LCDx. Haha.
>
> Benoit, I am familiar with buttons and switches, I've had a BX24
for
> a few years nowbut I am not sure how to capture a serial input
from
> the LCD since the keypad is connected to it.
>
> Steve, I have read the manual many times and picked up some things
> from it. I just haven't been able to see any sample code or
anything
> that shows how to debug.print a keypad press or use it to select
> something. I don't have my code in front of me but I do believe I
> have set the OpenCom port setup for input and output of the LCD. I
> am just not sure what command I need to debug.print what key has
been
> pressed. Once I learn how to do that then I am sure I can figure
out
> how to get it to change variables, select or tab through menus.
Till
> then I'm stuck!
>
> If anyone is interested I can upload my whole code and allow you to
> poke holes in it and make things work. I always struggle the first
> time before I try somethingthen after that it's not bad at all.
> I've never used a keypad input for anything and I have been
> struggling/waiting for quite some time to get it to work.
>
> Conrad
>
>
> --- In b..., "mr_tentacle_too"
> wrote:
> >
> > Hello Conrad. I assume you have the user manual for the LCD+, if
> not
> > you can find it here: http://www.basicx.com/Products/LCD+/LCD%
> 2Btech.htm
> >
> > There is an example for sending data to the LCD in the back of
the
> > manual.
> >
> > I took a quick read through the manual, and what you need to do
is
> read
> > the serial data coming back from the keypad - it gets sent out
the
> TX
> > line on the LCD+ when you press a key. You must first set the
com
> port
> > up to have the correct line speed (9600 is the default), then
call
> > OpenCom on that comm port (Com1 or Com3).
> >
> > In the OpenCOmm call you provide two queues, one for input from
the
> > device, and one for output to it.
> >
> > With the comm port open, you can then read the input queue by
> calling
> > GetQueue, and send data back to the LCD with PutQueue or
> PutQueueStr.
> >
> > -steve
> >
> >
> > --- In b..., "Conrad A*****" wrote:
> > >
> > > I am completely stuck on a project and have looked everywhere
and
> > found
> > > nothing. I have a keypad plugged into a LCD+ display which is
> > > connected to the BX24. Now I want to let the BX24 know that a
> key
> > has
> > > been pressed. Either by a debug.print or anything of that
sort,
> just
> > > to let me know it recognizes that I am pushing a button. Can
> anyone
> > > please help me? Just a snippit of code or any advice? I am
> > completely
> > > stuck and can't go much futher until I figure this out.
> > >
>



Take a look at what I've got so far:

'---------------------------------
Public Sub LCDIntro()

Dim Keypad_Recv as Byte

'Open Com3 serial port queues.
Call OpenQueue(Com3_Out, 40)
Call OpenQueue(Com3_In, 30)
'Open Com3 at 9600, N, 8, 1
Call OpenCom(3, 9600, Com3_In, Com3_Out)
'Define pins for Com3 (RX = pin14, TX = pin13).
Call DefineCom3(14, 13, bx1000_1000)

'Clear LCD Screen.
Call PutQueuestr(Com3_Out, Chr(Clear_Screen))

'Replaces the keypad # entry to the LCD with an * and also
shuts off the buzzer.
'Call PutQueueStr(Com3_Out, Chr(24) & Chr(bx0000_0101) )

'Call PutQueueStr(Com3_Out, Chr(15)) 'Shuts backlight off.
'Call PutQueueStr(Com3_Out, Chr(4)) 'Hides cursor
Call Delay(0.5)

Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(22))
Call PutQueueStr(Com3_Out, "ACE ENGINEERING")
Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(43))
Call PutQueueStr(Com3_Out, "VERSION 1.0.03")

Do
Debug.Print "1"
Call GetQueue(Com3_In, Keypad_Recv, 1)
Debug.Print "2"
Debug.Print "Key value:"; CStr(Keypad_Recv)
Debug.Print "3"
Loop

Call Sleep(4.0)

End Sub
'---------------------------------

The sub is called in the main sub, the Com3_In(1 To 30) and Com3_Out
(1 To 40). I added the Debug.Print "1", "2" and "3" to see how the
do-loop is working. Debug.Print "1" shows up but it just hangs on
the GetQueue and no key presses trigger it to print the "Key
value:". Any advice?

I feel I am just about there, I am getting excited!

Conrad
--- In b..., "mr_tentacle_too"
wrote:
>
> Hi Conrad. According to the docs the keypad sends a 1-byte "tag"
for
> each of the keys immediately upon a key press. I could not find
what
> the default values are, but this should be easy to determine. You
> can send your own table of values for the tags, too.
>
> Assuming you want to display the returned value with a debug.print,
> you would do something like this (assuming you use COM3 for the
> LCD+2):
>
> dim byte_recv as byte
>
> call definecom3(...)
>
> call openqueue(in_q,15)
> call openqueue(out_q,15)
>
> call opencom(3,9600,in_q,out_q)
>
> do
> call getqueue(in_q,byte_recv,1)
> debug.print "Key value:"; cstr(byte_recv)
> loop
>
> Note that the loop will be blocked for input at the "getqueue"
until
> a character is received.
>
>
> --- In b..., "Conrad A*****" wrote:
> >
> > Thanks for the replies!
> >
> > Ken, after reading your email, you are correct the code for the
> LCDx
> > is different than the LCD+. I found out in fact mine is LCD+2
(not
> > that it really matters), so the code you provided won't work in
my
> > case. Although I did read the LCDx manual and it is far more
> > descriptive and understanding than the tidbit given for the
LCD+/+2
> > variant. Kinda makes me want to buy an LCDx. Haha.
> >
> > Benoit, I am familiar with buttons and switches, I've had a BX24
> for
> > a few years nowbut I am not sure how to capture a serial input
> from
> > the LCD since the keypad is connected to it.
> >
> > Steve, I have read the manual many times and picked up some
things
> > from it. I just haven't been able to see any sample code or
> anything
> > that shows how to debug.print a keypad press or use it to select
> > something. I don't have my code in front of me but I do believe
I
> > have set the OpenCom port setup for input and output of the LCD.
I
> > am just not sure what command I need to debug.print what key has
> been
> > pressed. Once I learn how to do that then I am sure I can figure
> out
> > how to get it to change variables, select or tab through menus.
> Till
> > then I'm stuck!
> >
> > If anyone is interested I can upload my whole code and allow you
to
> > poke holes in it and make things work. I always struggle the
first
> > time before I try somethingthen after that it's not bad at all.
> > I've never used a keypad input for anything and I have been
> > struggling/waiting for quite some time to get it to work.
> >
> > Conrad
> >
> >
> > --- In b..., "mr_tentacle_too"
> > wrote:
> > >
> > > Hello Conrad. I assume you have the user manual for the LCD+,
if
> > not
> > > you can find it here: http://www.basicx.com/Products/LCD+/LCD%
> > 2Btech.htm
> > >
> > > There is an example for sending data to the LCD in the back of
> the
> > > manual.
> > >
> > > I took a quick read through the manual, and what you need to do
> is
> > read
> > > the serial data coming back from the keypad - it gets sent out
> the
> > TX
> > > line on the LCD+ when you press a key. You must first set the
> com
> > port
> > > up to have the correct line speed (9600 is the default), then
> call
> > > OpenCom on that comm port (Com1 or Com3).
> > >
> > > In the OpenCOmm call you provide two queues, one for input from
> the
> > > device, and one for output to it.
> > >
> > > With the comm port open, you can then read the input queue by
> > calling
> > > GetQueue, and send data back to the LCD with PutQueue or
> > PutQueueStr.
> > >
> > > -steve
> > >
> > >
> > > --- In b..., "Conrad A*****" wrote:
> > > >
> > > > I am completely stuck on a project and have looked everywhere
> and
> > > found
> > > > nothing. I have a keypad plugged into a LCD+ display which
is
> > > > connected to the BX24. Now I want to let the BX24 know that
a
> > key
> > > has
> > > > been pressed. Either by a debug.print or anything of that
> sort,
> > just
> > > > to let me know it recognizes that I am pushing a button. Can
> > anyone
> > > > please help me? Just a snippit of code or any advice? I am
> > > completely
> > > > stuck and can't go much futher until I figure this out.
> > > >
> > >
>



Hi Conrad. Put the DefineCom3 call before the OpenCom call. I am
not sure the order makes a difference but logically it makes more
sense.

In your DefineCom3 call you are setting the port to inverted logic,
so another thing to try is setting it to NON-inverted.

I am assuming all the output to the LCD is working. If you have a
scope, hook it to the RX line from the LCD and set it to edge-trigger
on the leading edge, this will show you if anything is coming back on
a key press.

-steve

--- In b..., "Conrad A*****" wrote:
>
> Take a look at what I've got so far:>
> '-------------------------------
--
> Public Sub LCDIntro()
>
> Dim Keypad_Recv as Byte
>
> 'Open Com3 serial port queues.
> Call OpenQueue(Com3_Out, 40)
> Call OpenQueue(Com3_In, 30)
> 'Open Com3 at 9600, N, 8, 1
> Call OpenCom(3, 9600, Com3_In, Com3_Out)
> 'Define pins for Com3 (RX = pin14, TX = pin13).
> Call DefineCom3(14, 13, bx1000_1000)
>
> 'Clear LCD Screen.
> Call PutQueuestr(Com3_Out, Chr(Clear_Screen))
>
> 'Replaces the keypad # entry to the LCD with an * and also
> shuts off the buzzer.
> 'Call PutQueueStr(Com3_Out, Chr(24) & Chr(bx0000_0101) )
>
> 'Call PutQueueStr(Com3_Out, Chr(15)) 'Shuts backlight off.
> 'Call PutQueueStr(Com3_Out, Chr(4)) 'Hides cursor
> Call Delay(0.5)
>
> Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(22))
> Call PutQueueStr(Com3_Out, "ACE ENGINEERING")
> Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(43))
> Call PutQueueStr(Com3_Out, "VERSION 1.0.03")
>
> Do
> Debug.Print "1"
> Call GetQueue(Com3_In, Keypad_Recv, 1)
> Debug.Print "2"
> Debug.Print "Key value:"; CStr(Keypad_Recv)
> Debug.Print "3"
> Loop
>
> Call Sleep(4.0)
>
> End Sub
> '-------------------------------
--
>
> The sub is called in the main sub, the Com3_In(1 To 30) and Com3_Out
> (1 To 40). I added the Debug.Print "1", "2" and "3" to see how the
> do-loop is working. Debug.Print "1" shows up but it just hangs on
> the GetQueue and no key presses trigger it to print the "Key
> value:". Any advice?
>
> I feel I am just about there, I am getting excited!
>
> Conrad
> --- In b..., "mr_tentacle_too"
> wrote:
> >
> > Hi Conrad. According to the docs the keypad sends a 1-byte "tag"
> for
> > each of the keys immediately upon a key press. I could not find
> what
> > the default values are, but this should be easy to determine.
You
> > can send your own table of values for the tags, too.
> >
> > Assuming you want to display the returned value with a
debug.print,
> > you would do something like this (assuming you use COM3 for the
> > LCD+2):
> >
> > dim byte_recv as byte
> >
> > call definecom3(...)
> >
> > call openqueue(in_q,15)
> > call openqueue(out_q,15)
> >
> > call opencom(3,9600,in_q,out_q)
> >
> > do
> > call getqueue(in_q,byte_recv,1)
> > debug.print "Key value:"; cstr(byte_recv)
> > loop
> >
> > Note that the loop will be blocked for input at the "getqueue"
> until
> > a character is received.
> >
> >
> > --- In b..., "Conrad A*****" wrote:
> > >
> > > Thanks for the replies!
> > >
> > > Ken, after reading your email, you are correct the code for the
> > LCDx
> > > is different than the LCD+. I found out in fact mine is LCD+2
> (not
> > > that it really matters), so the code you provided won't work in
> my
> > > case. Although I did read the LCDx manual and it is far more
> > > descriptive and understanding than the tidbit given for the
> LCD+/+2
> > > variant. Kinda makes me want to buy an LCDx. Haha.
> > >
> > > Benoit, I am familiar with buttons and switches, I've had a
BX24
> > for
> > > a few years nowbut I am not sure how to capture a serial input
> > from
> > > the LCD since the keypad is connected to it.
> > >
> > > Steve, I have read the manual many times and picked up some
> things
> > > from it. I just haven't been able to see any sample code or
> > anything
> > > that shows how to debug.print a keypad press or use it to
select
> > > something. I don't have my code in front of me but I do
believe
> I
> > > have set the OpenCom port setup for input and output of the
LCD.
> I
> > > am just not sure what command I need to debug.print what key
has
> > been
> > > pressed. Once I learn how to do that then I am sure I can
figure
> > out
> > > how to get it to change variables, select or tab through
menus.
> > Till
> > > then I'm stuck!
> > >
> > > If anyone is interested I can upload my whole code and allow
you
> to
> > > poke holes in it and make things work. I always struggle the
> first
> > > time before I try somethingthen after that it's not bad at
all.
> > > I've never used a keypad input for anything and I have been
> > > struggling/waiting for quite some time to get it to work.
> > >
> > > Conrad
> > >
> > >
> > > --- In b..., "mr_tentacle_too"
> > > wrote:
> > > >
> > > > Hello Conrad. I assume you have the user manual for the
LCD+,
> if
> > > not
> > > > you can find it here: http://www.basicx.com/Products/LCD+/LCD%
> > > 2Btech.htm
> > > >
> > > > There is an example for sending data to the LCD in the back
of
> > the
> > > > manual.
> > > >
> > > > I took a quick read through the manual, and what you need to
do
> > is
> > > read
> > > > the serial data coming back from the keypad - it gets sent
out
> > the
> > > TX
> > > > line on the LCD+ when you press a key. You must first set
the
> > com
> > > port
> > > > up to have the correct line speed (9600 is the default), then
> > call
> > > > OpenCom on that comm port (Com1 or Com3).
> > > >
> > > > In the OpenCOmm call you provide two queues, one for input
from
> > the
> > > > device, and one for output to it.
> > > >
> > > > With the comm port open, you can then read the input queue by
> > > calling
> > > > GetQueue, and send data back to the LCD with PutQueue or
> > > PutQueueStr.
> > > >
> > > > -steve
> > > >
> > > >
> > > > --- In b..., "Conrad A*****"
wrote:
> > > > >
> > > > > I am completely stuck on a project and have looked
everywhere
> > and
> > > > found
> > > > > nothing. I have a keypad plugged into a LCD+ display which
> is
> > > > > connected to the BX24. Now I want to let the BX24 know
that
> a
> > > key
> > > > has
> > > > > been pressed. Either by a debug.print or anything of that
> > sort,
> > > just
> > > > > to let me know it recognizes that I am pushing a button.
Can
> > > anyone
> > > > > please help me? Just a snippit of code or any advice? I
am
> > > > completely
> > > > > stuck and can't go much futher until I figure this out.
> > > > >
> > > >
> > >
>



THANK YOU! I have been waiting/trying for so long to get this to
work...finally!!! I know in the past if I pressed button "1" then
it'd show a "1" on the LCD screen. Now I am getting a funny looking
icon on the screen. I believe related to this is the outputted "key
value". This is what I get:

Keypad Digit = Key Value
1 = 8
2 = 64
3 = 128
4 = 1
5 = 0
6 = 0
7 = 5
8 = 0
9 = 129
0 = 8
Up = 0
Down = 40
2nd = 0
Clear = 0
Help = 0
Enter = 0

Any idea how to have it output a key value equal to the keyboard
digit and for the text and direction keys, having it's own unique
numerical value?

Thank you so much for your help so far. I am going to keep plugging
away at this and I definately appreciate your input! Anyone else
reading this, feel free to chime in if you wish. :D

Conrad

--- In b..., "mr_tentacle_too"
wrote:
>
>
> Hi Conrad. Put the DefineCom3 call before the OpenCom call. I am
> not sure the order makes a difference but logically it makes more
> sense.
>
> In your DefineCom3 call you are setting the port to inverted logic,
> so another thing to try is setting it to NON-inverted.
>
> I am assuming all the output to the LCD is working. If you have a
> scope, hook it to the RX line from the LCD and set it to edge-
trigger
> on the leading edge, this will show you if anything is coming back
on
> a key press.
>
> -steve
>
> --- In b..., "Conrad A*****" wrote:
> >
> > Take a look at what I've got so far:>
> > '-----------------------------
--
> --
> > Public Sub LCDIntro()
> >
> > Dim Keypad_Recv as Byte
> >
> > 'Open Com3 serial port queues.
> > Call OpenQueue(Com3_Out, 40)
> > Call OpenQueue(Com3_In, 30)
> > 'Open Com3 at 9600, N, 8, 1
> > Call OpenCom(3, 9600, Com3_In, Com3_Out)
> > 'Define pins for Com3 (RX = pin14, TX = pin13).
> > Call DefineCom3(14, 13, bx1000_1000)
> >
> > 'Clear LCD Screen.
> > Call PutQueuestr(Com3_Out, Chr(Clear_Screen))
> >
> > 'Replaces the keypad # entry to the LCD with an * and also
> > shuts off the buzzer.
> > 'Call PutQueueStr(Com3_Out, Chr(24) & Chr(bx0000_0101) )
> >
> > 'Call PutQueueStr(Com3_Out, Chr(15)) 'Shuts backlight off.
> > 'Call PutQueueStr(Com3_Out, Chr(4)) 'Hides cursor
> > Call Delay(0.5)
> >
> > Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(22))
> > Call PutQueueStr(Com3_Out, "ACE ENGINEERING")
> > Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(43))
> > Call PutQueueStr(Com3_Out, "VERSION 1.0.03")
> >
> > Do
> > Debug.Print "1"
> > Call GetQueue(Com3_In, Keypad_Recv, 1)
> > Debug.Print "2"
> > Debug.Print "Key value:"; CStr(Keypad_Recv)
> > Debug.Print "3"
> > Loop
> >
> > Call Sleep(4.0)
> >
> > End Sub
> > '-----------------------------
--
> --
> >
> > The sub is called in the main sub, the Com3_In(1 To 30) and
Com3_Out
> > (1 To 40). I added the Debug.Print "1", "2" and "3" to see how
the
> > do-loop is working. Debug.Print "1" shows up but it just hangs
on
> > the GetQueue and no key presses trigger it to print the "Key
> > value:". Any advice?
> >
> > I feel I am just about there, I am getting excited!
> >
> > Conrad
> > --- In b..., "mr_tentacle_too"
> > wrote:
> > >
> > > Hi Conrad. According to the docs the keypad sends a 1-
byte "tag"
> > for
> > > each of the keys immediately upon a key press. I could not
find
> > what
> > > the default values are, but this should be easy to determine.
> You
> > > can send your own table of values for the tags, too.
> > >
> > > Assuming you want to display the returned value with a
> debug.print,
> > > you would do something like this (assuming you use COM3 for the
> > > LCD+2):
> > >
> > > dim byte_recv as byte
> > >
> > > call definecom3(...)
> > >
> > > call openqueue(in_q,15)
> > > call openqueue(out_q,15)
> > >
> > > call opencom(3,9600,in_q,out_q)
> > >
> > > do
> > > call getqueue(in_q,byte_recv,1)
> > > debug.print "Key value:"; cstr(byte_recv)
> > > loop
> > >
> > > Note that the loop will be blocked for input at the "getqueue"
> > until
> > > a character is received.
> > >
> > >
> > > --- In b..., "Conrad A*****" wrote:
> > > >
> > > > Thanks for the replies!
> > > >
> > > > Ken, after reading your email, you are correct the code for
the
> > > LCDx
> > > > is different than the LCD+. I found out in fact mine is
LCD+2
> > (not
> > > > that it really matters), so the code you provided won't work
in
> > my
> > > > case. Although I did read the LCDx manual and it is far more
> > > > descriptive and understanding than the tidbit given for the
> > LCD+/+2
> > > > variant. Kinda makes me want to buy an LCDx. Haha.
> > > >
> > > > Benoit, I am familiar with buttons and switches, I've had a
> BX24
> > > for
> > > > a few years nowbut I am not sure how to capture a serial
input
> > > from
> > > > the LCD since the keypad is connected to it.
> > > >
> > > > Steve, I have read the manual many times and picked up some
> > things
> > > > from it. I just haven't been able to see any sample code or
> > > anything
> > > > that shows how to debug.print a keypad press or use it to
> select
> > > > something. I don't have my code in front of me but I do
> believe
> > I
> > > > have set the OpenCom port setup for input and output of the
> LCD.
> > I
> > > > am just not sure what command I need to debug.print what key
> has
> > > been
> > > > pressed. Once I learn how to do that then I am sure I can
> figure
> > > out
> > > > how to get it to change variables, select or tab through
> menus.
> > > Till
> > > > then I'm stuck!
> > > >
> > > > If anyone is interested I can upload my whole code and allow
> you
> > to
> > > > poke holes in it and make things work. I always struggle the
> > first
> > > > time before I try somethingthen after that it's not bad at
> all.
> > > > I've never used a keypad input for anything and I have been
> > > > struggling/waiting for quite some time to get it to work.
> > > >
> > > > Conrad
> > > >
> > > >
> > > > --- In b..., "mr_tentacle_too"
> > > > wrote:
> > > > >
> > > > > Hello Conrad. I assume you have the user manual for the
> LCD+,
> > if
> > > > not
> > > > > you can find it here:
http://www.basicx.com/Products/LCD+/LCD%
> > > > 2Btech.htm
> > > > >
> > > > > There is an example for sending data to the LCD in the back
> of
> > > the
> > > > > manual.
> > > > >
> > > > > I took a quick read through the manual, and what you need
to
> do
> > > is
> > > > read
> > > > > the serial data coming back from the keypad - it gets sent
> out
> > > the
> > > > TX
> > > > > line on the LCD+ when you press a key. You must first set
> the
> > > com
> > > > port
> > > > > up to have the correct line speed (9600 is the default),
then
> > > call
> > > > > OpenCom on that comm port (Com1 or Com3).
> > > > >
> > > > > In the OpenCOmm call you provide two queues, one for input
> from
> > > the
> > > > > device, and one for output to it.
> > > > >
> > > > > With the comm port open, you can then read the input queue
by
> > > > calling
> > > > > GetQueue, and send data back to the LCD with PutQueue or
> > > > PutQueueStr.
> > > > >
> > > > > -steve
> > > > >
> > > > >
> > > > > --- In b..., "Conrad A*****"
> wrote:
> > > > > >
> > > > > > I am completely stuck on a project and have looked
> everywhere
> > > and
> > > > > found
> > > > > > nothing. I have a keypad plugged into a LCD+ display
which
> > is
> > > > > > connected to the BX24. Now I want to let the BX24 know
> that
> > a
> > > > key
> > > > > has
> > > > > > been pressed. Either by a debug.print or anything of
that
> > > sort,
> > > > just
> > > > > > to let me know it recognizes that I am pushing a button.
> Can
> > > > anyone
> > > > > > please help me? Just a snippit of code or any advice? I
> am
> > > > > completely
> > > > > > stuck and can't go much futher until I figure this out.
> > > > > >
> > > > >
> > > >
> > >
>



Hi. Glad to hear you have it working. You can load your own key
table into the LCD+2 by sending a 17-byte string where the first
character is CHR(20) and the next 16 are the key values you want, in
order. So, something like this:

call putqueuestr(out_q,chr(20)+"1234567890ABCDEF")

or whatever 1-byte tag values you want.

-steve
--- In b..., "Conrad A*****" wrote:
>
> THANK YOU! I have been waiting/trying for so long to get this to
> work...finally!!! I know in the past if I pressed button "1" then
> it'd show a "1" on the LCD screen. Now I am getting a funny
looking
> icon on the screen. I believe related to this is the
outputted "key
> value". This is what I get:
>
> Keypad Digit = Key Value
> 1 = 8
> 2 = 64
> 3 = 128
> 4 = 1
> 5 = 0
> 6 = 0
> 7 = 5
> 8 = 0
> 9 = 129
> 0 = 8
> Up = 0
> Down = 40
> 2nd = 0
> Clear = 0
> Help = 0
> Enter = 0
>
> Any idea how to have it output a key value equal to the keyboard
> digit and for the text and direction keys, having it's own unique
> numerical value?
>
> Thank you so much for your help so far. I am going to keep
plugging
> away at this and I definately appreciate your input! Anyone else
> reading this, feel free to chime in if you wish. :D
>
> Conrad
>
> --- In b..., "mr_tentacle_too"
> wrote:
> >
> >
> > Hi Conrad. Put the DefineCom3 call before the OpenCom call. I
am
> > not sure the order makes a difference but logically it makes more
> > sense.
> >
> > In your DefineCom3 call you are setting the port to inverted
logic,
> > so another thing to try is setting it to NON-inverted.
> >
> > I am assuming all the output to the LCD is working. If you have
a
> > scope, hook it to the RX line from the LCD and set it to edge-
> trigger
> > on the leading edge, this will show you if anything is coming
back
> on
> > a key press.
> >
> > -steve
> >
> > --- In b..., "Conrad A*****" wrote:
> > >
> > > Take a look at what I've got so far:>
> > > '---------------------------
--
> --
> > --
> > > Public Sub LCDIntro()
> > >
> > > Dim Keypad_Recv as Byte
> > >
> > > 'Open Com3 serial port queues.
> > > Call OpenQueue(Com3_Out, 40)
> > > Call OpenQueue(Com3_In, 30)
> > > 'Open Com3 at 9600, N, 8, 1
> > > Call OpenCom(3, 9600, Com3_In, Com3_Out)
> > > 'Define pins for Com3 (RX = pin14, TX = pin13).
> > > Call DefineCom3(14, 13, bx1000_1000)
> > >
> > > 'Clear LCD Screen.
> > > Call PutQueuestr(Com3_Out, Chr(Clear_Screen))
> > >
> > > 'Replaces the keypad # entry to the LCD with an * and also
> > > shuts off the buzzer.
> > > 'Call PutQueueStr(Com3_Out, Chr(24) & Chr(bx0000_0101) )
> > >
> > > 'Call PutQueueStr(Com3_Out, Chr(15)) 'Shuts backlight off.
> > > 'Call PutQueueStr(Com3_Out, Chr(4)) 'Hides cursor
> > > Call Delay(0.5)
> > >
> > > Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(22))
> > > Call PutQueueStr(Com3_Out, "ACE ENGINEERING")
> > > Call PutQueueStr(Com3_Out, Chr(Position_Cursor) & Chr(43))
> > > Call PutQueueStr(Com3_Out, "VERSION 1.0.03")
> > >
> > > Do
> > > Debug.Print "1"
> > > Call GetQueue(Com3_In, Keypad_Recv, 1)
> > > Debug.Print "2"
> > > Debug.Print "Key value:"; CStr(Keypad_Recv)
> > > Debug.Print "3"
> > > Loop
> > >
> > > Call Sleep(4.0)
> > >
> > > End Sub
> > > '---------------------------
--
> --
> > --
> > >
> > > The sub is called in the main sub, the Com3_In(1 To 30) and
> Com3_Out
> > > (1 To 40). I added the Debug.Print "1", "2" and "3" to see how
> the
> > > do-loop is working. Debug.Print "1" shows up but it just hangs
> on
> > > the GetQueue and no key presses trigger it to print the "Key
> > > value:". Any advice?
> > >
> > > I feel I am just about there, I am getting excited!
> > >
> > > Conrad
> > > --- In b..., "mr_tentacle_too"
> > > wrote:
> > > >
> > > > Hi Conrad. According to the docs the keypad sends a 1-
> byte "tag"
> > > for
> > > > each of the keys immediately upon a key press. I could not
> find
> > > what
> > > > the default values are, but this should be easy to
determine.
> > You
> > > > can send your own table of values for the tags, too.
> > > >
> > > > Assuming you want to display the returned value with a
> > debug.print,
> > > > you would do something like this (assuming you use COM3 for
the
> > > > LCD+2):
> > > >
> > > > dim byte_recv as byte
> > > >
> > > > call definecom3(...)
> > > >
> > > > call openqueue(in_q,15)
> > > > call openqueue(out_q,15)
> > > >
> > > > call opencom(3,9600,in_q,out_q)
> > > >
> > > > do
> > > > call getqueue(in_q,byte_recv,1)
> > > > debug.print "Key value:"; cstr(byte_recv)
> > > > loop
> > > >
> > > > Note that the loop will be blocked for input at
the "getqueue"
> > > until
> > > > a character is received.
> > > >
> > > >
> > > > --- In b..., "Conrad A*****"
wrote:
> > > > >
> > > > > Thanks for the replies!
> > > > >
> > > > > Ken, after reading your email, you are correct the code for
> the
> > > > LCDx
> > > > > is different than the LCD+. I found out in fact mine is
> LCD+2
> > > (not
> > > > > that it really matters), so the code you provided won't
work
> in
> > > my
> > > > > case. Although I did read the LCDx manual and it is far
more
> > > > > descriptive and understanding than the tidbit given for the
> > > LCD+/+2
> > > > > variant. Kinda makes me want to buy an LCDx. Haha.
> > > > >
> > > > > Benoit, I am familiar with buttons and switches, I've had a
> > BX24
> > > > for
> > > > > a few years nowbut I am not sure how to capture a serial
> input
> > > > from
> > > > > the LCD since the keypad is connected to it.
> > > > >
> > > > > Steve, I have read the manual many times and picked up some
> > > things
> > > > > from it. I just haven't been able to see any sample code
or
> > > > anything
> > > > > that shows how to debug.print a keypad press or use it to
> > select
> > > > > something. I don't have my code in front of me but I do
> > believe
> > > I
> > > > > have set the OpenCom port setup for input and output of the
> > LCD.
> > > I
> > > > > am just not sure what command I need to debug.print what
key
> > has
> > > > been
> > > > > pressed. Once I learn how to do that then I am sure I can
> > figure
> > > > out
> > > > > how to get it to change variables, select or tab through
> > menus.
> > > > Till
> > > > > then I'm stuck!
> > > > >
> > > > > If anyone is interested I can upload my whole code and
allow
> > you
> > > to
> > > > > poke holes in it and make things work. I always struggle
the
> > > first
> > > > > time before I try somethingthen after that it's not bad at
> > all.
> > > > > I've never used a keypad input for anything and I have been
> > > > > struggling/waiting for quite some time to get it to work.
> > > > >
> > > > > Conrad
> > > > >
> > > > >
> > > > > --- In b..., "mr_tentacle_too"
> > > > > wrote:
> > > > > >
> > > > > > Hello Conrad. I assume you have the user manual for the
> > LCD+,
> > > if
> > > > > not
> > > > > > you can find it here:
> http://www.basicx.com/Products/LCD+/LCD%
> > > > > 2Btech.htm
> > > > > >
> > > > > > There is an example for sending data to the LCD in the
back
> > of
> > > > the
> > > > > > manual.
> > > > > >
> > > > > > I took a quick read through the manual, and what you need
> to
> > do
> > > > is
> > > > > read
> > > > > > the serial data coming back from the keypad - it gets
sent
> > out
> > > > the
> > > > > TX
> > > > > > line on the LCD+ when you press a key. You must first
set
> > the
> > > > com
> > > > > port
> > > > > > up to have the correct line speed (9600 is the default),
> then
> > > > call
> > > > > > OpenCom on that comm port (Com1 or Com3).
> > > > > >
> > > > > > In the OpenCOmm call you provide two queues, one for
input
> > from
> > > > the
> > > > > > device, and one for output to it.
> > > > > >
> > > > > > With the comm port open, you can then read the input
queue
> by
> > > > > calling
> > > > > > GetQueue, and send data back to the LCD with PutQueue or
> > > > > PutQueueStr.
> > > > > >
> > > > > > -steve
> > > > > >
> > > > > >
> > > > > > --- In b..., "Conrad A*****"
> > wrote:
> > > > > > >
> > > > > > > I am completely stuck on a project and have looked
> > everywhere
> > > > and
> > > > > > found
> > > > > > > nothing. I have a keypad plugged into a LCD+ display
> which
> > > is
> > > > > > > connected to the BX24. Now I want to let the BX24 know
> > that
> > > a
> > > > > key
> > > > > > has
> > > > > > > been pressed. Either by a debug.print or anything of
> that
> > > > sort,
> > > > > just
> > > > > > > to let me know it recognizes that I am pushing a
button.
> > Can
> > > > > anyone
> > > > > > > please help me? Just a snippit of code or any advice?
I
> > am
> > > > > > completely
> > > > > > > stuck and can't go much futher until I figure this out.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
>