Skip to content

Commit

Permalink
Merge pull request #22 from Gadgetoid/gadgetoid-working
Browse files Browse the repository at this point in the history
Performance optimization and code cleanup
  • Loading branch information
Gadgetoid committed Nov 3, 2021
2 parents af5f2f6 + 6139351 commit fd8e954
Show file tree
Hide file tree
Showing 14 changed files with 671 additions and 321 deletions.
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://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.

0 comments on commit fd8e954

Please sign in to comment.