![]() |
[SOLVED] GPIO buttons on moOde 9. - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7) +--- Thread: [SOLVED] GPIO buttons on moOde 9. (/showthread.php?tid=6495) |
GPIO buttons on moOde 9. - the_bertrum - 05-20-2024 I have a single GPIO button defined on my Pi3A+ based player but alas it's no longer working in moOde 9. On another thread, Tim found this: Code: pi@moode9:~ $ sudo /var/www/daemon/gpio_buttons.py A bit of search on the interweb tells me that "NoneType" is Python for "null" so I'm not sure why that applies to the output from datetime.. Anyway, I did a bit of digging in my own system and find different errors. With the GPIO button configured, but not activated the script runs cleanly and printls out the configuration: Code: master@prometheus:~ $ sudo /var/www/daemon/gpio_buttons.py When the button is enabled: Code: master@prometheus:~ $ sudo /var/www/daemon/gpio_buttons.py I have no idea why Tim got the NoneType error when I didn't though... RE: GPIO buttons on moOde 9. - Tim Curtis - 05-20-2024 I think it could be that the cfg_gpio table has null values in the empty columns. This and your other error are most likely the result of insufficient QA. I must speak with that guy ;-) RE: GPIO buttons on moOde 9. - the_bertrum - 05-20-2024 (05-20-2024, 07:09 PM)Tim Curtis Wrote: I think it could be that the cfg_gpio table has null values in the empty columns. This and your other error are most likely the result of insufficient QA. I must speak with that guy ;-) Ah, give that guy a break, Getting moOde 9 out at all is a seriously amazing thing, and where's the fun if there aren't deliberate mistakes for us to find? RE: GPIO buttons on moOde 9. - TheOldPresbyope - 05-20-2024 (05-20-2024, 07:51 PM)the_bertrum Wrote:(05-20-2024, 07:09 PM)Tim Curtis Wrote: I think it could be that the cfg_gpio table has null values in the empty columns. This and your other error are most likely the result of insufficient QA. I must speak with that guy ;-) Besides, all us early-adopters had ample chances to explore these nooks and crannies in the code during the pre-releases season. Seems to me you can spread the guilt around. And don't forget the sysadmin's motto from back in the day, "never install the x.0 version; always wait for the point release". Regards, Kent RE: GPIO buttons on moOde 9. - Tim Curtis - 05-20-2024 lol, you are all guilty! RE: GPIO buttons on moOde 9. - the_bertrum - 05-20-2024 I never thought to try the pre releases on my system with buttons... RE: GPIO buttons on moOde 9. - Tim Curtis - 05-20-2024 Run the sql commands below to fix up the cfg_gpio table. Code: moodeutl -q "UPDATE cfg_gpio set pin='' WHERE pin IS NULL" RE: GPIO buttons on moOde 9. - the_bertrum - 05-21-2024 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 Code: master@apollo:~ $ moodeutl -q "UPDATE cfg_gpio set pull='PUD_UP'" Code: master@apollo:~ $ sudo /var/www/daemon/gpio_buttons.py Let's see if setting the value directly in the code works: Code: master@apollo:~ $ sudo nano /var/www/daemon/gpio_buttons.py This is why I'm now a manager, not a technician. RE: GPIO buttons on moOde 9. - the_bertrum - 05-21-2024 Then most pertinent search result for that error.... This post. Sigh. RE: GPIO buttons on moOde 9. - the_bertrum - 05-21-2024 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): But hang on, that array of possible values is an array of variables! Sure enough up there at the top: Code: PUD_OFF = 20 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. |