Question

Currently I am working on a project which has following setup.

  1. AVR micro-controller
  2. IDE - AVR Studio
  3. Operating system - FreeRTOS

For input I am using a keypad matrix of 4x3. I have already coded for 4x3 keypad to take inputs as numbers. But now I want to make it alpha-numeric. Like we see in our mobile phone keypads.

Example - Key 2 will be used to take input for 2,a,b,c. Single press key 2, we will get number 2, double press key 2 then we will get 'a', tripple press key 2 then we will get 'b' and fourtimes press key 2 then we will get 'd' on scree.

I hope all of you understood what I mean above. Can anybody give some code idea in C to implement this type of functionality?

Was it helpful?

Solution

You most likely just need to keep track of the system time of the last key press and compare it to the system time of the next key press. If the current key is the same key as the last press and the time between presses is small (say, under one second), replace the current input character with the next character in the list of characters for that key. If the time difference is more than one second, or if a different key was pressed, accept the current character and add a new character, starting at the first character in the list for the key.

OTHER TIPS

see the issue is when you press 2(say) in xxx sec time later after 30 millisec if you check and find that 2 is pressed then there are two cases. case1> the pressed key is new and is same as previous case2> the pressed key is same as previous and it is pressed from xxx till now contineously.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top