Sang.IoT.SSD1306 1.2.4

dotnet add package Sang.IoT.SSD1306 --version 1.2.4                
NuGet\Install-Package Sang.IoT.SSD1306 -Version 1.2.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sang.IoT.SSD1306" Version="1.2.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sang.IoT.SSD1306 --version 1.2.4                
#r "nuget: Sang.IoT.SSD1306, 1.2.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sang.IoT.SSD1306 as a Cake Addin
#addin nuget:?package=Sang.IoT.SSD1306&version=1.2.4

// Install Sang.IoT.SSD1306 as a Cake Tool
#tool nuget:?package=Sang.IoT.SSD1306&version=1.2.4                

Sang.IoT.SSD1306

.NET library to use SSD1306-based 128x64 pixel OLED displays with a IoT device.Passed the test on the Jetson nano device.

.NET 类库,用于驱动 IOT 设备基于 SSD1306 分辨率 128*64 的 OLED 显示器,已在 Jetson Nano 设备上测试通过。

Instructions:

Step 1

Create a new .NET Console App

dotnet new console -o i2c_oled
Step 2

Add the Sang.IoT.SSD1306 to the project.

dotnet add package Sang.IoT.SSD1306
Step 3

Replace the contents of Program.cs with the following code:

using Sang.IoT.SSD1306;

using (var oled = new SSD1306_128_64(1)) {
    oled.Begin();
    // set data to oled
    byte[] c = new byte[128*64]{...};
    oled.SetBuffer(c);
    oled.Display();
}

Display Image

using Sang.IoT.SSD1306;

using (var oled = new SSD1306_128_64(1)) {
    oled.Begin();
    oled.Image("assets/test.png");
    oled.Display();
}

Display Text

using Sang.IoT.SSD1306;
using SkiaSharp;

using (var oled = new SSD1306_128_64(1)) {

    oled.Begin();
    oled.Clear();

    using(var bitmap = new SKBitmap(128, 64, true)){
        SKCanvas canvas = new SKCanvas(bitmap);
        SKPaint paint = new SKPaint() { 
            Color = new SKColor(255, 255, 255),
            StrokeWidth = 1, //画笔宽度
            Typeface = SKTypeface.FromFile("/home/sangsq/i2c_led/SourceHanSansCN-Normal.ttf"),
            TextSize = 13,  //字体大小
            Style = SKPaintStyle.Fill,
        };
        canvas.DrawText("公众号:sangxiao99 ", 0, 13, paint);
        paint.TextSize = 30;
        canvas.DrawText("桑榆肖物 ", 0, 50, paint);
        oled.Image(bitmap.Encode(SKEncodedImageFormat.Png, 100).ToArray());
    }

    oled.Display();
}

Clear

Use oled.Clear();.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.4 169 3/2/2024
1.2.3 571 6/26/2022