Also if there is anyone that has a Beagle Bone that can help me port this over to it aswell I would appreciate it. I've had a few requests but I don't own one yet to do the work on. (unless someone ones to send me one :) )
https://pypi.python.org/pypi/matrix_keypad
Introduction
Python Library for Matrix Keypads. Written and tested on a Model B Raspberry Pi. Supports both a 3x4 and 4x4 keypad included
Current Version:
v1.2.2
Project Page: Project_Page
PyPI page: PyPI_Page
Python Library for Matrix Keypads. Written and tested on a Model B Raspberry Pi. Supports both a 3x4 and 4x4 keypad included
Current Version: | |
---|---|
v1.2.2 | |
Project Page: | Project_Page |
PyPI page: | PyPI_Page |
Author
Author: Chris Crumpacker
Email: chris@chriscrumpacker.com
Web: http://www.chriscrumpacker.com
Blog: http://crumpspot.blogspot.com
Author: | Chris Crumpacker |
---|---|
Email: | chris@chriscrumpacker.com |
Web: | http://www.chriscrumpacker.com |
Blog: | http://crumpspot.blogspot.com |
Prerequisites
If you are using the Raspberry Pi you will need to install the Python Development Toolkit. First update your package list:
sudo apt-get update
Now install the Dev Kit:
sudo apt-get install python-dev
Then to install Rpi.GPIO itself:
sudo apt-get install python-rpi.gpio
Installing Setuptools next so that you can use PIP is also helpful:
https://pypi.python.org/pypi/setuptools/1.1
If the I2C Port expander MCP23017 or MCP23008 is being used on a RPi, the Adafruit Python library for I2C and the MCP will need to be installed.
You can clone the whole library like so:
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
or the two files needed can be pulled out, Adafruit_I2C.py & Adafruit_MCP230xx.py.
If using a BeagleBone Black you must install the Adafruit_BBIO. This will give us access to the Adafruit_BBIO.GPIO library that will interface with the pins. Instructions on installing the BBIO library can be found here. The easiest way to install is:
/usr/bin/ntpdate -b -s -u pool.ntp.org
opkg update && opkg install python-pip python-setuptools
pip install Adafruit_BBIO
For manual installation:
git clone git://github.com/adafruit/adafruit-beaglebone-io-python.git
#set the date and time
/usr/bin/ntpdate -b -s -u pool.ntp.org
#install dependency
opkg update && opkg install python-distutils
cd adafruit-beaglebone-io-python
python setup.py install
If you are using the Raspberry Pi you will need to install the Python Development Toolkit. First update your package list:
sudo apt-get update
Now install the Dev Kit:
sudo apt-get install python-dev
Then to install Rpi.GPIO itself:
sudo apt-get install python-rpi.gpio
Installing Setuptools next so that you can use PIP is also helpful:
https://pypi.python.org/pypi/setuptools/1.1
If the I2C Port expander MCP23017 or MCP23008 is being used on a RPi, the Adafruit Python library for I2C and the MCP will need to be installed.
You can clone the whole library like so:
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
or the two files needed can be pulled out, Adafruit_I2C.py & Adafruit_MCP230xx.py.
If using a BeagleBone Black you must install the Adafruit_BBIO. This will give us access to the Adafruit_BBIO.GPIO library that will interface with the pins. Instructions on installing the BBIO library can be found here. The easiest way to install is:
/usr/bin/ntpdate -b -s -u pool.ntp.org opkg update && opkg install python-pip python-setuptools pip install Adafruit_BBIO
For manual installation:
git clone git://github.com/adafruit/adafruit-beaglebone-io-python.git #set the date and time /usr/bin/ntpdate -b -s -u pool.ntp.org #install dependency opkg update && opkg install python-distutils cd adafruit-beaglebone-io-python python setup.py install
Install
You can use the source from just downloading the files or Install it as a library via PIP:
pip install matrix_keypad
If using the Adafruit I2C code on a Raspberry Pi, you will need to create links to the Adafruit I2C and MCP230xx code since they are not installed as packages.:
sudo ln -s [path to Adafruit python code]/AdafruitMCP230xx/*.py /usr/local/lib/python2.7/dist-packages/matrix_keypad
Note: you will have to change the part in the brackets and maybe the path to the where the matrix keypad package is
You can use the source from just downloading the files or Install it as a library via PIP:
pip install matrix_keypad
If using the Adafruit I2C code on a Raspberry Pi, you will need to create links to the Adafruit I2C and MCP230xx code since they are not installed as packages.:
sudo ln -s [path to Adafruit python code]/AdafruitMCP230xx/*.py /usr/local/lib/python2.7/dist-packages/matrix_keypad
Note: you will have to change the part in the brackets and maybe the path to the where the matrix keypad package is
Files Included
README.txt
LICENSE.txt
setup.py
matrix_keypad/
__init__.py
BBb_GPIO.py
RPi_GPIO.py
MCP230xx.py
matrix_keypad_demo.py
matrix_keypad_demo2.py
README.txt LICENSE.txt setup.py matrix_keypad/ __init__.py BBb_GPIO.py RPi_GPIO.py MCP230xx.py matrix_keypad_demo.py matrix_keypad_demo2.py
Usage
See the demo scripts included to see this all in action.
To call the library select which one you intend to use and use the correct line:
from matrix_keypad import MCP230xx
or:
from matrix_keypad import RPi_GPIO
or:
from matrix_keypad import BBb_GPIO
Then initialize and give the library a short name so it is easier to reference later. For the MCP version:
kp = MCP230xx.keypad(address = 0x21, num_gpios = 8, columnCount = 4)
The variables in the keypad function call in this example are the I2C address, then if you are using the MCP23017 or MCP23008 you have to put the number of GPIO pin avaialable (default is 8), Then the "columnCount" is 3 for the 4x3 keypads and 4 for the 4x4 keypads.
For the standard GPIO version you only have to reference the column count and only if you want to change it to the 4x4, it defaults at the 3x4:
kp = RPi_GPIO.keypad(ColumnCount = 4)
It is possible to just check to see if a digit is currently pressed.:
checkKeypad = kp.getKey()
Or a simple function to call the keypad library and loop through it waiting for a digit press
def digit():
# Loop while waiting for a keypress
digitPressed = None
while digitPressed == None:
digitPressed = kp.getKey()
return digitPressed
See the demo scripts included to see this all in action.
To call the library select which one you intend to use and use the correct line:
from matrix_keypad import MCP230xx
or:
from matrix_keypad import RPi_GPIO
or:
from matrix_keypad import BBb_GPIO
Then initialize and give the library a short name so it is easier to reference later. For the MCP version:
kp = MCP230xx.keypad(address = 0x21, num_gpios = 8, columnCount = 4)
The variables in the keypad function call in this example are the I2C address, then if you are using the MCP23017 or MCP23008 you have to put the number of GPIO pin avaialable (default is 8), Then the "columnCount" is 3 for the 4x3 keypads and 4 for the 4x4 keypads.
For the standard GPIO version you only have to reference the column count and only if you want to change it to the 4x4, it defaults at the 3x4:
kp = RPi_GPIO.keypad(ColumnCount = 4)
It is possible to just check to see if a digit is currently pressed.:
checkKeypad = kp.getKey()
Or a simple function to call the keypad library and loop through it waiting for a digit press
def digit(): # Loop while waiting for a keypress digitPressed = None while digitPressed == None: digitPressed = kp.getKey() return digitPressed
Version History
v0.1.0:
Initial Scripts
v1.0.0:
Initial package build
v1.0.1:
Initial package build and push to PyPI
v1.0.2:
Updating the matrix_keypad_demo2.py to demo selecting the 4x4 keypad
v1.0.3:
Moved Version Log in README
Updated README Links
v1.0.4:
Updated References to include the PiLarm code as the inspiration for the "...demo2.py" code
v1.0.5:
Updates to the code in both main libs to fix some indenting and other issues from coping the code from blogger to a text file.
Updates to the keypad picking section for the constants to make it actually work
v1.0.6:
Fixes to more indenting issues. :(
v1.1.0:
Updated main libs and the demo code.
Added install directions to handle the links to the adafruit code
v1.1.1:
Updated ...demo.py and demo2.py to reflect new package name.
Updated README as well
v1.1.2:
Updating the README project links
Updating the code's comments
v1.1.3:
Repackage
v1.2b:
Beta code added for BeagleBone Black support
Updated the demo code to include examples intializing the BBb_GPIO code
Update all library and demo code with new Comment Header
v1.2.2:
Updated the BBb library with feedback from testers
v0.1.0: |
Initial Scripts
|
---|---|
v1.0.0: |
Initial package build
|
v1.0.1: |
Initial package build and push to PyPI
|
v1.0.2: |
Updating the matrix_keypad_demo2.py to demo selecting the 4x4 keypad
|
v1.0.3: |
Moved Version Log in README
Updated README Links
|
v1.0.4: |
Updated References to include the PiLarm code as the inspiration for the "...demo2.py" code
|
v1.0.5: |
Updates to the code in both main libs to fix some indenting and other issues from coping the code from blogger to a text file.
Updates to the keypad picking section for the constants to make it actually work
|
v1.0.6: |
Fixes to more indenting issues. :(
|
v1.1.0: |
Updated main libs and the demo code.
Added install directions to handle the links to the adafruit code
|
v1.1.1: |
Updated ...demo.py and demo2.py to reflect new package name.
Updated README as well
|
v1.1.2: |
Updating the README project links
Updating the code's comments
|
v1.1.3: |
Repackage
|
v1.2b: |
Beta code added for BeagleBone Black support
Updated the demo code to include examples intializing the BBb_GPIO code
Update all library and demo code with new Comment Header
|
v1.2.2: |
Updated the BBb library with feedback from testers
|
Code References
Column and Row scanning adapted from Bandono's matrixQPI which is wiringPi based.
Support for the BeagleBone Black has been added with the help of Daniel Marcus, Details on his project can be found here; dmarcstudios.com
matrix_keypad_demo2.py is based on some work that Jeff Highsmith had done in making his PiLarm that was featured on Make.
Column and Row scanning adapted from Bandono's matrixQPI which is wiringPi based.
Support for the BeagleBone Black has been added with the help of Daniel Marcus, Details on his project can be found here; dmarcstudios.com
matrix_keypad_demo2.py is based on some work that Jeff Highsmith had done in making his PiLarm that was featured on Make.
File | Type | Py Version | Uploaded on | Size | |
---|---|---|---|---|---|
matrix_keypad-1.2.2.tar.gz (md5) | Source | 2013-09-10 | 6KB | ||
matrix_keypad-1.2.2.zip (md5) | Source | 2013-09-10 | 14KB | ||
- Downloads (All Versions):
- 4 downloads in the last day
- 212 downloads in the last week
- 923 downloads in the last month
- Author: Chris Crumpacker
- Home Page: http://crumpspot.blogspot.com/p/keypad-matrix-python-package.html
- Categories
- Development Status :: 4 - Beta
- Environment :: Other Environment
- Intended Audience :: Developers
- License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
- Operating System :: OS Independent
- Programming Language :: Python
- Programming Language :: Python :: 3
- Topic :: Software Development :: Libraries :: Python Modules
- Topic :: System :: Hardware
- Package Index Owner: crump
- DOAP record: matrix_keypad-1.2.2.xml
Journal | |||
---|---|---|---|
Action | Date | User | Address |
create | 2013-08-19 21:39 | crump | 199.27.73.20 |
add Owner crump | 2013-08-19 21:39 | crump | 199.27.73.20 |
update hosting_mode | 2013-08-20 13:45 | crump | 199.27.73.22 |
update hosting_mode | 2013-08-20 13:45 | crump | 199.27.73.20 |
new release | 2013-09-10 11:30 | crump | 199.27.73.21 |
add source file matrix_keypad-1.2.2.tar.gz | 2013-09-10 11:30 | crump | 199.27.73.21 |
add source file matrix_keypad-1.2.2.zip | 2013-09-10 11:30 | crump | 199.27.73.21 |
This comment has been removed by a blog administrator.
ReplyDeleteThanks for this. Can you tell me a little about the connections between the keypad and the MCP23008? I can't get the rows and columns right by guessing. Thanks!
ReplyDeleteI got this setup and it works great, however it kills the CPU and runs it at around 90%. I'm assuming this is because it's constantly calling getKey(). Is there anyway to lessen this load? Maybe a way of converting this to use RPi.GPIO's new interrupt support?
ReplyDelete@DreadCodeMonkey The pad4pi library uses RPi.GPIO's interrupt support instead of a polling loop. It uses negligible CPU on my Pi while waiting for a key press.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for providing a good stuff.
ReplyDeletePython Flask Training
Flask Framework
Python Flask Online Training
Informative blog. Thanks for sharing.
ReplyDeletePython Training in Hyderabad
Python Training
Python Online Training
It is really great to create this wonderful blog to read. Ogen Infosystem is a leading web designing and development service provider in Delhi, India.
ReplyDeleteWebsite Designing Company in India
I use to read the blogs on daily bases, but today i found your blog quite interesting and unique, providing the great information and helpful to all. Keep it up and waiting for your latest updates thanks. We offers multiple services in digital marketing, some of our services are:
ReplyDeleteDigital marketing Company
SMM Services
PPC Services in Delhi
Website Design & Development Packages
Web Development Packages
Web Development Package
Social Media Management Packages
Social Media Management Services
Goodness, this is enticing research. I'm cheerful I seen this as and got to section it. extraordinary occupation upon this content material. I leaned toward it bounty. much thanks to you for the inescapable and specific data. Download Dll Fixer Crack
ReplyDeleteThat is a valuable instrument and every individual who utilizes the component and downloads information and riding on the web, needs to utilize this application.Malwarebytes Anti-Malware Serial
ReplyDelete
ReplyDeleteOne of the first benefits is that it is easy to get software that is free.
https://getcrackpc.com/adobe-creative-cloud-crack/
This is so interesting post, thank you for sharing Poker Game Development Company
ReplyDeleteHai! Nice blog you had , Thanks for sharing article
ReplyDeletetesting tools online training in hyderabad
This page has a lot of helpful information, so I'm glad I found it. I appreciate you sharing this tale. custom erp software
ReplyDeleteI want to express my gratitude for taking the time and effort to write this post. I'm hoping you'll keep producing your very finest work in the future as well.
ReplyDeleteLearn Azure Devops Course
This comment has been removed by the author.
ReplyDelete"Your content is a valuable resource about the Python package. Clear explanations and helpful examples."
ReplyDeletepython full stack training institute in KPHB
How come your Business be helpful in terms of legal if any software gets discarded. You will be needed contract lawyer for all terms.
ReplyDeleteReally informative articles. For legal contract you can get reviews from here. legal and contract services reviews
ReplyDeleteAmazing article you have shared. As per the requirements uin the reviews then you can contact any legal and contract service review manager for any kind of legal advice.
ReplyDelete