/FlexLabs.Inky

Combined library for V2/V3 Inky pHAT and Inky wHAT.

Primary LanguageC#

Inky

Build status Build status FlexLabs.Inky on NuGet
FlexLabs.Inky.Text on NuGet

.NET Standard library for the Inky pHAT and Inky wHAT e-paper displays.

Inky pHAT

Inky pHAT is a 212x104 pixel e-paper display, available in red/black/white, yellow/black/white and black/white. It's great for nametags and displaying very low frequency information such as a daily calendar or weather overview.

Inky wHAT

Inky wHAT is a 400x300 pixel e-paper display available in red/black/white, yellow/black/white and black/white. It's got tons of resolution for detailed daily todo lists, multi-day weather forecasts, bus timetables and more.

Installation

The core library is called FlexLabs.Inky and can be installed from NuGet into any .NET Standard compatible project.

The second library is called FlexLabs.Inky.Text and contains a basic text renderer, with a couple simple fonts that can be used in your projects.

Usage

The Inky library contains modules for both the pHAT and wHAT, load the InkyPHAT one as follows. You'll need to pick your colour, one of Red, Yellow or Black and instantiate the class:

var inky = new InkyPHat(InkyDisplayColour.Red);

If you're using the wHAT you'll need to load the InkyWHAT class from the Inky library like so:

var inky = new InkyWHat(InkyDisplayColour.Red);

Once you've initialised Inky, there are only three methods you need to be concerned with:

Set Border

Set the border colour of you pHAT or wHAT.

inky.BorderColour = InkyPixelColour.Red;

The colour should be one of InkyPixelColour.Red, InkyPixelColour.Yellow, InkyPixelColour.White or InkyPixelColour.Black with available colours depending on your display type.

Set Pixel

Set a pixel in the Inky's internal buffer. You'll need the pixel location and the colour of the pixel:

inky.SetPixel(x, y, InkyPixelColour.Red);

Update The Display

Once you've prepared and set your image, and chosen a border colour, you can update your e-ink display with:

await inky.RenderBuffer();

Extensions

There are several extension methods that can simplify rendering content on your inky pHAT or wHAT

Draw a rectangle

Used to draw a rectangle.

inky.DrawRectangle(x1, y1, x2, y2, borderColour);

You can also draw a filled rectangle by passing the optional fillColour parameter:

inky.DrawRectangle(x1, y1, x2, y2, borderColour, fillColour);

Draw a string

By using the FlexLabs.Inky.Text package, you can draw text on your screen.

As the screen can't render in greyscale, the library comes with several simple fonts optimised for the display. You can also create your own fonts, and use them instead.

var font = DotMatrix.Size6;
inky.DrawString(x, y, colour, font, text);