Toggle Navigation
Hatchery
Eggs
Midi Reaper Control
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import keypad, display, midi, touchpads blue = 0x689be8 orange = 0xe8a468 red = 0xe86868 pink = 0xe868c6 yellow = 0xe8dd68 green = 0x8ee868 channel=0 def toggle (pressed): global channel if not pressed: return print ('toggled') if channel==0: channel=1 else: channel=0 keymap = [blue,blue,blue,orange, blue, red, orange, pink, 0x000000,0x000000,blue,blue, red, 0x000000, green, yellow] index = 0 for key in keymap: x, y = index % 4, index // 4 index += 1 display.drawPixel(x,y,key) display.flush() def on_key(key_index, pressed): x, y = key_index % 4, int(key_index / 4) if pressed: print('Sending Note On', key_index) midi.note_on(midi.CENTRAL_C + key_index, midi_channel=channel) display.drawPixel(x, y, 0xF8B700) display.flush() else: print('Sending Note Off', key_index) midi.note_off(midi.CENTRAL_C + key_index, midi_channel=channel) display.drawPixel(x, y, keymap[key_index]) display.flush() keypad.add_handler(on_key) touchpads.on(touchpads.OK, toggle)