Thank you for your donation!


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


Solved: GPIO buttons on moOde 9.
#8
OK, well I'm really stumped.
The NULL condition only occurs when no button assignments have been set, as soon as those are configured I see no more null errors, although Tim's commands also work for fixing that condition of course.
The issue now is that as soon as button assignments are set, the GPIO.setup() function fails because it doesn't like the value of the pull_up_down parameter.  The error message is "ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN".  So I did some hacking.  With the button set up using the UI on a clean system that never had any buttons set previously I see this:
Code:
master@apollo:~ $ sudo /var/www/daemon/gpio_buttons.py
2024-05-21 08:00:44 bounce_time=1000
2024-05-21 08:00:44 row1, pin27, enabled=1, pull=GPIO.PUD_UP, command=command
Traceback (most recent call last):
 File "/var/www/daemon/gpio_buttons.py", line 50, in <module>
   GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down=btn_1_pull)
 File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 647, in setup
   raise ValueError(
ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN
OK, so pull_up_down needs to be PUD_UP but is set to the value of btn_1_pull which is set to the value of 'pull' which is GPIO.PUD_UP.  So:

Code:
master@apollo:~ $ moodeutl -q "UPDATE cfg_gpio set pull='PUD_UP'"
That should do the job...

Code:
master@apollo:~ $ sudo /var/www/daemon/gpio_buttons.py
2024-05-21 08:01:26 bounce_time=1000
2024-05-21 08:01:26 row1, pin27, enabled=1, pull=PUD_UP, command=command
Traceback (most recent call last):
 File "/var/www/daemon/gpio_buttons.py", line 50, in <module>
   GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down=btn_1_pull)
 File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 647, in setup
   raise ValueError(
ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN
But, but, just.... grrrr
Let's see if setting the value directly in the code works:

Code:
master@apollo:~ $ sudo nano /var/www/daemon/gpio_buttons.py

        GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down='PUD_UP')

master@apollo:~ $ sudo /var/www/daemon/gpio_buttons.py
2024-05-21 08:11:36 bounce_time=1000
2024-05-21 08:11:36 row1, pin27, enabled=1, pull=PUD_UP, command=command
Traceback (most recent call last):
  File "/var/www/daemon/gpio_buttons.py", line 50, in <module>
    GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down='PUD_UP')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 647, in setup
    raise ValueError(
ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN

This is why I'm now a manager, not a technician.
----------------
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: