Giter Club home page Giter Club logo

pad4pi's People

Contributors

antogg avatar brettmclean avatar tatagatha avatar thijstriemstra avatar wikinaut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pad4pi's Issues

Randomly stops responding to key presses

Caveat: This may not have anything to do with your library (for which I owe you a beer), in which case sending me off in the right direction would fantastic.
Background: I have an 6 x 5 grid switches (discrete microswitches) that are part of a game I am building. I'm still in the tinkering phase, but the goal is to cause patterns of Neopixels to light up as various switches are pressed. I am using Python 3 on a Raspberry Pi Zero W.
Problem: I can press one switch at a time and get the number of the switch, but randomly the Pi0W will stop responding the key presses. The script is still running because control-C breaks out of it and resets the LEDs. Frequency of key pressing is every second or so, not faster. This happens after a random number of presses: sometimes 5, sometimes 65, sometimes 107. I removed all the Neopixel references and the behavior is identical. I have an LED that is triggered and reset (lambda) in the function that's called every time a key press interrupt happens. When the script stops responding, that LED does not trigger so I am thinking somehow an interrupt is not being generated. Why? No idea. Maybe I'm doing something wrong, but I'm using very similar keypad code in other projects without any trouble.
Code without Neopixels (pastebin)
Code with Neopixels (pastebin)
Edit: I pared the size of the matrix to 3x3 and gave up pressing keys at 450. I upped the matrix to 4x4 and got to 82 before I had the same issue.

Possible brief direct short if multiple keys are pressed at one time

The problem arises in this piece of code here:

        # Scan columns for pressed key
        colVal = None
        if rowVal is not None:
            for i in range(len(self._col_pins)):
                GPIO.output(self._col_pins[i], GPIO.HIGH)
                if GPIO.input(self._row_pins[rowVal]) == GPIO.HIGH:
                    GPIO.output(self._col_pins[i], GPIO.LOW)
                    colVal = i
                    break
                GPIO.output(self._col_pins[i], GPIO.LOW)

Suppose we have a 2x2 matrix, and someone pushes A1, connecting the first column and first row. All is well.

Now, they later press B1, which doesn't trigger a new row that wasn't already low, no interrupt, all is well.

Keeping those pressed, they press A2 or B2. getKey is triggered, and the first column is driven high for the test, but it is connected to the second column(which is a low output), and you get a short.

Then we do the same for the second column and get a short again. If the repeat timer is doing stuff, this happens over and over again.

wrong key returned when press quickly

Hi

I have found that if i enter numbers quickly (4x4 matrix keypad) it sometimes reports the wrong key pressed, (usually the 1st key in the row, but not always) i.e press key 3 rapidly and it reports a key of '1', sometimes 2, but never 'A'

if i press 'A' in quick succession i can often get 1, 2, or 3
if i press '2' in quick succession i get either 1 or 2, but never 3 or A

def printKey(key):
print(key) # wrong number here

i have tried multiple options with repeats and delays to no avail

any idea how to fix this please. sometimes waiting a few seconds between presses still reports the wrong key

thanks

Bob

Parametrize `GPIO.cleanup()` call in keypad cleanup

The current implementation of Keypad.cleanup() always calls GPIO.cleanup():

pad4pi/pad4pi/rpi_gpio.py

Lines 165 to 168 in 0e560a1

def cleanup(self):
if self._repeat_timer is not None:
self._repeat_timer.cancel()
GPIO.cleanup()

However, for some applications it may be necessary to still be able to use RPi.GPIO after keypad cleanup, for example if the keypad should be active only occasionally (i.e. instantiated and destroyed multiple number of times).

When using this keypad library simulatenously with any HD44780 LCD display library based on RPi.GPIO, currently it is necessary to perform keypad cleanup at the very end. Otherwise, the following error will appear when trying to clear the display with lcd.clear() after keypad cleanup:

RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)

According to RPi.GPIO documentation, GPIO.cleanup() should be called at the end any program. This can be easily achieved by simply placing GPIO.cleanup() at the end of the script separately or using exit handlers (atexit) manually by the library user.

For convenience and compability purposes, the suggested solution is to call GPIO.cleanup() conditionally, depending on the value of a boolean parameter (enabled by default). Otherwise, GPIO.remove_event_detect() should be called to unregister all interrupts. This will allow developers to configure the behaviour depending on the application.

