An idea would be to use the lookup command for your translation from numbers to numbers-ASCII conversion.
Now about the numbers to assebly in a byte. What is the range of your input?
0-255 or 0-999?
Ioannis
An idea would be to use the lookup command for your translation from numbers to numbers-ASCII conversion.
Now about the numbers to assebly in a byte. What is the range of your input?
0-255 or 0-999?
Ioannis
Hi Ioannis
Thanks for the reply :-)
Lookup is already implemented and working .
My range would be anything really (inifinity ??) but I guess I could use 0 to 999
It's like dialling on a phone ... you dial the numbers and then press the dial button :-)
I want to type numbers in and then press the # key and * to backspace or clear last entry ...
Kind regards
Dennis
Well, if you go for the 999 then a 0-65535 is possible as the final result needs a word variable.
One idea untested is this:
As there is the index counter, there is no need to press '#'. Numbers must be entered in 5 digit format, e.g. 00123.Code:array var byte[5] index var byte i var byte word_v var word 'Get keypress index=0 loop: gosub key_read if mykey=32 then loop 'No key press returns 32 array[index]=myvar index=index+1 if index=5 then calculate_result goto loop ... caculate_result: word_var=0:mult=10000 for i=index-1 to 0 step -1 word_var=word_var*mult+array[i] mult=mult/10 next i index=0 goto display_result
Also there is no filter if the user keys in a number greater than 65535, in which case result will be of course wrong due to overflow.
Ioannis
Last edited by Ioannis; - 23rd November 2009 at 21:02.
Hi Ioannis
Thank you for the code example... I'm just thinking that perhaps it would indeed be more practical to use 255 as the max number, in which case I would need to declare a byte as opposed to a word ...not so ?
Kind regards
Dennis
Yes, that is correct. Rest applies of course.
But don't be afraid of the word variable!
Ioannis
Hi all
The keypad code has been working very well ! Thanks mister_e!
Initially I had to wire alter the wiring to the keypad to the PIC to get things working now in order to match the header pins for PORT B on a dev board I am building I need to alter the include file somehow to match my keypad.
I was hoping someone could point me in the right direction for this or tell me where to change the code to match the desired pin configuration.
Here is what I have now:
EXISTING CONFIG (WORKING)
-------------------------
Columns Rows
______________ _____________
Keypad 7 6 5 4 3 2 1 0
PIC B4 B5 B6 B7 B0 B1 B2 B3
Here's what I would like to be
DESIRED CONFIG
--------------
Columns Rows
______________ _____________
Keypad 7 6 5 4 3 2 1 0
PIC B7 B6 B5 B4 B3 B2 B1 B0
I would appreciate any help/info
Kind regards
Dennis
Last edited by Dennis; - 7th January 2010 at 23:34.
Check the attached file
Dennis
Bookmarks