Skip to content

Commit 62cca9f

Browse files
Merge branch 'feature/change_address'
2 parents 4b82741 + b1a8372 commit 62cca9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+10841
-397
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build Documentation and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- feature/change_address
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
id-token: write
13+
pages: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: true
18+
19+
jobs:
20+
# Build job
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
# Checkout the repository
25+
- name: Checkout repository
26+
uses: actions/checkout@v2
27+
with:
28+
fetch-depth: 0
29+
submodules: "true"
30+
31+
- name: Set Version
32+
run: echo "PROJECT_NUMBER = `git describe --tags`" >> ./docs/doxygen/doxygen-config
33+
34+
- name: Build Documentation
35+
uses: mattnotmitt/doxygen-action@v1.9.5
36+
with:
37+
doxyfile-path: "./docs/doxygen/doxygen-config"
38+
39+
# Upload the documentation as an artifact
40+
- name: Upload documentation
41+
uses: actions/upload-pages-artifact@v3.0.1
42+
with:
43+
path: ./docs/html
44+
45+
# Deploy job
46+
deploy:
47+
# Add a dependency to the build job
48+
needs: build
49+
50+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
51+
permissions:
52+
pages: write # to deploy to Pages
53+
id-token: write # to verify the deployment originates from an appropriate source
54+
55+
# Deploy to the github-pages environment
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
60+
# Specify runner + deployment step
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Deploy to GitHub Pages
64+
id: deployment
65+
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action

README.md

Lines changed: 99 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,145 @@
1-
Qwiic_Relay_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-relay/" alt="Package">
9-
<img src="https://img.shields.io/pypi/pyversions/sparkfun-qwiic-relay.svg" /></a>
10-
<a href="https://github.com/sparkfun/Qwiic_Relay_Py/issues" alt="Issues">
11-
<img src="https://img.shields.io/github/issues/sparkfun/Qwiic_Relay_Py.svg" /></a>
12-
<a href="https://sparkfun-qwiic-relay.readthedocs.io/en/latest/?" alt="Documentation">
13-
<img src="https://readthedocs.org/projects/sparkfun-qwiic-relay/badge/?version=latest&style=flat" /></a>
14-
<a href="https://github.com/sparkfun/Qwiic_Relay_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 RELAY - Python Package](docs/images/gh-banner.png "qwiic RELAY Python Package")
212

22-
<img src="https://cdn.sparkfun.com/assets/parts/1/5/7/5/4/16833-SparkFun_Qwiic_Quad_Solid_State_Relay_Kit-01.jpg" align="right" width=300 alt="SparkFun Qwiic Solid State Relay">
3+
# SparkFun Qwiic RELAY - Python Package
234

