Adafruit Running PyPortal Code User Manual

Running PyPortal Code on Blinka with Displayio
Created by Melissa LeBlanc-Williams
Last updated on 2020-10-20 02:25:10 PM EDT
Overview
Since the PyPortal came out (https://adafru.it/MbN), there have been many examples written which take advantage of
the CircuitPython displayio graphics system (https://adafru.it/MbO). We have been working on writing a version of
displayio that runs on Blinka, the CircuitPython compatibility layer for Python 3 on single board computers. With Blinka,
the FT232H (https://adafru.it/xhf).
To make things even easier, we also wrote a version of the PyPortal library that runs on Blinka to make it even easier
to get up and running. The Raspberry Pi is already connected to the internet, so we decided to take advantage of this
and removed much of the code that handled managing the connections and replaced it with the Linux equivalents.
The Blinka PyPortal library is a port of the original PyPortal library that is intended to be run in CPython. It leverages
the Blinka Displayio library, which is a port of the original CircuitPython displayio library and is built on top of Adafruit
Blinka and the Python Imaging Library. The idea behind the PyPortal library is to be able to run many of the examples
that are currently available for the PyPortal with minimal changes.
Parts
To run the examples, you'll need a Raspberry Pi or FT232H. If you are going the Raspberry Pi route, a Raspberry Pi 4 is
preferred due to its processing speed:
© Adafruit Industries https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio Page 3 of 19
For the Raspberry Pi, you will also need a PiTFT such as the 3.2" TFT:
If you would like to play sound, one of the easiest ways is to connect an amplified speaker to the Raspberry Pi such as
the Monoprice 5-watt amp:
If you would prefer to run it directly from your computer, you could use an FT232H:
Raspberry Pi 4 Model B - 4 GB RAM
$55.00
IN STOCK
Add To Cart
PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen
$39.95
IN STOCK
Add To Cart
Monoprice 5-Watt Guitar Amplifier, Portable Recorder
$29.95
IN STOCK
Add To Cart
© Adafruit Industries https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio Page 4 of 19
For the FT232H, you will need a Breakout TFT such as the 2.8" TFT Breakout:
Adafruit FT232H Breakout - General Purpose USB to GPIO, SPI, I2C
$14.95
IN STOCK
Add To Cart
2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket
OUT OF STOCK
Out Of Stock
© Adafruit Industries https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio Page 5 of 19
Raspberry Pi Setup
Setting up the Raspberry Pi is easy. Since the PiTFT comes preassembled, all you need to do is place it onto the GPIO
pins.
Since there are
dozens
of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other
platforms, please visit the guide for CircuitPython on Linux to see whether your platform is
supported (https://adafru.it/BSN).
Connect the display as shown below to your Raspberry Pi.
Additional Parts
If you don't already have a 3.5mm cable, you'll want to grab one of those:
Stereo 3.5mm Plug/Plug Audio Cable - 6 feet
OUT OF STOCK
Out Of Stock
© Adafruit Industries https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio Page 6 of 19
If you are using a Raspberry Pi 4 and have some active cooling on it such as the Pimoroni Fan Shim or Heatsink Case,
you may want to attach a 40-pin stacking header so that the pins on the PiTFT don't interfere:
Software Setup
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also
require enabling SPI on your platform and verifying you are running Python 3. Since each platform is a little different,
and Linux changes often, please visit the CircuitPython on Linux guide to get your computer
ready (https://adafru.it/BSN)!
Pillow Library
We also need PIL, the Python Imaging Library, to allow graphics and using text with custom fonts. There are several
system libraries that PIL relies on, so installing via a package manager is the easiest way to bring in everything:
sudo apt-get install python3-pil
NumPy Library
A recent improvement of the RGB_Display library makes use of NumPy for additional speed. This can be installed with
the following command:
sudo apt-get install python3-numpy
Install the PyPortal Library
You'll next want to install the Blinka PyPortal library. Installing this library will also install all of the dependencies, so it's
really easy to setup. Just run the following command:
pip3 install adafruit-blinka-pyportal
Stacking Header for Pi A+/B+/Pi 2/Pi 3 - 2x20 Extra Tall Header
$2.95
IN STOCK
Add To Cart
Note this is not a kernel driver that will let you have the console appear on the TFT. However, this is handy
when you can't install an fbtft driver, and want to use the TFT purely from 'user Python' code!
If you have already installed the kernel module, you will need to remove it by running the installer and
choosing uninstall.
© Adafruit Industries https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio Page 7 of 19
Loading...
+ 12 hidden pages