You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had problems with the modules MMM-Buttons and MMM-Button that they didn't recognize button presses or fired several presses. I think the Javascript onoff library to access the GPIOs is very bad.
My button (connected to GND and GPIO) worked without problems when using a simple python script!
So I found the following workaround as a replacement for the button modules:
add the following line to /etc/rc.local: python /home/pi/button.py &
Script
#!/usr/bin/python
import RPi.GPIO as GPIO
import urllib2
import time
# Button number in GPIO numbering
GPIO_BUTTON = 27
# Shutdown time in seconds
SHUTDOWN = 5
# Debounce time in seconds
DEBOUNCE = 0.15
GPIO.setmode(GPIO.BCM)
# Set pin as input
GPIO.setup(GPIO_BUTTON,GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Initialize
start = 99999999999999
# Callback-Function
def WORK(PIR_GPIO):
global start
if GPIO.input(GPIO_BUTTON):
diff = time.time() - start
if diff > SHUTDOWN:
urllib2.urlopen("http://localhost:8080/remote?action=SHUTDOWN").read()
elif diff > DEBOUNCE:
urllib2.urlopen("http://localhost:8080/remote?action=NOTIFICATION¬ification=PAGE_UP").read()
else:
start = time.time()
try:
GPIO.add_event_detect(GPIO_BUTTON, GPIO.BOTH, callback=WORK)
while True:
time.sleep(60)
except KeyboardInterrupt:
GPIO.cleanup()
Description
The script measures the time the button is pressed. On release it decides if it was a long press, which means a shutdown, a short press which means in my case send a broadcast to change the page or too short which will be ignored.
For shutdown and broadcast it uses the remote control http interface!
The text was updated successfully, but these errors were encountered:
Just an FYI, you might get better feedback in those respective repos than here, since MM core can't really do anything about making sure modules well support the RPi platform.
I had problems with the modules MMM-Buttons and MMM-Button that they didn't recognize button presses or fired several presses. I think the Javascript onoff library to access the GPIOs is very bad.
My button (connected to GND and GPIO) worked without problems when using a simple python script!
So I found the following workaround as a replacement for the button modules:
python /home/pi/button.py &
Script
Description
The script measures the time the button is pressed. On release it decides if it was a long press, which means a shutdown, a short press which means in my case send a broadcast to change the page or too short which will be ignored.
For shutdown and broadcast it uses the remote control http interface!
The text was updated successfully, but these errors were encountered: