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
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
11
+
The SparkFun Qwiic GPIO Expander GPIO Module provides a simple and cost effective solution for adding GPIO Expander 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.
28
12
29
-
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
13
+
This repository implements a Python package for the SparkFun Qwiic GPIO. This package works with Python, MicroPython and CircuitPython.
This python package enables the user to access the features of the GPIO via a single Qwiic cable. This includes <setting GPIOs, reading GPIOs, inverting GPIOs> and more. The capabilities of the GPIO are each demonstrated in the included examples.
27
+
28
+
New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
29
+
30
+
### Supported SparkFun Products
31
+
32
+
This Python package supports the following SparkFun qwiic products on Python, MicroPython and Circuit python.
| 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.
38
46
39
-
Supported Platforms
40
-
--------------------
41
-
The Qwiic GPIO Python package current supports the following platforms:
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.
48
50
49
-
Documentation
50
-
-------------
51
-
The SparkFun Qwiic GPIO module documentation is hosted at [ReadTheDocs](https://sparkfun-qwiic-gpio.readthedocs.io/en/latest/?)
51
+
### Python
52
52
53
-
Installation
54
-
-------------
53
+
#### PyPi Installation
55
54
56
-
### PyPi Installation
57
-
This repository is hosted on PyPi as the [sparkfun-qwiic-gpio](https://pypi.org/project/sparkfun-qwiic-gpio/) package. On systems that support PyPi installation via pip, this library is installed using the following commands
55
+
The package is primarily installed using the `pip3` command, downloading the package from the Python Index - "PyPi".
58
56
59
-
For all users (note: the user must have sudo privileges):
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:
60
+
```sh
61
+
python3 -m venv path/to/venv
62
+
```
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).
64
+
65
+
Next, install the qwiic package with:
66
+
```sh
67
+
path/to/venv/bin/pip3 install sparkfun-qwiic-gpio
68
+
```
69
+
Now you should be able to run any example or custom python scripts that have `import qwiic_gpio` by running e.g.:
70
+
```sh
71
+
path/to/venv/bin/python3 example_script.py
72
+
```
73
+
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.
To install, make sure the setuptools package is installed on the system.
87
+
### CircuitPython Installation
88
+
If not already installed, follow the [instructions here](https://docs.circuitpython.org/projects/circup/en/latest/#installation) to install CircUp on your computer.
71
89
72
-
Direct installation at the command line:
90
+
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
73
91
```sh
74
-
python setup.py install
92
+
circup bundle-add sparkfun/Qwiic_Py
75
93
```
76
94
77
-
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.
78
96
```sh
79
-
python setup.py sdist
80
-
```
81
-
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_gpio
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)
101
+
82
102
```sh
83
-
cd dist
84
-
pip install sparkfun_qwiic_gpio-<version>.tar.gz
85
-
103
+
circup example qwiic_gpio\qwiic_gpio_ex1a_write
104
+
circup example qwiic_gpio\qwiic_gpio_ex1b_write_port
105
+
circup example qwiic_gpio\qwiic_gpio_ex2a_read
106
+
circup example qwiic_gpio\qwiic_gpio_ex2b_read_port
107
+
circup example qwiic_gpio\qwiic_gpio_ex3a_inversion
108
+
circup example qwiic_gpio\qwiic_gpio_ex3b_inversion_port
86
109
```
110
+
87
111
Example Use
88
112
---------------
89
-
See the examples directory for more detailed use examples.
113
+
Below is a quickstart program to print readings from the GPIO.
114
+
115
+
See the examples directory for more detailed use examples and [examples/README.md](https://github.com/sparkfun/qwiic_gpio_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_gpio_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 Gpio Ex1A Write
7
+
This script sets up a GPIO 0 as an output and toggles
8
+
the output HIGH and LOW.
9
+
10
+
This device sinks current. When an output is LOW then current will flow.
11
+
12
+
## Qwiic Gpio Ex1B Write Port
13
+
This script flips all 8 outputs on and off every second.
14
+
15
+
## Qwiic Gpio Ex2A Read
16
+
This script allows the user to read a value from GPIO 0
0 commit comments