pimoroni / mopidy-raspberry-gpio

Mopidy GPIO Control Plugin for the Raspberry Pi (Using RPi.GPIO)
Apache License 2.0
21 stars 25 forks source link

Adding functionality to allow to go previous by long pressing X #18

Open joopdo opened 11 months ago

joopdo commented 11 months ago

This pull request introduces a new feature for the Raspberry GPIO Frontend. It modifies the button event handling logic for Pin 16 as follows:

  1. A short press (less than 2 seconds) on Pin 16 triggers the handle_next function.
  2. A long press (2 seconds or more) on Pin 16 triggers the handle_prev function.

This logic ensures that only one event is triggered based on the duration of the button press, preventing multiple events from disturbing the playlist.

Changes Made

Modified the gpio_event method to handle button press duration for Pin 16.
Implemented logic to trigger handle_next for short presses and handle_prev for long presses on Pin 16.

Important! Make sure Mopidy or mpc has repeat off, otherwise you don't go previous but to start of song.