Qwiic_Keypad_Py
Python for SFE Qwiic Keypad
Loading...
Searching...
No Matches
Qwiic_Keypad_Py



follow on Twitter

SparkFun Qwiic Keypad Breakout

Python module for the qwiic keypad, which is part of the SparkFun Qwiic Keypad - 12 Button

This python package is a port of the existing SparkFun Qwiic Keypad Arduino Library

This package can be used in conjunction with the overall SparkFun qwiic Python Package

New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.

Contents

  • Dependencies
  • Installation
  • Documentation
  • Example Use

Dependencies

This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py

Documentation

The SparkFun qwiic Keypad module documentation is hosted at ReadTheDocs

Installation

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-keypad package. On systems that support PyPi installation via pip, this library is installed using the following commands

For all users (note: the user must have sudo privileges):

sudo pip install sparkfun-qwiic-keypad

For the current user:

pip install sparkfun-qwiic-keypad

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line:

python setup.py install

To build a package for use with pip:

python setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.

cd dist
pip install sparkfun_qwiic_keypad-<version>.tar.gz

Example Use

See the examples directory for more detailed use examples.

import qwiic_keypad
import time
import sys
def runExample():
print("\nSparkFun qwiic Keypad Example 1\n")
if myKeypad.is_connected() == False:
print("The Qwiic Keypad device isn't connected to the system. Please check your connection", \
file=sys.stderr)
return
myKeypad.begin()
button = 0
while True:
# necessary for keypad to pull button from stack to readable register
myKeypad.update_fifo()
button = myKeypad.get_button()
if button == -1:
print("No keypad detected")
time.sleep(1)
elif button != 0:
# Get the character version of this char
charButton = chr(button)
if charButton == '#':
print()
elif charButton == '*':
print(" ", end="")
else:
print(charButton, end="")
# Flush the stdout buffer to give immediate user feedback
sys.stdout.flush()
time.sleep(.25)
# Development in progress
QwiicKeypad.
Definition: qwiic_keypad.py:87

SparkFun - Start Something