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 88 forks source link

switches not working with GPIOZero #158

Closed vwillcox closed 6 years ago

vwillcox commented 6 years ago

Currently I can't call the switches with GPIOZero. They do not respond.

shawaj commented 6 years ago

Have you soldered them in?

There's no real way they can't work. What gpio are you trying to use?

vwillcox commented 6 years ago

I can use the buttons with normal GPIO

I converted:

  SW1 = 16
   SW2 = 26
   SW3 = 20
   SW4 = 21

into

sw1 = Button(16) sw2 = Button(26) etc

Then ran a button_ispressed() and got nothing out

francesco-vannini commented 6 years ago

Hello,

Try with this approach instead

from gpiozero import Button sw1 = Button(16) sw1.wait_for_press() print("SW1 was pressed!")

vwillcox commented 6 years ago

pi@raspberrypi:~/speedtest-cron $ python Python 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170124] on linux2 Type "help", "copyright", "credits" or "license" for more information.

from gpiozero import Button sw1 = Button(16) sw1.wait_for_press()

nothing....

tvoverbeek commented 6 years ago

When looking at the schematics for the PaPiRus HAT (https://github.com/PiSupply/PaPiRus/blob/master/hardware/PaPiRus%20HAT/Latest%20Version%20-%20v1.9/2014-035-01-Pi-ePaper-circuit_v1_9.pdf) you see that the switches have their own pull-up resistors on the board. When using the pull_up=False argument to Button, there is an RPi internal pull_down to ground (ca 50k). When SW1 is open the gpio input will be high, when closed low. This corresponds to button_pressed and button_released respectively, i.e. reversed logic.

Change your code to the following:

from gpiozero import Button
sw1 = Button(16, pull_up=False)
sw1.wait_for_release()
print('Sw1 pressed')
vwillcox commented 6 years ago

Thanks :) I see that does now work. I believe this is closed :)