piclist 2004\06\20\094117a >
Thread: {handling keys}
www.piclist.com/techref/microchip/devices.htm?key=pic
flavicon
face BY : Koen van Leeuwen email (remove spam text)



On Friday 18 June 2004 19:59, Bob Axtell wrote:
> While it would seem that testing that a key is pressed would seem
> simple, it actually isn't because most applications need to know
> when it was RELEASED as well. In fact, for me, a keypress occurs when it
> is PRESSED THEN RELEASED.
>
> About 10 years ago I began using a bulletproof way to process keys:
>
> 1. I read the keys- all of them- every 10ms or so. I can either read 'em
> all at one tome, or rotate so that I read each one on a rotating basis.
> Doesn't matter how its done, it works perfectly regardless.
>
> 2. Every 10ms I read the key and shift its value into a register
> decicated just for that application.
>
> 3. If the key is ZERO when it is pressed, I look for the pattern
> b'11110000' on that key's register. When that is seen, that key was
> PRESSED AND RELEASED, so set a flag. To prevent more action, jam the
> key's register with '11111111' so it can't be used again.

What happens with key bounce? Isn't it possible that bouncing during release
of the key would produce the pattern b'11101000'?

> This works great. If anyone is interested, I'll publish some code.

I'm interested :o)


Koen

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

<200406201538.45760.koen@vanleeuwen.xs4all.nl> 7bit

In reply to: <40D32D70.6050206@yahoo.com>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic

Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) {handling keys}

month overview.

new search...