Replace the USB relay (crelay) with direct GPIO control of the Wondom GAB8 amplifier SHDN (shutdown) pins. This eliminates the problems caused by USB power cycling:
- ALSA device disconnection and state resets
- Sendspin streams becoming stale (RUNNING with appl_ptr=0 indefinitely)
- Need for cooldown timers after power-off to avoid false activity detection
- Dependency on crelay and USB relay hardware
With GPIO SHDN control, the USB audio connection stays alive. Only the amplifier output stage is enabled/disabled.
Using the left side of the Raspberry Pi 5 40-pin header, pins 9–15:
| Amp | GND Pin | SHDN Pin | GPIO |
|---|---|---|---|
| amp1 | 6 | 13 | 27 |
| amp2 | 14 | 15 | 22 |
| amp3 | 9 | 11 | 17 |
Connect each GPIO pin to the SHDN pin on the corresponding GAB8 amplifier board. Each amp gets its own GND pin from the Pi header.
Connect the SYNC pins of all three GAB8 boards together (daisy-chain: amp1 SYNC → amp2 SYNC → amp3 SYNC). This synchronizes PWM switching frequencies across boards and prevents audible beating/interference from unsynchronized Class-D switching.
TODO: Confirm SHDN pin logic level on the GAB8 (active-low or active-high) before implementing.
- Update
powermanager.shto usegpiosetinstead ofcrelay - Remove the
RELAY_OFF_COOLDOWNworkaround (no longer needed since USB stays connected) - Remove the
is_sendspin_active()workaround (ALSA state will be reliable) - Simplify
is_any_card_active()— can rely on standard ALSA status checks - Update the web UI relay control API to use GPIO
- Update lox-audioserver relay configuration (or bypass it for GPIO)
- Add udev rules or systemd service to set initial GPIO state at boot
gpiodpackage (already installed)libgpiod/python3-libgpiod(already installed)- Physical wiring from Pi GPIO header to GAB8 SHDN pins