コード例 #1
0
def keys_display():  # Display the current values of the keys on screen
    for k in range(9):  # The first 9 keys
        group[k].text = str(key_values[k])
        macropad.pixels[k] = colors[key_values[k]]
    group[10].text = str(key_values[9])  # The 'Zero' position number
    group[9].text = " "  # Start blanks
    group[11].text = " "  # Status blanks
    macropad.pixels[10] = colors[key_values[9]]
    macropad.display.refresh()
    macropad.pixels.show()


# INITIALIZATION -----------------------

macropad = MacroPad()  # Set up MacroPad library and behavior
macropad.display.auto_refresh = False
macropad.pixels.auto_write = False

# Set up displayio group with all the labels
group = displayio.Group()
for key_index in range(12):
    x = key_index % 3
    y = key_index // 3
    group.append(
        label.Label(
            terminalio.FONT,
            text='',
            color=0xFFFFFF,
            anchored_position=((macropad.display.width - 1) * x / 2,
                               macropad.display.height - 1 - (3 - y) * 12),
コード例 #2
0
# SPDX-FileCopyrightText: 2021 John Park for Adafruit Industries
# SPDX-License-Identifier: MIT
# Macropad MIDI Tester
# Play MIDI notes with keys
# Click encoder to switch modes
# Turn encoder to adjust CC, ProgramChange, or PitchBend
from adafruit_macropad import MacroPad
from rainbowio import colorwheel

CC_NUM = 74  # select your CC number

macropad = MacroPad(
    rotation=180)  # create the macropad object, rotate orientation

# --- Pixel setup --- #
key_color = colorwheel(120)  # fill with cyan to start
macropad.pixels.brightness = 0.1
macropad.pixels.fill(key_color)

# --- MIDI variables ---
mode = 0
mode_text = ["Patch", ("CC #%s" % (CC_NUM)), "Pitch Bend"]
midi_values = [0, 16, 8]  # bank, cc value, pitch
# Chromatic scale starting with C3 as bottom left keyswitch (or use any notes you like)
midi_notes = [57, 58, 59, 54, 55, 56, 51, 52, 53, 48, 49, 50]

# --- Display text setup ---
text_lines = macropad.display_text("Macropad MIDI Tester")
text_lines[0].text = "Mode: Patch {}".format(midi_values[0] +
                                             1)  # Patch display offset by 1
text_lines[1].text = "Press knob for modes"
コード例 #3
0
                macropad.pixels[i] = self.macros[i][0]
                group[i].text = self.macros[i][1]
            else:  # Key not in use, no label or LED
                macropad.pixels[i] = 0
                group[i].text = ''
        macropad.keyboard.release_all()
        macropad.consumer_control.release()
        macropad.mouse.release_all()
        macropad.stop_tone()
        macropad.pixels.show()
        macropad.display.refresh()


# INITIALIZATION -----------------------

macropad = MacroPad()
macropad.display.auto_refresh = False
macropad.pixels.auto_write = False

# Set up displayio group with all the labels
group = displayio.Group()
for key_index in range(12):
    x = key_index % 3
    y = key_index // 3
    group.append(
        label.Label(
            terminalio.FONT,
            text='',
            color=0xFFFFFF,
            anchored_position=((macropad.display.width - 1) * x / 2,
                               macropad.display.height - 1 - (3 - y) * 12),