Skip to content

Commit

Permalink
Merge pull request #30 from pimoroni/repackage
Browse files Browse the repository at this point in the history
Repackage to pyproject/hatch and port to gpiod
  • Loading branch information
Gadgetoid authored Jun 12, 2024
2 parents 3e63dc3 + 3348a0a commit 277fdf2
Show file tree
Hide file tree
Showing 37 changed files with 1,186 additions and 511 deletions.
2 changes: 1 addition & 1 deletion library/.coveragerc → .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[run]
source = ST7789
source = st7789
omit =
.tox/*
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ common troubleshooting steps below before creating the issue:
library the code depends on is not installed. Check the tutorial/guide or
README to ensure you have installed the necessary libraries. Usually the
missing library can be installed with the `pip` tool, but check the tutorial/guide
for the exact command.
for the exact command.

- **Be sure you are supplying adequate power to the board.** Check the specs of
your board and power in an external power supply. In many cases just
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: 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 }}

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/
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
24 changes: 14 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
name: Python Tests
name: Tests

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

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

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

- 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 --upgrade setuptools 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' }}
File renamed without changes.
81 changes: 49 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,66 @@
.PHONY: usage install uninstall
LIBRARY_NAME := $(shell hatch project metadata name 2> /dev/null)
LIBRARY_VERSION := $(shell hatch version 2> /dev/null)

.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 "python-readme: generate library/README.md 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 "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

python-readme: library/README.md
dev-deps:
python3 -m pip install -r requirements-dev.txt
sudo apt install dos2unix shellcheck

check:
@bash check.sh

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

library/README.md: README.md library/CHANGELOG.txt
cp README.md library/README.md
printf "\n# Changelog\n" >> library/README.md
cat library/CHANGELOG.txt >> 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
cd library; python setup.py bdist_wheel
nopost:
@bash check.sh --nopost

python-sdist: python-readme python-license
cd library; python 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-deploy: python-dist
twine upload library/dist/*
testdeploy: build
twine upload --repository testpypi dist/*

python-testdeploy: python-dist
twine upload --repository-url https://test.pypi.org/legacy/ library/dist/*
deploy: nopost build
twine upload dist/*
44 changes: 10 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,29 @@
[![Python Versions](https://img.shields.io/pypi/pyversions/st7789.svg)](https://pypi.python.org/pypi/st7789)


Python library to control ST7789 TFT LCD displays.
Python library to control an ST7789 TFT LCD display

Designed to work with the following Pimoroni ST7789 based SPI breakouts and Raspberry Pi HATs:
Designed specifically to work with a ST7789 based 240x240 pixel TFT SPI display. (Specifically the [1.3" SPI LCD from Pimoroni](https://shop.pimoroni.com/products/1-3-spi-colour-lcd-240x240-breakout)).

- [1.54" SPI Colour Square LCD (240x240) Breakout](https://shop.pimoroni.com/products/1-54-spi-colour-square-lcd-240x240-breakout)
- [1.3" SPI Colour Square LCD (240x240) Breakout](https://shop.pimoroni.com/products/1-3-spi-colour-lcd-240x240-breakout)
- [1.3" SPI Colour Round LCD (240x240) Breakout](https://shop.pimoroni.com/products/1-3-spi-colour-round-lcd-240x240-breakout)
- [Display HAT Mini](https://shop.pimoroni.com/products/display-hat-mini) (2.0" 320x240 LCD)

![Photo showing four different Pimoroni ST7789-based products](st7789-combined.jpg)
![Animated GIF showing the ST7789 SPI LCD displaying Deploy/Rainbows in alternating frames](https://raw.githubusercontent.com/pimoroni/st7789-python/master/square-lcd-breakout-1.gif)

# Installation

First, make sure you have the following dependencies:
Make sure you have the following dependencies:

````bash
sudo apt update
sudo apt install python3-rpi.gpio python3-spidev python3-pip python3-pil python3-numpy
````
sudo apt-get update
sudo apt-get install python-rpi.gpio python-spidev python-pip python-pil python-numpy
````

Install this library by running:

````bash
sudo pip3 install st7789
````
sudo pip install st7789
````

You will also need to make sure I2C and SPI are enabled in raspi-config (`sudo raspi-config`) - you can find them under Interface Options.

# Examples

You can find some examples of use in the examples folder. Clone this repo with:

```bash
git clone https://github.com/pimoroni/st7789-python
```

and navigate into the examples folder with:

```bash
cd ~/st7789-python/examples/
```

You can pass most of them a parameter (`square`, `rect`, `round`, or `dhmini`) to specify the size/shape/rotation of screen, like this:
You might also need to enable I2C and SPI in raspi-config. See example of usage in the examples folder.

```bash
python3 shapes.py dhmini
```

# Licensing & History

Expand Down
9 changes: 9 additions & 0 deletions ST7789.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from warnings import warn

from st7789 import * # noqa F403

warn(
'Using "import ST7789" is deprecated. Please "import st7789" (all lowercase)!',
DeprecationWarning,
stacklevel=2,
)
Loading

0 comments on commit 277fdf2

Please sign in to comment.