Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Beaglebone Python Programming

You're reading from  Learning Beaglebone Python Programming

Product type Book
Published in Jul 2015
Publisher
ISBN-13 9781784399702
Pages 196 pages
Edition 1st Edition
Languages

The Adafruit_BBIO library


The Adafruit_BBIO library is structured differently than PyBBIO. While PyBBIO is structured such that, essentially, the entire API is accessed directly from the first level of the bbio package; Adafruit_BBIO instead has the package tree broken up by a peripheral subsystem. For instance, to use the GPIO API you have to import the GPIO package:

from Adafruit_BBIO import GPIO

Otherwise, to use the PWM API you would import the PWM package:

from Adafruit_BBIO import PWM

This structure follows a more standard Python library model, and can also save some space in your program's memory because you're only importing the parts you need (the difference is pretty minimal, but it is worth thinking about).

The same program shown above using PyBBIO could be rewritten to use Adafruit_BBIO:

from Adafruit_BBIO import GPIO
import time

GPIO.setup("GPIO1_16", GPIO.OUT)
try:
  while True:
    GPIO.output("GPIO1_16", GPIO.HIGH)
    time.sleep(0.5)
    GPIO.output("GPIO1_16", GPIO.LOW)
   ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}