GPIO Buttons do not work (python script error)
hardware is a raspberry pi 3 with a hifiberry amp and a rc522, using 223B touch buttons for gpio input.
everything works except the gpio-buttons
installed the gpio-buttons
i get the following erros when i start the daemon
pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control $ ./gpio_control.py
INFO:root:['VolumeControl', 'PrevNextControl', 'PlayPause', 'Shutdown', 'Volume0', 'VolumeUp', 'VolumeDown', 'NextSong', 'PrevSong', 'Halt']
INFO:root:adding GPIO-Device, VolumeControl
VolumeControl
INFO:gpio_control:VolumeControl as TwoButtonControl
INFO:GPIODevices.two_button_control:adding new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:root:adding GPIO-Device, PrevNextControl
PrevNextControl
INFO:root:adding TwoButtonControl
INFO:GPIODevices.two_button_control:adding new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:GPIODevices.simple_button:{}: set when_pressed
INFO:GPIODevices.simple_button:add new action
INFO:root:adding GPIO-Device, PlayPause
PlayPause
Traceback (most recent call last):
File "./gpio_control.py", line 105, in <module>
devices = get_all_devices(config)
File "./gpio_control.py", line 83, in get_all_devices
device = generate_device(config[section], section)
File "./gpio_control.py", line 54, in generate_device
pull_up_down=config.get('pull_up_down', fallback='GPIO.PUD_UP'))
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 66, in __init__
self.pull_up_down = parse_pull_up_down(pull_up_down)
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 34, in parse_pull_up_down
raise KeyError('Unknown Pull Up/Down type {pull_up_down}'.format(pull_up_down=pull_up_down))
KeyError: 'Unknown Pull Up/Down type GPIO.PUD_UP'
Exception ignored in: <function SimpleButton.__del__ at 0x765ca3d8>
Traceback (most recent call last):
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 110, in __del__
GPIO.remove_event_detect(self.pin)
AttributeError: 'SimpleButton' object has no attribute 'pin'
[DEFAULT]
enabled: True
[VolumeControl]
enabled: True
Type: TwoButtonControl ;or RotaryEncoder
PinUp: 5
PinDown: 6
pull_up: True
hold_time: 0.3
hold_repeat: True
timeBase: 0.1 ;only for RotaryEncoder
functionCallDown: functionCallVolD
functionCallUp: functionCallVolU
functionCallTwoButtons: functionCallVol0 ;only for TwoButtonControl
[PrevNextControl]
enabled: True
Type: TwoButtonControl
Pin1: 22
Pin2: 23
functionCall1: functionCallPlayerPrev
functionCall2: functionCallPlayerNext
functionCallTwoButtons: None
pull_up: True
hold_time: 0.3
hold_repeat: False
[PlayPause]
enabled: True
Type: Button
Pin: 27
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerPause
[Shutdown]
enabled: False
Type: Button
Pin: 3
pull_up: True
hold_time: 2
functionCall: functionCallShutdown
[Volume0]
enabled: False
Type: Button
Pin: 17
pull_up: True
hold_time: 0.3
functionCall: functionCallVol0
[VolumeUp]
enabled: False
Type: Button
Pin: 16
pull_up: True
hold_time: 0.3
hold_repeat: True
functionCall: functionCallVolU
[VolumeDown]
enabled: False
Type: Button
Pin: 19
pull_up: True
hold_time: 0.3
hold_repeat: True
functionCall: functionCallVolD
[NextSong]
enabled: False
Type: Button
Pin: 26
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerNext
[PrevSong]
enabled: False
Type: Button
Pin: 20
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerPrev
[Halt]
enabled: False
Type: Button
Pin: 21
pull_up: True
hold_time: 0.3
functionCall: functionCallPlayerPauseForce
tested the functionality with simple_button.py and it worked
pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control/GPIODevices $ python simple_button.py
please enter pin no to test
27
FunctionCall with (27,)
FunctionCall with (27,)
FunctionCall with (27,)
FunctionCall with (27,)
FunctionCall with (27,)
pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control/GPIODevices $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~/RPi-Jukebox-RFID/components/gpio_control/GPIODevices $ cd /home/pi/RPi-Jukebox-RFID/ && git status | head -2
Refresh index: 100% (390/390), done.
On branch develop
Your branch is up to date with 'origin/develop'.
i.e. scripts/installscripts/buster-install-default.sh
without spotify support
Raspberry Pi 3 Model B Rev 1.2
RC522
Hifi Berry Amp
default settings imported to /home/pi/.config/phoniebox/gpio-settings.ini
This should been fixed, see https://github.com/MiczFlor/RPi-Jukebox-RFID/commit/5c93f67e9799900709bfbce9a756ac4f5c68d7e1#diff-7de2980ae0dfe3a67ec69f2e922125be
We just released 2.1, which should fix this issue.
Hi.
I have upgraded to version 2.1.
Now the gpio buttons are not working anymore.
Before the upgrade the buttons worked fine.
GPIO Buttons are enabled on the settings Page.
What's the output of tail -n 500 /var/log/syslog?
Hi there,
after updating from 2.0 to 2.1 the buttons didn't work anymore. I also made a clean install and got this issue too. I didn't changed the configuration in any way.
The output of the command tail -n 500 /var/log/syslog is
INFO:root:adding GPIO-Device, PlayPause
VolumeControl
PrevNextControl
PlayPause
Traceback (most recent call last):
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/gpio_control.py", line 105, in <module>
devices = get_all_devices(config)
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/gpio_control.py", line 83, in get_all_devices
device = generate_device(config[section], section)
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/gpio_control.py", line 54, in generate_device
pull_up_down=config.get('pull_up_down', fallback='GPIO.PUD_UP'))
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 66, in __init__
self.pull_up_down = parse_pull_up_down(pull_up_down)
File "/home/pi/RPi-Jukebox-RFID/components/gpio_control/GPIODevices/simple_button.py", line 34, in parse_pull_up_down
raise KeyError('Unknown Pull Up/Down type {pull_up_down}'.format(pull_up_down=pull_up_down))
KeyError: 'Unknown Pull Up/Down type GPIO.PUD_UP'
phoniebox-gpio-control.service: Main process exited, code=exited, status=1/FAILURE
phoniebox-gpio-control.service: Failed with result 'exit-code'.
Edit:
I missed the point, that the config is taken from ~\.config\phoniebox\gpio_settings.ini after disabling the PlayPause there, the service comes up. But the parsing seems not to work for other default buttons two. I'll try to dig a little bit deeper.
So I could bring it back to work with changing the following line in gpio_control.py:
pull_up_down=config.get('pull_up_down', fallback='GPIO.PUD_UP'))
pull_up_down=config.get('pull_up_down', fallback=GPIO.PUD_UP))
It seems, that there is a string expected but in the simple_button.py it is checked for the real values. So first line (if pull_up_down in [GPIO.PUD_UP, GPIO.PUD_DOWN, GPIO.PUD_OFF]:) isn't hit because 'GPIO.PUD_UP' doesn't match value 22 for example. So there should be also a string to const conversion done before checking or while checking.
Thanks for digging into that.
Could you open a pull request fixing this?
@s-martin I will fix this today in the evening and create a PR. Furthermore I found an issue with the volume up or down not using the configured volume step. Will perhaps also take a look into this.