Skip to content

Commit

Permalink
Neopixel and menu fixes (#62)
Browse files Browse the repository at this point in the history
* Sampler bugfixes and slight menu improvements

Correction in neopixel mapping

Added sampled (kick too low for speaker, but works on headphones)

Changed default MIDI channel to 1

* Fixing LED indexing in MIDI controller and HID Controller
Improving menu flow in sampler

---------

Co-authored-by: SkaFreak <skafreak@users.noreply.github.com>
  • Loading branch information
skafreak and skafreak authored Aug 9, 2023
1 parent 1ddd51c commit f5c22f4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
9 changes: 7 additions & 2 deletions Software/Production/HIDState.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
select_enc,
volume_enc,
)
from utils import (
neoindex,
)

from State import State

Expand Down Expand Up @@ -102,10 +105,12 @@ def update(self, machine):
if key_event.key_number < 10:
if key_event.pressed:
self.kbd.press(self.keymap[key_event.key_number])
neopixels[key_event.key_number] = (255, 0, 0)
mapped_neopixel = neoindex(key_event.key_number)
neopixels[mapped_neopixel] = (255, 0, 0)
if key_event.released:
self.kbd.release(self.keymap[key_event.key_number])
neopixels[key_event.key_number] = (100, 100, 100)
mapped_neopixel = neoindex(key_event.key_number)
neopixels[mapped_neopixel] = (100, 100, 100)
elif (key_event.key_number == 10) and key_event.pressed: # Select Button
machine.go_to_state("menu")
return
Expand Down
9 changes: 7 additions & 2 deletions Software/Production/MIDIState.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from adafruit_display_text import label
from State import State

from utils import (
neoindex,
)
from setup import (
display,
keys,
Expand Down Expand Up @@ -62,13 +65,15 @@ def update(self, machine):
key = key_event.key_number
self.notes.append(key)
send_note_on(key, 4)
neopixels[key] = (255, 0, 0)
mapped_neopixel = neoindex(key)
neopixels[mapped_neopixel] = (255, 0, 0)
if key_event.released:
key = key_event.key_number
if key in self.notes:
self.notes.remove(key)
send_note_off(key, 4)
neopixels[key] = (100, 100, 100)
mapped_neopixel = neoindex(key)
neopixels[mapped_neopixel] = (100, 100, 100)
elif (key_event.key_number == 10) and key_event.pressed: # Select Button
machine.go_to_state("menu")
return
Expand Down
22 changes: 18 additions & 4 deletions Software/Production/SequencerState.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def __init__(self):
self.samples = wav_files

def enter(self, machine):
self.highlight = 1
self.shift = 0
self.last_position = 0
if machine.animation is None:
machine.animation = Rainbow(neopixels, speed=0.1)
Expand All @@ -177,9 +179,10 @@ def exit(self, machine):
State.exit(self, machine)

def select_wav(self):
# Show valid files, select with encoder knob/button
# Reset menu status
self.highlight = 1
self.shift = 0
# Show valid files, select with encoder knob/button
while True:
if self.last_position != select_enc.position:
(self.highlight, self.shift) = selector_calcs(
Expand All @@ -194,9 +197,13 @@ def select_wav(self):
key_event = keys.events.get()
if key_event and key_event.pressed:
selection = self.samples[self.highlight - 1 + self.shift]["name"]
# Reset menu status
self.highlight = 1
self.shift = 0
return selection

def select_sequence(self, sequence_array):
# Reset menu status
self.highlight = 1
self.shift = 0
# Show valid sequences, select with encoder knob/button
Expand Down Expand Up @@ -301,12 +308,17 @@ def edit_sequence(self, fsequences):
)
file_sequences.show_sequence(selected_sequence)
neopixels.show()
# Update to play/pause button for final hardware


# Exit on click of select encoder
key_event = keys.events.get()
if key_event and key_event.pressed and key_event.key_number == 10:
# Reset menu status
self.highlight = 1
self.shift = 0
# Exit editing menu
editing_sequence = False
# Press encoder to exit
# Press play to start


def remove_sequence(self, fsequences):
pass
Expand Down Expand Up @@ -366,6 +378,8 @@ def name(self):
return "sequencer_play"

def enter(self, machine):
# Clear key states
keys.events.clear()
# Get current encoder positions
self.volume_position = volume_enc.position
self.select_position = select_enc.position
Expand Down
1 change: 0 additions & 1 deletion Software/Production/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
select_enc,
volume_enc,
)
from audiocore import WaveFile
from StartupState import StartupState
from FlashyState import FlashyState
from MIDIState import MIDIState
Expand Down

0 comments on commit f5c22f4

Please sign in to comment.