NanoFramework.Graphics
📦 .NET nanoFramework Graphics and UI class library
Install / Use
/learn @nanoframework/NanoFramework.GraphicsREADME

Welcome to the .NET nanoFramework Graphics repository
Build status
| Component | Build Status | NuGet Package |
|:-|---|---|
| nanoFramework.Graphics | |
|
| nanoFramework.Graphics.Core |
|
|
| nanoFramework.Graphics.Gc9A01 |
|
|
| nanoFramework.Graphics.Ili9341 |
|
|
| nanoFramework.Graphics.Ili9342 |
|
|
| nanoFramework.Graphics.Otm8009A |
|
|
| nanoFramework.Graphics.Ssd1306 |
|
|
| nanoFramework.Graphics.Ssd1331 |
|
|
| nanoFramework.Graphics.St7735 |
|
|
| nanoFramework.Graphics.St7789 |
|
|
Usage
Important:
- This library is still work in progress. There may be breaking changes happening while work on this library progresses.
- So far only SPI interface has been implemented.
Check the samples for more detailed usage.
Initializing the screen
It is important to understand that the driver will be loaded when the screen routing will be initialized from the managed code. Also keep in mind that most screens are actually smaller than the size the driver is capable of handling, also that the real screen can start at a position that is not the typical origin (0,0).
You must initialize the screen before being able to create a bitmap or display anything.
This code snippet works with the ESP32 WROVER KIT pinout, in this case, the screen size matches the driver size:
const int backLightPin = 5;
const int chipSelect = 22;
const int dataCommand = 21;
const int reset = 18;
const int screenWidth = 320;
const int screenHeight = 240;
DisplayControl.Initialize(new SpiConfiguration(1, chipSelect, dataCommand, reset, backLightPin), new ScreenConfiguration(0, 0, screenWidth, screenHeight), screenBufferSize);
This code snippet is for a M5 Stick where the screen size is smaller than the driver size and starts an offset position of X=26 and Y=1 coordinate:
int backLightPin = -1; // Not managed thru ESP32 but thru AXP192
int chipSelect = 5;
int dataCommand = 23;
int reset = 18;
Configuration.SetPinFunction(4, DeviceFunction.SPI1_MISO); // 4 is unused but necessary
Configuration.SetPinFunction(15, DeviceFunction.SPI1_MOSI);
Configuration.SetPinFunction(13, DeviceFunction.SPI1_CLOCK);
DisplayControl.Initialize(new SpiConfiguration(1, chipSelect, dataCommand, reset, backLightPin), new ScreenConfiguration(26, 1, 80, 160), 10 * 1024);
Note that depending on your target, especially for ESP32, you may have to setup the pins. Even if physically not used, the MISO pin must be setup to a valid pin.
As you can see it is possible as well not to define the backlight pin. It is the same for the rest pins. Both can be set to -1. Note that in most of the cases, both are connected and needed. In the case of the M5 Stick, the backlight pin is managed thru an AXP192. If you don't switch on the backlight pin, your screen will always be black. It is important to check how this pin can be switched on.
Using generic graphic SPI drivers
It's now possible to use generic graphic SPI drivers. It does require to build an image with the Generic_SPI.cpp driver. Once the image is flashed on the device, you can give the driver commands directly from a class in managed code. When building with a specific driver, the generic driver will be ignored even if you provide it.
Here is an example based on the ST7735S driver, we've been using enum for the registers:
private enum St7735
{
NOP = 0x00,
SOFTWARE_RESET = 0x01,
POWER_STATE = 0x10,
Sleep_Out = 0x11,
Invertion_Off = 0x20,
Invertion_On = 0x21,
Gamma_Set = 0x26,
Display_OFF = 0x28,
Display_ON = 0x29,
Column_Address_Set = 0x2A,
Page_Address_Set = 0x2B,
Memory_Write = 0x2C,
Colour_Set = 0x2D,
Me
Related Skills
node-connect
339.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
