VK204-25 & Auto Repeat Mode
VK204-25 & Auto Repeat Mode
Using a keypad via RS232 to an Atmel microcontroller board. Everything works fine except for a problem with the auto key repeat mode. It turns on with 254 126 0 for typematic mode. When I send 254 96, it does not turn the repeating off. What am I missing?
[quote="Raquel"]Thanks for posting. I do not see any reason for the module not to follow command 254 96 and turn off auto repeat mode. Do you mind sending a piece of your code?[/quote]
'Jog x axis
Gosub Akr_on
Do
Gosub Clr_kb
Gosub Get_kp
If A = 1 Then Jog = Out
If A = 2 Then Jog = In
If A = 3 Then Exit Do
Loop
Gosub Akr_off
End
'Get keypress sub
Sub Get_kp()
A = 0
Gosub Clr_kb
A = Waitkey()
End Sub
'Clear key buffer sub
Sub Clr_kb()
Print Chr(254) ; Chr(69)
End Sub
'Auto key repeat on sub
Sub Akr_on()
Print Chr(254) ; Chr(126) ; Chr(0)
End Sub
'Auto key repeat off sub
Sub Akr_off()
Print Chr(254) ; Chr(96)
End Sub
-=-=-=-=-=-=-=-=-=-
'Jog x axis
Gosub Akr_on
Do
Gosub Clr_kb
Gosub Get_kp
If A = 1 Then Jog = Out
If A = 2 Then Jog = In
If A = 3 Then Exit Do
Loop
Gosub Akr_off
End
'Get keypress sub
Sub Get_kp()
A = 0
Gosub Clr_kb
A = Waitkey()
End Sub
'Clear key buffer sub
Sub Clr_kb()
Print Chr(254) ; Chr(69)
End Sub
'Auto key repeat on sub
Sub Akr_on()
Print Chr(254) ; Chr(126) ; Chr(0)
End Sub
'Auto key repeat off sub
Sub Akr_off()
Print Chr(254) ; Chr(96)
End Sub
-=-=-=-=-=-=-=-=-=-
Hi kfaria,
I do not see anything wrong with the code. Have you seen A == 3? Since this is the only branch that will actually send the command 254 96, make sure that you actually get the value 3.
By the way, there is really no need to clear the keypad buffer every single time you read a keypad key. The keypad buffer is intended to keep all the keys that are not sent in case you chose to poll the keys pressed instead of being autotransmitted like what you have. Each key when transmitted IS put in the buffer, but then the keys sent when in autotransmit are keys that are NOT from the buffer but from actual key presses.
I do not see anything wrong with the code. Have you seen A == 3? Since this is the only branch that will actually send the command 254 96, make sure that you actually get the value 3.
By the way, there is really no need to clear the keypad buffer every single time you read a keypad key. The keypad buffer is intended to keep all the keys that are not sent in case you chose to poll the keys pressed instead of being autotransmitted like what you have. Each key when transmitted IS put in the buffer, but then the keys sent when in autotransmit are keys that are NOT from the buffer but from actual key presses.
Raquel Malinis
Design and Development
Matrix Orbital
Design and Development
Matrix Orbital
Hi kfaria
Okay, now we know that the command is being sent. But the problem is even if it is sent, you still see repeated data coming on the RS232 lines on about 2ms apart? I just want to know how you can actually tell that the module did not follow command 254 96 (since in the original code, after sending 254 96, there is no more WaitKey()). The normal operation would be: if the module receives 254 96, it will stop sending repeated data about 2ms apart (providing that the key is being held pressed). But if a new key is pressed, this will be transmitted via RS232.
Okay, now we know that the command is being sent. But the problem is even if it is sent, you still see repeated data coming on the RS232 lines on about 2ms apart? I just want to know how you can actually tell that the module did not follow command 254 96 (since in the original code, after sending 254 96, there is no more WaitKey()). The normal operation would be: if the module receives 254 96, it will stop sending repeated data about 2ms apart (providing that the key is being held pressed). But if a new key is pressed, this will be transmitted via RS232.
Raquel Malinis
Design and Development
Matrix Orbital
Design and Development
Matrix Orbital