Skip to main content

Simple GPIO calculator for libgpiod based on its chardev.

Project description

Simple GPIO calculator for libgpiod based on its chardev using the formula chardev = (alphabet_index - 1) * 32 + pin which is also used on sysfs.

Installation

pip install git+https://github.com/yeyeto2788/GPIO_Calculator

Usage

from gpio_calculator import Calculator

calculator = Calculator()

# Get chardev based on pin letter and pin number.
# Return should be 242
calculator.get_chardev("H", 18)

# Get chardev from list.
# Returns a list of converted items [242, 243, 244].
calculator.get_chardevs(["H18", "H19", "H20"])

# Get pin from chardev.
# Returns the pin number H18.
calculator.get_pin(242)

# Get all pins from chardevs.
# Returns all pins found H18, H19, H20.
calculator.get_pins([242, 243, 244])

Contributing

All contributions, pull requests and comments are welcome!

When contributing it is important to test the module in order to make sure everything is working as expected. For that install dependencies to run the tests.

pip install pytest pytest-cov mock pylint

Running tests and see coverage.

py.test --cov -v --cov-config=.coveragerc --cov-report=html

This will generate a report with the coverage which is at 98% now, let’s try to keep it at the same percentage.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for GPIO-Calculator, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size GPIO_Calculator-1.0.2-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size GPIO-Calculator-1.0.2.tar.gz (10.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page