24-
Python module for the Qwiic Relays, Listed below
25-
* [SparkFun Qwiic Single Relay](https://www.sparkfun.com/products/15093)
26-
* [SparkFun Qwiic Quad Relay](https://www.sparkfun.com/products/15102)
27-
* [SparkFun Qwiic Quad Solid State Relay](https://www.sparkfun.com/products/16833)
28-
* [SparkFun Qwiic Dual Solid State Relay](https://www.sparkfun.com/products/16810)
5+
![PyPi Version](https://img.shields.io/pypi/v/sparkfun_qwiic_relay)
6+
![GitHub issues](https://img.shields.io/github/issues/sparkfun/qwiic_relay_py)
7+
![License](https://img.shields.io/github/license/sparkfun/qwiic_relay_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_relay_py/classqwiic__relay_1_1_qwiic_relay.html)
2910

30-
This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)
11+
The SparkFun Qwiic Relay RELAY Module provides a simple and cost effective solution for adding Relay 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.
3112

32-
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 RELAY. This package works with Python, MicroPython and CircuitPython.
3314

34-
## Contents
15+
### Contents
3516

36-
* [Supported Platforms](#supported-platforms)
37-
* [Dependencies](#dependencies)
17+
* [About](#about-the-package)
18+
* [Getting Started](#getting-started)
3819
* [Installation](#installation)
39-
* [Documentation](#documentation)
40-
* [Example Use](#example-use)
20+
* [Supported Platforms](#supported-platforms)
21+
* [Documentation](https://docs.sparkfun.com/qwiic_relay_py/classqwiic__relay_1_1_qwiic_relay.html)
22+
* [Examples](#examples)
23+
24+
## About the Package
25+
26+
This python package enables the user to access the features of the RELAY via a single Qwiic cable. This includes setting relay state, reading relay state, set slow PWM value and more. The capabilities of the RELAY 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).
4129

42-
Supported Platforms
43-
--------------------
44-
The Qwiic Relay Python package current supports the following platforms:
45-
* [Raspberry Pi](https://www.sparkfun.com/search/results?term=raspberry+pi)
30+
### Supported SparkFun Products
4631

47-
Dependencies
48-
---------------
49-
This driver package depends on the qwiic I2C driver:
50-
[Qwiic_I2C_Py](https://github.com/sparkfun/Qwiic_I2C_Py)
32+
This Python package supports the following SparkFun qwiic products on Python, MicroPython and Circuit python.
5133

52-
Documentation
53-
-------------
54-
The SparkFun Qwiic Relay module documentation is hosted at [ReadTheDocs](https://sparkfun-qwiic-relay.readthedocs.io/en/latest/?)
34+
* [SparkFun Relay Sensor - RELAY](http://www.sparkfun.com/qwiic)
5535

56-
Installation
57-
-------------
36+
### Supported Platforms
5837

59-
### PyPi Installation
60-
This repository is hosted on PyPi as the [sparkfun-qwiic-relay](https://pypi.org/project/sparkfun-qwiic-relay/) package. On systems that support PyPi installation via pip, this library is installed using the following commands
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)
6143

62-
For all users (note: the user must have sudo privileges):
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.
46+
47+
## Installation
48+
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:
6360
```sh
64-
sudo pip install sparkfun-qwiic-relay
61+
python3 -m venv path/to/venv
6562
```
66-
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).
6764

65+
Next, install the qwiic package with:
6866
```sh
69-
pip install sparkfun-qwiic-relay
67+
path/to/venv/bin/pip3 install sparkfun-qwiic-relay
68+
```
69+
Now you should be able to run any example or custom python scripts that have `import qwiic_relay` by running e.g.:
70+
```sh
71+
path/to/venv/bin/python3 example_script.py
7072
```
7173

72-
### Local Installation
73-
To install, make sure the `setuptools` package is installed on the system.
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.
7476

75-
Direct installation at the command line:
77+
Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.
7678
```sh
77-
python setup.py install
79+
mpremote mip install github:sparkfun/qwiic_relay_py
7880
```
7981

80-
To build a package for use with pip:
82+
If you would also like to install the examples for this repository, issue the following mip command as well:
8183
```sh
82-
python setup.py sdist
83-
```
84-
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
84+
mpremote mip install --target "" github:sparkfun/qwiic_relay_py@examples
85+
```
86+
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.
89+
90+
Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
91+
```sh
92+
circup bundle-add sparkfun/Qwiic_Py
93+
```
94+
95+
Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.
8596
```sh
86-
cd dist
87-
pip install sparkfun_qwiic_relay-<version>.tar.gz
88-
97+
circup install --py qwiic_relay
8998
```
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. 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+
102+
```sh
103+
circup example qwiic_relay\qwiic_relay_ex1_single
104+
circup example qwiic_relay\qwiic_relay_ex2_dual
105+
circup example qwiic_relay\qwiic_relay_ex3_quad
106+
circup example qwiic_relay\qwiic_relay_ex4_pwm
107+
```
108+
90109
Example Use
91110
---------------
92-
See the examples directory for more detailed use examples.
111+
Below is a quickstart program to print readings from the RELAY.
112+
113+
See the examples directory for more detailed use examples and [examples/README.md](https://github.com/sparkfun/qwiic_relay_py/blob/main/examples/README.md) for a summary of the available examples.
93114

94115
```python
95-
from __future__ import print_function
116+
96117
import qwiic_relay
97118
import time
98119
import sys
99120

100-
myRelays = qwiic_relay.QwiicRelay()
121+
myRelay = qwiic_relay.QwiicRelay(qwiic_relay.SINGLE_RELAY_DEFUALT_ADDR)
101122

102123
def runExample():
124+
print("\nSparkFun Qwiic Relay Example 1 - Single\n")
103125

104-
print("\nSparkFun Qwiic Relay Example 1\n")
105-
106-
if myRelays.begin() == False:
126+
if myRelay.begin() == False:
107127
print("The Qwiic Relay isn't connected to the system. Please check your connection", \
108128
file=sys.stderr)
109129
return
110130

111-
#Turn on relays one and three
112-
myRelays.set_relay_on(1)
113-
myRelays.set_relay_on(3)
114-
time.sleep(1)
115-
116-
#Print the status of all relays
117-
for relayNum in range(4):
118-
current_status = None
119-
if myRelays.get_relay_state(relayNum) is True:
120-
current_status = "On"
121-
else:
122-
current_status = "Off"
123-
print("Status 1: " + current_status + "\n")
124-
125-
#Turn off 1 and 3, turn on 2 and 4
126-
myRelays.set_relay_off(1)
127-
myRelays.set_relay_on(2)
128-
myRelays.set_relay_off(3)
129-
myRelays.set_relay_on(4)
130-
time.sleep(1)
131-
131+
for i in range(2):
132+
myRelay.set_relay_on()
132133

133-
#Turn all relays on, then turn them all off
134-
myRelays.set_all_relays_on()
135-
time.sleep(1)
136-
137-
myRelays.set_all_relays_off()
138-
134+
print("Relay state: " + str(myRelay.get_relay_state()))
135+
136+
time.sleep(1)
137+
138+
myRelay.set_relay_off()
139+
140+
print("Relay state: " + str(myRelay.get_relay_state()))
139141

142+
time.sleep(1)
140143

141144
if __name__ == '__main__':
142145
try:

docs/apiref.rst

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

docs/conf.py

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

0 commit comments

Comments
 (0)