# Adafruit Mini TFT - 0.96" 160x80

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/042/850/medium800/lcds___displays_3533_top_demo_01_ORIG.jpg?1498066146)

It's the size of your thumbnail, with glorious 160x80 pixel color... it's the Adafruit Mini TFT Breakout! This very very small display is only 0.96" diagonal, packed with RGB pixels, for making very small high-density displays.

![](https://cdn-learn.adafruit.com/assets/assets/000/042/852/medium800/lcds___displays_3533_iso_ORIG.jpg?1498066174)

The display uses 4-wire SPI to communicate and has its own pixel-addressable frame buffer, it can be used with every kind of microcontroller. Even a very small one with low memory and few pins available!

![](https://cdn-learn.adafruit.com/assets/assets/000/118/160/medium800/arduino_compatibles_3533-10.jpg?1675706104)

The breakout has the TFT display soldered on (it uses a delicate flex-circuit connector) as well as a ultra-low-dropout 3.3V regulator and a 3/5V level shifter so you can use it with 3.3V or 5V power and logic. We also had a little space so we placed a microSD card holder so you can easily load full color bitmaps from a FAT16/FAT32 formatted microSD card. The microSD card is not included,&nbsp;[but you can pick one up here](http://www.adafruit.com/products/102).

![](https://cdn-learn.adafruit.com/assets/assets/000/042/853/medium800/lcds___displays_3533_top_demo_02_ORIG.jpg?1498066220)

Of course, we wouldn't just leave you with a datasheet and a "good luck!" -&nbsp;we've written a full open source graphics library that can draw pixels, lines, rectangles, circles, text and bitmaps as well as example code and a wiring tutorial. The code is written for Arduino but can be easily ported to your favorite microcontroller!

 **Specifications:**

- 0.96" diagonal LCD TFT display
- 160x80 resolution, 16-bit color
- 4 wire SPI digital interface - SCK, MOSI, CS and DC pins.
- Built-in microSD slot - uses 2 more digital lines
- 5V compatible! Use with 3.3V or 5V logic
- Onboard 3.3V @ 150mA LDO regulator
- 1 white LED backlight, transistor connected so you can PWM dim the backlight
- 0.1" pitch header for easy breadboarding
- 2 removable mounting holes in corners
- Current draw is based on LED backlight usage: with full backlight draw is ~25mA

# Adafruit Mini TFT - 0.96" 160x80

## Display Versions

As of January 27, 2023 - This product has gone through a pretty significant revision which requires firmware updates! The TFT display uses different initialization code (otherwise it will appear offset and inverted) and the microSD holder is also now push-pull. The previous version of the holder was the push-push type.

We've also updated this PCB with **[Adafruit Pinguin](https://github.com/adafruit/Adafruit_Pinguin)**&nbsp;to make a lovely and legible silkscreen. This new version is plug-in compatible (same pinout and PCB shape) but the TFT requires new code compilation and upload!

Because of the different display versions, you will need to pay attention to the way you initialize the driver for the language you will be using it with.

It's easy to tell the difference if you know what to look for. On the reverse side of the TFT, the Revision A version has a larger chip on the back as well as an A inside of a circle in the upper-righthand corner:

![](https://cdn-learn.adafruit.com/assets/assets/000/118/163/medium800/arduino_compatibles_RevAMarked.jpg?1675708047)

On the reverse side of the TFT, the Revision B version has a smaller chip on the back. The display is plugged in on this revision and it has a B inside of a circle in the top center:

![](https://cdn-learn.adafruit.com/assets/assets/000/118/164/medium800/arduino_compatibles_RevBMarked.jpg?1675708109)

# Adafruit Mini TFT - 0.96" 160x80

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/042/849/medium800/lcds___displays_pinouts.jpg?1498065998)

This color display uses SPI to receive image data. That means you need at least 4 pins - clock, data in, tft cs and d/c. If you'd like to have SD card usage too, add another 2 pins - data out and card cs. However, there's a couple other pins you may want to use, lets go thru them all!

- **3-5V / Vin** - this is the power pin, connect to 3-5VDC - it has reverse polarity protection but try to wire it right!
- **3.3V** - this is the 3.3V output from the onboard regulator
- **GND** - this is the power and signal ground pin
- **SCK** - this is the SPI clock input pin. Use 3-5V logic level
- **MISO** - this is the SPI Microcontroller In Serial Out pin, its used for the SD card. It isn't used for the TFT display which is write-only. It is 3.3V logic out (but can be read by 5V logic)
- **MOSI** - this is the SPI Microcontroller Out Serial In pin, it is used to send data from the microcontroller to the SD card and/or TFT. Use 3-5V logic level
- **TFT\_CS** - this is the TFT SPI chip select pin. Use 3-5V logic level
- **RST** - this is the TFT reset pin. Connect to ground to reset the TFT! Its best to have this pin controlled by the library so the display is reset cleanly, but you can also connect it to the Arduino Reset pin, which works for most cases. There is an automatic-reset chip connected so it will reset on power-up. Use 3-5V logic level
- **D/C** - this is the TFT SPI data or command selector pin. Use 3-5V logic level
- **SD Card CS / SDCS -** this is the SD card chip select, used if you want to read from the SD card. Use 3-5V logic level
- **Lite** - this is the PWM input for the backlight control. It is by default pulled high (backlight on) you can PWM at any frequency or pull down to turn the backlight off. Use 3-5V logic level

# Adafruit Mini TFT - 0.96" 160x80

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/042/881/medium800/lcds___displays_3533-01.jpg?1498148240)

The board comes with all surface-mount components pre-soldered. The included header strip can be soldered on for convenient use on a breadboard or with 0.1" connectors. You can also skip this step and solder on wires.

## Prepare the header strip:

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - **long pins down**

![lcds___displays_DSC_3485.jpg](https://cdn-learn.adafruit.com/assets/assets/000/042/882/medium640/lcds___displays_DSC_3485.jpg?1498148337)

## Add the breakout board:

Place the breakout board over the pins so that the short pins poke through the breakout pads

![lcds___displays_DSC_3486.jpg](https://cdn-learn.adafruit.com/assets/assets/000/042/883/medium640/lcds___displays_DSC_3486.jpg?1498148369)

## And Solder!

Be sure to solder all 5 pins for reliable electrical contact.  
  
_(For tips on soldering, be sure to check out our_ [_Guide to Excellent Soldering_](http://learn.adafruit.com/adafruit-guide-excellent-soldering)_)._

![lcds___displays_DSC_3487.jpg](https://cdn-learn.adafruit.com/assets/assets/000/042/884/medium640/lcds___displays_DSC_3487.jpg?1498148403)

![lcds___displays_DSC_3492.jpg](https://cdn-learn.adafruit.com/assets/assets/000/042/885/medium640/lcds___displays_DSC_3492.jpg?1498148421)

![lcds___displays_DSC_3495.jpg](https://cdn-learn.adafruit.com/assets/assets/000/042/886/medium640/lcds___displays_DSC_3495.jpg?1498148445)

You're done! Check your solder joints visually and continue onto the next steps

![lcds___displays_DSC_3496.jpg](https://cdn-learn.adafruit.com/assets/assets/000/042/887/medium640/lcds___displays_DSC_3496.jpg?1498148490)

# Adafruit Mini TFT - 0.96" 160x80

## Wiring & Test

![](https://cdn-learn.adafruit.com/assets/assets/000/042/854/medium800/lcds___displays_3533_top_demo_01_ORIG.jpg?1498066275)

# Basic Graphics Test Wiring

Wiring up the display in SPI mode is pretty easy as there's not that many pins! We'll be using hardware SPI, but you can also use software SPI (any pins) later. Start by connecting the power pins

- **3-5V Vin** connects to the microcontroller **5V** pin
- **GND** connects to Arduino ground
- **CLK** connects to SPI clock. On Arduino Uno/Duemilanove/328-based, thats **Digital 13**. On Mega's, its **Digital 52** and on Leonardo/Due its **ICSP-3** ([See SPI Connections for more details](http://arduino.cc/en/Reference/SPI))
- **MISO** is not connected
- **MOSI** connects to SPI MOSI. On Arduino Uno/Duemilanove/328-based, thats **Digital 11**. On Mega's, its **Digital 51** and on Leonardo/Due its **ICSP-4** ([See SPI Connections for more details](http://arduino.cc/en/Reference/SPI "Link: http://arduino.cc/en/Reference/SPI"))
- **CS** connects to our SPI Chip Select pin. We'll be using **Digital 10** but you can later change this to any pin
- **RST** is not connected
- **D/C** connects to our SPI data/command select pin. We'll be using **Digital 8** but you can later change this pin too.  
  

For the level shifter we use the [CD74HC4050](http://www.ti.com/product/cd74hc4050?keyMatch=CD74HC4050&tisearch=Search-EN-Everything) which has a typical propagation delay of ~10ns

![](https://cdn-learn.adafruit.com/assets/assets/000/042/858/medium800/lcds___displays_nosdwiring_bb.png?1498067152)

[basicwiring.fzz Fritzing file](https://cdn-learn.adafruit.com/assets/assets/000/042/857/original/basicwiring.fzz?1498066970)
# Install Arduino Libraries

We have example code ready to go for use with these TFTs. It's written for Arduino, which should be portable to any microcontroller by adapting the C++ source.

_Three_ libraries need to be installed&nbsp;using the **Arduino Library Manager** …this is the preferred and modern way. From the Arduino “Sketch” menu, select “Include Library” then “Manage Libraries…”

![](https://cdn-learn.adafruit.com/assets/assets/000/067/415/medium800/arduino_compatibles_manage-libraries.png?1544587437)

Type “gfx” in the search field to quickly find the first library — **Adafruit\_GFX** :

![](https://cdn-learn.adafruit.com/assets/assets/000/067/416/medium800/arduino_compatibles_adafruit-gfx-library-manager.png?1544587459)

Repeat the search and install steps, looking for the **Adafruit\_BusIO** and **Adafruit\_ST7735&nbsp;** libraries.

After restarting the Arduino software, you should see a new **example** folder called **Adafruit\_ST7735,&nbsp;** and inside, an example called **graphicstest**.

![](https://cdn-learn.adafruit.com/assets/assets/000/042/856/medium800/lcds___displays_adafruit_products_gfxtest.png?1498066920)

In the graphicstest source code, look for the lines as follows:

```auto
// Use this initializer if using a 1.8" TFT screen:
tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab

// OR use this initializer if using a 1.8" TFT screen with offset such as WaveShare:
// tft.initR(INITR_GREENTAB);      // Init ST7735S chip, green tab

// OR use this initializer (uncomment) if using a 1.44" TFT:
//tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab

// OR use this initializer (uncomment) if using a 0.96" 160x80 TFT:
//tft.initR(INITR_MINI160x80);  // Init ST7735S mini display
// OR use this initializer (uncomment) if using a 0.96" 160x80 TFT with 
// plug-in FPC (if you see the display is inverted!)
//tft.initR(INITR_MINI160x80_PLUGIN);  // Init ST7735S mini display
```

If you have the newer Revision B display, comment out the first line, and uncomment the fifth, so it looks like:

```auto
// Use this initializer if using a 1.8" TFT screen:
//tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab

// OR use this initializer if using a 1.8" TFT screen with offset such as WaveShare:
// tft.initR(INITR_GREENTAB);      // Init ST7735S chip, green tab

// OR use this initializer (uncomment) if using a 1.44" TFT:
//tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab

// OR use this initializer (uncomment) if using a 0.96" 160x80 TFT:
//tft.initR(INITR_MINI160x80);  // Init ST7735S mini display
// OR use this initializer (uncomment) if using a 0.96" 160x80 TFT with 
// plug-in FPC (if you see the display is inverted!)
tft.initR(INITR_MINI160x80_PLUGIN);  // Init ST7735S mini display
```

If you have the older Revision A display, comment out the first line, and uncomment the fourth, so it looks like:

```auto
// Use this initializer if using a 1.8" TFT screen:
//tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab

// OR use this initializer if using a 1.8" TFT screen with offset such as WaveShare:
// tft.initR(INITR_GREENTAB);      // Init ST7735S chip, green tab

// OR use this initializer (uncomment) if using a 1.44" TFT:
//tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab

// OR use this initializer (uncomment) if using a 0.96" 160x80 TFT:
tft.initR(INITR_MINI160x80);  // Init ST7735S mini display
// OR use this initializer (uncomment) if using a 0.96" 160x80 TFT with 
// plug-in FPC (if you see the display is inverted!)
//tft.initR(INITR_MINI160x80_PLUGIN);  // Init ST7735S mini display
```

Now upload the sketch to your Arduino. You may need to press the Reset button to reset the arduino and TFT. You should see a collection of graphical tests draw out on the TFT.

![](https://cdn-learn.adafruit.com/assets/assets/000/042/859/medium800/lcds___displays_text.jpg?1498067360)

# Changing Pins

Now that you have it working, there's a few things you can do to change around the pins.

If you're using Hardware SPI, the CLOCK and MOSI pins are 'fixed' and cant be changed. But you can change to software SPI, which is a bit slower, and that lets you pick any pins you like. Find these lines:

```auto
// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);
 
// Option 2: use any pins but a little slower!
#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
```

Comment out option 1, and uncomment option 2. Then you can change the **TFT\_** pins to whatever pins you'd like!

The 0.96" TFT has a auto-reset circuit on it so you probably dont need to use the **RST** pin. You can change

`#define TFT_RST    9`

to

`#define TFT_RST   -1`

so that pin isn't used either. Or connect it up for manual TFT resetting!

# Adafruit Mini TFT - 0.96" 160x80

## Adafruit GFX library

![](https://cdn-learn.adafruit.com/assets/assets/000/019/543/medium800/adafruit_products_128x128_top_display_07_ORIG.jpg?1409937908)

The Adafruit\_GFX library for Arduino provides a common syntax and set of graphics functions for all of our TFT, LCD and OLED displays. This allows Arduino sketches to easily be adapted between display types with minimal fuss…and any new features, performance improvements and bug fixes will immediately apply across our complete offering of color displays.  
  
The GFX library is what lets you draw points, lines, rectangles, round-rects, triangles, text, etc.

![](https://cdn-learn.adafruit.com/assets/assets/000/019/544/medium800/adafruit_products_128x128_top_display_08_ORIG.jpg?1409937941)

Check out our detailed tutorial here [http://learn.adafruit.com/adafruit-gfx-graphics-library](http://learn.adafruit.com/adafruit-gfx-graphics-library) It covers the latest and greatest of the GFX library!

# Adafruit Mini TFT - 0.96" 160x80

## Drawing Bitmaps

There is a built in microSD card slot into the breakout, and we can use that to load bitmap images! You will need a microSD card formatted **FAT16 or FAT32** (they almost always are by default).  
  
Its really easy to draw bitmaps! Lets start by downloading this image of ADABOT

![](https://cdn-learn.adafruit.com/assets/assets/000/042/860/medium800/lcds___displays_minibot.bmp?1498068005)

Notice its rotated because the screen is 'naturally' portrait but we want the image to be landscape

Copy **minibot**. **bmp** into the base directory of a microSD card and insert it into the microSD socket in the breakout.

Two more wires are required to interface with the onboard SD card:

- You'll need to connect up the **MISO** pin to the SPI MISO line on your microcontroller. On Arduino Uno/Duemilanove/328-based, thats **Digital 12**. On Mega's, its **Digital 50** and on Leonardo/Due its **ICSP-1** ([See SPI Connections for more details](http://arduino.cc/en/Reference/SPI))
- Also, **SDCS** pin to **Digital 4** on your Arduino as well. You can change this pin later, but stick with this for now.

![](https://cdn-learn.adafruit.com/assets/assets/000/042/861/medium800/lcds___displays_sdwiring_bb.png?1498068105)

[sdwiring.fzz Fritzing file](https://cdn-learn.adafruit.com/assets/assets/000/042/862/original/sdwiring.fzz?1498068110)
You may want to try the **SD library** examples before continuing, especially one that lists all the files on the SD card

Open the&nbsp; **File→examples→Adafruit ImageReader Library→**** BreakoutST7735 - 160x80**&nbsp;example:

![](https://cdn-learn.adafruit.com/assets/assets/000/078/317/medium800/arduino_compatibles_example-160x80.png?1563390019)

Now upload the&nbsp;example sketch to the Arduino. You should see ADABOT appear! If you have any problems, check the serial console for any messages such as not being able to initialize the microSD card or not finding the image.

![](https://cdn-learn.adafruit.com/assets/assets/000/042/864/medium800/lcds___displays_minibot.jpg?1498068555)

To make new bitmaps, make sure they are less than 160 by 80 pixels and save them in **24-bit BMP format**! They must be in 24-bit format, even if they are not 24-bit color as that is the easiest format for the Arduino. You can rotate images using the **setRotation()** procedure  
  
You can draw as many images as you want - dont forget the names must be less than 8 characters long. Just copy the BMP drawing routines below loop() and call

> **bmpDraw(bmpfilename, x, y);**

For each bitmap. They can be smaller than 160x80 and placed in any location on the screen.

# Adafruit Mini TFT - 0.96" 160x80

## CircuitPython Displayio Quickstart

You will need a board capable of running CircuitPython such as the Metro M0 Express or the Metro M4 Express. You can also use boards such as the Feather M0 Express or the Feather M4 Express. We recommend either the Metro M4 or the Feather M4 Express because it's much faster and works better for driving a display. For this guide, we will be using a Feather M4 Express. The steps should be about the same for the Feather M0 Express or either of the Metros. If you haven't already, be sure to check out our&nbsp;[Feather M4 Express](https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51/assembly)&nbsp;guide.

### Adafruit Feather M4 Express - Featuring ATSAMD51

[Adafruit Feather M4 Express - Featuring ATSAMD51](https://www.adafruit.com/product/3857)
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox, half bird, OK?) This feather is powered by our new favorite chip, the **ATSAMD51J19** -&nbsp; with...

In Stock
[Buy Now](https://www.adafruit.com/product/3857)
[Related Guides to the Product](https://learn.adafruit.com/products/3857/guides)
![Angled shot of a Adafruit Feather M4 Express. ](https://cdn-shop.adafruit.com/640x480/3857-10.jpg)

## Preparing the Breakout

Before using the TFT Breakout, you will need to solder the headers or some wires to it. Be sure to check out the&nbsp;[Adafruit Guide To Excellent Soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering).&nbsp;After that the breakout should be ready to go.

## Wiring the Breakout to the Feather

- **3-5V VIN** connects to the Feather&nbsp; **3V** pin
- **GND** connects toFeather ground
- **SCK** connects to SPI clock. On the Feather that's **SCK**.
- **MISO** connects to SPI MISO. On the Feather that's **MI**
- **MOSI** connects to SPI MOSI. On the Feather that's **MO**
- **TFTCS** connects to our SPI Chip Select pin. We'll be using **Digital 9** but you can later change this to any pin
- **DC** connects to our SPI data/command select pin. We'll be using **Digital 10** but you can later change this pin too.
- **RST** &nbsp;connects to our reset pin. We'll be using **Digital 6** but you can later change this pin too.

![](https://cdn-learn.adafruit.com/assets/assets/000/079/496/medium800/arduino_compatibles_160x80-breakout-feather-m4_bb.png?1565900280)

[160x80-breakout-feather-m4.fzz](https://cdn-learn.adafruit.com/assets/assets/000/079/497/original/160x80-breakout-feather-m4.fzz?1565900303)
## Required CircuitPython Libraries

To use this display with `displayio`, there is only one required library.

[Adafruit_CircuitPython_ST7735R](https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/releases)
First, make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next, you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle).&nbsp; Our introduction guide has&nbsp;[a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries)&nbsp;for both express and non-express boards.

Remember for non-express boards, you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_st7735r**

Before continuing make sure your board's lib folder or root filesystem has the&nbsp; **adafruit\_st7735r** &nbsp;file copied over.

## Code Example Additional Libraries

For the Code Example, you will need an additional library. We decided to make use of a library so the code didn't get overly complicated.

[Adafruit_CircuitPython_Display_Text](https://github.com/adafruit/Adafruit_CircuitPython_Display_Text)
Go ahead and install this in the same manner as the driver library by copying the&nbsp; **adafruit\_display\_text** folder over to the **lib** folder on your CircuitPython device.

## CircuitPython Code Example
Here is the example for the newer Revision B 0.96" displays:

https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/blob/main/examples/st7735r_minitft_revb_simpletest.py

The example for the Older Revision A of the display has slightly different initialization code, but is otherwise the same.

https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/blob/main/examples/st7735r_minitft_simpletest.py

Let's take a look at the sections of code one by one.&nbsp;We start by importing the board so that we can initialize&nbsp;`SPI`,&nbsp;`displayio`,`terminalio` for the font, a `label`, and the&nbsp;`adafruit_st7735r`&nbsp;driver.

```auto
import board
import displayio
import terminalio
from adafruit_display_text import label
from adafruit_st7735r import ST7735R
```

Next we release any previously used displays. This is important because if the Feather is reset, the display pins are not automatically released and this makes them available for use again.

```auto
displayio.release_displays()
```

Next, we set the SPI object to the board's SPI with the easy shortcut function&nbsp;`board.SPI()`. By using this function, it finds the SPI module and initializes using the default SPI parameters.

```auto
spi = board.SPI()
tft_cs = board.D5
tft_dc = board.D6
```

In the next line, we set the display bus to FourWire which makes use of the SPI bus.

```auto
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
```

Finally, we initialize the driver with a width of 160 and a height of 80. If we stopped at this point and ran the code, we would have a terminal that we could type at and have the screen update. Because we want to use the display horizontally and the default orientation is vertical, we rotate it **270** degrees.

One other parameter that we provide is `invert=True` which bitwise inverts all color values for the display. This display also has **1** empty row and **26** empty columns, so we pass it the `rowstart` and `colstart` parameters.

```auto
display = ST7735R(display_bus, width=160, height=80, rowstart=1, colstart=26, rotation=270, invert=True)
```

For the older revision A, there are a few minor differences. We need to provide `bgr=True` because the color ordering of certain displays is Blue, Green, Red rather than the usual Red, Green, Blue. The display is also not inverted, so we leave that parameter off. This display also has no empty rows and only **24** empty columns, so we pass it the&nbsp;`colstart` parameter only.

```auto
display = ST7735R(display_bus, width=160, height=80, colstart=24, rotation=270, bgr=True)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/500/medium800/arduino_compatibles_160x80-text.jpeg?1565903207)

Next we create a background splash image. We do this by creating a group that we can add elements to and adding that group to the display. In this example, we are limiting the maximum number of elements to 10, but this can be increased if you would like. The display will automatically handle updating the group.

```auto
splash = displayio.Group(max_size=10)
display.root_group = splash
```

Next we create a Bitmap which is like a canvas that we can draw on. In this case we are creating the Bitmap to be the same size as the screen, but only have one color. The Bitmaps can currently handle up to 256 different colors. We create a Palette with one color and set that color to 0x00FF00 which happens to be green. Colors are Hexadecimal values in the format of RRGGBB. Even though the Bitmaps can only handle 256 colors at a time, you get to define what those 256 different colors are.

```auto
color_bitmap = displayio.Bitmap(160, 80, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00 # Bright Green
```

With all those pieces in place, we create a TileGrid by passing the bitmap and palette and draw it at&nbsp;`(0, 0)`&nbsp;which represents the display's upper left.

```auto
bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0, y=0)
splash.append(bg_sprite)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/501/medium800/arduino_compatibles_160x80-green.jpeg?1565903219)

Next we will create a smaller purple square. The easiest way to do this is the create a new bitmap that is a little smaller than the full screen with a single color and place it in a specific location. In this case, we will create a bitmap that is 5 pixels smaller on each side. The screen is **160x80** , so we'll want to subtract 10 from each of those numbers.

We'll also want to place it at the position&nbsp;`(5, 5)` so that it ends up centered.

```auto
inner_bitmap = displayio.Bitmap(150, 70, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088 # Purple
inner_sprite = displayio.TileGrid(inner_bitmap,
                                  pixel_shader=inner_palette,
                                  x=5, y=5)
splash.append(inner_sprite)
```

Since we are adding this after the first square, it's automatically drawn on top. Here's what it looks like now.

![](https://cdn-learn.adafruit.com/assets/assets/000/079/502/medium800/arduino_compatibles_160x80-green-purple.jpeg?1565903237)

Next let's add a label that says "Hello World!" on top of that. We're going to use the built-in Terminal Font and scale it up by a factor of two. To scale the label only, we will make use of a subgroup, which we will then add to the main group.

Labels are centered vertically, so we'll place it at 40 for the Y coordinate, and around 11 pixels make it appear to be centered horizontally, but if you want to change the text, change this to whatever looks good to you. Let's go with some yellow text, so we'll pass it a value of `0xFFFF00`.

```auto
text_group = displayio.Group(max_size=10, scale=2, x=11, y=40)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)
```

Finally, we place an infinite loop at the end so that the graphics screen remains in place and isn't replaced by a terminal.

```auto
while True:
    pass
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/503/medium800/arduino_compatibles_160x80-hello-world.jpeg?1565903264)

## Where to go from here

Be sure to check out this excellent&nbsp;[guide to CircuitPython Display Support Using displayio](https://learn.adafruit.com/circuitpython-display-support-using-displayio)

# Adafruit Mini TFT - 0.96" 160x80

## Python Wiring and Setup

# Wiring
It's easy to use display breakouts with Python and the&nbsp;[Adafruit CircuitPython RGB Display](https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display)&nbsp;module.&nbsp; This module allows you to easily write Python code to control the display.

We'll cover how to wire the display to your Raspberry Pi. First assemble your display.

Since there's&nbsp;_dozens_&nbsp;of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Connect the display as shown below to your Raspberry Pi.

Info: 

Warning: 

## ILI9341 and HX-8357-based Displays

### 2.2" Display

- **CLK** connects to SPI clock. On the Raspberry Pi, that's **SCLK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, that's also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later.
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later as well.
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**

![](https://cdn-learn.adafruit.com/assets/assets/000/084/668/medium800/arduino_compatibles_2.2_TFT_bb.jpg?1574277297)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/669/original/2.2_TFT.fzz?1574277335)
### 2.4", 2.8", 3.2", and 3.5" Displays

These displays are set up to use the 8-bit data lines by default. We want to use them for SPI. To do that, you'll need to either solder bridge some pads on the back or connect the appropriate IM lines to 3.3V with jumper wires. Check the back of your display for the correct solder pads or IM lines to put it in SPI mode.

- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later.
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later as well.

Warning: 

![](https://cdn-learn.adafruit.com/assets/assets/000/084/676/medium800/arduino_compatibles_2.8_TFT_bb.jpg?1574277504)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/670/original/2.8_TFT.fzz?1574277361)
## ST7789 and ST7735-based Displays

### 1.3", 1.54", and 2.0" IPS TFT Display

- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/677/medium800/arduino_compatibles_2.0_TFT_bb.jpg?1574277527)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/671/original/2.0_TFT.fzz?1574277392)
### 0.96", 1.14", and 1.44" Displays

- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/678/medium800/arduino_compatibles_1.44_TFT_bb.jpg?1574277538)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/672/original/1.44_TFT.fzz?1574277409)
### 1.8" Display

- **GND** connects to the Raspberry Pi's **ground**
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **LITE** connects to the Raspberry Pi's **3V** pin. This can be used to separately control the backlight.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/679/medium800/arduino_compatibles_1.8_TFT_bb.jpg?1574277564)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/673/original/1.8_TFT.fzz?1574277427)
## SSD1351-based Displays

### 1.27" and 1.5" OLED Displays

- **GND** connects to the Raspberry Pi's **ground**
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/680/medium800/arduino_compatibles_1.5_OLED_bb.jpg?1574277589)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/674/original/1.5_OLED.fzz?1574277454)
## SSD1331-based Display

### 0.96" OLED Display

- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later.
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later as well.
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**

![](https://cdn-learn.adafruit.com/assets/assets/000/096/091/medium800/arduino_compatibles_0.96_OLED_bb.jpg?1603118613)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/096/092/original/0.96_OLED.fzz?1603118637)
# 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://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Warning: 

## Python Installation of RGB Display Library

Once that's done, from your command line run the following command:

- `pip3 install adafruit-circuitpython-rgb-display`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

If that complains about pip3 not being installed, then run this first to install it:

- `sudo apt-get install python3-pip`

## DejaVu TTF Font

Raspberry Pi usually comes with the DejaVu font already installed, but in case it didn't, you can run the following to install it:

- `sudo apt-get install fonts-dejavu`

This package was previously calls **ttf-dejavu** , so if you are running an older version of Raspberry Pi OS, it may be called that.

## 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`

If you installed the PIL through PIP, you may need to install some additional libraries:

- `sudo apt-get install libopenjp2-7 libtiff5 libatlas-base-dev`

That's it. You should be ready to go.

# Adafruit Mini TFT - 0.96" 160x80

## Python Usage

Warning: 

Now that you have everything setup, we're going to look over three different examples. For the first, we'll take a look at automatically scaling and cropping an image and then centering it on the display.

## Turning on the Backlight

On some displays, the backlight is controlled by a separate pin such as the 1.3" TFT Bonnet with Joystick. On such displays, running the below code will likely result in the display remaining black. To turn on the backlight, you will need to add a small snippet of code. If your backlight pin number differs, be sure to change it in the code:

```python
# Turn on the Backlight
backlight = DigitalInOut(board.D26)
backlight.switch_to_output()
backlight.value = True
```

## Displaying an Image

Here's the full code to the example. We will go through it section by section to help you better understand what is going on. Let's start by downloading an image of Blinka. This image has enough border to allow resizing and cropping with a variety of display sizes and rations to still look good.

![](https://cdn-learn.adafruit.com/assets/assets/000/082/210/medium800/arduino_compatibles_blinka.jpg?1570817179)

Make sure you save it as **blinka.jpg** and place it in the same folder as your script. Here's the code we'll be loading onto the Raspberry Pi. We'll go over the interesting parts.

https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/main/examples/rgb_display_pillow_image.py

So we start with our usual imports including a couple of Pillow modules and the display drivers. That is followed by defining a few pins here. The reason we chose these is because they allow you to use the same code with the PiTFT if you chose to do so.

```python
import digitalio
import board
from PIL import Image, ImageDraw
import adafruit_rgb_display.ili9341 as ili9341
import adafruit_rgb_display.st7789 as st7789
import adafruit_rgb_display.hx8357 as hx8357
import adafruit_rgb_display.st7735 as st7735
import adafruit_rgb_display.ssd1351 as ssd1351
import adafruit_rgb_display.ssd1331 as ssd1331

# Configuration for CS and DC pins
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)
```

Next we'll set the baud rate from the default 24 MHz so that it works on a variety of displays. The exception to this is the SSD1351 driver, which will automatically limit it to 16MHz even if you pass 24MHz. We'll set up out SPI bus and then initialize the display.

We wanted to make these examples work on as many displays as possible with very few changes. The ILI9341 display is selected by default. For other displays, go ahead and comment out these lines:

```python
disp = ili9341.ILI9341(
    spi,
    rotation=90,  # 2.2", 2.4", 2.8", 3.2" ILI9341
```

and uncomment the line appropriate for your display and possibly the line below in the case of longer initialization sequences. The displays have a rotation property so that it can be set in just one place.

```python
#disp = st7789.ST7789(spi, rotation=90,                            # 2.0" ST7789
#disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180,  # 1.3", 1.54" ST7789
#disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789
#disp = hx8357.HX8357(spi, rotation=180,                           # 3.5" HX8357
#disp = st7735.ST7735R(spi, rotation=90,                           # 1.8" ST7735R
#disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3,   # 1.44" ST7735R
#disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80,       # 0.96" MiniTFT Rev A ST7735R
#disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80,    # 0.96" MiniTFT Rev B ST7735R
#x_offset=26, y_offset=1,#disp = ssd1351.SSD1351(spi, rotation=180,                         # 1.5" SSD1351
#disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351
#disp = ssd1331.SSD1331(spi, rotation=180,                         # 0.96" SSD1331
disp = ili9341.ILI9341(
    spi,
    rotation=90,  # 2.2", 2.4", 2.8", 3.2" ILI9341
    cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE
)
```

Next we read the current rotation setting of the display and if it is 90 or 270 degrees, we need to swap the width and height for our calculations, otherwise we just grab the width and height. We will create an `image` with our dimensions and use that to create a `draw` object. The `draw` object will have all of our drawing functions.

```python
# Create blank image for drawing.
# Make sure to create image with mode 'RGB' for full color.
if disp.rotation % 180 == 90:
    height = disp.width   # we swap height/width to rotate it to landscape!
    width = disp.height
else:
    width = disp.width   # we swap height/width to rotate it to landscape!
    height = disp.height
image = Image.new('RGB', (width, height))
 
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
```

Next we clear whatever is on the screen by drawing a black rectangle. This isn't strictly necessary since it will be overwritten by the image, but it kind of sets the stage.

```python
# Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0))
disp.image(image)
```

Next we open the Blinka image, which we've named **blinka.jpg** , which assumes it is in the same directory that you are running the script from. Feel free to change it if it doesn't match your configuration.

```python
image = Image.open("blinka.jpg")
```

Here's where it starts to get interesting. We want to scale the image so that it matches either the width or height of the display, depending on which is smaller, so that we have some of the image to chop off when we crop it. So we start by calculating the width to height ration of both the display and the image. If the height is the closer of the dimensions, we want to match the image height to the display height and let it be a bit wider than the display. Otherwise, we want to do the opposite.

Once we've figured out how we're going to scale it, we pass in the new dimensions and using a **Bicubic** rescaling method, we reassign the newly rescaled image back to `image`. Pillow has quite a few different methods to choose from, but Bicubic does a great job and is reasonably fast.

```python
# Scale the image to the smaller screen dimension
image_ratio = image.width / image.height
screen_ratio = width / height
if screen_ratio < image_ratio:
    scaled_width = image.width * height // image.height
    scaled_height = height
else:
    scaled_width = width
    scaled_height = image.height * width // image.width
image = image.resize((scaled_width, scaled_height), Image.BICUBIC)
```

Next we want to figure the starting x and y points of the image where we want to begin cropping it so that it ends up centered. We do that by using a standard centering function, which is basically requesting the difference of the center of the display and the center of the image. Just like with scaling, we replace the `image` variable with the newly cropped image.

```python
# Crop and center the image
x = scaled_width // 2 - width // 2
y = scaled_height // 2 - height // 2
image = image.crop((x, y, x + width, y + height))
```

Finally, we take our image and display it. At this point, the image should have the exact same dimensions at the display and fill it completely.

```python
disp.image(image)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/228/medium800/arduino_compatibles_2.2_Breakout_Image.jpeg?1570818097)

## Drawing Shapes and Text

In the next example, we'll take a look at drawing shapes and text. This is very similar to the displayio example, but it uses Pillow instead. Here's the code for that.

https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/main/examples/rgb_display_pillow_demo.py

Just like in the last example, we'll do our imports, but this time we're including the `ImageFont` Pillow module because we'll be drawing some text this time.

```python
import digitalio
import board
from PIL import Image, ImageDraw, ImageFont
import adafruit_rgb_display.ili9341 as ili9341
```

Next we'll define some parameters that we can tweak for various displays. The `BORDER` will be the size in pixels of the green border between the edge of the display and the inner purple rectangle. The `FONTSIZE` will be the size of the font in points so that we can adjust it easily for different displays.

```python
BORDER = 20
FONTSIZE = 24
```

Next, just like in the previous example, we will set up the display, setup the rotation, and create a draw object. **If you have are using a different display than the ILI9341, go ahead and adjust your initializer as explained in the previous example.** After that, we will setup the background with a green rectangle that takes up the full screen. To get green, we pass in a tuple that has our **Red** , **Green** , and **Blue** color values in it in that order which can be any integer from `0` to `255`.

```python
draw.rectangle((0, 0, width, height), fill=(0, 255, 0))
disp.image(image)
```

Next we will draw an inner purple rectangle. This is the same color value as our example in displayio quickstart, except the hexadecimal values have been converted to decimal. We use the `BORDER` parameter to calculate the size and position that we want to draw the rectangle.

```python
draw.rectangle((BORDER, BORDER, width - BORDER - 1, height - BORDER - 1),
               fill=(170, 0, 136))
```

Next we'll load a TTF font. The `DejaVuSans.ttf` font should come preloaded on your Pi in the location in the code. We also make use of the `FONTSIZE` parameter that we discussed earlier.

```python
# Load a TTF Font
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', FONTSIZE)
```

Now we draw the text Hello World onto the center of the display. You may recognize the centering calculation was the same one we used to center crop the image in the previous example. In this example though, we get the font size values using the `getsize()` function of the font object.

```python
# Draw Some Text
text = "Hello World!"
(font_width, font_height) = font.getsize(text)
draw.text((width//2 - font_width//2, height//2 - font_height//2),
          text, font=font, fill=(255, 255, 0))
```

Finally, just like before, we display the image.

```python
disp.image(image)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/164/medium800/arduino_compatibles_2.2_Breakout_Demo.jpeg?1570647999)

## Displaying System Information

In this last example we'll take a look at getting the system information and displaying it. This can be very handy for system monitoring. Here's the code for that example:

https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/main/examples/rgb_display_pillow_stats.py

Just like the last example, we'll start by importing everything we imported, but we're adding two more imports. The first one is `time` so that we can add a small delay and the other is `subprocess` so we can gather some system information.

```python
import time
import subprocess
import digitalio
import board
from PIL import Image, ImageDraw, ImageFont
import adafruit_rgb_display.ili9341 as ili9341
```

Next, just like in the first two examples, we will set up the display, setup the rotation, and create a draw object. **If you have are using a different display than the ILI9341, go ahead and adjust your initializer as explained in the previous example.**

Just like in the first example, we're going to draw a black rectangle to fill up the screen. After that, we're going to set up a couple of constants to help with positioning text. The first is the `padding` and that will be the Y-position of the top-most text and the other is `x` which is the X-Position and&nbsp;represents the left side of the text.

```python
# First define some constants to allow easy positioning of text.
padding = -2
x = 0
```

Next, we load a font just like in the second example.

```python
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24)
```

Now we get to the main loop and by using `while True:`, it will loop until **Control+C** is pressed on the keyboard. The first item inside here, we clear the screen, but notice that instead of giving it a tuple like before, we can just pass `0` and it will draw black.

```python
draw.rectangle((0, 0, width, height), outline=0, fill=0)
```

Next, we run a few scripts using the `subprocess` function that get called to the Operating System to get information. The in each command is passed through awk in order to be formatted better for the display. By having the OS do the work, we don't have to. These little scripts came from `https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load`

```python
cmd = "hostname -I | cut -d\' \' -f1"
IP = "IP: "+subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
CPU = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB  %.2f%%\", $3,$2,$3*100/$2 }'"
MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%d GB  %s\", $3,$2,$5}'"
Disk = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "cat /sys/class/thermal/thermal_zone0/temp |  awk \'{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}\'" # pylint: disable=line-too-long
Temp = subprocess.check_output(cmd, shell=True).decode("utf-8")
```

Now we display the information for the user. Here we use yet another way to pass color information. We can pass it as a color string using the pound symbol, just like we would with HTML. With each line, we take the height of the line using `getsize()` and move the pointer down by that much.

```python
y = padding
draw.text((x, y), IP, font=font, fill="#FFFFFF")
y += font.getsize(IP)[1]
draw.text((x, y), CPU, font=font, fill="#FFFF00")
y += font.getsize(CPU)[1]
draw.text((x, y), MemUsage, font=font, fill="#00FF00")
y += font.getsize(MemUsage)[1]
draw.text((x, y), Disk, font=font, fill="#0000FF")
y += font.getsize(Disk)[1]
draw.text((x, y), Temp, font=font, fill="#FF00FF")
```

Finally, we write all the information out to the display using `disp.image()`. Since we are looping, we tell Python to sleep for `0.1` seconds so that the CPU never gets too busy.

```python
disp.image(image)
time.sleep(.1)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/169/medium800/arduino_compatibles_2.2_Breakout_Stats.jpeg?1570657644)

# Adafruit Mini TFT - 0.96" 160x80

## Downloads

# Files:

- [Fritzing Object in Adafruit Fritzing library](https://github.com/adafruit/Fritzing-Library)
- [EagleCAD files on GitHub](https://github.com/adafruit/Adafruit-0.96-160x80-TFT-Display-Breakout-PCB)
- [Raw TFT Display datasheet](https://cdn-learn.adafruit.com/assets/assets/000/043/903/original/XJ0.9TFT-13PIN.pdf?1500009325)

# Schematics and Fabrication Print
![](https://cdn-learn.adafruit.com/assets/assets/000/043/901/medium800/lcds___displays_schem.png?1500009166)

For the level shifter we use the [CD74HC4050](http://www.ti.com/product/cd74hc4050?keyMatch=CD74HC4050&tisearch=Search-EN-Everything) which has a typical propagation delay of ~10ns

![](https://cdn-learn.adafruit.com/assets/assets/000/043/902/medium800/lcds___displays_fabprint.png?1500009171)


## Featured Products

### Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout

[Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout](https://www.adafruit.com/product/3533)
Say hello to our **0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout** – we think it's **T** - **F** - **T** errific! It's the size of your thumbnail, with glorious 160x80 pixel color. This very very small display is only...

In Stock
[Buy Now](https://www.adafruit.com/product/3533)
[Related Guides to the Product](https://learn.adafruit.com/products/3533/guides)
### SD/MicroSD Memory Card (8 GB SDHC)

[SD/MicroSD Memory Card (8 GB SDHC)](https://www.adafruit.com/product/1294)
Add mega-storage in a jiffy using this 8 GB class 4 micro-SD card. It comes with a SD adapter so you can use it with any of our shields or adapters. Preformatted to FAT so it works out of the box with our projects. Tested and works great with our <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1294)
[Related Guides to the Product](https://learn.adafruit.com/products/1294/guides)

## Related Guides

- [Adafruit AS7262 6-channel Visible Light Sensor](https://learn.adafruit.com/adafruit-as7262-6-channel-visible-light-sensor.md)
- [Adafruit Si5351 Clock Generator Breakout](https://learn.adafruit.com/adafruit-si5351-clock-generator-breakout.md)
- [Adafruit QT Py ESP32-S3](https://learn.adafruit.com/adafruit-qt-py-esp32-s3.md)
- [Adafruit CAN Bus FeatherWing](https://learn.adafruit.com/adafruit-can-bus-featherwing.md)
- [Adafruit ESP32-S3 TFT Feather](https://learn.adafruit.com/adafruit-esp32-s3-tft-feather.md)
- [Creating Slideshows in CircuitPython](https://learn.adafruit.com/creating-slideshows-in-circuitpython.md)
- [Adafruit PC Joystick to seesaw I2C Adapter](https://learn.adafruit.com/adafruit-pc-joystick-to-seesaw-i2c-adapter.md)
- [Adafruit Monochrome 1.12" 128x128 OLED Graphic Display](https://learn.adafruit.com/adafruit-monochrome-1-12-in-128x128-oled.md)
- [Compiling ATSAMD21 Bootloader](https://learn.adafruit.com/compiling-m0-atsamd21-bootloader.md)
- [CLUE Metal Detector in CircuitPython](https://learn.adafruit.com/clue-metal-detector-circuitpython.md)
- [Adafruit TCS3430 / TCS34303 Ambient Tri-Stimulus Color Sensor](https://learn.adafruit.com/adafruit-tcs3430-tcs34303-ambient-tri-stimulus-color-sensor.md)
- [PicoDVI Arduino Library: Video Out for RP2040 Boards](https://learn.adafruit.com/picodvi-arduino-library-video-out-for-rp2040-boards.md)
- [Adafruit I2C QT Rotary Encoder](https://learn.adafruit.com/adafruit-i2c-qt-rotary-encoder.md)
- [Mini Raspberry Pi Handheld Notebook](https://learn.adafruit.com/mini-raspberry-pi-handheld-notebook-palmtop.md)
- [Arduin-o-Phone](https://learn.adafruit.com/arduin-o-phone-arduino-powered-diy-cellphone.md)
