UI: MIDI 44–47 -> Color 2, 48–51 -> Color 1; label 'alternating' as 'alternating pulse'; MIDI note 39 sends 'ap'; fix async UI scheduler usage (no create_task)

This commit is contained in:
2025-10-04 02:09:55 +13:00
parent f2e775f6f5
commit 9045b10631

View File

@@ -254,7 +254,7 @@ class MidiController:
36: "alternating_phase",
37: "o",
38: "f",
39: "a",
39: "ap",
40: "p",
41: "r",
42: "rd",
@@ -273,17 +273,20 @@ class MidiController:
except Exception as e:
logging.error(f"Failed to POST pattern change: {e}")
return
# Color selection notes 44-51 map to color slots 0-7
# Color selection notes 44-51 map to color slots and targets
if 44 <= msg.note <= 51:
slot_index = msg.note - 44
# Set the selected slot for the currently chosen target (0=Color1, 1=Color2)
self.selected_indices[self.next_selected_target] = slot_index
# Notes 44-47 → Color 2 (target index 1), 48-51 → Color 1 (target index 0)
target = 1 if 44 <= msg.note <= 47 else 0
self.selected_indices[target] = slot_index
# Update indicator to reflect last target used
self.next_selected_target = target
if callable(self.on_select_palette_indices):
try:
self.on_select_palette_indices(self.selected_indices)
except Exception as _e:
logging.debug(f"Failed to persist selected indices: {_e}")
logging.info(f"Set Color {self.next_selected_target+1} to slot {slot_index+1}")
logging.info(f"Set Color {target+1} to slot {slot_index+1}")
elif msg.type == 'control_change':
# Handle control change messages
@@ -801,7 +804,7 @@ class UIClient:
"alternating_phase": "alternating\nphase",
"off": "off",
"flicker": "flicker",
"alternating": "alternating",
"alternating": "alternating\npulse",
"pulse": "pulse",
"rainbow": "rainbow",
"radiate": "radiate",
@@ -819,7 +822,7 @@ class UIClient:
# Normalize current pattern for highlight (map short codes to long names)
current_raw = self.midi_controller.current_pattern or self.current_pattern
short_to_long = {
"o": "off", "f": "flicker", "a": "alternating", "p": "pulse",
"o": "off", "f": "flicker", "a": "alternating", "ap": "alternating", "p": "pulse",
"r": "rainbow", "rd": "radiate", "sm": "segmented_movement",
}
current_pattern = short_to_long.get(current_raw, current_raw)