Macropad non-ascii character sequence

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kayaking_t
 
Posts: 15
Joined: Tue Jul 14, 2020 10:04 am

Macropad non-ascii character sequence

Post by kayaking_t »

I'm wondering if anyone has created a macro for using non-ascii spanish characters like ñ (alt+0241) and ¡ (alt+0161) as key presses on the Macropad. I use these characters all the time and always forget when the alt coding is for them. Also, I'm noticing that these special characters aren't showing on the display of the Macropad. I'm currently using the Project Bundle from the Macropad Hotkeys adafruit learn guide (https://learn.adafruit.com/macropad-hot ... igurations). Thanks in advance.

User avatar
kayaking_t
 
Posts: 15
Joined: Tue Jul 14, 2020 10:04 am

Re: Macropad non-ascii character sequence

Post by kayaking_t »

I did figure out how to setup the typing of the alt codes, but I'm still unable to get the actual non-ascii character to show correctly on the display. If there is a way of changing it to work, let me know. I had to setup release of the keycodes as well. Here's my circuit python code (it has both emoji's and spanish alt codes).

Code: Select all

# MACROPAD Hotkeys example: Universal Numpad

from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values

app = {                    # REQUIRED dict, must be named 'app'
    'name' : 'español & emoji', # Application name
    'macros' : [           # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x202000, '~n', [Keycode.ALT, 
            Keycode.KEYPAD_ZERO, -Keycode.KEYPAD_ZERO, 
            Keycode.KEYPAD_TWO, -Keycode.KEYPAD_TWO, 
            Keycode.KEYPAD_FOUR, -Keycode.KEYPAD_FOUR,
            Keycode.KEYPAD_ONE, -Keycode.KEYPAD_ONE, 
            -Keycode.ALT]),
        (0x202000, "'a", [Keycode.ALT, 
            Keycode.KEYPAD_ZERO, -Keycode.KEYPAD_ZERO, 
            Keycode.KEYPAD_TWO, -Keycode.KEYPAD_TWO, 
            Keycode.KEYPAD_TWO, -Keycode.KEYPAD_TWO,
            Keycode.KEYPAD_FIVE, -Keycode.KEYPAD_FIVE, 
            -Keycode.ALT]),
        (0x202000, '?', [Keycode.ALT, 
            Keycode.KEYPAD_ZERO, -Keycode.KEYPAD_ZERO, 
            Keycode.KEYPAD_ONE, -Keycode.KEYPAD_ONE, 
            Keycode.KEYPAD_NINE, -Keycode.KEYPAD_NINE,
            Keycode.KEYPAD_ONE, -Keycode.KEYPAD_ONE, 
            -Keycode.ALT]),
        # 2nd row ----------
        (0x202000, '~N', [Keycode.ALT, 
            Keycode.KEYPAD_ZERO, -Keycode.KEYPAD_ZERO, 
            Keycode.KEYPAD_TWO, -Keycode.KEYPAD_TWO, 
            Keycode.KEYPAD_ZERO, -Keycode.KEYPAD_ZERO,
            Keycode.KEYPAD_NINE, -Keycode.KEYPAD_NINE, 
            -Keycode.ALT]),
        (0x202000, "'A", [Keycode.ALT, 
            Keycode.KEYPAD_ZERO, -Keycode.KEYPAD_ZERO, 
            Keycode.KEYPAD_ONE, -Keycode.KEYPAD_ONE, 
            Keycode.KEYPAD_NINE, -Keycode.KEYPAD_NINE,
            Keycode.KEYPAD_THREE, -Keycode.KEYPAD_THREE, 
            -Keycode.ALT]),
        (0x202000, '!', [Keycode.ALT, 
            Keycode.KEYPAD_ZERO, -Keycode.KEYPAD_ZERO, 
            Keycode.KEYPAD_ONE, -Keycode.KEYPAD_ONE, 
            Keycode.KEYPAD_SIX, -Keycode.KEYPAD_SIX,
            Keycode.KEYPAD_ONE, -Keycode.KEYPAD_ONE, 
            -Keycode.ALT]),
        # 3rd row ----------
        (0x202000, 'ohms', [Keycode.ALT, 
            Keycode.KEYPAD_TWO, -Keycode.KEYPAD_TWO, 
            Keycode.KEYPAD_THREE, -Keycode.KEYPAD_THREE,
            Keycode.KEYPAD_FOUR, -Keycode.KEYPAD_FOUR, 
            -Keycode.ALT]),
        (0x202000, 'Tongue', [':p', Keycode.SPACE]),
        (0x202000, 'wink', [';)', Keycode.SPACE]),
        # 4th row ----------
        (0x202000, 'straight', [':|', Keycode.SPACE]),
        (0x202000, 'sad', [':(', Keycode.SPACE]),
        (0x202000, 'happy', [':)', Keycode.SPACE]),
        # Encoder button ---
        (0x000000, '', [Keycode.BACKSPACE])
    ]
}

