Thin-Film-Transistor LEDs

Over the SPI interface, you can communicate with various devices using the Minnowboard. In this notebook, you can communicate with a wide variety of TFT LCD screens. You can find some examples such as these two displays:

2.8'' ILI9341

3.5'' HXD8357D

Review the wiki page at http://wiki.minnowboard.org/Projects/Maker_TFTLCD for hardware requirements and setup.


In [ ]:
# Get the Python Imaging Libraries for drawing shapes and working with images
import Image
import ImageDraw
import ImageFont

# Get our driver and GPIO libraries
import pyDrivers.ILI9341 as TFT
import Adafruit_GPIO.GPIO as GPIO
import Adafruit_GPIO.SPI as SPI

# Minnowboard MAX configuration.
DC = 25 
RST = 26
SPI_PORT = 0
SPI_DEVICE = 0

Using the TFT Class

The TFT LCD userspace library can run without requiring a kernel module. Using it in this mode will be somewhat slower, suitable for drawing images one-at-a-time.


In [ ]:
# Create TFT LCD display class.
disp = TFT.ILI9341(DC, rst=RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=1000000))

# Initialize display.
disp.begin()

# Clear the display to a red background.
# Can pass any tuple of red, green, blue values (from 0 to 255 each).
disp.clear((255, 0, 0))

# Get a PIL Draw object to start drawing on the display buffer.
draw = disp.draw()

Using the PIL Drawing class

The Python Imaging library makes it easy to draw simple shapes.


In [ ]:
draw.rectangle((10, 90, 110, 160), outline=(255,255,0), fill=(0,0,255))
# Write buffer to the screen
disp.display()

Using PIL for image files

Additionally, you can display image files on your TFT LCD, supporting different kinds of filetypes such as PNG and JPEG.


In [ ]:
image = Image.open('logo.png')
image = image.rotate(90).resize((240,320))
disp.display(image)