Skip to content

A .NET 8.0 library collection for drawing text and graphics on small displays. Includes base interfaces, text rendering, bitmap fonts, and hardware implementations for SSD1306 OLED displays via I2C.

License

Notifications You must be signed in to change notification settings

AdamTovatt/oled-sharp

Repository files navigation

OledSharp

NuGet version NuGet Downloads License: MIT

OledSharp Header

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.

Font5x5 Example

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).

Overview

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.

Libraries

Important

Please refer to the specific library README.md files for documentation, this is just the overview file for the repository in general.

Core Library

  • 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.

Hardware Implementations

Quick Start - Writing on an SSD1306 display

  1. Install the libraries:

    dotnet add package OledSharp
    dotnet add package OledSharp.SSD1306
  2. Figure out your I2C bus id

  3. 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.

License

MIT License - see project files for details.

Repository

https://github.com/AdamTovatt/oled-sharp

About

A .NET 8.0 library collection for drawing text and graphics on small displays. Includes base interfaces, text rendering, bitmap fonts, and hardware implementations for SSD1306 OLED displays via I2C.

Topics

Resources

License

Stars

Watchers

Forks

Languages