u8g2
2.29.11Features
-
Support for a wide range of monochrome display controllers including SSD, SH, ST, UC, and IST series.
-
Dual-mode operation: U8g2 (full graphics) and U8x8 (text-only, direct-to-display).
-
Memory-optimized rendering using 1-page, 2-page, or full-frame buffer configurations.
-
Extensive font support with virtually no restriction on font height.
-
Comprehensive graphics primitives for drawing lines, boxes, circles, and frames.
-
Multiple communication protocol support: 3-wire/4-wire SPI, I2C (Hardware and Software), and 8-bit parallel (6800/8080).
-
Software-based display rotation for 0, 90, 180, and 270 degrees, plus mirroring support.
-
MUI (Minimal User Interface) subsystem for creating interactive menus and forms.
-
U8log component for emulating a serial terminal output on the display.
-
16-bit coordinate mode support for displays exceeding 240x240 pixel dimensions.
-
Support for specialized display technologies including E-Ink and VFD controllers.
-
Dynamic memory allocation options for page buffers to optimize RAM usage.
-
Integrated icon and symbol font libraries.
-
Tile-based coordinate system in U8x8 mode for extreme memory efficiency.
-
Hardware I2C pin remapping support for compatible microcontroller architectures.
Architecture
U8g2 is designed with a layered architecture that balances hardware abstraction with graphical flexibility. At the lowest level, the library interacts with display hardware through specific communication drivers (SPI, I2C, or Parallel). The U8x8 sub-library serves as the foundational layer, providing a direct-to-display interface that operates on 8x8 pixel tiles. This layer requires no RAM buffer in the microcontroller, making it suitable for the most resource-constrained environments.
Sitting above the hardware abstraction is the U8g2 graphics engine. This layer manages the rendering pipeline and provides the API for drawing primitives and complex fonts. A core architectural feature is the Page Buffer mechanism. To support high-resolution displays on microcontrollers with limited RAM, U8g2 can render the screen in horizontal slices (pages). The application uses a firstPage()/nextPage() loop to redraw the scene for each slice, which the library then transfers to the display controller. This allows for full graphical support even when the MCU cannot hold a complete frame buffer in memory.
Use Cases
This library is ideal for:
- Industrial Monitoring: Displaying real-time sensor data, telemetry, and diagnostic information on ruggedized monochrome LCDs.
- User Interfaces: Building interactive menus, settings screens, and forms using the MUI (Minimal User Interface) module.
- Portable Instrumentation: Implementing low-power visual feedback for handheld devices like multimeters, environmental sensors, or testers.
- System Logging: Utilizing the U8log component to create an on-screen terminal for real-time debugging without requiring a secondary PC connection.
- Battery-Powered Devices: Leveraging U8x8 mode to minimize CPU cycles and RAM usage, thereby extending the battery life of wearable or remote hardware.
- Retro Gaming and Hobbyist Projects: Rendering simple sprites and graphics on accessible platforms like Arduino, ESP32, and STM32.
Getting Started
To begin developing with U8g2, users should first identify their display controller and the desired communication interface. In the Arduino IDE, the library can be installed via the Library Manager. The setup process involves selecting a specific Constructor that matches the hardware; this constructor defines the controller type, the buffer strategy (Full, 1-page, or 2-page), and the physical pin connections.
Once the constructor is defined, the u8g2.begin() function initializes the display and sends the required setup sequence. Drawing operations are typically performed within a do...while loop using u8g2.firstPage() and u8g2.nextPage(). For developers working in pure C or porting to new platforms, the library provides a specific C-API and documentation for implementing custom hardware abstraction layers. Detailed reference manuals and setup guides for various controllers can be found in the official Wiki.
Related Projects (19)
View All 19 Projects →Lumen
Lumen is an open-source desktop hardware node based on the ESP32-C3 and FreeRTOS. It functions as a programmable interaction device similar to a Stream Deck, featuring a 240x240 display, rotary encoder, and integrated sensors for system monitoring and game state feedback.
E-Paper ESP32-C6 Firmware
Firmware for an ESP32-C6 based E-Paper display device featuring BLE provisioning, AWS IoT connectivity, and OTA updates. It targets the Spectra 6 7.3-inch display and integrates motion sensing via the KXTJ3-1057 accelerometer.
ESP32-C3 Supermini OLED Display Driver
A technical implementation and hardware guide for the ESP32-C3 Supermini board equipped with a 0.42-inch OLED. It provides a specific software workaround for the U8g2 library to support the non-standard 72x40 resolution using coordinate offsets. The project includes pin mappings and an Arduino-based example for I2C display communication.
SI4732 Radio
A custom firmware project for a home-built radio receiver based on the ESP32-S2 and SI4732 module. It features a high-resolution Sharp LS027B7DH01 LCD and utilizes the Arduino framework with libraries like U8g2 and PU2CLR SI4735 for multi-band radio reception.
ESP32 Web Radio Evo3
An advanced internet radio streamer built on the ESP32-S3 platform, featuring support for MP3, AAC, VORBIS, and FLAC streams. It integrates a web server for remote control, an OLED display for visualization, and supports both rotary encoder and infrared remote inputs.
ESP32-S3 SoundFont (SF2) Sampler Synthesizer
A high-performance wavetable synthesizer firmware for the ESP32-S3 that enables high-quality SoundFont 2 (SF2) playback. It leverages PSRAM for sample loading and supports USB MIDI, external I2S DACs, and runtime switching between LittleFS and SD card storage.
PixelForge
PixelForge is a browser-based image converter that transforms PNG and JPG images into Arduino-compatible C header files. It supports RGB565 and OLED bitmap formats for popular embedded display libraries like TFT_eSPI and U8g2, targeting platforms such as ESP32, STM32, and RP2040.
Clawtype
A Rust-embedded firmware for the SparkFun ProMicro RP2040 that implements a variant of the Chordite chorded keyboard. It leverages the Embassy async framework to provide HID keyboard and mouse functionality with support for IMU-based motion sensing and LCD displays.