I want to be able to type in a number like 124 and end it with a #
So this number (the actual number 124) can be transmitted.
If you could imagine a cellphone or cordless landline...
As you type in the numbers on the keypad you can see them on the screen and then you press dial or possibly C(clear or *) to backspace one digit.
And when you are happy with the number on screen you press dial (in my case #) then your number is dialled (in my case TX'd)
So that means that now the keypad works correctly, and when you press the wanted key you obtain the correct caracter.
To acheive what you want, you will need an additional array and a few variables:
The array will retain the numbers you key in and a variable should keep track of the number of time you have pressed the keys.
Here a snippet
Code:
Ratain var byte
Ret_Char var byte [10]
Ret_Count var byte
Ret_Prnt var byte
Ret_Clst var byte
Ret:Prnt = "#"
Ret_Clst = "*"
Loop:
Ret_Char[Ret_Count]=Key_Char ' here you transfer the char of the key pressed
If Retain = 0 then ' Retain is a flag then if set will do your job
Hserout [Ret_Char[Ret_Count]]
else
If Ret_Char[Ret_Count] = Ret_Clst then ' if key = "*" then step-back counter
Ret_Count = Ret_Count - 1
goto Clear_Count
endif
If Ret_Char[Ret_Count] = Ret_Prnt then ' if key = "#" then send string
Hserout [str Ret_Char \ Ret_count-1]
RetCount = 0
goto Clear_Count
endif
Ret_Count = Ret_Count + 1
Clear_Count:
endif
return
I set the array Ret_Char to 10 elements, if you need more then adjiust it for your need. The snippet is not tested so some adjustment could be necessary.
Al.
Last edited by aratti; - 21st November 2009 at 20:02.
All progress began with an idea
Bookmarks