User avatar
SolderMask
 
Posts: 19
Joined: Tue Jul 20, 2021 1:50 pm

Re: Macropad non-ascii character sequence

Post by SolderMask »

This looks great, but I can't get your code to work. Did a copy and paste, saved it, but it does not show as a viable macro when I turn the encoder.

Anyone else get it to work? Or found a fix?

User avatar
kayaking_t
 
Posts: 15
Joined: Tue Jul 14, 2020 10:04 am

Re: Macropad non-ascii character sequence

Post by kayaking_t »

SolderMask wrote:This looks great, but I can't get your code to work. Did a copy and paste, saved it, but it does not show as a viable macro when I turn the encoder.

Anyone else get it to work? Or found a fix?
Not sure what to suggest. I do have the entire contents of my Macropad up in github if that would help: https://github.com/AndNotOr-Designs/macroPad

User avatar
SolderMask
 
Posts: 19
Joined: Tue Jul 20, 2021 1:50 pm

Re: Macropad non-ascii character sequence

Post by SolderMask »

Thanks @kayaking_t,

I downloaded your files as a zip. I didn't see a ***.uf2 file (figured it was pretty essential) so I tried it with and without that file. Got the red error blink in LED #1 and the screen looks to say:
KER_ENABLE
Code done running.


I'm wondering if you are using a vastly different version of the main ***.uf2 file and that is causing things to act differently?
I'm running adafruit-circuitpython-adafruit_macropad_rp2040-en_US-7.0.0-alpha.5.uf2

I love that you added MP3 files- presumably to announce which macro you are switching to? I'll dive into your code.py and macros to see if I can learn more on how you got these to work.

Kind regards!

User avatar
kayaking_t
 
Posts: 15
Joined: Tue Jul 14, 2020 10:04 am

Re: Macropad non-ascii character sequence

Post by kayaking_t »

SolderMask wrote: I'm wondering if you are using a vastly different version of the main ***.uf2 file and that is causing things to act differently?
I'm running adafruit-circuitpython-adafruit_macropad_rp2040-en_US-7.0.0-alpha.5.uf2
I followed the instructions on the .uf2 file from the instructions here: https://learn.adafruit.com/macropad-hot ... cuitpython
SolderMask wrote: I love that you added MP3 files- presumably to announce which macro you are switching to? I'll dive into your code.py and macros to see if I can learn more on how you got these to work.
Kind regards!
Yes, it's set so that I can not have to look at the keypad to know what screen I'm on for the hot keys. I do have to modify the order as it is a bit out of order right now, I just haven't had the time...

User avatar
kayaking_t
 
Posts: 15
Joined: Tue Jul 14, 2020 10:04 am

Re: Macropad non-ascii character sequence

Post by kayaking_t »

kayaking_t wrote: I do have to modify the order as it is a bit out of order right now, I just haven't had the time...
Order is fixed now and GitHub is updated. Happy coding!

User avatar
SolderMask
 
Posts: 19
Joined: Tue Jul 20, 2021 1:50 pm

Re: Macropad non-ascii character sequence

Post by SolderMask »

kayaking_t wrote: I followed the instructions on the .uf2 file from the instructions here: https://learn.adafruit.com/macropad-hot ... cuitpython
I got it to work-

I forgot that I had to go into bootloader mode (as pointed out in the URL you sent). I updated the .uf2 file (I was running the Alpha version)... makes sense that it has to be using the correct OS version.

Figured I'd spell this out, should someone else end up in the same boat as me. Thanks for the help!

---

On a side note, if someone knows, should another version come along, is there a way to have a checksum built into the code.py file to let you know there is a version conflict (as in, the code.py was written for 7.0.0 and someone is running a different version, unaware?)

User avatar
kayaking_t
 
Posts: 15
Joined: Tue Jul 14, 2020 10:04 am

Re: Macropad non-ascii character sequence

Post by kayaking_t »

SolderMask wrote: I got it to work-
That's GREAT to hear! Thanks for letting me know. I'm really new to this avenue of programming, so I'm definitely NOT the one to ask about checksums...

Happy coding!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”