Skip to content

Commit 6c65402

Browse files
authored
Merge pull request #2570 from adafruit/4x4_update
Updating 4x4 midi code
2 parents 48c4052 + dc4d862 commit 6c65402

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

4x4_MIDI_Messenger/code.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
import adafruit_displayio_ssd1306
1919
import adafruit_midi
2020
from adafruit_midi.control_change import ControlChange
21+
import neopixel
22+
23+
# default MIDI channel (1-16)
24+
midi_in_channel = 2
25+
midi_out_channel = 2
2126

2227
# MIDI CC messages, values and names assigned to each encoder
2328
cc_values = [
@@ -32,7 +37,7 @@
3237
{'cc_val': (1, 3), 'cc_message': (22), 'cc_name': "Mod Bank"},
3338
{'cc_val': (1, 3), 'cc_message': (23), 'cc_name': "Mode"},
3439
{'cc_val': (0, 1), 'cc_message': (102), 'cc_name': "Bypass/Engage"},
35-
{'cc_val': (60, 200), 'cc_message': (93), 'cc_name': "Tap Tempo"},
40+
{'cc_val': (0, 127), 'cc_message': (93), 'cc_name': "Tap Tempo"},
3641
{'cc_val': (0, 1), 'cc_message': (24), 'cc_name': "Loop (R Hold)"},
3742
{'cc_val': (0, 1), 'cc_message': (25), 'cc_name': "Scan (L Hold)"},
3843
{'cc_val': (0, 127), 'cc_message': (26), 'cc_name': "Clear (Both Hold)"},
@@ -78,8 +83,6 @@
7883
splash.append(status_area)
7984
# MIDI over UART setup for MIDI FeatherWing
8085
uart = busio.UART(board.TX, board.RX, baudrate=31250, timeout=0.001)
81-
midi_in_channel = 1
82-
midi_out_channel = 1
8386
midi = adafruit_midi.MIDI(
8487
midi_in=uart,
8588
midi_out=uart,
@@ -135,6 +138,9 @@
135138
pix2.brightness = 0.5
136139
pix3 = adafruit_seesaw.neopixel.NeoPixel(ss3, 18, 4, auto_write = True)
137140
pix3.brightness = 0.5
141+
# onboard Feather neopixel
142+
pix_feather = neopixel.NeoPixel(board.NEOPIXEL, 1, auto_write = True)
143+
pix_feather.brightness = 0.5
138144
# encoder position arrays
139145
last_pos0 = [60, 60, 60, 60]
140146
last_pos1 = [60, 60, 60, 0]
@@ -155,6 +161,9 @@
155161
pix1[r] = colorwheel(c1[r])
156162
pix2[r] = colorwheel(c2[r])
157163
pix3[r] = colorwheel(c3[r])
164+
# feather neopixel color
165+
c_feather = 0
166+
pix_feather[0] = colorwheel(c_feather)
158167
# array of all 16 encoder positions
159168
encoder_posititions = [60, 60, 60, 60, 60, 60, 60, 60, 0, 0, 0, 120, 0, 0, 0, 0]
160169

@@ -170,6 +179,7 @@ def __init__(self):
170179
self.color = c0
171180
self.index = 0
172181
self.strip = pix0
182+
self.feather_color = c_feather
173183

174184
async def send_midi(midi_msg):
175185
# sends MIDI message if send_msg is True/button pressed
@@ -191,7 +201,9 @@ async def send_midi(midi_msg):
191201
async def rainbows(the_color):
192202
# Updates colors of the neopixels to scroll through rainbow
193203
while True:
204+
the_color.feather_color += 8
194205
the_color.strip[the_color.index] = colorwheel(the_color.color[the_color.index])
206+
pix_feather[0] = colorwheel(the_color.feather_color)
195207
await asyncio.sleep(0)
196208

197209
async def monitor_interrupts(pin0, pin1, pin2, pin3, the_color, midi_msg): #pylint: disable=too-many-statements

0 commit comments

Comments
 (0)