(34S) Full Key Scan Map w/ A-Z to 1-26 conversion [highly compressed; <37 steps!] - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (34S) Full Key Scan Map w/ A-Z to 1-26 conversion [highly compressed; <37 steps!] (/thread-6732.html) |
(34S) Full Key Scan Map w/ A-Z to 1-26 conversion [highly compressed; <37 steps!] - Nick - 08-26-2016 02:14 PM This key scan / menu converts letters A-Z to 1-26 with the exception of Y which is firmware reserved (substitute any key/chord of your choice for Y/25). The design uses exclusion and accumulating offsets for compression. If you desire values other than 1-26, insert your additional offset after line 25 (ex. to convert to ASCII). If you can compress it further, I'd love to see it and learn some new tricks. The demo returns 1-26 for A-Z and negative values for the remaining scan codes. Insert your code everywhere you like! Enjoy, Nick Code: 01 LBL 'KEY' Comments: All labels shown (except KEY and 00) are required due to the alpha conversion formula's use of exclusion. If you're not using them, they still need to be in place and you can simply route them to no-action/loop as a group. Insert your code to respond to A-Z between 25 and 26 including any further offset(s) (ex. ASCII). Step 26 loops to repeat the demo. Insert your code for other keys after labels at steps 27 through 36, adjusting branching as desired. Step 37 denotes scan codes for the demo and can be removed. Step 38 loops to repeat the demo. Edit: Updated Subject from 39 to 37 steps! RE: (34S) Full Key Scan Map w/ A-Z to 1-26 conversion [highly compressed; <39 steps!] - Nick - 08-26-2016 11:49 PM In response to a mini-challenge, Didier Lachieze posted the following improvement at a reduction of two steps! Great job: (08-26-2016 03:49 PM)Didier Lachieze Wrote: Nice job! It's pretty well compressed already. Code: 01 LBL 'KEY' Comments: Due to Didier's use of additional exclusion (an improvement), this makes labels {2, 5, 6, 7} still reserved -- they cannot appear in the routine if it is to perform as specified (you'd get unintended branching -- unless that were your intention). And now that I think of it, the scan codes of A - Z are also reserved, but this could be of benefit as it allows you to override the behavior of any letter by adding a label that contains its original scan code. How about that... |