Skip to content

Instantly share code, notes, and snippets.

@willwm
Last active August 31, 2022 19:32
Show Gist options
  • Save willwm/7f0a6c9c1020c15a7098b66910a44d09 to your computer and use it in GitHub Desktop.
Save willwm/7f0a6c9c1020c15a7098b66910a44d09 to your computer and use it in GitHub Desktop.
MacroPad RP2040: My Macros
# SPDX-FileCopyrightText: 2021 Phillip Burgess for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# MACROPAD Hotkeys example: Microsoft Edge web browser for Windows
from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values
app = { # REQUIRED dict, must be named 'app'
'name': 'macOS', # Application name
'macros': [ # List of button macros...
# COLOR LABEL KEY SEQUENCE
# 1st row ----------
(0x000000, 'esc', [Keycode.ESCAPE]),
(0x000000, 'tab', [Keycode.TAB]),
(0x000000, 'delete', [Keycode.BACKSPACE]),
# 2nd row ----------
(0x000000, '< Back', [Keycode.COMMAND, Keycode.LEFT_ARROW]),
(0x000000, 'Fwd >', [Keycode.COMMAND, Keycode.RIGHT_ARROW]),
(0x000000, 'Reload', [Keycode.COMMAND, 'r']),
# 3rd row ----------
(0x000000, 'Save', [Keycode.COMMAND, 's']),
(0x000000, 'Enter', [Keycode.ENTER]),
(0x000000, 'Cmd+d', [Keycode.COMMAND, 'd']),
# 4th row ----------
(0x000000, 'Close', [Keycode.COMMAND, 'w']), # Close tab
(0x000000, 'Reopen', [Keycode.COMMAND, Keycode.LEFT_SHIFT, 't']), # Undo Close tab
(0x000000, 'F12', [Keycode.F12]), # Open Chrome/Safari/Firefox Developer tools
# Encoder button ---
(0x000000, '', [Keycode.OPTION, Keycode.COMMAND, Keycode.ESCAPE]) # Force Quit
]
}
from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values
app = { # REQUIRED dict, must be named 'app'
"name": "F1-F12", # Application name
"macros": [ # List of button macros...
# COLOR LABEL KEY SEQUENCE
# 1st row ----------
(0x101010, "F1", [Keycode.F1]),
(0x101010, "F2", [Keycode.F2]),
(0x101010, "F3", [Keycode.F3]),
# 2nd row ----------
(0x101010, "F4", [Keycode.F4]),
(0x101010, "F5", [Keycode.F5]),
(0x101010, "F6", [Keycode.F6]),
# 3rd row ----------
(0x101010, "F7", [Keycode.F7]),
(0x101010, "F8", [Keycode.F8]),
(0x101010, "F9", [Keycode.F9]),
# 4th row ----------
(0x101010, "F10", [Keycode.F10]),
(0x101010, "F11", [Keycode.F11]),
(0x101010, "F12", [Keycode.F12]),
# Encoder button ---
(0x000000, "", [Keycode.ESCAPE]),
],
}
# SPDX-FileCopyrightText: 2021 Emma Humphries for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# MACROPAD Hotkeys example: Numpad (based on Universal Numpad)
from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values
app = { # REQUIRED dict, must be named 'app'
"name": "Numpad", # Application name
"macros": [ # List of button macros...
# COLOR LABEL KEY SEQUENCE
# 1st row ----------
(0x101010, "7", ["7"]),
(0x101010, "8", ["8"]),
(0x101010, "9", ["9"]),
# 2nd row ----------
(0x101010, "4", ["4"]),
(0x101010, "5", ["5"]),
(0x101010, "6", ["6"]),
# 3rd row ----------
(0x101010, "1", ["1"]),
(0x101010, "2", ["2"]),
(0x101010, "3", ["3"]),
# 4th row ----------
(0x101010, "BkSp", [Keycode.BACKSPACE]),
(0x101010, "0", ["0"]),
(0x101010, ".", ["."]),
# Encoder button ---
(0x000000, "", [Keycode.ESCAPE]),
],
}
# SPDX-FileCopyrightText: 2021 Phillip Burgess for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# MACROPAD Hotkeys example: Tones
# The syntax for Tones in macros is highly peculiar, in order to maintain
# backward compatibility with the original keycode-only macro files.
# The third item for each macro is a list in brackets, and each value within
# is normally an integer (Keycode), float (delay) or string (typed literally).
# Consumer Control codes were added as list-within-list, and then mouse and
# tone further complicate this by adding dicts-within-list. Each tone-related
# item is the key 'tone' with either an integer frequency value, or 0 to stop
# the tone mid-macro (tone is also stopped when key is released).
# Helpful: https://en.wikipedia.org/wiki/Piano_key_frequencies
# This example ONLY shows tones (and delays), but really they can be mixed
# with other elements (keys, codes, mouse) to provide auditory feedback.
app = { # REQUIRED dict, must be named 'app'
'name' : 'Tones', # Application name
'macros' : [ # List of button macros...
# COLOR LABEL KEY SEQUENCE
# 1st row ----------
(0x200000, 'C3', [{'tone':131}]),
(0x202000, 'C4', [{'tone':262}]),
(0x002000, 'C5', [{'tone':523}]),
# 2nd row ----------
(0x000020, 'Rising', [{'tone':131}, 0.2, {'tone':262}, 0.2, {'tone':523}]),
(0x000000, '', []),
(0x000020, 'Falling', [{'tone':523}, 0.2, {'tone':262}, 0.2, {'tone':131}]),
# 3rd row ----------
(0x000000, '1000hz', [{'tone':1000}]),
(0x000000, '', []),
(0x000000, '2600hz', [{'tone':2600}]),
# 4th row ----------
(0x000000, '', []),
(0x000000, '', []),
(0x000000, '', []),
# Encoder button ---
(0x000000, '', [])
]
}
# SPDX-FileCopyrightText: 2021 Phillip Burgess for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# MACROPAD Hotkeys example: Consumer Control codes (media keys)
# The syntax for Consumer Control macros is a little peculiar, in order to
# maintain backward compatibility with the original keycode-only macro files.
# The third item for each macro is a list in brackets, and each value within
# is normally an integer (Keycode), float (delay) or string (typed literally).
# Consumer Control codes are distinguished by enclosing them in a list within
# the list, which is why you'll see double brackets [[ ]] below.
# Like Keycodes, Consumer Control codes can be positive (press) or negative
# (release), and float values can be inserted for pauses.
# To reference Consumer Control codes, import ConsumerControlCode like so...
from adafruit_hid.consumer_control_code import ConsumerControlCode
# You can still import Keycode as well if a macro file mixes types!
# See other macro files for typical Keycode examples.
app = { # REQUIRED dict, must be named 'app'
'name' : 'Media', # Application name
'macros' : [ # List of button macros...
# COLOR LABEL KEY SEQUENCE
# 1st row ----------
(0x000000, '', []),
(0x000000, '', []),
(0x000000, '', []),
# 2nd row ----------
(0x000000, '', []),
(0x000000, '', []),
(0x000000, '', []),
# 3rd row ----------
(0x000000, '<<', [[ConsumerControlCode.SCAN_PREVIOUS_TRACK]]),
(0x000000, 'Play/Pause', [[ConsumerControlCode.PLAY_PAUSE]]),
(0x000000, '>>', [[ConsumerControlCode.SCAN_NEXT_TRACK]]),
# 4th row ----------
(0x000000, 'Mute', [[ConsumerControlCode.MUTE]]),
(0x000000, 'Vol-', [[ConsumerControlCode.VOLUME_DECREMENT]]),
(0x000000, 'Vol+', [[ConsumerControlCode.VOLUME_INCREMENT]]),
# Encoder button ---
(0x000000, '', [])
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment