Many articles have been written about this; however having most of the info in one place is a nice thing...
I will not cover the wiring part here; here is an example for the 96x64 RGB OLED featured in this article's picture.
Raspberry GNU/Linux already contains kernel modules for most of the existing LCD and OLED display controller chips. One may "manually" load those modules during or after boot, however I find it a bit cleaner to use device tree overlays. Another option of course is to access the SPI and GPIOs from userspace with the correct Python library, this is not covered here.
Device tree overlays
The Device Tree is the data structure used by "modern" Linuxes to describe the underlying hardware to the kernel. At boot time, one may, just before the kernel starts, insert additional devices using overlays. To load a device overlay on a Raspberry Pi, simply add "
dtoverlay=xxxx" (and optional parameters, see below) to your
/boot/config.txt; this causes
/boot/overlays/xxxx.dtbo to be added to the device tree at boot.
The display at the top of this article is an Adafruit 0.96" RGB OLED display with 96x64 pixels and 65535 colors. It uses the standard
oled-ssd1331 overlay; the line in config.txt is actually
dtoverlay=oled-ssd1331,bgr=1 because the RGB subpixels are in the reverse order for that particular display, and has been wired as per the link at the beginning of this article.
I have prepared two prototype overlays (heavily inspired by the official overlays and Noralf Trønnes' work) at https://github.com/trbljump/rpi-overlays. Just compile the relevant one with e.g.
dtc -W no-unit_address_vs_reg -@ -I dts -O dtb -o wave144.dtbo wave144.dts (
/usr/bin/dtc is part of the
device-tree-compiler package) and move the resulting dtbo to
/boot/overlays. Again: those are prototypes! There is an issue with the Waveshare 1.44" display: the 128x128 LCD is wired so that the origin is actually off by two rows and one column. The resulting framebuffer will appear to be 132x132 pixels.
If you'd like to use your display as the boot console, add
fbcon=map:10 to your kernel command line (
/boot/cmdline.txt). This swaps framebuffers 0 (the built-in one) and 1 (your new display) in the eyes of the fbcon module.
The font I'm using is
font4x6.psf from https://github.com/nbah22/tiny-font . Copy this file to
/etc/default/console-setup as below, and reboot (caches have to be set).
# CONFIGURATION FILE FOR SETUPCON
# Consult the console-setup(5) manual page.
Disabling getty for this console
If you do not really want to have a login prompt on this console, just disable it using