It's one thing to just plug an HDMI monitor into the mini HDMI port on your BBB and get a picture. In many cases, this is may be all you care about for a project. However, for bona fide embedded or mobile scenarios where you need a display, using the HDMI option can be overkill; your needs are low power, small form factor, and just enough display to convey basic information.
In this section, we will take a look at two other options for display: a mini OLED display available as a breadboard-able PCB and a custom BBB cape designed with a very small LCD panel.
Hooking up a mini OLED
In this recipe, we will take a look at a very small 1.3 inch OLED display with a resolution of 128 x 64 pixels. It has a monochrome screen, which means that we will not be watching Lawrence of Arabia on this device. Instead, we will explore some methods for basic control and input and take a preliminary peek at typical design choices for embedded devices.
The nice thing about experimenting with a device like this is that we can make use of another set of pins available on BeagleBone Black: the Serial Peripheral Interface or SPI pins. The BBB packs two SPI ports, and we will use one of these. Some of the advantages of this interface include higher throughout and lower power consumption than I2C, which we used in an earlier recipe in this chapter.
To be clear, this recipe will not result in an alternative desktop display. Instead, it is the basis for building a more robust—albeit considerably smaller—low-powered display option for your customized prototyping requirements and tests. To demo the screen, we will run Python scripts as they are an easier entrée into the hardware.
You'll need the following items:
Adafruit's OLED comes with its own tutorial and Python example scripts. Although we will rely on the Adafruit Python BBIO library, we will actually use an additional Python library developed by Guy Carpenter and modified by Ethan Zonca along with our own custom example code.
Now that you're ready, let's get started:
To be clear, here is the hookup in table form:
$ cd /boot
uEnv.txt:
$ sudo nano uEnv.txt
##This line added to enable device tree overlay for SPIDEV optargs=capemgr.enable_partno=BB-SPIDEV1
# reboot
/dev/spidev1.0
and /dev/spidev1.1
files are visible, indicating that the SPI drivers are available for access:$ sudo -i # ls -l /dev/spidev*
You should get an output similar to this:
crw-rw---T 1 root spi 153, 1 Mar 1 20:46 /dev/spidev1.0 crw-rw---T 1 root spi 153, 0 Mar 1 20:46 /dev/spidev1.1
# apt-get update # apt-get install build-essential python-dev python-pip python-imaging python-smbus python-dateutil # pip install spidev # pip install pil # pip install Adafruit_BBIO
# git clone https://github.com/HudsonWerks/OLED-SSD1306.git
# /OLED-SSD1306/samples # ls
# python oled-test1.py
If all went well, you will see text cycling on the screen with messages from ground control.
# nano oled-test1.py
http://192.168.7.2:3000/ide.html
), create a new .py
file called oled-test1.py
, and then copy and paste the code from your nano window into the IDE file window. From here, you can begin customizing the code, starting with the messages displayed on the screen.The following is some supporting information:
3.145.119.199