HP39GII GETKEY command - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: HP39GII GETKEY command (/thread-229032.html) |
HP39GII GETKEY command - Charles C(UK) - 08-11-2012 I am struggling with the HP39GII GETKEY command. This crude bit of code works under the emulator, although with a few glitches and false returns:
EXPORT TRY1() i.e. it reads and displays key press codes until key 5 (F6) is pressed. -1 is displayed when no key is depressed. When I USB it across to the actual HP39GII, it doesn't work at all. Zero is returned whatever the state of the keyboard. I tried a similar program on my HP39GS and this behaved as expected. On this earlier model, a call of GETKEY actually suspends processing until a key is pressed. On the HP39GII it just runs through but throws up the code number for the last key pressed. Has anybody else successfully used GETKEY on their hardware HP39GII?
Edited: 11 Aug 2012, 10:58 a.m.
Re: HP39GII GETKEY command - Tim Wessman - 08-11-2012 Thanks for the information. Will investigate. Send me an email at timwessman at hp.com. I believe the change to not pause was made since it seemed most of the time people wanted to use this is a loop and continue processing (for example, a game or moving an object). Pausing meant that was pretty much impossible. We could probably investigate having an optional "time" value from 0 on up that would specific the amount of wait time. Thoughts?
TW
Re: HP39GII GETKEY command - Gilles Carpentier - 08-11-2012 The 50G is fine for this...
1/ Wait Command: Suspends program execution for specified time, or until a key is pressed. (see AUR) If i'm not wrong, i remember also that the 0 WAIT on the 50G use very few power (on the the contrary of a loop with a key test)
On my 39gII Rev 16633 GETKEY don't work
EXPORT Test Tim, a question : why many functions are in CAPS but few not (for example why 'string' and not 'STRING' ?
Edited: 11 Aug 2012, 7:15 p.m.
Re: HP39GII GETKEY command - Patrice - 08-11-2012 Hi Charles,
Please state the version/date of your emulator and rom. As for GETKEY not suspending execution, it is a behavior which match the manual. I don't like it as any program which use it will drain the batteries while waiting for the keyboard.
Patrice
Re: HP39GII GETKEY command - Tim Wessman - 08-11-2012 Generally, it means they came from XCAS, or started in XCAS and then later a strictly numeric version was made.
TW
Re: HP39GII GETKEY command - Charles C(UK) - 08-12-2012 Version string on the emulator is 2012 07 10 17565. It behaves as Gilles reports in his post above.
The physical calculator's ROM is 09/May/2012 Revision 16633. Edited: 12 Aug 2012, 1:28 a.m.
Re: HP39GII GETKEY command - Patrice - 08-12-2012 This should explain. The bug was here in May and was corrected before your emulator release.
Check for ROM update.
Re: HP39GII GETKEY command - Charles C(UK) - 08-12-2012 I will re-flash as soon as a newer ROM download becomes available. I have a work-around for the "GETKEY" problem that uses the "ISKEYDOWN" function, which works properly. Code like this could be re-jigged as a function in any given program:
Keys are polled sequentially until one is found to be down or key 50 has been reached. If a key was down its id is reported. Key 0 (F1) exits the program. This works like the wait-until-a-key-is-pressed style "GETKEY" command on the HP39GS.
Re: HP39GII GETKEY command - Gilles Carpentier - 08-12-2012 Hi Charles Interesting. It works fine. I think there is differences between your program and GETKEY : - if you call 2 times TRY1 and a key is pushed (and not released) , it will returs 2 times the code key. I imagine GETKEY would only returns the key for the first call (if you don't release the key and push again)as it uses the keyboard buffer. - The buffer is not cleared with ISKEYDOWN (you can can clear it with a call of GETKEY if ISKEYDOWN) To manage the keyboard, we need 3 functions : 1/ GETKEY (to read the last key in the buffer) 2/ ISKEYDOWN (to scan the keyboard in real time)- Perfect for games ;) 3/ WAIT(0) like the 50G : stop the program, and wait until a key is down and then return the key number - low power consumption) PS : I've not tried yet, but it will be interesting to see if ISKEYDOWN can manage multiple keys down in the same time EDIT : Yes you can, with the real calc (not with 17565 rev emulator (perhaps because of the PC keyboard ? You can't push 2 keys only with the mouse ;) ) :
EXPORT MyFirstGame So you can handle FIRE and Left/Right keys pressed in the same time Another example :
EXPORT MyFirstGame Is it possible to access to one item of a sublist to avoid use of temporary variable (m in this exemple) ?
For example here :(i want to get "nine") The only way i have found is : m:=k(3); ....m(2)...
Edited: 12 Aug 2012, 9:41 a.m.
|