Skip to main content

I/O Communication Library

Project description

ahio

ahio is a communication library whose goal is to abstract the interfacing with various I/O hardwares, so that changing hardware becomes possible with minimum code modification. It's desired that an application that already works with an I/O hardware will only need pin remapping and possibly initial setup change to work with another hardware, not entire code rewrite.

It works with drivers, which are installed in the ahio.drivers package. Every driver must implement the API described in the ahio.abstract_driver package. If you plan to use this library or develop a driver, read the documentation there.

Installation

Simplest way is to use pip: pip3 install ahio Alternatively you can checkout this repository and run python3 setup.py install

Basic usage

# Import the package:
import ahio

# You can see what drivers are available in this platform by calling
print(ahio.list_available_drivers())

# Instantiate the desired driver
with ahio.new_driver('Arduino') as arduino:
  # The driver can have a driver-specific setup function. Call it as/if needed.
  arduino.setup('/dev/tty.usbmodem1421')

  # Map the pins. From now on, when you use 1 in the API, it will have effects
  # on pin D3 in the Arduino. If you change hardware in the future, just change
  # the mapping.
  arduino.map_pin(1, arduino.Pins.D3)
  arduino.map_pin(2, arduino.Pins.D13)
  arduino.map_pin(3, arduino.Pins.A1)

  # Change a pin direction (Input or Output)
  arduino.set_pin_direction([1, 2], ahio.Direction.Output)
  arduino.set_pin_direction(3, ahio.Direction.Input)

  # Set the output of a pin
  arduino.write([1, 2], ahio.LogicValue.High)
  arduino.write(1, 0.4, pwm=True)

  # Read the input of a pin
  print(arduino.read(3))

Documentation

Documentation is hosted at GitHub

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

ahio-1.0.19.tar.gz (17.4 kB view details)

Uploaded Source

File details

Details for the file ahio-1.0.19.tar.gz.

File metadata

  • Download URL: ahio-1.0.19.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for ahio-1.0.19.tar.gz
Algorithm Hash digest
SHA256 163fc5c6e54efae28cf10f0669d2b3bc6b8d19d75ff5d183e22053962ebea9fb
MD5 9e80dc905a9265002515fe606fb0c44d
BLAKE2b-256 b36e6b78741ccc956790331fe51c00abc5072bf231165b7f0927e897d6d8b8ee

See more details on using hashes here.

Supported by

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