05-21-2024, 08:40 AM
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:
But hang on, that array of possible values is an array of variables! Sure enough up there at the top:
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:
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.
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
Back in /var/www/daemon/gpio_buttons.py, I did this:
Code:
GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down=22)
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
Robert