A .NET 8.0 library for drawing text and graphics on small displays. This library provides a simple abstraction for pixel-based displays with built-in text rendering capabilities using fonts defined through the IFont interface.
The picture above shows an example of what the included font looks like on a 128x64 px display (the image is scaled up 4x for better visibility).
This repository contains OledSharp which is a collection of libraries for drawing on small displays. The main library provides the core interfaces and text rendering capabilities, while additional libraries provide specific hardware implementations.
Important
Please refer to the specific library README.md files for documentation, this is just the overview file for the repository in general.
- OledSharp - Base library with interfaces, text rendering, and default font
Warning
The documentation file for the OledSharp base library is not the same as this file! You should read the documentation file for that library if you want to know how to use it.
- OledSharp.SSD1306 - SSD1306 OLED display implementation via I2C
- OledSharp.Png - PNG output implementation for testing and debugging
-
Install the libraries:
dotnet add package OledSharp
dotnet add package OledSharp.SSD1306
-
Figure out your I2C bus id
-
Write to the screen:
using OledSharp.SSD1306; // Create SSD1306 display instance (I2C bus 1, device address 0x3C) using (IOledDisplay display = new SSD1306Display(busId: 1, deviceAddress: 0x3C)) { display.Initialize(); // Create text renderer TextRenderer renderer = new TextRenderer(display); // Draw with word wrapping renderer.DrawWrappedString( x: 2, // 2 px in from the left edge y: 2, // 2 px in from the left edge text: "This is a long text that will wrap", maxWidth: display.Width - 4); // 2 px from the right edge too // Push changes to display display.PushBuffer(); }
Important
See the specific library documentation for detailed usage examples. Both OledSharp.SSD1306 and OledSharp are good to read here.
MIT License - see project files for details.

