Skip to content

Commit 8a359aa

Browse files
Autogenerated. Convert PyPi packaging and add Readme Updates
1 parent 2a4c828 commit 8a359aa

File tree

6 files changed

+172
-196
lines changed

6 files changed

+172
-196
lines changed

README.md

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,121 @@
1-
Qwiic_GPIO_Py
2-
==================
3-
<p align="center">
4-
<img src="https://cdn.sparkfun.com/assets/custom_pages/2/7/2/qwiic-logo-registered.jpg" width=200>
5-
<img src="https://www.python.org/static/community_logos/python-logo-master-v3-TM.png" width=240>
6-
</p>
7-
<p align="center">
8-
<a href="https://pypi.org/project/sparkfun-qwiic-gpio/" alt="Package">
9-
<img src="https://img.shields.io/pypi/pyversions/sparkfun-qwiic-gpio.svg" /></a>
10-
<a href="https://github.com/sparkfun/Qwiic_GPIO_Py/issues" alt="Issues">
11-
<img src="https://img.shields.io/github/issues/sparkfun/Qwiic_GPIO_Py.svg" /></a>
12-
<a href="https://sparkfun-qwiic-gpio.readthedocs.io/en/latest/?" alt="Documentation">
13-
<img src="https://readthedocs.org/projects/sparkfun-qwiic-gpio/badge/?version=latest&style=flat" /></a>
14-
<a href="https://github.com/sparkfun/Qwiic_GPIO_Py/blob/master/LICENSE" alt="License">
15-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
16-
<a href="https://twitter.com/intent/follow?screen_name=sparkfun">
17-
<img src="https://img.shields.io/twitter/follow/sparkfun.svg?style=social&logo=twitter"
18-
alt="follow on Twitter"></a>
19-
20-
</p>
1+
![Qwiic GPIO - Python Package](docs/images/gh-banner.png "qwiic GPIO Python Package")
212

22-
<img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/5/9/9/3/17047-SparkFun_Qwiic_GPIO-01.jpg" align="right" width=300 alt="SparkFun Qwiic GPIO">
3+
# SparkFun Qwiic GPIO - Python Package
234

