#driver #electronics #gpio #color #let


Rust library for displays using the ST7735 driver

1 unstable release

0.1.0 Feb 18, 2019

#1064 in Hardware support

MIT license

586 lines


This is a library for displays using the ST7735 driver. Documentation is available here.

Display example

Currently, there is support for using hardware SPI as well as software SPI to communicate to the display. Note that using hardware SPI is much faster and recommended to be used if supported by the connecting device.

The driver also provides a simple graphics library which currently supports drawing the following shapes:

  • Rectangles (filled and border only)
  • Circles (filled and border only)
  • Lines (horizontal, vertical, and diagonal)
  • Text (characters)


To use the crate please add the following to your Cargo.toml:

st7735 = "0.1.0"

Please refer to /examples for more examples.

extern crate st7735;
use st7735::color::{Color, DefaultColor};
use st7735::fonts::font57::Font57;
use st7735::Orientation;
use st7735::ST7734;

let mut display = ST7734::new_with_spi("/dev/spidev0.0", 25);
let color_red = Color::from_default(DefaultColor::Red);
display.draw_horizontal_line(0, 128, 20, &color_red);
display.draw_horizontal_line(0, 128, 140, &color_red);
display.draw_rect(30, 30, 60, 70, &Color::from_default(DefaultColor::Blue));

Connecting the Display

I tested this create using a Raspberry Pi model A and a SainSmart 1.8" TFT LCD Display with the following wiring for SPI:

Raspberry Pi Display
GND (Pin 6) CS
GPIO 25 (Pin 22) RS/DC
GPIO 10 (Pin 19) SDA
GPIO 11 (Pin 23) SCL
GND (Pin 6) GND
5V (Pin 2) VCC

When using the software SPI with other pins or even in the hardware SPI case it might be necessary to explicitly give permission to access GPIOs on the Raspberry Pi:

echo "25" > /sys/class/gpio/export
sudo sh -c 'echo out > /sys/class/gpio/gpio25/direction'


To build this crate on the target platform (for example a Raspberry Pi) you can simply run cargo build if cargo is installed.

To build this crate on a platform used for development that is not the target platform (for example macOS), I recommend using crosstool-ng which will install the necessary toolchains. To build the crate for a Raspberry Pi model A run:

cargo build --target=arm-unknown-linux-gnueabi

For more details about installing required tools and setting up everything to build this crate, I wrote a more elaborate blog post about setting up Rust for embedded system programming on macOS.


  • Support more shapes
  • Support rendering text instead of just one character
  • Support more fonts
  • Add support for reading SD card
  • Draw bitmaps


This crate is based on the series Add a TFT Display to the Raspberry Pi by Bruce E. Hall and the Adafruit-ST7735-Library .


Contributions are always welcome! Feel free to fork the repository and create pull-requests.




~87K SLoC