??? 06/21/10 13:09 Read: times |
#176802 - Time to code Responding to: ???'s previous message |
I greatly appreciate all the responses so far. They will be immensely helpful. Specially thanks Jerson for sharing the trick. I'll surely fit it somewhere in my code.
And yes I was guessing too that a layer above the keypad routines will be required with low level routines unchanged. So I didn't change the low level ones. I have 2 functions for scanning keypad at present: unsigned char get_key_status(void) { unsigned char code keypad[4][3]= { '1','2','3', '4','5','6', '7','8','9', '*','0','#' }; ... return keypad[x][y]; ...That is, a function which when called returns the instantaneous key being pressed during it's execution. Otherwise returns 0 and exits. This is useful when continuous scanning is required e.g in while loops etc. The other one is bring_key() which when called stays in loop until a key is pressed, returns that key & exits. This is useful when some menu comes on the interface & user has to choose options from 1,2,3 etc. and there's nothing really special to do until user chooses an option. To start with, I decided to make a routine that prints 'a' if 2 is pressed. If 2 is pressed again within 1 sec, it replaces 'a' with 'b'. Now the very primitive pseudocode that I have thought of for just getting the '2' key to work for inputting a,b is multitap_mode() //called from main() { WHILE FOREVER { IF any_key_pressed //key = '2' here THEN { print_base_char_for_key //eg 'a' for 2 FOR(i=0;i<1000,i++) //scan 1000 times in 1 sec { IF same_key_pressed_again //no support for pressing other keys yet THEN { DECREMENT cursor_position print_next_char_for_key //should print 'b' now //will be 1 more loop here } DELAY (1ms) //wait for 1 second total in for loop } } } } There should be 1 more embedded for loop for 'c' which I haven't added yet. No exit paths to main() too. There is much to do here. I have to use for loop since unfortunately all my timers are used for other purposes. So using timers for delay length measurement is not possible. Any improvements/suggestions? -Regards, Munish |
Topic | Author | Date |
Ideas for Multi-tap keyboard routine | 01/01/70 00:00 | |
just follow | 01/01/70 00:00 | |
Multi-tap is not too difficult | 01/01/70 00:00 | |
Two-step operation. Keyboard input + post-processing | 01/01/70 00:00 | |
State Machine! | 01/01/70 00:00 | |
Agree 100% | 01/01/70 00:00 | |
Time to code | 01/01/70 00:00 | |
Software Timers! | 01/01/70 00:00 | |
Practical Limits | 01/01/70 00:00 | |
Don't lock up in infinite loops everywhere | 01/01/70 00:00 | |
In the pseudo code... | 01/01/70 00:00 | |
State Machine | 01/01/70 00:00 | |
Divide by 5 | 01/01/70 00:00 | |
Timer resolution | 01/01/70 00:00 | |
State Machine | 01/01/70 00:00 | |
Looks not bad programming practice | 01/01/70 00:00 | |
Using Timer May Still be Possible | 01/01/70 00:00 | |
Done ! | 01/01/70 00:00 | |
Very Cool!!! | 01/01/70 00:00 | |
Compare with zero is better | 01/01/70 00:00 | |
Avoid ISR jitter using timer T1 | 01/01/70 00:00 | |
Code! | 01/01/70 00:00 | |
Thanks Munish...![]() | 01/01/70 00:00 |