24-
Python module for the Qwiic GPIO
25-
* [SparkFun Qwiic GPIO](https://www.sparkfun.com/products/17047)
5+
![PyPi Version](https://img.shields.io/pypi/v/sparkfun_qwiic_gpio)
6+
![GitHub issues](https://img.shields.io/github/issues/sparkfun/qwiic_gpio_py)
7+
![License](https://img.shields.io/github/license/sparkfun/qwiic_gpio_py)
8+
![X](https://img.shields.io/twitter/follow/sparkfun)
9+
[![API](https://img.shields.io/badge/API%20Reference-blue)](https://docs.sparkfun.com/qwiic_gpio_py/classqwiic__gpio_1_1_qwiic_g_p_i_o.html)
2610

27-
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.
2812

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.
3014

31-
## Contents
15+
### Contents
3216

33-
* [Supported Platforms](#supported-platforms)
34-
* [Dependencies](#dependencies)
17+
* [About](#about-the-package)
18+
* [Getting Started](#getting-started)
3519
* [Installation](#installation)
36-
* [Documentation](#documentation)
37-
* [Example Use](#example-use)
20+
* [Supported Platforms](#supported-platforms)
21+
* [Documentation](https://docs.sparkfun.com/qwiic_gpio_py/classqwiic__gpio_1_1_qwiic_g_p_i_o.html)
22+
* [Examples](#examples)
23+
24+
## About the Package
25+
26+
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.
33+
34+
* [SparkFun GPIO Expander Sensor - GPIO](http://www.sparkfun.com/qwiic)
35+
36+
### Supported Platforms
37+
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) |
41+
| MicroPython | Raspberry Pi - RP2, ESP32 | [SparkFun RP2040 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2040.html), [SparkFun RP2350 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2350.html), [SparkFun ESP32 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-esp32-wroom-usb-c.html)
42+
|CircuitPython | Raspberry Pi - RP2, ESP32 | [SparkFun RP2040 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2040.html), [SparkFun RP2350 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-rp2350.html), [SparkFun ESP32 Thing+](https://www.sparkfun.com/sparkfun-thing-plus-esp32-wroom-usb-c.html)
43+
44+
> [!NOTE]
45+
> 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.
3846
39-
Supported Platforms
40-
--------------------
41-
The Qwiic GPIO Python package current supports the following platforms:
42-
* [Raspberry Pi](https://www.sparkfun.com/search/results?term=raspberry+pi)
47+
## Installation
4348

44-
Dependencies
45-
---------------
46-
This driver package depends on the qwiic I2C driver:
47-
[Qwiic_I2C_Py](https://github.com/sparkfun/Qwiic_I2C_Py)
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.
4850

49-
Documentation
50-
-------------
51-
The SparkFun Qwiic GPIO module documentation is hosted at [ReadTheDocs](https://sparkfun-qwiic-gpio.readthedocs.io/en/latest/?)
51+
### Python
5252

53-
Installation
54-
-------------
53+
#### PyPi Installation
5554

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".
5856

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.
6078
```sh
61-
sudo pip install sparkfun-qwiic-gpio
79+
mpremote mip install github:sparkfun/qwiic_gpio_py
6280
```
63-
For the current user:
6481

82+
If you would also like to install the examples for this repository, issue the following mip command as well:
6583
```sh
66-
pip install sparkfun-qwiic-gpio
84+
mprmeote mip install github:sparkfun/qwiic_gpio_py@examples
6785
```
6886

69-
### Local Installation
70-
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.
7189

72-
Direct installation at the command line:
90+
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
7391
```sh
74-
python setup.py install
92+
circup bundle-add sparkfun/Qwiic_Py
7593
```
7694

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.
7896
```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+
82102
```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
86109
```
110+
87111
Example Use
88112
---------------
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.
90116

91117
```python
92118

93-
from __future__ import print_function
94119
import qwiic_gpio
95120
import time
96121
import sys
@@ -106,41 +131,16 @@ def runExample():
106131
return
107132

108133
myGPIO.begin()
109-
myGPIO.mode_0 = myGPIO.GPIO_OUT
110-
myGPIO.mode_1 = myGPIO.GPIO_OUT
111-
myGPIO.mode_2 = myGPIO.GPIO_OUT
112-
myGPIO.mode_3 = myGPIO.GPIO_OUT
113-
myGPIO.mode_4 = myGPIO.GPIO_OUT
114-
myGPIO.mode_5 = myGPIO.GPIO_OUT
115-
myGPIO.mode_6 = myGPIO.GPIO_OUT
116-
myGPIO.mode_7 = myGPIO.GPIO_OUT
117-
myGPIO.setMode()
134+
myGPIO.pinMode(0, myGPIO.GPIO_OUT)
118135

119136
while True:
120-
myGPIO.out_status_0 = myGPIO.GPIO_HI
121-
myGPIO.out_status_1 = myGPIO.GPIO_HI
122-
myGPIO.out_status_2 = myGPIO.GPIO_HI
123-
myGPIO.out_status_3 = myGPIO.GPIO_HI
124-
myGPIO.out_status_4 = myGPIO.GPIO_HI
125-
myGPIO.out_status_5 = myGPIO.GPIO_HI
126-
myGPIO.out_status_6 = myGPIO.GPIO_HI
127-
myGPIO.out_status_7 = myGPIO.GPIO_HI
128-
myGPIO.setGPIO()
129-
print("set hi")
137+
myGPIO.digitalWrite(0, myGPIO.GPIO_HI)
138+
print("set pin 0 hi!")
130139
time.sleep(1)
131-
myGPIO.out_status_0 = myGPIO.GPIO_LO
132-
myGPIO.out_status_1 = myGPIO.GPIO_LO
133-
myGPIO.out_status_2 = myGPIO.GPIO_LO
134-
myGPIO.out_status_3 = myGPIO.GPIO_LO
135-
myGPIO.out_status_4 = myGPIO.GPIO_LO
136-
myGPIO.out_status_5 = myGPIO.GPIO_LO
137-
myGPIO.out_status_6 = myGPIO.GPIO_LO
138-
myGPIO.out_status_7 = myGPIO.GPIO_LO
139-
myGPIO.setGPIO()
140-
print("set lo")
140+
myGPIO.digitalWrite(0, myGPIO.GPIO_LO)
141+
print("set pin 0 lo!")
141142
time.sleep(1)
142143

143-
144144
if __name__ == '__main__':
145145
try:
146146
runExample()

docs/images/gh-banner.png

667 KB
Loading

examples/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Sparkfun GPIO Examples Reference
2+
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
17+
------------------------------------------------------------------------
18+
19+
## Qwiic Gpio Ex2B Read Port
20+
This script allows the user to read the status of all 8 GPIO simultaneously
21+
------------------------------------------------------------------------
22+
23+
## Qwiic Gpio Ex3A Inversion
24+
This script shows how to invert the input signal on a pin
25+
------------------------------------------------------------------------
26+
27+
## Qwiic Gpio Ex3B Inversion Port
28+
This script shows how to invert the input signal on multiple pins
29+
------------------------------------------------------------------------
30+
31+

pyproject.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
4+
[project]
5+
name = "sparkfun_qwiic_gpio"
6+
version = "0.0.2"
7+
description = long_description
8+
readme = "DESCRIPTION.rst"
9+
10+
authors = [{name="Sparkfun Electronics", email="info@sparkfun.com"}]
11+
dependencies = ["sparkfun_qwiic_i2c"]
12+
13+
classifiers=[
14+
# How mature is this project? Common values are
15+
# 3 - Alpha
16+
# 4 - Beta
17+
# 5 - Production/Stable
18+
"Development Status :: 5 - Production/Stable",
19+
20+
# Indicate who your project is intended for
21+
"Intended Audience :: Developers",
22+
"Topic :: Software Development :: Build Tools",
23+
24+
# Pick your license as you wish (should match "license" above)
25+
"License :: OSI Approved :: MIT License",
26+
27+
# Specify the Python versions you support here. In particular, ensure
28+
# that you indicate whether you support Python 2, Python 3 or both.
29+
"Programming Language :: Python :: 3.5",
30+
"Programming Language :: Python :: 3.6",
31+
"Programming Language :: Python :: 3.7",
32+
"Programming Language :: Python :: 3.8",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
38+
"Programming Language :: Python :: 3.14",
39+
"Programming Language :: Python :: Implementation :: MicroPython",
40+
# NOTE: CircuitPython is also supported, but no classifier exists for it
41+
]
42+
43+
keywords = ["electronics, maker"]
44+
45+
[project.urls]
46+
homepage = "http://www.sparkfun.com/qwiic"
47+
48+
[tool.setuptools]
49+
py-modules = ["qwiic_gpio"]

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)