Skip to content

Commit

Permalink
Autogenerated. Convert PyPi packaging and add Readme Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolm-sparkfun committed Feb 4, 2025
1 parent 2a4c828 commit 8a359aa
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 196 deletions.
184 changes: 92 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,121 @@
Qwiic_GPIO_Py
==================
<p align="center">
<img src="https://cdn.sparkfun.com/assets/custom_pages/2/7/2/qwiic-logo-registered.jpg" width=200>
<img src="https://www.python.org/static/community_logos/python-logo-master-v3-TM.png" width=240>
</p>
<p align="center">
<a href="https://pypi.org/project/sparkfun-qwiic-gpio/" alt="Package">
<img src="https://img.shields.io/pypi/pyversions/sparkfun-qwiic-gpio.svg" /></a>
<a href="https://github.com/sparkfun/Qwiic_GPIO_Py/issues" alt="Issues">
<img src="https://img.shields.io/github/issues/sparkfun/Qwiic_GPIO_Py.svg" /></a>
<a href="https://sparkfun-qwiic-gpio.readthedocs.io/en/latest/?" alt="Documentation">
<img src="https://readthedocs.org/projects/sparkfun-qwiic-gpio/badge/?version=latest&style=flat" /></a>
<a href="https://github.com/sparkfun/Qwiic_GPIO_Py/blob/master/LICENSE" alt="License">
<img src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
<a href="https://twitter.com/intent/follow?screen_name=sparkfun">
<img src="https://img.shields.io/twitter/follow/sparkfun.svg?style=social&logo=twitter"
alt="follow on Twitter"></a>

</p>
![Qwiic GPIO - Python Package](docs/images/gh-banner.png "qwiic GPIO Python Package")

<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">
# SparkFun Qwiic GPIO - Python Package

