GeekFunkLabs / fluidpatcher

A performance-oriented patch interface for FluidSynth
MIT License
124 stars 15 forks source link

Add double press shutdown #34

Closed Faeb35 closed 2 years ago

Faeb35 commented 2 years ago

Related to the issue #33 I experienced with my old Axiom 49, I came up with the idea to use another trigger for the shutdown instead of holding one of the patch-buttons for 5 seconds to initiate the shutdown. My idea was to initiate the shutdown by pressing the DEC_PATCH and INC_PATCH simultaneously for 5 times in a row.

With this pull request I added some options: LONGPRESS_SHUTDOWN = False DOUBLEPRESS_SHUTDOWN = True DOUBLEPRESS_SHUTDOWN_COUNT = 5 DOUBLEPRESS_SHUTDOWN_TIMEFRAME_MS = 600

With LONGPRESS_SHUTDOWN and DOUBLEPRESS_SHUTDOWN you can enable or disable the desired shutdown behaviour. DOUBLEPRESS_SHUTDOWN_COUNT configures how many times you need to simultaneously press DEC_PATCH and INC_PATCH to initiate the shutdown. DOUBLEPRESS_SHUTDOWN_TIMEFRAME_MS configures the timeframe within the two buttons must be pressed. For my setup I figured out that 600ms is the sweat spot, below 500ms it wasn't working accurately. If the value is to high, fast switching between patches can be recognized as double pressed. The counter, how many times you hit the two buttons simultaniously, will be reset to 0 when you "change direction". When you hit DEC_PATCH as last button, you need to hit INC_PATCH or vice versa, to get the counter reset. With this I think is very unlikely that someone shutsdown the pi unintended.

I need to remark, that this is my first time coding with Python, so bear with me. I'm also pretty unexperienced with all that GIT stuff. Additionally I have to remark, that I don't really expect this to get merged, I just want to provide a solution for people having the same issue as I did (mmc controll don't send 0 when released 0). If you're indeed thinking about getting this merged, dont' hesitate to update my code, I think there may be some room for improvements ;-)

albedozero commented 2 years ago

This is an ingenious way of solving the problem of buttons that don't send a zero value, hats off! You got me thinking about the issue, and my idea was to make it possible to use a different button for shutdown, so the patch buttons won't trigger it. Unfortunately, my commits created a conflict with your branch. Since this seems like a bit of an edge case and I think it's wise to avoid option creep in the main branch I'll hold off on merging this for now. Thanks!