No description
Find a file
Drew Fustini 65af1c728c create release 1.0.5
1.0.5
----
* @pdp7 (5):
  * Merge pull request #153 from MarkAYoder/master
  * Fix print syntax to avoid python3 errors
  * Merge pull request #160 from MarkAYoder/master
  * document how to read QEP1
  * Update rotary-encoder-eqep-test.md

* @MarkAYoder (20):
  * Have GP0_1 working
  * Removed --force to speed things up
  * Added GP0 1, 2 and 3
  * Flashes 4 LEDs
  * Works with button
  * Blinks red and gree LEDs
  * Blinks all 6 GPIOs
  * Added red and green LEDs
  * i2c works
  * PWD isn't working, yet
  * Added port setup
  * Switched to apt install
  * Added tmp101 to name
  * Added LED matrix example
  * Removed newline from print
  * Added fade
  * Adding GPIO defs for uart1
  * Testing UT1_0, not working yet
  * Switched GP0_0 to GP0_3, etc.
  * Added PAUSE and MODE buttons.
2017-09-01 03:50:15 +00:00
.github Add GitHub pull request template 2016-05-27 13:23:46 -07:00
Adafruit_BBIO Fix print syntax to avoid python3 errors 2017-08-23 22:20:46 +00:00
doc Update rotary-encoder-eqep-test.md 2017-08-31 21:58:42 -05:00
m4 Add PWM c++ tests 2017-03-31 02:17:00 -07:00
overlays added exclusive use to spi0 overlay, removed unused pins from spi1 overlay 2014-11-20 15:19:22 -05:00
source Merge pull request #160 from MarkAYoder/master 2017-08-30 19:39:19 -05:00
test Workaround test failure until TIMERn bug is fixed 2017-08-23 07:59:56 +00:00
udev add udev rules and script for non-root access to gpio 2017-04-04 04:27:04 +00:00
.gitignore Add 2 versions of library with c++98 and c++11 abi 2017-03-31 02:17:00 -07:00
.travis.yml Testing: Create Tox and Travis CI config 2015-05-13 10:52:29 +02:00
Adafruit_I2C.py Add support for Python 3 2015-05-06 08:29:00 +02:00
CHANGELOG.rst create release 1.0.5 2017-09-01 03:50:15 +00:00
configure.ac Instruct users to open GitHub issue instead email 2017-04-02 07:23:41 -05:00
distribute_setup.py Initial Commit 2013-06-10 20:16:39 +00:00
fix_py_compile.py Add support for Python 3 2015-05-06 08:29:00 +02:00
Makefile Removed --force to speed things up 2017-07-28 15:36:09 -04:00
Makefile.am Add libadafruit-bbio with C++ wrappers for PWM/GPIO 2017-03-31 02:17:00 -07:00
MANIFEST.in remove recursive-exclude statements 2013-07-03 01:21:22 +00:00
README.rst Merge branch 'master' of https://github.com/adafruit/adafruit-beaglebone-io-python 2016-10-30 10:55:47 +00:00
setup.py create release 1.0.5 2017-09-01 03:50:15 +00:00
tox.ini Update tox to notify pytest must be run on beagle 2017-01-10 08:59:02 +00:00

**PLEASE NOTE:  This library may have breaking changes as development continues.  Please read the changelog anytime you update the library!**

**The PWM Duty Cycle range was reversed in 0.0.15 from 100(off)-0(on) to 0(off)-100(on).  Please update your code accordingly.**

**Adafruit's BeagleBone IO Python Library**

This is a set of Python tools to allow GPIO, PWM, and ADC access on the BeagleBone using the Linux 3.8 Kernel and above (latest releases).

It has been tested on the 5-20 and 6-6 Angstrom image on the BeagleBone Black.

**Note: BBIO has been renamed to Adafruit_BBIO.**

**Installation on Angstrom**

Easiest::

    /usr/bin/ntpdate -b -s -u pool.ntp.org
    opkg update && opkg install python-pip python-setuptools
    pip install Adafruit_BBIO
    
Manual::

    git clone git://github.com/adafruit/adafruit-beaglebone-io-python.git 
    #set the date and time 
    /usr/bin/ntpdate -b -s -u pool.ntp.org 
    #install dependency 
    opkg update && opkg install python-distutils 
    cd adafruit-beaglebone-io-python 
    python setup.py install

