Read the statement by Michael Teeuw here.
[MMM-Buttons] Connect multiple buttons to send configurable notifications
-
@Jopyth Moved my post here out from another thread.
I am having one more issue though. Using a python test program i can see every single instance of my button press is registered instantly. But in the mirror it seems MMM-Buttons doesnt register pushes unless sometimes I double or triple click…then sometimes the button registers 5-6 times. I’m not really sure how to debug this sort of thing.
Also would it be right to assume the pull up/down resistors were not enabled with MMM-Buttons?
-
@Mar all is here https://forum.magicmirror.builders/topic/211/button
;-)
-
-
@istepgueu Ive taken your button.py program and modified it for me two buttons 5/6. And while the program reads my button presses perfectly, MM-Buttons doesnt at all. I pretty much have to double click each time to make a button register. It switches my profiles just fine … but just takes lots of clicks to register.
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(6, GPIO.IN, pull_up_down=GPIO.PUD_UP) tries = 0 while (tries < 200000): if GPIO.input(6): print("Open 6") else: print("Close 6") if GPIO.input(5): print("Open 5") else: print ("Close 5") time.sleep(0.5) tries = tries + 1
-
@istepgueu Will take a look through this now, but i already have a 1k resistor between pins 5/6 and the respective button. Hopefully something else comes up here.
Yes my problem seems a bit opposite of what was posted in your link. I dont have any erroneous button presses, it just takes a few clicks until MMM-Buttons registers the click. You button.py registers every click instantly. So must be something in the buttons code?
-
@Mar @istepgueu The library (
onoff
) I am currently using does not directly allow configuring pull up and pull down resistors, and I was not able to make it consistently work (see Readme).Therefore I myself made use of the “right” pins for my setup, as the readme says:
The defaults can be seen in Table 6-31 on pages 102 and 103 of the BCM2835 ARM Peripherals documentation.
There I simply used buttons with the correct default pull-up/pull-down resistor configuration (second column of that table), and I wanted a few pins close together on the board, so I chose GPIO 22,23,24 and 25 (connected 4 buttons), since they all have the default of a low input.
-
@Jopyth Thanks for the response, and that seems to make complete sense. I missed that part in the documentation.
Though upon trying PINS 22/23 i am still getting the same result. The button.py program detects each individual click properly, but in the MM I have to double (sometimes triple) click the button so that it registers. I can see it registers as it shows up in the pm2 logs and my profile changes.
Im not sure if its an issue with the buttons as they are a standard 4 pin button and the test script works fine with them?
-
@Mar Well its not, as if it were documented anywhere in my readme. :( Should probably add this somewhere.
How long are you pressing the button? For a very short time? Note, that if the press is longer than 500ms it will not be registered as a (short) press (it is the
maxShortPressTime
and can be configured).If this is not the case, I am sorry, but I have no real idea how to fix it, without having the same situation on my Pi.
-
@Jopyth I thought this also, and set the short time from 0-1000ms and still will only register the second of a double click.
Its very consistent though, i can get it to work 100% of the time with a double click like opening a folder on the computer. one click doesnt do anything, and I don’t believe the longPress worked at all (But i wasnt using it so not that bothered with it).
Maybe its just the buttons…i just dont have anything else around that i could use to test as a button.
-
@Jopyth Just tested with buttons ripped out from an old monitor and same issue, needed to double click. I suppose i will slowly go through the code and try break it down and see. any advice on which functions to start with?