Python module for the Qwiic GPIO
* [SparkFun Qwiic GPIO](https://www.sparkfun.com/products/17047)
![PyPi Version](https://img.shields.io/pypi/v/sparkfun_qwiic_gpio)
![GitHub issues](https://img.shields.io/github/issues/sparkfun/qwiic_gpio_py)
![License](https://img.shields.io/github/license/sparkfun/qwiic_gpio_py)
![X](https://img.shields.io/twitter/follow/sparkfun)
[![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)

This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
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.

New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).
This repository implements a Python package for the SparkFun Qwiic GPIO. This package works with Python, MicroPython and CircuitPython.

## Contents
### Contents

* [Supported Platforms](#supported-platforms)
* [Dependencies](#dependencies)
* [About](#about-the-package)
* [Getting Started](#getting-started)
* [Installation](#installation)
* [Documentation](#documentation)
* [Example Use](#example-use)
* [Supported Platforms](#supported-platforms)
* [Documentation](https://docs.sparkfun.com/qwiic_gpio_py/classqwiic__gpio_1_1_qwiic_g_p_i_o.html)
* [Examples](#examples)

## About the Package

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.

New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).

### Supported SparkFun Products

This Python package supports the following SparkFun qwiic products on Python, MicroPython and Circuit python.

* [SparkFun GPIO Expander Sensor - GPIO](http://www.sparkfun.com/qwiic)

### Supported Platforms

| Python | Platform | Boards |
|--|--|--|
| 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) |
| 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)
|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)

> [!NOTE]
> 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.
Supported Platforms
--------------------
The Qwiic GPIO Python package current supports the following platforms:
* [Raspberry Pi](https://www.sparkfun.com/search/results?term=raspberry+pi)
## Installation

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

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

Installation
-------------
#### PyPi Installation

### PyPi Installation
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
The package is primarily installed using the `pip3` command, downloading the package from the Python Index - "PyPi".

For all users (note: the user must have sudo privileges):
Note - the below instructions outline installation on a Linux-based (Raspberry Pi) system.

First, setup a virtual environment from a specific directory using venv:
```sh
python3 -m venv path/to/venv
```
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).

Next, install the qwiic package with:
```sh
path/to/venv/bin/pip3 install sparkfun-qwiic-gpio
```
Now you should be able to run any example or custom python scripts that have `import qwiic_gpio` by running e.g.:
```sh
path/to/venv/bin/python3 example_script.py
```

### MicroPython Installation
If not already installed, follow the [instructions here](https://docs.micropython.org/en/latest/reference/mpremote.html) to install mpremote on your computer.

Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.
```sh
sudo pip install sparkfun-qwiic-gpio
mpremote mip install github:sparkfun/qwiic_gpio_py
```
For the current user:

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

### Local Installation
To install, make sure the setuptools package is installed on the system.
### CircuitPython Installation
If not already installed, follow the [instructions here](https://docs.circuitpython.org/projects/circup/en/latest/#installation) to install CircUp on your computer.

Direct installation at the command line:
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
```sh
python setup.py install
circup bundle-add sparkfun/Qwiic_Py
```

To build a package for use with pip:
Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.
```sh
python setup.py sdist
```
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
circup install --py qwiic_gpio
```

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)

```sh
cd dist
pip install sparkfun_qwiic_gpio-<version>.tar.gz

circup example qwiic_gpio\qwiic_gpio_ex1a_write
circup example qwiic_gpio\qwiic_gpio_ex1b_write_port
circup example qwiic_gpio\qwiic_gpio_ex2a_read
circup example qwiic_gpio\qwiic_gpio_ex2b_read_port
circup example qwiic_gpio\qwiic_gpio_ex3a_inversion
circup example qwiic_gpio\qwiic_gpio_ex3b_inversion_port
```

Example Use
---------------
See the examples directory for more detailed use examples.
Below is a quickstart program to print readings from the GPIO.

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.

```python

from __future__ import print_function
import qwiic_gpio
import time
import sys
Expand All @@ -106,41 +131,16 @@ def runExample():
return

myGPIO.begin()
myGPIO.mode_0 = myGPIO.GPIO_OUT
myGPIO.mode_1 = myGPIO.GPIO_OUT
myGPIO.mode_2 = myGPIO.GPIO_OUT
myGPIO.mode_3 = myGPIO.GPIO_OUT
myGPIO.mode_4 = myGPIO.GPIO_OUT
myGPIO.mode_5 = myGPIO.GPIO_OUT
myGPIO.mode_6 = myGPIO.GPIO_OUT
myGPIO.mode_7 = myGPIO.GPIO_OUT
myGPIO.setMode()
myGPIO.pinMode(0, myGPIO.GPIO_OUT)

while True:
myGPIO.out_status_0 = myGPIO.GPIO_HI
myGPIO.out_status_1 = myGPIO.GPIO_HI
myGPIO.out_status_2 = myGPIO.GPIO_HI
myGPIO.out_status_3 = myGPIO.GPIO_HI
myGPIO.out_status_4 = myGPIO.GPIO_HI
myGPIO.out_status_5 = myGPIO.GPIO_HI
myGPIO.out_status_6 = myGPIO.GPIO_HI
myGPIO.out_status_7 = myGPIO.GPIO_HI
myGPIO.setGPIO()
print("set hi")
myGPIO.digitalWrite(0, myGPIO.GPIO_HI)
print("set pin 0 hi!")
time.sleep(1)
myGPIO.out_status_0 = myGPIO.GPIO_LO
myGPIO.out_status_1 = myGPIO.GPIO_LO
myGPIO.out_status_2 = myGPIO.GPIO_LO
myGPIO.out_status_3 = myGPIO.GPIO_LO
myGPIO.out_status_4 = myGPIO.GPIO_LO
myGPIO.out_status_5 = myGPIO.GPIO_LO
myGPIO.out_status_6 = myGPIO.GPIO_LO
myGPIO.out_status_7 = myGPIO.GPIO_LO
myGPIO.setGPIO()
print("set lo")
myGPIO.digitalWrite(0, myGPIO.GPIO_LO)
print("set pin 0 lo!")
time.sleep(1)


if __name__ == '__main__':
try:
runExample()
Expand Down
Binary file added docs/images/gh-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Sparkfun GPIO Examples Reference
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).

NOTE: Any numbering of examples is to retain consistency with the Arduino library from which this was ported.

## Qwiic Gpio Ex1A Write
This script sets up a GPIO 0 as an output and toggles
the output HIGH and LOW.

This device sinks current. When an output is LOW then current will flow.

## Qwiic Gpio Ex1B Write Port
This script flips all 8 outputs on and off every second.

## Qwiic Gpio Ex2A Read
This script allows the user to read a value from GPIO 0
------------------------------------------------------------------------

## Qwiic Gpio Ex2B Read Port
This script allows the user to read the status of all 8 GPIO simultaneously
------------------------------------------------------------------------

## Qwiic Gpio Ex3A Inversion
This script shows how to invert the input signal on a pin
------------------------------------------------------------------------

## Qwiic Gpio Ex3B Inversion Port
This script shows how to invert the input signal on multiple pins
------------------------------------------------------------------------


49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[build-system]
requires = ["setuptools"]

[project]
name = "sparkfun_qwiic_gpio"
version = "0.0.2"
description = long_description
readme = "DESCRIPTION.rst"

authors = [{name="Sparkfun Electronics", email="info@sparkfun.com"}]
dependencies = ["sparkfun_qwiic_i2c"]

classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 5 - Production/Stable",

# Indicate who your project is intended for
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",

# Pick your license as you wish (should match "license" above)
"License :: OSI Approved :: MIT License",

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: MicroPython",
# NOTE: CircuitPython is also supported, but no classifier exists for it
]

keywords = ["electronics, maker"]

[project.urls]
homepage = "http://www.sparkfun.com/qwiic"

[tool.setuptools]
py-modules = ["qwiic_gpio"]
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 8a359aa

Please sign in to comment.