Debouncing or noise problems with a self-made 2x4 layout

Thanks for your code, I found it used here http://codelectron.com/how-to-make-a-soundboard-using-raspberry-pi-step-by-step-guide-memebox/ (code: https://github.com/codelectron/Soundboard ).

I noticed that sometimes a wrong key is decoded for one of my 2 x 4 keypads, see image. Each micropad with 4 keys has one "row" and four "columns". Each cable is about 70 cm long; perhaps the debouncing can be fine-tuned?
img_20180603_001946

My layout:

# Setup Keypad
KEYPAD = [
        ["1","2","3","4"],
        ["5","6","7","8"]
]

COL_PINS = [11,23,24,25] # BCM numbering
ROW_PINS = [17,27] # BCM numbering

RuntimeError: Conflicting edge detection already enabled for this GPIO channel

I try running the sample code and when I get to the line

keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS)

I get the error

RuntimeError: Conflicting edge detection already enabled for this GPIO channel

Other than changing the row and column pins to match my actual wiring, the code is identical to the sample provided with the library. What am I missing here?

Cannot import name 'rpi_gpio'

`from pad4pi import rpi_gpio
#import pad4pi
#import RPi.GPIO as rpi_gpio

KEYPAD = [
[1,2,3],
[4,5,6],
[7,8,9],
["*",0,"#"]
]

ROW_PINS = [4,14,15,17] # BCM numbering
COL_PINS = [18,27,22] # BCM numbering

factory = rpi_gpio.KeypadFactory()

Try factory.create_4_by_3_keypad

and factory.create_4_by_4_keypad for reasonable defaults

keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS)

def printKey(key):
print(key)

printKey will be called each time a keypad button is pressed

keypad.registerKeyPressHandler(printKey)`

o/pad4pi.py", line 1, in <module> from pad4pi import rpi_gpio ImportError: cannot import name 'rpi_gpio'

Keyboard factory also doesnt work

save keypad number input

I am trying to get the key that i pressed(the value of the key) , but I get an error: "local variable 'Key' referenced before assignment " I am using from pad4pi import rpi_gpio,
keypadcode.txt
i want to get the Key from the printKey function and use it in the main function , how can i do this

Missing Buttons

I've been using Pad4pi on a 4x5 keypad with no problems for a while. recently I purchased a new 3x4 keypad. I modified my code but some some reason I am missing some of the buttons. I have checked the keypad using a power source and LED so can confirm the all the buttons work and are wired correctly. My code is below:


from pad4pi import rpi_gpio

import time

KEYPAD = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
["*", 0, "#"]
]

COL_PINS = [16, 5, 13] # BCM numbering 5 1 3
ROW_PINS = [19, 20, 21, 6] # BCM numbering 4 6 7 2

factory = rpi_gpio.KeypadFactory()

keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS)

def printKey(key):
print(key)

keypad.registerKeyPressHandler(printKey)

try:
while(True):
time.sleep(0.2)
except:
keypad.cleanup()


I am not getting a response from the keys; 1,5,6,7,*,0,#.

Have you any suggestions please?

No module named 'pad4pi'

I follwed the instructions The Interpreter ceeps giving me the same answer.
Import Error : No module named 'pad4pi'
Kann it be bequase it is no hocked up or wrongli hocked up?
or some other reason.

Allow key press handlers to be unregistered

Client code can currently register handler functions to be called when a button is pressed on the keypad. Ideally, client code should also be able to unregister handler functions when they no longer want a certain action to be performed on key press.

Currently, the only way to do this is to call keypad.cleanup() and then create a new Keypad instance, which is inconvenient.

Double key presses

Hi, thanks for writing this nice code, it should help me getting the CPU usage of my pi down!

However, I am running in to an issue which I am finding hard to debug: (almost) every time I press a key it is registered as a double press. Is there anything I can do about that?

Thanks!

doesn’t load for programs running at boot time

I’m not sure whether this is a problem with the library or the installation script or something else, but I have a couple of python programs using pad4pi that I want to run at boot time.

The software works perfectly if run from the command line, whether launched from its own directory or any other. However if I try to run at launch by putting the script in rc.local, nothing happens and I log the following error:

Traceback (most recent call last):
  File "/home/pi/sound.py", line 4, in <module>
    from pad4pi import rpi_gpio
ImportError: No module named pad4pi

Why would the library be available from the command line but not at launch? Can this be fixed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.