Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
672 changes: 672 additions & 0 deletions hackpads/shambhavi's_macropad/CAD/case.step

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions hackpads/shambhavi's_macropad/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# midi macropad :)
the (push switch) keys play the (musical) key's tonic triad notes; <br> turning the rotary encoder changes the key of the notes; <br> the OLED display shows what key you're in.<br><br>i need all the parts soldered, thank you!


### inspiration
i wanted to be able to make music more intuitively and easily than simply using a traditional mouse and keyboard setup.

### hardest challenges
- learning to use fusion360 😧
- learning what all these new words meant (use a matrix? configure the keyboard?? compile the code?!)

### fun facts!
when i get the hackpad, i'll probably try to code the OLED display and rotary encoder to act as a metronome :D

# BOM:
- 1x Seeed XIAO RP2040 through-hole (preferably black, otherwise green)
- 1x 0.91 inch OLED Display
- 3x MX-Style switches
- 1x EC11 Rotary Encoder
- 1x PCB
- 3x Blank DSA keycaps
- 1x case (preferably lime green! otherwise any green or black)
Empty file.
69 changes: 69 additions & 0 deletions hackpads/shambhavi's_macropad/firmware/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from kmk.kmk_keyboard import KMKKeyboard
from kmk.keys import KC
from kmk.scanners import DiodeOrientation
from kmk.extensions.rotary_encoder import RotaryEncoder

from kmk.extensions.oled import Oled, OledDisplayMode
from kmk.modules.midi import MidiKeys

keyboard = KMKKeyboard()
keyboard.modules.append(MidiKeys())


key_change = 0
note_names = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']

keyboard.row_pins = (11,10,9) #push switches / keys
keyboard.diode_orientation = DiodeOrientation.COL2ROW


def calculate_keymap():
global key_change
return[
[KC.MIDI_NOTE(60 + key_change,127)], #c
[KC.MIDI_NOTE(64 + key_change,127)], #e
[KC.MIDI_NOTE(67 + key_change,127)], #g
]


keyboard.keymap = calculate_keymap() #original

def update_key_change(x):
global key_change
key_change += x
key_change = max(min(key_change, 24), -24)
keyboard.keymap = calculate_keymap()

def midi_note_to_name(midi_note):
octave = (midi_note // 12) - 1
note = note_names[midi_note % 12]
return f"{note}{octave}"

encoder = RotaryEncoder(
pins=(1,8),
up=lambda: update_key_change(1),
down=lambda: update_key_change(-1)
)
keyboard.extensions.append(encoder)

def oled_update(oled):
oled.clear()
note1 = midi_note_to_name(60 + key_change)
note2 = midi_note_to_name(64 + key_change)
note3 = midi_note_to_name(67 + key_change)
oled.write_line(f"key: {note1}")
oled.write_line(f"notes: {note1}, {note2}, {note3}")

oled_ext = Oled(
OledDisplayMode.LAYER,
flip=False,
sda=5,
scl=6,
i2c_addr=0x3C
)

oled_ext.on_oled_update = oled_update
keyboard.extensions.append(oled_ext)

if __name__ == '__main__':
keyboard.go()
Loading