Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: GPIO buttons on moOde 9.
#10
Right, well.  I'm sure there's a reason for this, but I can't imagine what it might be.

The GPIO.setup() function is defined in /usr/lib/python3/dist-packages/RPi/GPIO/__init__.py and the error I see is there:
Code:
       if pull_up_down not in (PUD_UP, PUD_DOWN, PUD_OFF):
           raise ValueError(
               'Invalid value for pull_up_down - should be either PUD_OFF, '
               'PUD_UP or PUD_DOWN')


But hang on, that array of possible values is an array of variables!  Sure enough up there at the top:
Code:
PUD_OFF = 20
PUD_DOWN = 21
PUD_UP = 22
I don't know, maybe they want to do some sums with these at some point....

Back in /var/www/daemon/gpio_buttons.py, I did this:

Code:
       GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down=22)
And lo and behold, the button now works.  Although it is is sluggish, but that's for another day.

I'm not sure what the best place to "fix" this is, probably easiest to set the numeric values into the GPIO table perhaps.  Hard coding in the gpio_buttons.py works for me for now though since I only have one button and I don't need to change it's direction.
----------------
Robert
Reply


Messages In This Thread
GPIO buttons on moOde 9. - by the_bertrum - 05-20-2024, 06:57 PM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-20-2024, 07:09 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-20-2024, 07:51 PM
RE: GPIO buttons on moOde 9. - by TheOldPresbyope - 05-20-2024, 08:22 PM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-20-2024, 08:30 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-20-2024, 09:42 PM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-20-2024, 10:37 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-21-2024, 07:57 AM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-21-2024, 08:03 AM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-21-2024, 08:40 AM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-21-2024, 08:51 AM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-21-2024, 11:16 AM
RE: GPIO buttons on moOde 9. - by Dorffen - 05-21-2024, 09:09 AM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-22-2024, 01:08 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-22-2024, 01:25 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-22-2024, 02:09 PM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-22-2024, 06:56 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-26-2024, 03:33 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-26-2024, 05:17 PM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-26-2024, 06:13 PM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-26-2024, 07:02 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-27-2024, 12:28 PM
RE: GPIO buttons on moOde 9. - by Tim Curtis - 05-27-2024, 12:54 PM
RE: GPIO buttons on moOde 9. - by the_bertrum - 05-27-2024, 01:51 PM

Forum Jump: