Add extra GPIO button support with custom sound playback

Features:
- Configurable extra button on any GPIO pin
- Upload and select custom sound for button press
- Non-blocking button operation (separate thread)
- Debounced to prevent double-triggers (0.5s)
- Works independently from phone handset
- Can be pressed anytime, even during recording

Configuration:
- gpio.extra_button_enabled: Enable/disable feature
- gpio.extra_button_pin: GPIO pin number (default: 27)
- gpio.extra_button_pressed_state: "LOW" or "HIGH"
- system.extra_button_sound: Default sound file

Web Interface:
- Display active button sound in alert
- "🔘 Set Button" action on greeting items
- Visual indicator (🔘) for active button sound
- Upload any WAV file and assign to button
- Play/preview button sounds in browser

Backend:
- RotaryPhone.play_extra_button_sound() method
- RotaryPhone.set_extra_button_sound() method
- Thread-based playback to not block main loop
- /set_extra_button_sound API endpoint
- Extra button sound tracked in user_config.json

Documentation:
- Extra button setup in README
- Configuration examples
- GPIO pin configuration
- Operation workflow

Use Cases:
- Play special message on button press
- Sound effects for wedding games
- Multiple interaction points
- Custom audio triggers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-24 14:57:31 +07:00
parent ef0373e60b
commit 2dde7d8e43
3 changed files with 132 additions and 10 deletions

View File

@@ -1,7 +1,10 @@
{
"gpio": {
"hook_pin": 17,
"hook_pressed_state": "LOW"
"hook_pressed_state": "LOW",
"extra_button_enabled": true,
"extra_button_pin": 27,
"extra_button_pressed_state": "LOW"
},
"audio": {
"device_index": 1,
@@ -22,6 +25,7 @@
},
"system": {
"active_greeting": "dialtone.wav",
"extra_button_sound": "button_sound.wav",
"volume": 70
}
}