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
The SparkFun Qwiic Button BUTTON Module provides a simple and cost effective solution for adding Button capabilities to your project. Implementing a SparkFun Qwiic I2C interface, these sensors can be rapidly added to any project with boards that are part of the SparkFun Qwiic ecosystem.
24
12
25
-
Python module for the [SparkFun Qwiic Button](https://www.sparkfun.com/products/15932)
13
+
This repository implements a Python package for the SparkFun Qwiic BUTTON. This package works with Python, MicroPython and CircuitPython.
26
14
27
-
This module is also compatible with the following products:
28
-
*[SparkFun Qwiic Button - Green LED](https://www.sparkfun.com/products/16842)
This python package is a port of the existing [SparkFun Qwiic Button Arduino Library](https://github.com/sparkfun/SparkFun_Qwiic_Button_Arduino_Library)
24
+
## About the Package
37
25
38
-
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
26
+
This python package enables the user to access the features of the BUTTON via a single Qwiic cable. This includes <checking button state, configuring button LED, change I2C address> and more. The capabilities of the BUTTON are each demonstrated in the included examples.
39
27
40
28
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
41
29
42
-
##Contents
30
+
### Supported SparkFun Products
43
31
44
-
*[Supported Platforms](#supported-platforms)
45
-
*[Dependencies](#dependencies)
46
-
*[Installation](#installation)
47
-
*[Documentation](#documentation)
48
-
*[Example Use](#example-use)
32
+
This Python package supports the following SparkFun qwiic products on Python, MicroPython and Circuit python.
49
33
50
-
Supported Platforms
51
-
--------------------
52
-
The Qwiic Button Python package current supports the following platforms:
The SparkFun Qwiic Button module documentation is hosted at [ReadTheDocs](https://qwiic-button-py.readthedocs.io/en/main/?)
38
+
| Python | Platform | Boards |
39
+
|--|--|--|
40
+
| Python | Linux |[Raspberry Pi](https://www.sparkfun.com/raspberry-pi-5-8gb.html) , [NVIDIA Jetson Orin Nano](https://www.sparkfun.com/nvidia-jetson-orin-nano-developer-kit.html) via the [SparkFun Qwiic SHIM](https://www.sparkfun.com/sparkfun-qwiic-shim-for-raspberry-pi.html)|
> The listed supported platforms and boards are the primary platform targets tested. It is fully expected that this package will work across a wide variety of Python enabled systems.
69
46
70
-
This repository is hosted on PyPi as the [sparkfun-qwiic-button](https://pypi.org/project/sparkfun-qwiic-button/) package. On systems that support PyPi installation via pip, this library is installed using the following commands
47
+
## Installation
71
48
72
-
For all users (note: the user must have sudo privileges):
49
+
The first step to using this package is installing it on your system. The install method depends on the python platform. The following sections outline installation on Python, MicroPython and CircuitPython.
50
+
51
+
### Python
52
+
53
+
#### PyPi Installation
54
+
55
+
The package is primarily installed using the `pip3` command, downloading the package from the Python Index - "PyPi".
56
+
57
+
Note - the below instructions outline installation on a Linux-based (Raspberry Pi) system.
58
+
59
+
First, setup a virtual environment from a specific directory using venv:
73
60
```sh
74
-
sudo pip install sparkfun-qwiic-button
61
+
python3 -m venv path/to/venv
75
62
```
76
-
For the current user:
63
+
You can pass any path as path/to/venv, just make sure you use the same one for all future steps. For more information on venv [click here](https://docs.python.org/3/library/venv.html).
Now you should be able to run any example or custom python scripts that have `import qwiic_button` by running e.g.:
78
70
```sh
79
-
pip install sparkfun-qwiic-button
71
+
path/to/venv/bin/python3 example_script.py
80
72
```
81
-
To install, make sure the setuptools package is installed on the system.
82
73
83
-
Direct installation at the command line:
74
+
### MicroPython Installation
75
+
If not already installed, follow the [instructions here](https://docs.micropython.org/en/latest/reference/mpremote.html) to install mpremote on your computer.
76
+
77
+
Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.
If not already installed, follow the [instructions here](https://docs.circuitpython.org/projects/circup/en/latest/#installation) to install CircUp on your computer.
89
+
90
+
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
84
91
```sh
85
-
python setup.py install
92
+
circup bundle-add sparkfun/Qwiic_Py
86
93
```
87
94
88
-
To build a package for use with pip:
95
+
Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.
89
96
```sh
90
-
python setup.py sdist
91
-
```
92
-
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
97
+
circup install --py qwiic_button
98
+
```
99
+
100
+
If you would like to install any of the examples from this repository, issue the corresponding circup command from below. (NOTE: The below syntax assumes you are using CircUp on Windows. Linux and Mac will have different path seperators (i.e. "/" vs. "\"). See the [CircUp "example" command documentation](https://learn.adafruit.com/keep-your-circuitpython-libraries-on-devices-up-to-date-with-circup/example-command) for more information)
circup example qwiic_button\qwiic_button_ex1_buttonPress
104
+
circup example qwiic_button\qwiic_button_ex2_LEDon
105
+
circup example qwiic_button\qwiic_button_ex3_LEDconfig
106
+
circup example qwiic_button\qwiic_button_ex4_queueUsage
107
+
circup example qwiic_button\qwiic_button_ex5_popQueue
108
+
circup example qwiic_button\qwiic_button_ex6_changeI2CAddress
109
+
circup example qwiic_button\qwiic_button_ex7_2Buttons
96
110
```
97
111
98
112
Example Use
99
-
-------------
100
-
See the examples directory for more detailed use examples.
113
+
---------------
114
+
Below is a quickstart program to print readings from the BUTTON.
115
+
116
+
See the examples directory for more detailed use examples and [examples/README.md](https://github.com/sparkfun/qwiic_button_py/blob/main/examples/README.md) for a summary of the available examples.
Below is a brief summary of each of the example programs included in this repository. To report a bug in any of these examples or to request a new feature or example [submit an issue in our GitHub issues.](https://github.com/sparkfun/qwiic_button_py/issues).
3
+
4
+
NOTE: Any numbering of examples is to retain consistency with the Arduino library from which this was ported.
5
+
6
+
## Qwiic Button Ex1 Buttonpress
7
+
Simple Example for the Qwiic Button. Checks whether the button is pressed and
8
+
then prints its status.
9
+
10
+
## Qwiic Button Ex2 Ledon
11
+
Simple Example for the Qwiic Button. Turns on the button's built in LED
12
+
when pressed and prints status.
13
+
14
+
## Qwiic Button Ex3 Ledconfig
15
+
Simple Example for the Qwiic Button. Checks whether the button is pressed and
16
+
and the LED pulses if it is.
17
+
18
+
## Qwiic Button Ex4 Queueusage
19
+
Simple Example for the Qwiic Button. Shows how to use he FIFO Queue on the Qwiic Button.
20
+
21
+
## Qwiic Button Ex5 Popqueue
22
+
Simple Example for the Qwiic Button. Shows how to use he FIFO Queue on the Qwiic Button.
23
+
24
+
## Qwiic Button Ex6 Changei2Caddress
25
+
Simple Example for the Qwiic Button. Shows how to change the I2C address of
26
+
the Qwiic Button
27
+
28
+
## Qwiic Button Ex7 2Buttons
29
+
Simple Example for the Qwiic Button. Daisy chain together two Qwiic Buttons
30
+
with different I2C addresses. This example works for a Qwiic Button with the
31
+
default address of 0x6F and one with an address changed to 0x5B. To change
32
+
the address of a Qwiic Button, please visit example 6.
0 commit comments