# Adafruit 1.27" and 1.5" Color OLED Breakout Board

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/010/391/medium800/lcds___displays_1431_LRG.jpg?1396904653)

We love our black and white monochrome displays but we also like to dabble with some color now and then. Our big 1.5" color OLED displays are perfect when you need a small display with vivid, high-contrast 16-bit color. The visible portion of the OLED measures 1.5" diagonal and contains 128x128 RGB pixels, each one made of red, green and blue OLEDs. Each pixel can be set with 16-bits of resolution for a large range of colors. Because the display uses OLEDs, there is no backlight, and the contrast is very high (black is really black). We picked this display for its excellent color, this is the nicest mini OLED we could find!   
  
This OLED uses the SSD1351 driver chip, which manages the display. You can talk to the driver chip using 4-wire write-only SPI (clock, data, chip select, data/command and an optional reset pin). Included on the fully assembled breakout is the OLED display and a small boost converter (required for providing 12V to the OLED) and a microSD card holder. This design includes built-in logic level shifting so you can use it with 3-5VDC power and logic levels. Our example code shows how to read a bitmap from the uSD card and display it all via SPI.

![back](https://cdn-shop.adafruit.com/970x728/1431-19.jpg )

The 1.5" version of the display comes with an EYESPI connector! This 18-pin 0.5mm pitch FPC connector has a flip-top connector for using a flex cable to hook up your display. It enables you to avoid soldering and get your display up off of the breadboard! Consider it a sort of "STEMMA QT for displays" - a way to quickly connect and extend display wiring that uses a lot of SPI pins. It also allows for communicating with displays over longer distances. The [EYESPI flex cables](https://www.adafruit.com/?q=eyespi+cable&sort=BestMatch) are available in multiple lengths to suit any project. This is especially useful for projects where you want your display mounted separate from your microcontroller.

![](https://cdn-learn.adafruit.com/assets/assets/000/010/392/medium800/lcds___displays_1431flower_LRG.jpg?1396904671)

## Board Technical Details

- 1.5" diagonal OLED, 16-bit color
- SPI interface
- 3.3-5V logic and power
- Micro-SD card holder
- Dimensions: 43.17mm / 1.7" x 42mm / 1.65" x 5.42mm / 0.2"

 **Please note:** all OLEDs have a “half life” — their brightness naturally diminishes over time, albeit over _many thousands_ of hours.&nbsp;This makes them a poor choice for always-on 24/7/365 use. Best to **turn off the display** when inactive, or consider using a **color LCD** for continuously running projects.

# Adafruit 1.27" and 1.5" Color OLED Breakout Board

## Pinouts

![back](https://cdn-shop.adafruit.com/970x728/1431-19.jpg )

## EYESPI

These displays now come with an EYESPI connector, which is an 18pin 0.5mm pitch connector that allows you to use a flex cable to connect your display to your microcontroller. For more details, visit the [EYESPI page](https://learn.adafruit.com/adafruit-1-5-color-oled-breakout-board/eyespi).

## Breakout Pins

This color display uses SPI to receive image data. That means you need at least 4 pins - clock, data in, oled 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!

- **Lite** - this is the PWM input for the backlight control. Connect to 3-5VDC to turn on the backlight. Connect to ground to turn it off. Or, you can PWM at any frequency.
- **MISO** - this is the SPI Microcontroller In Serial Out pin, its used for the SD card. It isn't used for the OLED display which is write-only
- **SCLK** - this is the SPI clock input pin
- **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 OLED
- **OLEDCS** - this is the OLED SPI chip select pin
- **SDCS -** this is the SD card chip select, used if you want to read from the SD card.
- **DC** - this is the OLED SPI data or command selector pin
- **RESET** - this is the OLED 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.
- **CD** - this is the SD card detect pin.
- **3Vo** - this is the 3V output from the onboard voltage regulator
- **Vin** &nbsp;- this is the power pin, connect to 3-5VDC - it has reverse polarity protection but try to wire it right!
- **GND** - this is the power and signal ground pin

# Adafruit 1.27" and 1.5" Color OLED Breakout Board

## EYESPI

Primary: 

![](https://cdn-learn.adafruit.com/assets/assets/000/117/660/medium800thumb/adafruit_products_1431-13.jpg?1674661577)

This display now comes with an **EYESPI connector**. This connector allows you to connect your display without soldering. There are [EYESPI cables](https://www.adafruit.com/?q=eyespi+cable&sort=BestMatch) available in multiple lengths, which means you can find one to fit any project. This is especially useful if your project requires the display to be freestanding, and not tied directly into a breadboard. Inspired by the popularity of STEMMA QT, it provides plug-n-play for displays!

## The EYESPI Connector and Cables

The EYESPI connector is an 18 pin 0.5mm pitch FPC connector with a flip-top tab for locking in the associated flex cable. It is designed to allow you to connect a display, without needing to solder headers or wires to the display.

The EYESPI connector location on this display is indicated below.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/661/medium800/adafruit_products_1431-19.jpg?1674661688)

The EYESPI cables are 18 pin 0.5mm pitch flex cables. They are ~9.6mm wide, and designed to fit perfectly into the EYESPI connector. Adafruit currently offers EYESPI cables in three different lengths: [50mm](https://www.adafruit.com/product/5462), [100mm](https://www.adafruit.com/product/5239), and [200mm](https://www.adafruit.com/product/5240).

Warning: 

## Wiring Your EYESPI Display

Wiring your EYESPI display to a microcontroller via the EYESPI connector requires the EYESPI breakout board and an EYESPI cable.

### Adafruit EYESPI Breakout Board - 18 Pin FPC Connector

[Adafruit EYESPI Breakout Board - 18 Pin FPC Connector](https://www.adafruit.com/product/5613)
Our most recent [display breakouts have come with a new feature:&nbsp;an 18-pin "EYE SPI" standard FPC connector with flip-top connector](https://www.adafruit.com/?q=eyespi&sort=BestMatch). This is intended to be a sort-of "<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/5613)
[Related Guides to the Product](https://learn.adafruit.com/products/5613/guides)
![Overhead video of a 1.9" TFT display connected via 18-pin FPC ribbon cable to a square-shaped microcontroller on a breadboard. The TFT plays an animated boot-up demo.](https://cdn-shop.adafruit.com/product-videos/640x480/5613-06.jpg)

### EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type

[EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type](https://www.adafruit.com/product/5239)
Connect this to that when a 18-pin FPC connector is needed. This 25 cm long cable is made of a flexible PCB. It's A-B style which means that pin one on one side will match with pin one on the other side. How handy!

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5239)
[Related Guides to the Product](https://learn.adafruit.com/products/5239/guides)
![Angled shot of a EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type. ](https://cdn-shop.adafruit.com/640x480/5239-00.jpg)

The following example shows how to connect the 1.5" OLED to a Feather RP2040 using the EYESPI breakout board.

Connect the following Feather pins to the associated EYESPI breakout pins:

- **breakout Vin** to **Feather 3.3V (red wire)**
- **breakout Lite** to **Feather 3.3V (yellow wire)**
- **breakout Gnd** to **Feather GND (black wire)**  
- **breakout SCK** to&nbsp; **Feather** **SCK (grey wire)**
- **breakout MISO** to&nbsp; **Feather** **MI (green wire)**  
- **breakout MOSI** to&nbsp; **Feather** **MO (purple wire)**  
- **breakout TCS** to **Feather D5 (blue wire)**
- **breakout DC** to **Feather D6 (orange wire)**
- **breakout RST** to **Feather D9 (cyan wire)**
- **breakout SDCS** to **Feather D10 (pink wire)**

![adafruit_products_1.5_OLED_EYESPI_wiring_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/662/medium640/adafruit_products_1.5_OLED_EYESPI_wiring_bb.jpg?1674661846)

Finally, connect your **display EYESPI connector** to the **breakout EYESPI connector** using an **EYESPI cable**. For details on using the EYESPI connector properly, visit [Plugging in an EYESPI Cable](https://learn.adafruit.com/adafruit-eyespi-breakout-board/plugging-in-an-eyespi-cable).

## EYESPI Pins

Though there are 18 pins available on the EYESPI connector, many displays do not use all available pins. This display requires the following pins:

- **Vin** - This is the power pin. To power the board (and thus your display), connect to the same power as the logic level of your microcontroller, e.g. for a 3V micro like a Feather, use 3V, and for a 5V micro like an Arduino, use 5V.
- **Lite** - This is the PWM input for the backlight control. It is by default pulled high (backlight on), however, you can PWM at any frequency or pull down to turn the backlight off.
- **Gnd** - This is common ground for power and logic.&nbsp;
- **MISO** - This is the SPI MISO ( **M** icrocontroller **I** n / **S** erial **O** ut) pin. It's used for the SD card. It isn't used for the display because it's write-only. It is 3.3V logic out (but can be read by 5V logic).
- **MOSI** - This is the SPI MOSI ( **M** icrocontroller **O** ut / **S** erial **I** n) pin. It is used to send data from the microcontroller to the SD card and/or display.&nbsp;
- **SCK** - This is the SPI clock input pin.
- **TCS** - This is the TFT SPI chip select pin.
- **RST** - This is the display reset pin. Connecting to ground resets the display! It's best to have this pin controlled by the library so the display is reset cleanly, but you can also connect it to the microcontroller's Reset pin, which works for most cases. Often, there is an automatic-reset chip on the display which will reset it on power-up, making this connection unnecessary in that case.
- **DC** - This is the display SPI data/command selector pin.
- **SDCS** - This is the SD card chip select pin. This pin is required for communicating with the SD card holder onboard the connected display.

# Adafruit 1.27" and 1.5" Color OLED Breakout Board

## Plugging in an EYESPI Cable

![](https://cdn-learn.adafruit.com/assets/assets/000/116/975/medium800/adafruit_products_edited_P1390328.jpg?1670356850)

You can connect an EYESPI compatible display to the EYESPI breakout board using an EYESPI cable. An EYESPI cable is an 18 pin flexible PCB (FPC). The FPC can only be connected properly in one orientation, so be sure to follow the steps below to ensure that your display and breakout are plugged in properly.

Each EYESPI cable has **blue stripes** on either end. On the other side of the cable, underneath the blue stripe, are the connector pins that make contact with the FPC connector pins on the display or breakout.

![adafruit_products_cableStripe.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/970/medium640thumb/adafruit_products_cableStripe.jpg?1670356463)

To begin inserting an EYESPI cable to an FPC connector, gently lift the FPC connector black latch up.&nbsp;

![adafruit_products_liftLatch.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/971/medium640thumb/adafruit_products_liftLatch.jpg?1670356608)

Then, insert the EYESPI cable into the open FPC connector by sliding the cable into the connector. You want to **see the blue stripe facing up towards you**. This inserts the cable pins into the FPC connector.

![adafruit_products_insertCable.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/972/medium640thumb/adafruit_products_insertCable.jpg?1670356741)

To secure the cable, lower the FPC connector latch onto the EYESPI cable.

![adafruit_products_lowerLatch.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/973/medium640thumb/adafruit_products_lowerLatch.jpg?1670356793)

Repeat this process for the FPC connector on your display. Again, ensure that the **blue stripe** on either end of the cable is facing up.

![adafruit_products_edited_P1390333.jpg](https://cdn-learn.adafruit.com/assets/assets/000/116/974/medium640/adafruit_products_edited_P1390333.jpg?1670356806)

# Adafruit 1.27" and 1.5" Color OLED Breakout Board

## Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/010/390/medium800/lcds___displays_1431bottom_LRG.jpg?1396904636)

![](https://cdn-learn.adafruit.com/assets/assets/000/021/376/medium800/lcds___displays_1673-05.jpg?1416851250)

The breakout board comes fully assembled and tested. We include an optional strip of header pins to make it easier to use this display in a breadboard. The header can be installed in just a few minutes with your soldering iron:

![](https://cdn-learn.adafruit.com/assets/assets/000/010/514/medium800/lcds___displays_2013_08_16_IMG_2093-1024.jpg?1376670619)

## Prepare the header strip
Cut the header to size and insert (long pins down) into a breadboard to stabilize for soldering.![lcds___displays_2013_08_16_IMG_2094-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/010/515/medium640/lcds___displays_2013_08_16_IMG_2094-1024.jpg?1376670735)

![lcds___displays_2013_05_02_IMG_1741-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/010/516/medium640/lcds___displays_2013_05_02_IMG_1741-1024.jpg?1376670771)

## Position the display
Place the display breakout on the header so that the short pins protrude through the holes.![lcds___displays_2013_08_16_IMG_2097-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/010/517/medium640/lcds___displays_2013_08_16_IMG_2097-1024.jpg?1376670888)

## And Solder!
Solder all pins to assure a good electrical connection.![lcds___displays_2013_08_16_IMG_2098-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/010/518/medium640/lcds___displays_2013_08_16_IMG_2098-1024.jpg?1376670986)

![lcds___displays_2013_08_16_IMG_2099-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/010/519/medium640/lcds___displays_2013_08_16_IMG_2099-1024.jpg?1376671038)

## Remove the protective film
Gently pull up on the tab to remove the film.![lcds___displays_2013_08_16_IMG_2100-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/010/520/medium640/lcds___displays_2013_08_16_IMG_2100-1024.jpg?1376671115)

# Adafruit 1.27" and 1.5" Color OLED Breakout Board

## Wiring and Graphics Test

The pinout ordering is the same for both the 1.27" and 1.5" version of the OLED!

![](https://cdn-learn.adafruit.com/assets/assets/000/037/786/medium800/lcds___displays_oleddemo_bb.png?1480973318)

[oleddemo.fzz Fritzing File](https://cdn-learn.adafruit.com/assets/assets/000/037/787/original/oleddemo.fzz?1480973327)
The library supports flexible wiring to minimize pin conflicts with other shields and breakouts. For the initial test, we'll use the same wiring as the "test" example from the library:

- **GND -\> GND (G)**  
- **5v -\> VIN (+)**  
- **#2 -\> SCLK (CL)**  
- **#3 -\> MOSI (SI)**  
- **#4 -\> DC**  
- **#5 -\> OLEDCS (OC)**
- **#6 -\> RST (R)**  

## Hint:
If you are confused by the abbreviations on the front of the board, the full signal names are printed on the back! ![](https://cdn-learn.adafruit.com/assets/assets/000/010/522/medium800/lcds___displays_1431bottom_LRG.jpg?1376672027)

![](https://cdn-learn.adafruit.com/assets/assets/000/021/377/medium800/lcds___displays_1673-05.jpg?1416851275)

# Installing the Arduino software

Now we can run the test software on the Arduino.

_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/413/medium800/adafruit_products_manage-libraries.png?1544587225)

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

![](https://cdn-learn.adafruit.com/assets/assets/000/067/414/medium800/adafruit_products_adafruit-gfx-library-manager.png?1544587243)

If using an earlier version of the Arduino IDE (pre-1.8.10), locate and install **Adafruit\_BusIO** (newer versions handle this prerequisite automatically).

Then repeat the search and install steps, looking for the&nbsp; **Adafruit\_SSD1351&nbsp;** library.

After you restart, you should be able to select **File→Examples→Adafruit\_SSD1351→**** test** - this is the example sketch that just tests the display by drawing text and shapes. Upload the sketch and you should see the following:

http://www.youtube.com/watch?feature=player_embedded&v=glodCEK1ax4

The test sketch demonstrates all the basic drawing functions of the Adafruit GFX Library. Read through the code to see how to draw text, circles, lines, etc.  
  
[**For a detailed tutorial on the Adafruit GFX library, including all the functions available please visit the GFX tutorial page**](http://learn.adafruit.com/adafruit-gfx-graphics-library)

# Adafruit 1.27" and 1.5" Color OLED Breakout Board

## Drawing Bitmaps

![](https://cdn-learn.adafruit.com/assets/assets/000/010/532/medium800/lcds___displays_1431flower_LRG.jpg?1376674718)

# Wiring for the Bitmap Example

Drawing bitmaps from the on-board micro SD card requires a few more connections to communicate with the SD card. The library allows you to use any pins. The Arduino connections listed below match the code in the "bmp" example from the library:

- **GND -\> GND (G)**
- **5v -\> VIN (+)**
- **#7 -\> SDCS (SC)**
- **#4 -\> DC**
- **#6 -\> RST (R)**
- **#5 -\> OLEDCS (OC)**
- **#11 -\> MOSI (SI)**
- **#12 -\> MISO (SO)**
- **#13 -\> SCLK (CL)**

Danger: 

![](https://cdn-learn.adafruit.com/assets/assets/000/010/524/medium800/lcds___displays_2013_08_16_IMG_2102-1024.jpg?1376672869)

## Hint:
If you are confused by the abbreviations on the front of the board, the full signal names are printed on the back! ![](https://cdn-learn.adafruit.com/assets/assets/000/010/525/medium800/lcds___displays_1431bottom_LRG.jpg?1376673240)

![](https://cdn-learn.adafruit.com/assets/assets/000/021/378/medium800/lcds___displays_1673-05.jpg?1416851320)

# Bitmap Example Sketch

To display bitmaps from the on-board micro SD slot, you will need a [micro SD card](http://www.adafruit.com/products/102)&nbsp;formatted **&nbsp;FAT16 or FAT32** &nbsp;(they almost always are by default).

![](https://cdn-learn.adafruit.com/assets/assets/000/010/528/medium800/lcds___displays_SD102_MED.jpg?1376673749)

There is a built in microSD card slot on the rear of the breakout and we can use that to load bitmap images!  
  
It's really easy to draw bitmaps. We have a library for it, Adafruit\_ImageReader, which can be installed through the Arduino Library Manager&nbsp;(Sketch→Include Library→Manage Libraries…). Enter “imageread” in the search field and the library is easy to spot:

![](https://cdn-learn.adafruit.com/assets/assets/000/074/501/medium800/adafruit_products_install-imagereader-lib.png?1555389608)

Next you can either download the image here or copy it from the images folder from inside the library files.

[Download lily128.bmp](https://raw.githubusercontent.com/adafruit/Adafruit_ImageReader/master/images/lily128.bmp)
## Insert the card
Insert the micro SD card into the slot on the back of the SSD1351 breakout board.![lcds___displays_2013_08_16_IMG_2103.jpg](https://cdn-learn.adafruit.com/assets/assets/000/010/530/medium640/lcds___displays_2013_08_16_IMG_2103.jpg?1376673987)

## Copy the bitmap file

Copy the file **"lily128.bmp"** from the Adafruit\_ImageReader\_Library\images folder (or wherever you saved it if you downloaded the file) over to the root directory of your micro-SD card.

![adafruit_products_lily-image-location.png](https://cdn-learn.adafruit.com/assets/assets/000/076/132/medium640/adafruit_products_lily-image-location.png?1558996198)

## Load the bitmap example sketch

Select **"Examples-\>Adafruit\_ImageReader\_Library-\>BreakoutSSD1351"** and upload it to your Arduino.

![adafruit_products_ssd1351-example-location.png](https://cdn-learn.adafruit.com/assets/assets/000/076/133/medium640/adafruit_products_ssd1351-example-location.png?1558996230)

In the example, find the following section of code:

```
// Load full-screen BMP file 'rgbwheel.bmp' at position (0,0) (top left).
// Notice the 'reader' object performs this, with 'tft' as an argument.
Serial.print(F("Loading rgbwheel.bmp to screen..."));
stat = reader.drawBMP("/rgbwheel.bmp", tft, 0, 0);
reader.printStatus(stat);   // How'd we do?
```

On the line with `reader.drawBMP()` change `"/rgbwheel.bmp"` to `"/lily128.bmp"`.

After that, upload it to your Arduino. When the Arduino restarts, you should see the flower as below!

![](https://cdn-learn.adafruit.com/assets/assets/000/010/533/medium800/lcds___displays_1431flower_LRG.jpg?1376676657)

To make new bitmaps, make sure they are less than 128 by 128 pixels and save them in&nbsp; **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 to decode. You can rotate images using the&nbsp;**setRotation()**&nbsp;procedure.

The BreakoutSSD1351 example sketch shows everything you need to work with BMP images. Here’s just the vital bits broken out…

Several header files are included at the top of the sketch. All of these are required…they let us access the SD card and the display, and provide the image-reading functions:

```
#include &lt;SPI.h&gt;
#include &lt;SD.h&gt;
#include &lt;Adafruit_GFX.h&gt;         // Core graphics library
#include &lt;Adafruit_SSD1351.h&gt;     // Hardware-specific library
#include &lt;Adafruit_ImageReader.h&gt; // Image-reading functions
```

Several #defines relate to hardware pin numbers, all fixed values when using the shield.

Then we declare the tft screen object, and the image-reader object like so:

```
#define SD_CS    7 // SD card select pin
#define TFT_CS   5 // TFT select pin
#define TFT_DC   4 // TFT display/command pin
#define TFT_RST  6 // Or set to -1 and connect to Arduino RESET pin

Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;SPI, TFT_CS, TFT_DC, TFT_RST);

Adafruit_ImageReader reader;     // Class w/image-reading functions
```

After the SD and TFT’s&nbsp;`begin()`&nbsp;functions have been called (see the example sketch again, in the&nbsp;`setup()`&nbsp;function), you can then call&nbsp;`reader.drawBMP()`&nbsp;to load an image from the card to the screen:

```
ImageReturnCode stat; // Status from image-reading functions
stat = reader.drawBMP("/lily128.bmp", tft, 0, 0);
```

You can draw as many images as you want — though remember the names must be less than 8 characters long. Call like so:

```
reader.drawBMP(filename, tft, x, y);
```

'x' and 'y' are pixel coordinates where top-left corner of the image will be placed. Images can be placed anywhere on screen…even partially off screen, the library will clip the section to load.

#### [**Image loading is explained in greater depth in the Adafruit\_GFX library guide.**](https://learn.adafruit.com/adafruit-gfx-graphics-library/loading-images)
# Adafruit 1.27" and 1.5" Color OLED Breakout Board

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

## Required CircuitPython Libraries

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

[Adafruit_CircuitPython_SSD1351](https://github.com/adafruit/Adafruit_CircuitPython_SSD1351/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\_ssd1351**

Before continuing make sure your board's lib folder or root filesystem has the&nbsp; **adafruit\_ssd1351** &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
https://github.com/adafruit/Adafruit_CircuitPython_SSD1351/blob/main/examples/ssd1351_simpletest.py

Let's take a look at the sections of code one by one. We're going to take a look at the code for the 1.5" display, but there is also an example available for the 128x96 1.27" display. The example is the same as we are covering in here but with the numbers adjusted for the different height.

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_ssd1351`&nbsp;driver.

```
import board
import displayio
import terminalio
from adafruit_display_text import label
from adafruit_ssd1351 import SSD1351
```

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.

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

```
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. Additionally, we need to set the baudrate to 16MHz since that is the maximum speed that the SSD1351 chip will run at. Anything higher creates strange artifacts on the screen.

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

Finally, we initialize the driver with a width of 128 and a height of 128. 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.

```
display = SSD1351(display_bus, width=128, height=128)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/404/medium800/adafruit_products_ssd1351-text-only.jpg?1565738357)

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.

```
splash = displayio.Group(max_size=10)
display.show(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.

```
color_bitmap = displayio.Bitmap(128, 128, 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.

```
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/405/medium800/adafruit_products_ssd1351-green.jpg?1565738380)

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 10 pixels smaller on each side. The screen is **128x128** , so we'll want to subtract 20 from each of those numbers.

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

```
inner_bitmap = displayio.Bitmap(108, 108, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088 # Purple
inner_sprite = displayio.TileGrid(inner_bitmap,
                                  pixel_shader=inner_palette,
                                  x=10, y=10)
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/407/medium800/adafruit_products_ssd1351-green-purple.jpg?1565738416)

Next let's add a label that says "Hello World!" on top of that. We're going to use the built-in Terminal Font. In this example, we won't be doing any scaling because of the small resolution compared to some of the other displays, so we'll add the label directly the main group. If we were scaling, we would have used a subgroup.

Labels are centered vertically, so we'll place it at 64 for the Y coordinate, and around 30 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`.

```
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=30, y=64)
splash.append(text_area)
```

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

```
while True:
    pass
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/408/medium800/adafruit_products_ssd1351-hello-world.jpg?1565738436)

## 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 1.27" and 1.5" Color OLED Breakout Board

## 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 1.27" and 1.5" Color OLED Breakout Board

## 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 &lt; 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 1.27" and 1.5" Color OLED Breakout Board

## Downloads and Links

# Data Sheets:

- [SSD1351 Display Controller Datasheet](http://www.adafruit.com/datasheets/SSD1351-Revision%201.3.pdf)
- [1.5" OLED Display Module datasheet](http://www.adafruit.com/datasheets/UG-2828GDEDF11.pdf)
- [Fritzing objects in the Adafruit Fritzing library](https://github.com/adafruit/Fritzing-Library)
- [EagleCAD PCB for 1.27" Color OLED](https://github.com/adafruit/Adafruit-1.27inch-Color-OLED-Breakout-PCB)
- [EagleCAD PCB for the 1.5" Color OLED](https://github.com/adafruit/Adafruit-1.5inch-Color-OLED-PCB)

# Schematic

Click to enlarge

![](https://cdn-learn.adafruit.com/assets/assets/000/027/580/medium800/lcds___displays_oledchem.png?1441396347)

For the level shifter we use the [CD74HC4050](http://www.ti.com/product/CD74HC4050) which has a typical propagation delay of ~10ns


## Featured Products

### Adafruit METRO 328 Fully Assembled - Arduino IDE compatible

[Adafruit METRO 328 Fully Assembled - Arduino IDE compatible](https://www.adafruit.com/product/50)
We sure love the ATmega328 here at Adafruit, and we use them&nbsp;_a lot_&nbsp;for our own projects. The processor has plenty of GPIO, Analog inputs, hardware UART SPI and I2C, timers and PWM galore - just enough for most simple projects. When we need to go small, we use a <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/50)
[Related Guides to the Product](https://learn.adafruit.com/products/50/guides)
### OLED Breakout Board - 16-bit Color 1.5" w/microSD holder

[OLED Breakout Board - 16-bit Color 1.5" w/microSD holder](https://www.adafruit.com/product/1431)
We love our black and white monochrome displays but we also like to dabble with some color now and then. Our big 1.5" color OLED displays are perfect when you need a small display with vivid, high-contrast 16-bit color. The visible portion of the OLED measures 1.5" diagonal and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1431)
[Related Guides to the Product](https://learn.adafruit.com/products/1431/guides)
### OLED Breakout Board - 16-bit Color 1.27" w/microSD holder

[OLED Breakout Board - 16-bit Color 1.27" w/microSD holder](https://www.adafruit.com/product/1673)
We love our black and white monochrome displays but we also like to dabble with some color now and then. Our 1.27" color OLED displays are perfect when you need a small display with vivid, high-contrast 16-bit color. The visible portion of the OLED measures 1.27" diagonal and...

In Stock
[Buy Now](https://www.adafruit.com/product/1673)
[Related Guides to the Product](https://learn.adafruit.com/products/1673/guides)
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/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

- [Arduino Lesson 16. Stepper Motors](https://learn.adafruit.com/adafruit-arduino-lesson-16-stepper-motors.md)
- [Arduino Lesson 10. Making Sounds](https://learn.adafruit.com/adafruit-arduino-lesson-10-making-sounds.md)
- [Bluetooth Temperature & Humidity Sensor](https://learn.adafruit.com/bluetooth-temperature-and-humidity-sensor.md)
- [Babel Fish](https://learn.adafruit.com/babel-fish.md)
- [Automatic Monitor Color Temperature Adjustment](https://learn.adafruit.com/automatic-monitor-color-temperature-adjustment.md)
- [Photocells](https://learn.adafruit.com/photocells.md)
- [Wave Shield](https://learn.adafruit.com/adafruit-wave-shield-audio-shield-for-arduino.md)
- [Using NeoPixels and Servos Together](https://learn.adafruit.com/neopixels-and-servos.md)
- [LED Lightbox](https://learn.adafruit.com/led-lightbox.md)
- [Character LCDs](https://learn.adafruit.com/character-lcds.md)
- [Animated Snake Eyes Bonnet for Raspberry Pi](https://learn.adafruit.com/animated-snake-eyes-bonnet-for-raspberry-pi.md)
- [SMS Texting Pet Food Dish](https://learn.adafruit.com/sms-texting-pet-food-dish.md)
- [Smart Cocktail Shaker](https://learn.adafruit.com/smart-cocktail-shaker.md)
- [Multi-tasking the Arduino - Part 1](https://learn.adafruit.com/multi-tasking-the-arduino-part-1.md)
- [Making Adabot: Part 2](https://learn.adafruit.com/making-adabot-part-2.md)
