SSD1306 OLED display implementation for OledSharp
$ dotnet add package OledSharp.SSD1306A .NET 8.0 implementation of IOledDisplay for SSD1306 OLED displays. This library provides direct hardware control for 128x64 pixel SSD1306 OLED displays via I2C communication.
[!IMPORTANT] This is a hardware-specific implementation. For the main library documentation and general usage, see OledSharp.
This library provides the SSD1306Display class which implements the IOledDisplay interface from the base OledSharp library. It handles low-level communication with SSD1306 OLED displays and provides pixel-level control.
To install the OledSharp.SSD1306 library via NuGet, run the following command in your project directory:
dotnet add package OledSharp.SSD1306
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
// Draw individual pixels
display.SetBufferPixel(10, 10, true);
display.SetBufferPixel(11, 11, true);
// Push changes to display
display.PushBuffer();
}
SSD1306Display display = new SSD1306Display(busId: 1, deviceAddress: 0x3C);
I2cDevice i2cDevice = I2cDevice.Create(settings);
SSD1306Display display = new SSD1306Display(i2cDevice);
MIT License - see project file for details.