Add patterns

This commit is contained in:
2025-09-09 21:40:27 +12:00
parent 9fc58a827b
commit 3b869851b8

View File

@@ -1,6 +1,5 @@
import mido
import asyncio
import time
import networking # <--- This will now correctly import your module
@@ -43,27 +42,55 @@ async def midi_to_websocket_listener(midi_port_index: int, websocket_uri: str):
match msg.type:
case 'note_on':
print(f" Note ON: Note={msg.note}, Velocity={msg.velocity}, Channel={msg.channel}")
# Add pattern_name variable to update a GUI later if needed.
pattern_name = "Unknown"
match msg.note:
case 32:
case 48: # Original Note 48 for 'pulse'
pattern_name = "pulse"
await ws_client.send_data({
"names": ["1"],
"settings": {
"pattern": "pulse",
"pattern": pattern_name,
"delay": delay,
"colors": ["#00ff00"],
"brightness": 100,
"num_leds": 200,
"num_leds": 120, # Corrected to 120
}
})
case 33:
case 49: # Original Note 49 for 'theater_chase'
pattern_name = "theater_chase"
await ws_client.send_data({
"names": ["2"],
"names": ["1"],
"settings": {
"pattern": "chase",
"speed": 10,
"color": "#00FFFF",
"pattern": pattern_name,
"delay": delay,
"colors": ["#00ff00"],
"brightness": 100,
"num_leds": 120,
"on_width": 10,
"off_width": 10,
"n1": 0,
"n2": 100
}
})
case 50: # Original Note 50 for 'alternating'
pattern_name = "alternating"
print("Triggering Alternating Pattern")
await ws_client.send_data({
"names": ["1"],
"settings": {
"pattern": pattern_name,
"delay": delay,
"colors": ["#00ff00", "#0000ff"],
"brightness": 100,
"num_leds": 120,
"n1": 10,
"n2": 10
}
})
# Potentially add logic here to use pattern_name if a GUI update is desired in the future
case 'control_change':
match msg.control:
case 36: