Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to gpiod for Bookworm/Pi 5 and beyond #182

Merged
merged 27 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
11fb4fe
Repackage to hatch/pyproject.toml.
Gadgetoid Nov 20, 2023
de42fb4
QA: Apply isort suggestions.
Gadgetoid Nov 20, 2023
faa14c8
QA: Apply ruff suggestions.
Gadgetoid Nov 20, 2023
624ca6e
QA: Apply codespell suggestions.
Gadgetoid Nov 20, 2023
0865247
Packaging: Add pillow as an example dependency.
Gadgetoid Nov 20, 2023
fe70476
Add resolution parameter to InkyMockImpression.
corranwebster Nov 20, 2023
b8635c0
QA: Apply cherry-picked Black suggestions.
Gadgetoid Nov 20, 2023
532e306
QA: Examples: Apply cherry-picked Black suggestions.
Gadgetoid Nov 20, 2023
88b8ea8
Begin port to gpiod.
Gadgetoid Nov 21, 2023
4feb1e4
Add auto dither to what.
Gadgetoid Nov 21, 2023
e5ab9ee
Sync with boilerplate.
Gadgetoid Jan 11, 2024
0fb414a
Inky 7.3: port to gpiod.
Gadgetoid Feb 6, 2024
b14439a
Packaging: Add dependencies and setup commands.
Gadgetoid Feb 6, 2024
f1eebde
QA: Fix tests.
Gadgetoid Feb 6, 2024
70d8d22
All: Always use software CS.
Gadgetoid Feb 6, 2024
cd66f78
Inky: Fix SPI CS, normalise image conversion.
Gadgetoid Feb 7, 2024
841bffa
Packaging: Add pillow as a dependency.
Gadgetoid Feb 7, 2024
a6f270a
QA: Include gpiod/gpiodevice mocks in auto tests.
Gadgetoid Feb 7, 2024
ffcc67a
All: Revert to using line numbers.
Gadgetoid Feb 7, 2024
caac90e
Sync with boilerplate.
Gadgetoid Jun 27, 2024
99ac046
Packaging: add example requirements file.
Gadgetoid Jun 27, 2024
47d6aaf
CI: Test install.
Gadgetoid Jun 27, 2024
bd6bf4c
CI: Sync with boilerplate for cleaned up names.
Gadgetoid Jun 27, 2024
113285e
Update README.md
helgibbons Jun 27, 2024
87b48d0
Add tests for set_image.
Gadgetoid Apr 10, 2024
0135ce3
Inky: remove unecessary canvas paste.
Gadgetoid Apr 10, 2024
85e868b
CI: Fix duplicate ENV in build.yml.
Gadgetoid Sep 6, 2024
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
2 changes: 1 addition & 1 deletion library/.coveragerc → .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source = inky
omit =
.tox/*
relative_files = True
data_file = ../.coverage
data_file = .coverage
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:
RELEASE_FILE: ${{ github.event.repository.name }}-${{ github.event.release.tag_name || github.sha }}-py${{ matrix.python }}
TERM: xterm-256color

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
27 changes: 16 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
name: Python Tests
name: Tests

on:
pull_request:
push:
branches:
- master
- main

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

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

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

- name: Install Dependencies
run: |
python -m pip install tox
make dev-deps

- name: Run Tests
working-directory: library
run: |
tox -e py
make pytest

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


5 changes: 0 additions & 5 deletions .stickler.yml

This file was deleted.

File renamed without changes.
File renamed without changes.
89 changes: 47 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,66 @@
LIBRARY_VERSION=`cat library/setup.py | grep version | awk -F"'" '{print $$2}'`
LIBRARY_NAME=`cat library/setup.py | grep name | awk -F"'" '{print $$2}'`
LIBRARY_NAME := $(shell hatch project metadata name 2> /dev/null)
LIBRARY_VERSION := $(shell hatch version 2> /dev/null)

.PHONY: usage install uninstall
.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 "check: peform basic integrity checks on the codebase"
@echo "python-readme: generate library/README.rst from README.md"
@echo "python-wheels: build python .whl files for distribution"
@echo "python-sdist: build python source distribution"
@echo "python-clean: clean python build and dist directories"
@echo "python-dist: build all python distribution files"
@echo "python-testdeploy: build all and deploy to test PyPi"
@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
./install.sh --unstable

uninstall:
./uninstall.sh

check:
@echo "Checking for trailing whitespace"
@! grep -IlUrn --color "[[:blank:]]$$" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
@echo "Checking for DOS line-endings"
@! grep -IlUrn --color "" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile
@echo "Checking library/CHANGELOG.txt"
@cat library/CHANGELOG.txt | grep ^${LIBRARY_VERSION}
@echo "Checking library/${LIBRARY_NAME}/__init__.py"
@cat library/${LIBRARY_NAME}/__init__.py | grep "^__version__ = '${LIBRARY_VERSION}'"
dev-deps:
python3 -m pip install -r requirements-dev.txt
sudo apt install dos2unix shellcheck

python-readme: library/README.md
check:
@bash check.sh

python-license: library/LICENSE.txt
shellcheck:
shellcheck *.sh

library/README.md: README.md
cp README.md library/README.md
qa:
tox -e qa

library/LICENSE.txt: LICENSE
cp LICENSE library/LICENSE.txt
pytest:
tox -e py

python-wheels: python-readme python-license
cd library; python3 setup.py bdist_wheel
nopost:
@bash check.sh --nopost

python-sdist: python-readme python-license
cd library; python3 setup.py sdist
tag: version
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"

python-clean:
-rm -r library/dist
-rm -r library/build
-rm -r library/*.egg-info
build: check
@hatch build

python-dist: python-clean python-wheels python-sdist
ls library/dist
clean:
-rm -r dist

python-testdeploy: python-dist
twine upload --repository-url https://test.pypi.org/legacy/ library/dist/*
testdeploy: build
twine upload --repository testpypi dist/*

python-deploy: check python-dist
twine upload library/dist/*
deploy: nopost build
twine upload dist/*
52 changes: 42 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Inky

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

Expand All @@ -22,23 +22,55 @@ Python library for [Inky pHAT](https://shop.pimoroni.com/products/inky-phat), [I

# Installation

First, make sure you have I2C and SPI enabled in `sudo raspi-config`.
# Installing

The Python pip package is named inky, on the Raspberry Pi install with:
We'd recommend using this library with Raspberry Pi OS Bookworm or later. It requires Python ≥3.7.

## Full install (recommended):

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 commands exactly as it appears below (check for typos) and follow the on-screen instructions:

```bash
git clone https://github.com/pimoroni/inky
cd inky
./install.sh
```

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

```
pip3 install inky[rpi,example-depends]
source ~/.virtualenvs/pimoroni/bin/activate
```

This will install Inky along with dependencies for the Raspberry Pi, plus fonts used by the examples.
## Development:

If you want to simulate Inky on your desktop, use:
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
git clone https://github.com/pimoroni/inky
cd inky
./install.sh --unstable
```
pip3 install inky
```

You may need to use `sudo pip3` or `sudo pip` depending on your environment and Python version.
## 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 inky`

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

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

* i2c: `sudo raspi-config nonint do_i2c 0`
* spi: `sudo raspi-config nonint do_spi 0`

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

# Usage

Expand Down
Loading