**Installation on Ubuntu/Debian**

Easiest::

    sudo ntpdate pool.ntp.org
    sudo apt-get update
    sudo apt-get install build-essential python-dev python-pip -y
    #easy_install -U distribute  //debian only
    sudo pip install Adafruit_BBIO
    
Manual::

    sudo ntpdate pool.ntp.org
    sudo apt-get update
    sudo apt-get install build-essential python-dev python-pip -y
    git clone git://github.com/adafruit/adafruit-beaglebone-io-python.git
    cd adafruit-beaglebone-io-python
    sudo python setup.py install
    cd ..
    sudo rm -rf adafruit-beaglebone-io-python
    
**Usage**

Using the library is very similar to the excellent RPi.GPIO library used on the Raspberry Pi. Below are some examples.

**GPIO Setup** 

Import the library, and setup as GPIO.OUT or GPIO.IN::

    import Adafruit_BBIO.GPIO as GPIO
    GPIO.setup("P8_14", GPIO.OUT)

You can also refer to the pin names::

    GPIO.setup("GPIO0_26", GPIO.OUT)

**GPIO Output** 

Setup the pin for output, and write GPIO.HIGH or GPIO.LOW. Or you can use 1 or 0.::

    import Adafruit_BBIO.GPIO as GPIO
    GPIO.setup("P8_14", GPIO.OUT) GPIO.output("P8_14", GPIO.HIGH)

**On-Board LEDs**

On-board LEDs (USR0-USR3) are handled by LED class driver rather than the GPIO pin driver.

They have a different path in the /sys/ filesystem.

Setup the pin for output and write GPIO.HIGH or GPIO.LOW::

    import Adafruit_BBIO.GPIO as GPIO
    import time
    
    for i in range(4):
        GPIO.setup("USR%d" % i, GPIO.OUT)

    while True:
        for i in range(4):
            GPIO.output("USR%d" % i, GPIO.HIGH)
            time.sleep(1)
        for i in range(4):
            GPIO.output("USR%d" % i, GPIO.LOW)
            time.sleep(1)
    
**GPIO Input**

Inputs work similarly to outputs.::

    import Adafruit_BBIO.GPIO as GPIO
    GPIO.setup("P8_14", GPIO.IN)
    
Polling inputs::
    
    if GPIO.input("P8_14"):
      print("HIGH")
    else:
      print("LOW")

Waiting for an edge (GPIO.RISING, GPIO.FALLING, or GPIO.BOTH::

    GPIO.wait_for_edge(channel, GPIO.RISING)

    or
    
    GPIO.wait_for_edge(channel, GPIO.RISING, timeout)

Detecting events::

    GPIO.add_event_detect("P9_12", GPIO.FALLING) 
    #your amazing code here 
    #detect wherever: 
    if GPIO.event_detected("P9_12"):
      print "event detected!"

**PWM**::

    import Adafruit_BBIO.PWM as PWM 
    #PWM.start(channel, duty, freq=2000, polarity=0) 
    #duty values are valid 0 (off) to 100 (on) 
    PWM.start("P9_14", 50)
    PWM.set_duty_cycle("P9_14", 25.5) 
    PWM.set_frequency("P9_14", 10)

    PWM.stop("P9_14")
    PWM.cleanup()
    
    #set polarity to 1 on start:
    PWM.start("P9_14", 50, 2000, 1)

**ADC**::

    import Adafruit_BBIO.ADC as ADC
    ADC.setup()

    #read returns values 0-1.0 
    value = ADC.read("P9_40")

    #read_raw returns non-normalized value 
    value = ADC.read_raw("P9_40")

**Running tests**

Install py.test to run the tests. You'll also need the python compiler package for py.test.::

    opkg update && opkg install python-compiler 
    #Either pip or easy_install 
    pip install -U pytest 
    easy_install -U pytest

Execute the following in the root of the project::

    py.test
    
**Credits**

The BeagleBone IO Python library was originally forked from the excellent MIT Licensed [RPi.GPIO](https://code.google.com/p/raspberry-gpio-python) library written by Ben Croston.

**License**

Written by Justin Cooper, Adafruit Industries. BeagleBone IO Python library is released under the MIT License.