Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/build-deploy-ghpages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build Documentation and Deploy

on:
push:
branches:
- main
- micropython_fixes
workflow_dispatch:

permissions:
contents: read
id-token: write
pages: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: "true"

- name: Set Version
run: echo "PROJECT_NUMBER = `git describe --tags`" >> ./docs/doxygen/doxygen-config

- name: Build Documentation
uses: mattnotmitt/doxygen-action@v1.9.5
with:
doxyfile-path: "./docs/doxygen/doxygen-config"

# Upload the documentation as an artifact
- name: Upload documentation
uses: actions/upload-pages-artifact@v3.0.1
with:
path: ./docs/html

# Deploy job
deploy:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
208 changes: 126 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,166 @@
Qwiic_TCA9548A_Py
==============
![Qwiic TCA9548A - Python Package](docs/images/gh-banner.png "qwiic TCA9548A Python Package")

<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-tca9548a/" alt="Package">
<img src="https://img.shields.io/pypi/pyversions/sparkfun_qwiic_tca9548a.svg" /></a>
<a href="https://github.com/sparkfun/Qwiic_TCA9548A_Py/issues" alt="Issues">
<img src="https://img.shields.io/github/issues/sparkfun/Qwiic_TCA9548A_Py.svg" /></a>
<a href="https://qwiic-TCA9548A-py.readthedocs.io/en/latest/?" alt="Documentation">
<img src="https://readthedocs.org/projects/qwiic-tca9548a-py/badge/?version=latest&style=flat" /></a>
<a href="https://github.com/sparkfun/Qwiic_TCA9548A_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>
# SparkFun Qwiic TCA9548A - Python Package

<img src="https://cdn.sparkfun.com/assets/parts/1/5/6/8/9/16784-SparkFun_Qwiic_Mux_Breakout_V2_-_8_Channel__TCA9548A_-01.jpg" align="right" width=300 alt="SparkFun Qwiic Mux for the Raspberry Pi">
![PyPi Version](https://img.shields.io/pypi/v/sparkfun_qwiic_tca9548a)
![GitHub issues](https://img.shields.io/github/issues/sparkfun/qwiic_tca9548a_py)
![License](https://img.shields.io/github/license/sparkfun/qwiic_tca9548a_py)
![X](https://img.shields.io/twitter/follow/sparkfun)
[![API](https://img.shields.io/badge/API%20Reference-blue)](https://docs.sparkfun.com/qwiic_tca9548a_py/classqwiic__tca9548a_1_1_qwiic_t_c_a9548_a.html)

Python module for the [SparkFun Qwiic Mux Breakout - 8 Channel (TCA9548A)](https://www.sparkfun.com/products/16784).
The SparkFun Qwiic I2C Mux TCA9548A Module provides a simple and cost effective solution for adding I2C Mux 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.

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

## Contents
* [Supported Platforms](#supported-platforms)
* [Dependencies](#dependencies)
### Contents

* [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_tca9548a_py/classqwiic__tca9548a_1_1_qwiic_t_c_a9548_a.html)
* [Examples](#examples)

## About the Package

This python package enables the user to access the features of the TCA9548A via a single Qwiic cable. This includes enabling channels, disabling channels, listing channels, controlling multiple I2C devices with the same address and more. The capabilities of the TCA9548A 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 Platforms
--------------------
The qwiic TCA9548A Python package current supports the following platforms:
* [Raspberry Pi](https://www.sparkfun.com/search/results?term=raspberry+pi)
<!-- Platforms to be tested
* [NVidia Jetson Nano](https://www.sparkfun.com/products/15297)
* [Google Coral Development Board](https://www.sparkfun.com/products/15318)
-->
### Supported SparkFun Products

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

Documentation
-------------
The SparkFun qwiic TCA9548A module documentation is hosted at [ReadTheDocs](https://qwiic-tca9548a-py.readthedocs.io/en/latest/?)
* [SparkFun I2C Mux Sensor - TCA9548A](https://www.sparkfun.com/products/14685)

Installation
-------------
### Supported Platforms

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

For all users (note: the user must have sudo privileges):
> [!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.

## Installation

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.

### Python

#### PyPi Installation

The package is primarily installed using the `pip3` command, downloading the package from the Python Index - "PyPi".

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
sudo pip install sparkfun-qwiic-tca9548a
python3 -m venv path/to/venv
```
For the current user:
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-tca9548a
```
Now you should be able to run any example or custom python scripts that have `import qwiic_tca9548a` by running e.g.:
```sh
pip install sparkfun-qwiic-tca9548a
path/to/venv/bin/python3 example_script.py
```

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

Direct installation at the command line:
Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.
```sh
python setup.py install
mpremote mip install github:sparkfun/qwiic_tca9548a_py
```

To build a package for use with pip:
If you would also like to install the examples for this repository, issue the following mip command as well:
```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.
mpremote mip install github:sparkfun/qwiic_tca9548a_py@examples
```

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

Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.
```sh
circup bundle-add sparkfun/Qwiic_Py
```

Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.
```sh
circup install --py qwiic_tca9548a
```

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)

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

circup example qwiic_tca9548a\qwiic_tca9548a_ex1
circup example qwiic_tca9548a\qwiic_tca9548a_ex2
circup example qwiic_tca9548a\simple_disable_channels
circup example qwiic_tca9548a\simple_enable_channels
```

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

See the examples directory for more detailed use examples and [examples/README.md](https://github.com/sparkfun/qwiic_tca9548a_py/blob/main/examples/README.md) for a summary of the available examples.

```python


import qwiic_tca9548a
import qwiic_i2c
import time
import sys

def runExample():

print("\nSparkFun TCA9548A Example 1\n")
test = qwiic_tca9548a.QwiicTCA9548A()

if test.is_connected() == False:
print("The Qwiic TCA9548A device isn't connected to the system. Please check your connection", \
file=sys.stderr)
return

print("\nSparkFun TCA9548A 8-Channel Mux Example 1\n")

myTca = qwiic_tca9548a.QwiicTCA9548A()

if myTca.connected == False:
print("The Qwiic TCA9548A 8-Channel Mux device isn't connected to the system. Please check your connection", \
file=sys.stderr)
return

i2c = qwiic_i2c.getI2CDriver()

while True:
print("Enabling channels 0 and 1")
myTca.disable_all()
myTca.enable_channels([0,1])
myTca.list_channels()

print("Checking for i2c devices on ports 0 and 1")
devices = i2c.scan()
print("Devices found: ", devices)
time.sleep(2)

print("Enabling channels 2 and 3")
myTca.disable_all()
myTca.enable_channels([2,3])
myTca.list_channels()

print("Checking for i2c devices on ports 2 and 3")
devices = i2c.scan()
print("Devices found: ", devices)
time.sleep(2)

if __name__ == '__main__':
try:
test.list_channels()
time.sleep(2)

test.enable_channels([4,5])
test.list_channels()
time.sleep(2)

test.disable_channels(5)
test.list_channels()
time.sleep(2)
runExample()
except (KeyboardInterrupt, SystemExit) as exErr:
print("\nEnding Example 1")
sys.exit(0)

except Exception as e:
print(e)
```
<p align="center">
<img src="https://cdn.sparkfun.com/assets/custom_pages/3/3/4/dark-logo-red-flame.png" alt="SparkFun - Start Something">
Expand Down
5 changes: 0 additions & 5 deletions docs/apiref.rst

This file was deleted.

68 changes: 0 additions & 68 deletions docs/conf.py

This file was deleted.

Loading