| Posted: 10:53am 24 Sep 2024 |
|
|
|
Hi Peter,
Something strange....
Below code checks for a change in MM.INFO(PS2) to detect if a key is pressed.
'check if a PS2 key is pressed Print "press any key" Do a=MM.Info(ps2) Pause 10 b=MM.Info(ps2) If a<>b Then Print a,b Loop Until a<>b Print "PS2 found"
If you run this code (F2) from the commandline it immediatly finds a PS2 keyboard. It must "remember" the F2 key you pressed on the PS2 keyboard to run the program. Similar with RUN+<enter>.
If you enter the editor (F4) and run the program from the editor (F2) the same happens.
But....
If you enter the editor, and make a change to the program (i.e. add a comment, space, whatever) and press F2 to run the program, it works as expected. It waits for you to press a key.
I cannot explain the difference. I would (of coarse) want the program to work like this. Show that a new key is pressed, not act on a key that might have been pressed before.
I tried reading MM.INFO(PS2) multiple times, as a dummy, to clear any buffers, prior to the loop, but that does not solve it.
This is 6.0.0 beta 6 on a RP2040 VGA platform.
Any idea ?
Volhout
EDIT: I found something . It is timing related. If you poll mm.info(ps2) too frequent you do not get usefull feedback. A 50ms delay between polling, and a "clear" of the buffer (reading mm.info(ps2) several times) prior to running the loop gives decent results. Edited 2024-09-24 21:38 by Volhout |