PyBBIO update – version 0.9.2

A few new features have been added in version 0.9.2:

WebCam library

The last of the GSoC 2014 additions from rseetham, the WebCam library allows live streaming of WebCam video over TCP, as well as capturing of still images to JPG files.

BBIOServer updates

The included JQuery has been updated to version 1.11.1. Also merged an update from Ikario that adds a range slider input element.

I2C improvement

ycoroneos added new quickwrite() and readTransaction() methods to the I2C objects that allow communicating with a wider range of devices.
To update to v0.9.2:

# pip install --upgrade PyBBIO

Super Simple BeagleBone Web Interface!

I've been working for a while now on PyBBIO, my Python library for BeagleBone hardware expansion. It's got some neat features, but my favorite so far is the BBIOServer library, which makes creating web interfaces to PyBBIO incredibly simple.

BBIOServer provides two things: a web server class called BBIOServer, and a HTML page class called Page. To use it you create a Page instance for every page you want your web interface to have, add content to them through the Page methods, then pass them all to the start() method of a BBIOServer instance, and it will create the pages complete with a sidebar to navigate between them, then start the server on the default port of 8000, or whatever port you have specified.

To create a single page with a button that toggles the USR3 on-board LED, as well as a monitor of its current state, would look something like this:

from bbio import *
from BBIOServer import *

server = BBIOServer()

def setup():
  page = Page("Server test")
  page.add_text("This is a test of the BBIOServer library.")
  page.add_button(lambda: toggle(USR3), "Toggle USR3", newline=True)
  page.add_monitor(lambda: pinState(USR3), "Current state:")

def loop():

run(setup, loop)

And if you run that and point your browser to http://your_beaglebone_ip_address:8000 you should see something like this:


In this case the Page instance uses the default stylesheet, but you can also point to other stylesheets in the PyBBIO/libraries/BBIOServer/src/ directory. Besides the default stylesheet, BBIOServer includes a stylesheet that makes the pages get along well with mobile browsers. If you replace page = Page("Server test") in the above code with page = Page("Server test", stylesheet="mobile.css"), then head to http://your_beaglebone_ip_address:8000 on your phone, you should see something like this:


Here's a quick video of one of the BBIOServer examples included in PyBBIO (see the code here):

Be sure to check out the BBIOServer documentation.