Skip to content

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

Open
joopdo wants to merge 1 commit into
pimoroni:masterfrom
joopdo:longpress-prev
Open

joopdo wants to merge 1 commit into
pimoroni:masterfrom
joopdo:longpress-prev

Conversation

@joopdo

@joopdo joopdo commented Oct 15, 2023

Copy link
Copy Markdown

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.

@Gadgetoid

Copy link
Copy Markdown
Member

16 is an arbitrary pin, if we want to support long/short presses it should probably be across all inputs and possible to specify in the config somehow.

This library sorely needs refactoring to use libgpiod, though, so perhaps that should be tackled first!

Great idea in theory, though, sorry for the delayed response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants