Skip to content
Open
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
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Build (Python ${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

env:
TERM: xterm-256color
RELEASE_FILE: ${{ github.event.repository.name }}-${{ github.event.release.tag_name || github.sha }}-py${{ matrix.python }}

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install Dependencies
run: |
make dev-deps

- name: Build Packages
run: |
make build

- name: Upload Packages
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_FILE }}
path: dist/
40 changes: 40 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Install Test

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Install (Python ${{ matrix.python }})
runs-on: ubuntu-latest
env:
TERM: xterm-256color
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Stub files & Patch install.sh
run: |
mkdir -p boot/firmware
touch boot/firmware/config.txt
sed -i "s|/boot/firmware|`pwd`/boot/firmware|g" install.sh
sed -i "s|sudo raspi-config|raspi-config|g" pyproject.toml
touch raspi-config
chmod +x raspi-config
echo `pwd` >> $GITHUB_PATH

- name: Run install.sh
run: |
./install.sh --unstable --force
39 changes: 39 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: QA

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Linting & Spelling
runs-on: ubuntu-latest
env:
TERM: xterm-256color

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python '3,11'
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install Dependencies
run: |
make dev-deps

- name: Run Quality Assurance
run: |
make qa

- name: Run Code Checks
run: |
make check

- name: Run Bash Code Checks
run: |
make shellcheck
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tests

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Test (Python ${{ matrix.python }})
runs-on: ubuntu-latest
env:
TERM: xterm-256color
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install Dependencies
run: |
make dev-deps

- name: Run Tests
run: |
make pytest

- name: Coverage
if: ${{ matrix.python == '3.9' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python -m pip install coveralls
coveralls --service=github

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ __pycache__
*.orig.*
packaging/*tar.xz
library/debian/
.coverage
.pytest_cache
.tox
6 changes: 6 additions & 0 deletions library/CHANGELOG.txt → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.0.0
-----

* Repackage to Pi 5 / Bookworm compatibility
* Switch from smbus to smbus2

0.0.6
-----

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Pimoroni Ltd.
Copyright (c) 2023 Pimoroni Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
LIBRARY_NAME := $(shell hatch project metadata name 2>&1)
LIBRARY_VERSION := $(shell hatch version 2>&1)

.PHONY: usage install uninstall check pytest qa build-deps check tag wheel sdist clean dist testdeploy deploy
usage:
ifdef LIBRARY_NAME
@echo "Library: ${LIBRARY_NAME}"
@echo "Version: ${LIBRARY_VERSION}\n"
else
@echo "WARNING: You should 'make dev-deps'\n"
endif
@echo "Usage: make <target>, where target is one of:\n"
@echo "install: install the library locally from source"
@echo "uninstall: uninstall the local library"
@echo "dev-deps: install Python dev dependencies"
@echo "check: perform basic integrity checks on the codebase"
@echo "qa: run linting and package QA"
@echo "pytest: run Python test fixtures"
@echo "clean: clean Python build and dist directories"
@echo "build: build Python distribution files"
@echo "testdeploy: build and upload to test PyPi"
@echo "deploy: build and upload to PyPi"
@echo "tag: tag the repository with the current version\n"

version:
@hatch version

install:
./install.sh --unstable

uninstall:
./uninstall.sh

dev-deps:
python3 -m pip install -r requirements-dev.txt
sudo apt install dos2unix shellcheck

check:
@bash check.sh

shellcheck:
shellcheck *.sh

qa:
tox -e qa

pytest:
tox -e py

nopost:
@bash check.sh --nopost

tag: version
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"

build: check
@hatch build

clean:
-rm -r dist

testdeploy: build
twine upload --repository testpypi dist/*

deploy: nopost build
twine upload dist/*
59 changes: 39 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,69 @@
# Pan-Tilt HAT

[![Build Status](https://img.shields.io/github/actions/workflow/status/pimoroni/pantilthat-python/test.yml?branch=main)](https://github.com/pimoroni/pantilthat-python/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/pantilthat-python/badge.svg?branch=main)](https://coveralls.io/github/pimoroni/pantilthat-python?branch=main)
[![PyPi Package](https://img.shields.io/pypi/v/pantilthat.svg)](https://pypi.python.org/pypi/pantilthat)
[![Python Versions](https://img.shields.io/pypi/pyversions/pantilthat.svg)](https://pypi.python.org/pypi/pantilthat)


https://shop.pimoroni.com/products/pan-tilt-hat

Pan-Tilt HAT is a two-channel servo driver designed to control a tiny servo-powered Pan/Tilt assembly. It also controls either PWM-dimmed lights or WS2812 pixels; up to 24 RGB or 18 RGBW.

## Installing
# Installing

We'd recommend using this library with Raspberry Pi OS Bookworm or later. It requires Python ≥3.7.

### Full install (recommended):
## Full install (recommended):

We've created an easy installation script that will install all pre-requisites and get your Pan-Tilt HAT
up and running with minimal efforts. To run it, fire up Terminal which you'll find in Menu -> Accessories -> Terminal
We've created an easy installation script that will install all pre-requisites and get you up and running with minimal efforts. To run it, fire up Terminal which you'll find in Menu -> Accessories -> Terminal
on your Raspberry Pi desktop, as illustrated below:

![Finding the terminal](http://get.pimoroni.com/resources/github-repo-terminal.png)

In the new terminal window type the command exactly as it appears below (check for typos) and follow the on-screen instructions:
In the new terminal window type the commands exactly as it appears below (check for typos) and follow the on-screen instructions:

```bash
curl https://get.pimoroni.com/pantilthat | bash
git clone https://github.com/pimoroni/pantilthat-python
cd pantilthat-python
./install.sh
```

### Manual install:
**Note** Libraries will be installed in the "pimoroni" virtual environment, you will need to activate it to run examples:

Enable i2c:

```bash
sudo raspi-config nonint do_i2c 0
```
source ~/.virtualenvs/pimoroni/bin/activate
```

Install the library:
## Development:

If you want to contribute, or like living on the edge of your seat by having the latest code, you can install the development version like so:

```bash
python3 -m pip install pantilthat
git clone https://github.com/pimoroni/pantilthat-python
cd pantilthat-python
./install.sh --unstable
```

ℹ️ Depending on your system, you might need to use `sudo` for the above command.
## Install stable library from PyPi and configure manually

* Set up a virtual environment: `python3 -m venv --system-site-packages $HOME/.virtualenvs/pimoroni`
* Switch to the virtual environment: `source ~/.virtualenvs/pimoroni/bin/activate`
* Install the library: `pip install pantilthat`

In some cases you may need to us `sudo` or install pip with: `sudo apt install python3-pip`.

### Development:
This will not make any configuration changes, so you may also need to enable:

If you want to contribute, or like living on the edge of your seat by having the latest code, you should clone this repository, `cd` to the library directory, and run:
* i2c: `sudo raspi-config nonint do_i2c 0`

You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configuration UI to enable interfaces.

Some of the examples have additional dependencies. You can install them with:

```bash
sudo python3 setup.py install
pip install -r requirements-examples.txt
```
(or `sudo python setup.py install` whichever your primary Python environment may be)

In all cases you will have to enable the i2c bus.

## Breakout Header Pinout

Expand Down
Loading