Posts: 2,110
Threads: 46
Joined: Mar 2020
Reputation:
99
(05-21-2024, 08:40 AM)the_bertrum Wrote: probably easiest to set the numeric values into the GPIO table perhaps.
Quick test of
Code: moodeutl -q "UPDATE cfg_gpio set pull=22"
Followed by
Code: btn_1_pull = int(row['pull'])
And all seems groovy
----------------
Robert
Posts: 82
Threads: 4
Joined: May 2024
Reputation:
2
05-21-2024, 09:09 AM
(This post was last modified: 05-21-2024, 09:11 AM by Dorffen.)
Even though my patience is challenged by ADHD it seems to fit my complete noobieness well that I’ll have to wait until tomorrow to get my raspberry.
Will need those GPIO buttons on my project.
100% Linux noob (Linexia?) - Promoted, by Tim, to ‘not noob’ ‘novice’, with a single vote from Robert.
I look forward am slightly nervous about what triggers the ‘dangerous’ promotion.
Proclaimed to ‘tinkerer status’ by Kent.
Almost anything is possible. It’s the subjective sum of the variables price, time and entertainment that determines whether it’s worth it or not.
Posts: 14,501
Threads: 332
Joined: Mar 2018
Reputation:
594
(05-21-2024, 08:51 AM)the_bertrum Wrote: (05-21-2024, 08:40 AM)the_bertrum Wrote: probably easiest to set the numeric values into the GPIO table perhaps.
Quick test of
Code: moodeutl -q "UPDATE cfg_gpio set pull=22"
Followed by
Code: btn_1_pull = int(row['pull'])
And all seems groovy
Wow, my bad. GPIO.PUD_UP and GPIO.PUD_DOWN are of course not strings as they are coded in the cfg_gpio table :-0
I'll post a link to updated script later today.
Posts: 14,501
Threads: 332
Joined: Mar 2018
Reputation:
594
05-22-2024, 01:08 PM
(This post was last modified: 05-22-2024, 01:10 PM by Tim Curtis.)
Here's are the fixes for GPIO Buttons. Please test and let me know the results.
Code: # Update code (paste the entire block)
sudo bash -c '
wget -q https://raw.githubusercontent.com/moode-player/moode/develop/www/gpio-config.php -O /var/www/gpio-config.php;
wget -q https://raw.githubusercontent.com/moode-player/moode/develop/www/templates/gpio-config.html -O /var/www/templates/gpio-config.html;
wget -q https://raw.githubusercontent.com/moode-player/moode/develop/www/daemon/gpio_buttons.py -O /var/www/daemon/gpio_buttons.py'
# Fix value of 'pull' column
moodeutl -q "UPDATE cfg_gpio set pull='22' WHERE pull='GPIO.PUD_UP'"
moodeutl -q "UPDATE cfg_gpio set pull='21' WHERE pull='GPIO.PUD_DOWN'"
# Fix nulls
moodeutl -q "UPDATE cfg_gpio set pin='' WHERE pin IS NULL"
moodeutl -q "UPDATE cfg_gpio set enabled='' WHERE enabled IS NULL"
moodeutl -q "UPDATE cfg_gpio set pull='' WHERE pull IS NULL"
moodeutl -q "UPDATE cfg_gpio set command='' WHERE command IS NULL"
moodeutl -q "UPDATE cfg_gpio set param='' WHERE param IS NULL"
moodeutl -q "UPDATE cfg_gpio set value='' WHERE value IS NULL"
Posts: 2,110
Threads: 46
Joined: Mar 2020
Reputation:
99
(05-22-2024, 01:08 PM)Tim Curtis Wrote: Here's are the fixes for GPIO Buttons. Please test and let me know the results.
Code: # Update code (paste the entire block)
sudo bash -c '
wget -q https://raw.githubusercontent.com/moode-player/moode/develop/www/gpio-config.php -O /var/www/gpio-config.php;
wget -q https://raw.githubusercontent.com/moode-player/moode/develop/www/templates/gpio-config.html -O /var/www/templates/gpio-config.html;
wget -q https://raw.githubusercontent.com/moode-player/moode/develop/www/daemon/gpio_buttons.py -O /var/www/daemon/gpio_buttons.py'
# Fix value of 'pull' column
moodeutl -q "UPDATE cfg_gpio set pull='22' WHERE pull='GPIO.PUD_UP'"
moodeutl -q "UPDATE cfg_gpio set pull='21' WHERE pull='GPIO.PUD_DOWN'"
# Fix nulls
moodeutl -q "UPDATE cfg_gpio set pin='' WHERE pin IS NULL"
moodeutl -q "UPDATE cfg_gpio set enabled='' WHERE enabled IS NULL"
moodeutl -q "UPDATE cfg_gpio set pull='' WHERE pull IS NULL"
moodeutl -q "UPDATE cfg_gpio set command='' WHERE command IS NULL"
moodeutl -q "UPDATE cfg_gpio set param='' WHERE param IS NULL"
moodeutl -q "UPDATE cfg_gpio set value='' WHERE value IS NULL"
Maybe I missed something... Or it could be because of the hacking I was doing earlier. I'll re-flash and try again.
Code: master@prometheus:~ $ sudo /var/www/daemon/gpio_buttons.py
bounce=1000ms
btn1, enabled y, gpio 27, pull-up, cmd=/home/master/StartStop.sh
Traceback (most recent call last):
File "/var/www/daemon/gpio_buttons.py", line 54, in <module>
GPIO.setup(int(row['pin']), GPIO.IN, pull_up_down=int(row['pull']))
File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 669, in setup
_check(lgpio.gpio_claim_input(_chip, gpio, {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 755, in gpio_claim_input
return _u2i(_lgpio._gpio_claim_input(handle&0xffff, lFlags, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
raise error(error_text(v))
lgpio.error: 'GPIO busy'
----------------
Robert
Posts: 2,110
Threads: 46
Joined: Mar 2020
Reputation:
99
Darn it, ran out of time. I'm away until Sunday. I'll test as soon as I'm back unless someone else has a suitable setup to try it...
----------------
Robert
Posts: 14,501
Threads: 332
Joined: Mar 2018
Reputation:
594
No prob. I'm sure my code modifications are golden ;-)
Posts: 2,110
Threads: 46
Joined: Mar 2020
Reputation:
99
OK, so looks like the tables are all good, but it now doesn't seem to fire the specified command. I get absolutely nothing out at all. The speicified script runs if I run it from the command line, but no hint of anything happening at all when the GPIO button is activated. I've even bypassed the switch and just touched the wires in case the switch was dodgy, no sign of life.
Can't see anything in any logs either, not sure where to begin debugging.
----------------
Robert
Posts: 2,110
Threads: 46
Joined: Mar 2020
Reputation:
99
Running the GPIO script in the command line gives this:
Code: master@prometheus:~ $ sudo /var/www/daemon/gpio_buttons.py
bounce=1000ms
btn1, enabled y, gpio 27, pull-up, cmd=/home/master/StartStop.sh
btn2, enabled n, gpio 02, pull-up, cmd=
btn3, enabled n, gpio 02, pull-up, cmd=
btn4, enabled n, gpio 02, pull-up, cmd=
btn5, enabled n, gpio 02, pull-up, cmd=
btn6, enabled n, gpio 02, pull-up, cmd=
btn7, enabled n, gpio 02, pull-up, cmd=
btn8, enabled n, gpio 02, pull-up, cmd=
[Errno 13] Permission denied: ''
The permission error comes when the button is pressed.
Not sure what the permission refers to.
----------------
Robert
Posts: 14,501
Threads: 332
Joined: Mar 2018
Reputation:
594
(05-26-2024, 05:17 PM)the_bertrum Wrote: Running the GPIO script in the command line gives this:
Code: master@prometheus:~ $ sudo /var/www/daemon/gpio_buttons.py
bounce=1000ms
btn1, enabled y, gpio 27, pull-up, cmd=/home/master/StartStop.sh
btn2, enabled n, gpio 02, pull-up, cmd=
btn3, enabled n, gpio 02, pull-up, cmd=
btn4, enabled n, gpio 02, pull-up, cmd=
btn5, enabled n, gpio 02, pull-up, cmd=
btn6, enabled n, gpio 02, pull-up, cmd=
btn7, enabled n, gpio 02, pull-up, cmd=
btn8, enabled n, gpio 02, pull-up, cmd=
[Errno 13] Permission denied: ''
The permission error comes when the button is pressed.
Not sure what the permission refers to.
I'll investigate.
|