Using an SPI screen and embedded_graphics from Linux on a Raspberry PI 5

Hi, I plan to use a small 1.5 inch RGB OLED screen connected to an Raspberry PI 5 for implementing a simple text-based user interface. Displaying graphics or a full-blown GUI is for later, at this stage it can be considered nice-to-have.

The RPI is running Bookworm and the display is a Waveshare 1.5inch RGB OLED module that uses a SH1107 SSD1351 driver and a four-wire SPI interface.

Currently I see the following options for writing to the screen from Rust:

  1. Using the embedded_graphics with the oled_async library.
  2. Custom code based on rppal with the Waveshare example code in C as a guide.

How feasible is the first option given that I would be using it from Linux on a RPI 5 and not a microcontroller like Arduino or the RP Pico?

Which approach would you recommend? Are there any better options I am missing?

I'm not awfully familiar with the RP ecosystem of embedded systems, however, you'd actually need to utilise libraries from both of your points!

rppal provides access to the Pi's interface, including the SPI interface, which implements the embedded_hal traits, which would allow you to use the embedded_graphics library which, from what I understand, would let you use the oled_async library to control it.

1 Like

Thanks!

With the oled_async driver, it looks like I need to have a Raspberry PI "board" from the embedded Rust ecosystem. Given that the Raspberry PI is an SBC and not a microcontroller, I worried that there might not be such a board definition.

However, based on your comment it seems like I should be able to provide the embedded_hal to the oled_async driver somehow and I will thus give this option a try before I start implementing something more custom.

(My other account, sorry for the switch)

From what I've quickly found out, you'll need to create an interface from display-interface-spi to using the SPI from rppal. You can then provide this interface in the .connect() method in old_async, which you can then use with embedded_graphics API.

1 Like

Fantastic - thanks for the help! I will start coding and come back here once I have tried it out. It might take a little while as I am doing this on my spare time.

Hi,

I tried to do the same thing and found a dedicated driver for the 1351 on crates.io

Unfortunately i could not get the compiler to pass my testcode so far :frowning:
Any luck on your side?

Hi, well I have made no real progress and come to the conclusion that I have to learn more about embedded graphics before continuing. Currently the project is at a standstill... :-/

If/when I make some progress I will update here.

If you manage to get your tests to work, I would be very appreciative if you would share your solution. :slight_smile:

I plan to use Arduino UNO Q embedded display for a similar purpose. But, since I didn't buy it yet, just bookmarking your thread.

I found something today that worked for me!

i needed to install cairo and use the "cross" package for crosscompiling for my raspberry pi.

$ cross build --target armv7-unknown-linux-gnueabihf --example hello

worked.