CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

HELP - How to automatically acquire a long number frm keypad

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ernest



Joined: 11 Feb 2004
Posts: 51

View user's profile Send private message

HELP - How to automatically acquire a long number frm keypad
PostPosted: Mon Apr 26, 2004 6:51 pm     Reply with quote

Hi,

The following is a routine for acquiring a 32-BIT number using RS232. Instead of using RS232, I would like to implement it using keypad to key in the value.

The problem is, an ENTER command needs to be entered in order to put the value into the variable for storage. How can I modify the routine either to be able to enter a 6-decimal digits (000000 -- 999999) and storing it into the variable without having to press the ENTER command or create an ENTER command from the keypad.

Thanks...

signed int32 get_long32() {
char s[11];
signed int32 l32;

// able to get max. cca.(32 bits) == 2^32 = 4,294,967,296
get_string(s, 11);

l32=atoi32(s);
return(l32);
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Apr 27, 2004 1:34 am     Reply with quote

To avoid the enter key you can use getc() in a loop, but then you allways need to enter 6 digits.

Code:

signed int32 get_long32() {
char s[11];
signed int32 l32;
int8 i;

for (i=0; i<6; i++)
  getc(s[i]);

l32=atoi32(s);
return(l32);
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Apr 27, 2004 2:24 pm     Reply with quote

wouldn't your keypad have a # or a * that could be used in place of the enter key?
valemike
Guest







PostPosted: Tue Apr 27, 2004 3:54 pm     Reply with quote

If the guy screws up entering the number, he'll want to correct it. Thus you should allow him to keep punching numbers until it displays what he wants.

If he keeps typing beyond the six digits, you might want to shift the most significant digit out of there, and just look at the most recent 6 digits. (That's how some microwaves work).

Now, to be able to save these without an "enter" button, perhaps you can tell them to hold down two keys for 3 seconds, like the "2" and the "9"

~~~~~~~~~~~~~~

Have the rest of you guys implemented keypad functions in the past? For me, my keypad functions end up being a state machine with states like "Key 1 hit, waiting for a release", "Keypad Idle", "Enter hit", "Key 1 hit for more than 3 seconds".

Without a state machine (and with, too), keypad programming becomes a nightmare!! It takes up a lot of code. Crying or Very sad
ernest



Joined: 11 Feb 2004
Posts: 51

View user's profile Send private message

PostPosted: Fri Apr 30, 2004 12:04 am     Reply with quote

Thanks a lot guys...really appreciate it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group