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

Performance optimization and code cleanup #22

Merged
merged 6 commits into from
Nov 3, 2021
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
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
source = gpio
omit =
.tox/*
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python Tests

on:
pull_request:
push:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: [2.7, 3.5, 3.7, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
run: |
python -m pip install --upgrade setuptools tox
- name: Run Tests
run: |
tox -e py
- name: Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python -m pip install coveralls
coveralls --service=github
if: ${{ matrix.python == '3.9' }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
__pycache__
*.pyc
*.egg*
.coverage
.tox/
build/
dist/
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include README.md
include LICENSE.txt
include setup.py
recursive-include gpio *.py
43 changes: 41 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,49 @@ It is intended to mimick [RPIO](http:https://pythonhosted.org/RPIO/) as much as possib
for all features, while also supporting additional (and better named) functionality
to the same methods.


## Supported Features

- get pin values with `read(pin)` or `input(pin)`
- set pin values with `set(pin, value)` or `output(pin, value)`
- set pin values with `write(pin, value)`, `set(pin, value)` or `output(pin, value)`
- get the pin mode with `mode(pin)`
- set the pin mode with `setup(pin, mode)`
- `mode` can currently equal `gpio.IN` or `gpio.OUT`
- create a `GPIOPin` class directly to `write` and `read` a pin

## Examples

### RPi.GPIO Drop-in

Good for up to 130KHz pin toggle on a Pi 400.

```python
import time

import gpio as GPIO

GPIO.setup(14, GPIO.OUT)

while True:
GPIO.output(14, GPIO.HIGH)
time.sleep(1.0)
GPIO.output(14, GPIO.LOW)
time.sleep(1.0)
```

### Use GPIOPin directly

Good for up to 160KHz pin toggle on a Pi 400.

This gives you a class instance you can manipulate directly, eliminating the lookup:

```python
import gpio

pin = gpio.GPIOPin(14, gpio.OUT)

while True:
pin.write(14, GPIO.HIGH)
time.sleep(1.0)
pin.write(14, GPIO.LOW)
time.sleep(1.0)
```
208 changes: 0 additions & 208 deletions gpio.py

This file was deleted.

Loading