I've just started using GCBASIC and, having a keypad handy and noticing that the routines were "not tested", I thought that I would give them a go.
There seems to be some confusion between the help file and the keypad.h file as to which connections should be which (and as far as I can see neither is correct). From my experiments using a 16F877 @ 4Mhz with a 4x4 keypad and displaying the results on a 2x16 LCD (which was very quickly set up I'm pleased to report) I can give the following results. I have avoided using row1 or col2 and have settled on row[123A] and col[2580] which uniquely specifies them without confusion.
I have found that:
PORT.0 connects to col[ABCD]
PORT.1 connects to col[369#]
PORT.2 connects to col[2580]
PORT.3 connects to col[147*]
PORT.4 connects to row[*0#D]
PORT.5 connects to row[789C]
PORT.6 connects to row[456B]
PORT.7 connects to row[123A]
and because the columns are designated as inputs (from keypad.h file) I have used 18kohm pullups on them (value chosen because it was handy).
These connections give the correct response using KeypadData function (i.e. number keys produce matching number and A B C D * # produce respectively 10 11 12 13 14 15 and no key pressed gives 255 as stated in keypad.h.
KeypadRaw produces:
1 = 32768 2 = 16384 3 = 8192 A = 4096
4 = 2048 5 = 1024 6 = 512 B = 256
7 = 128 8 = 64 7 = 32 C = 16
* = 8 0 = 4 # = 2 D = 1
and no key pressed = 0.
This latter function has the capability of reading multiple key presses at one time (providing the software is up to it, timing the read) which is not true of the KeypadData function.
I hope the above is of use to somebody - I searched the forums but couldn't find a reference to keypads.
On another topic, I have been setting up PSPad editor (which I already use) to handle GCBASIC and MPASMWIN on Windows Vista. I found that I was totally confused by Vista's handling of files saved to the Program Files folder but I believe I have now got it sorted. If anybody wants clarification on the topic, I might be able to help with what I have learned so far.
Geoff in darkest Cumbria
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've just started using GCBASIC and, having a keypad handy and noticing that the routines were "not tested", I thought that I would give them a go.
There seems to be some confusion between the help file and the keypad.h file as to which connections should be which (and as far as I can see neither is correct). From my experiments using a 16F877 @ 4Mhz with a 4x4 keypad and displaying the results on a 2x16 LCD (which was very quickly set up I'm pleased to report) I can give the following results. I have avoided using row1 or col2 and have settled on row[123A] and col[2580] which uniquely specifies them without confusion.
I have found that:
PORT.0 connects to col[ABCD]
PORT.1 connects to col[369#]
PORT.2 connects to col[2580]
PORT.3 connects to col[147*]
PORT.4 connects to row[*0#D]
PORT.5 connects to row[789C]
PORT.6 connects to row[456B]
PORT.7 connects to row[123A]
and because the columns are designated as inputs (from keypad.h file) I have used 18kohm pullups on them (value chosen because it was handy).
These connections give the correct response using KeypadData function (i.e. number keys produce matching number and A B C D * # produce respectively 10 11 12 13 14 15 and no key pressed gives 255 as stated in keypad.h.
KeypadRaw produces:
1 = 32768 2 = 16384 3 = 8192 A = 4096
4 = 2048 5 = 1024 6 = 512 B = 256
7 = 128 8 = 64 7 = 32 C = 16
* = 8 0 = 4 # = 2 D = 1
and no key pressed = 0.
This latter function has the capability of reading multiple key presses at one time (providing the software is up to it, timing the read) which is not true of the KeypadData function.
I hope the above is of use to somebody - I searched the forums but couldn't find a reference to keypads.
On another topic, I have been setting up PSPad editor (which I already use) to handle GCBASIC and MPASMWIN on Windows Vista. I found that I was totally confused by Vista's handling of files saved to the Program Files folder but I believe I have now got it sorted. If anybody wants clarification on the topic, I might be able to help with what I have learned so far.
Geoff in darkest Cumbria