Initial commit: Arduino Uno Q USB Audio Synth project
- USB gadget (UAC1 + MIDI) with boot persistence - USB host mode with auto-detection - Pure Data synth patch with ALSA + UDP netreceive MIDI input - MIDI rawmidi-to-UDP bridge (midi-bridge.py) - LED matrix visualization (led-matrix-viz.py via arduino-router RPC) - MCU sketch for LED matrix control (Arduino_RouterBridge + ArduinoGraphics) - Conftest/OPA Rego policy validation suite for .pd files - gen_synth_pd.py: programmatic .pd file generator - System services: midi-bridge, led-matrix-viz, pd-synth-auto, usb-role-detect - Justfile with deploy, enable, diagnostic recipes - Diagnostic script (diag.sh)
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# on-usb-role-change.sh — Called by udev on USB role/connect events.
|
||||
# Re-detects role, stops/restarts Pd with appropriate config.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROLE_FILE="/run/usb-role"
|
||||
LOG_TAG="[USB-HOTPLUG]"
|
||||
|
||||
# Debounce: skip if we just ran (within 3s)
|
||||
LOCK="/tmp/usb-role-change.lock"
|
||||
if [ -f "$LOCK" ]; then
|
||||
age=$(($(date +%s) - $(stat -c %Y "$LOCK" 2>/dev/null || echo 0)))
|
||||
[ "$age" -lt 3 ] && exit 0
|
||||
fi
|
||||
touch "$LOCK"
|
||||
|
||||
logger -t "$LOG_TAG" "USB role change event — re-detecting..."
|
||||
|
||||
/usr/local/bin/detect-usb-role.sh
|
||||
|
||||
# Restart Pd if it's running
|
||||
if systemctl is-active pd-synth-auto &>/dev/null; then
|
||||
logger -t "$LOG_TAG" "Restarting Pd with new role"
|
||||
systemctl restart pd-synth-auto
|
||||
fi
|
||||
Reference in New Issue
Block a user