(34S) Full Key Scan Map w/ A-Z to 1-26 conversion [highly compressed; <37 steps!]
08-26-2016, 02:14 PM (This post was last modified: 08-27-2016 12:11 AM by Nick.)
Post: #1
 Nick Member Posts: 64 Joined: Aug 2016
(34S) Full Key Scan Map w/ A-Z to 1-26 conversion [highly compressed; <37 steps!]
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' 02 LBL 00 03 VIEW X 04 PSE 99 05 KEY? X 06 GTO 00 07 LBL?->X 08 GTO->X 09 ENTER 10 SDR 001 11 IP 12 GTO->X 13 LBL 01 14 DEC Y 15 DEC Y 16 LBL 03 17 LBL 04 18 DEC Y 19 LBL 02 20 LBL 05 21 LBL 06 22 LBL 07 23 # 007 24 * 25 - 26 GTO 00 27 LBL 24 28 LBL 25 29 LBL 26 30 LBL 31 31 LBL 35 32 LBL 41 33 LBL 51 34 LBL 61 35 LBL 62 36 LBL 72 37 +/- 38 GTO 00 39 RTN

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!
08-26-2016, 11:49 PM (This post was last modified: 08-27-2016 01:07 AM by Nick.)
Post: #2
 Nick Member Posts: 64 Joined: Aug 2016
RE: (34S) Full Key Scan Map w/ A-Z to 1-26 conversion [highly compressed; <39 steps!]
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.
But ... as it is a challenge, here is a 37 steps version:

Code:
01 LBL 'KEY' 02 LBL 00 03 VIEW X 04 PSE 99 05 KEY? X 06 GTO 00 07 LBL?->X 08 GTO->X 09 ENTER 10 SDR 001 11 IP 12 LBL?->X 13 GTO->X 14 SKIP 006 15 LBL 01 16 DEC Y 17 DEC Y 18 LBL 03 19 LBL 04 20 DEC Y 21 # 007 22 * 23 - 24 GTO 00 25 LBL 24 26 LBL 25 27 LBL 26 28 LBL 31 29 LBL 35 30 LBL 41 31 LBL 51 32 LBL 61 33 LBL 62 34 LBL 72 35 +/- 36 GTO 00 37 RTN