PiSupply / PaPiRus

Resources for PaPiRus ePaper eInk displays
https://www.pi-supply.com/product/papirus-epaper-eink-screen-hat-for-raspberry-pi/
Other
346 stars 85 forks source link

Differenciate from short-click to long-click #191

Closed GeiserX closed 6 years ago

GeiserX commented 6 years ago

Hi,

I think it would be great to have some functionality to detect between a short click to the switch, from a long (i.e. 5-seconds). I think this is not implemented yet. This way we could use superior functions to detect them and do different things based on this.

How would you approach this? What do you think?

tvoverbeek commented 6 years ago

You can do this already today in your own Python scripts. The PaPirus buttons are connected to the GPIO pins: For the HAT:

SW1 = BUT1 = pin 36 = GPIO 16
SW2 = BUT2 = pin 37 = GPIO 26
SW3 = BUT3 = pin 38 = GPIO 20
SW4 = BUT4 = pin 40 = GPIO 21

For the PaPirus Zero:

SW1 = BUT5 = pin 40 = GPIO 21
SW2 = BUT4 = pin 36 = GPIO 16
SW3 = BUT1 = pin 38 = GPIO 20
SW4 = BUT3 = pin 35 = GPIO 19
SW5 = BUT2 = pin 37 = GPIO 26

Look at the gpiozero package where the Button class has everything you want. See https://gpiozero.readthedocs.io/en/stable/api_input.html#button