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


Download files

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

Source Distribution

GPIO-Calculator-1.0.2.tar.gz (10.0 kB view hashes)

Uploaded Source

Built Distribution

GPIO_Calculator-1.0.2-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page