Table of Contents

Class DisplayControl

Namespace
nanoFramework.UI
Assembly
nanoFramework.Graphics.dll

Display Control.

public static class DisplayControl
Inheritance
DisplayControl
Inherited Members

Properties

BitsPerPixel

Gets the number of bits per pixel used to display the screen. Currently 16 bits in RGB565 format.

public static int BitsPerPixel { get; }

Property Value

int

FullScreen

Gets a Bitmap object that is the size of the current display.

public static Bitmap FullScreen { get; }

Property Value

Bitmap

Remarks

Please make sure you check if you have enough memory with IsFullScreenBufferAvailable. If you don't have enough, the BitMap won't get initialized and will be null.

IsFullScreenBufferAvailable

Determines if a full size buffer is available based on the current screen configuration.

public static bool IsFullScreenBufferAvailable { get; }

Property Value

bool

LongerSide

Gets the number of pixels for the longer side of the screen.

public static int LongerSide { get; }

Property Value

int

MaximumBufferSize

Gets the maximum buffer size for Bitmap in bytes.

public static uint MaximumBufferSize { get; }

Property Value

uint

Orientation

Gets the current display orientation, either landscape or portrait.

public static DisplayOrientation Orientation { get; }

Property Value

DisplayOrientation

ScreenHeight

Gets the number of pixels for the height of the screen based on the orientation.

public static int ScreenHeight { get; }

Property Value

int

ScreenWidth

Gets the number of pixels for the width of the screen based on the orientation.

public static int ScreenWidth { get; }

Property Value

int

ShorterSide

Gets the number of pixels for the shorter side of the screen.

public static int ShorterSide { get; }

Property Value

int

Methods

ChangeOrientation(DisplayOrientation)

Changes the orientation of the display and recreates the display canvas with new dimensions.

public static bool ChangeOrientation(DisplayOrientation orientation)

Parameters

orientation DisplayOrientation

The new orientation to set.

Returns

bool

True if the orientation was supported and changed.

Remarks

When the orientation is changed, the display canvas is disposed and recreated with the new dimensions when FullScreen property is next called.

Clear()

Clears the screen.

public static void Clear()

Initialize(I2cConfiguration, ScreenConfiguration, uint)

Initializes the screen to use with I2C configuration.

public static uint Initialize(I2cConfiguration i2c, ScreenConfiguration screen, uint bufferSize = 20480)

Parameters

i2c I2cConfiguration
screen ScreenConfiguration

A screen configuration.

bufferSize uint

The desired buffer size allocation, 0 for default.

Returns

uint

The maximum buffer size possible allocation in bytes.

Remarks

You may have to configure the pins properly for the I2C configuration to be valid before initializing your screen.

Initialize(SpiConfiguration, ScreenConfiguration, uint)

Initializes the screen for use with Spi configuration.

public static uint Initialize(SpiConfiguration spi, ScreenConfiguration screen, uint bufferSize = 20480)

Parameters

spi SpiConfiguration

Spi configuration.

screen ScreenConfiguration

A screen configuration.

bufferSize uint

The desired buffer size allocation, 0 for default.

Returns

uint

The maximum buffer size possible allocation in bytes.

Remarks

You may have to configure the pins properly for the Spi configuration to be valid before initializing your screen.

Write(string, ushort, ushort, ushort, ushort, Font, Color, Color)

Directly write on the screen a text at coordinate x,y a width,height with a background and foreground color.

public static void Write(string text, ushort x, ushort y, ushort width, ushort height, Font font, Color foreground, Color background)

Parameters

text string

The text to write.

x ushort

The x coordinate.

y ushort

The y coordinate.

width ushort

The width of the area to display.

height ushort

The height of the area to display.

font Font

The font to use.

foreground Color

Foreground color.

background Color

Background color.

Write(ushort, ushort, ushort, ushort, Color[])

Directly write in the screen at coordinate x,y a width,height buffer of 16 bits colors.

public static void Write(ushort x, ushort y, ushort width, ushort height, Color[] colors)

Parameters

x ushort

The x coordinate.

y ushort

The y coordinate.

width ushort

The width of the area to display.

height ushort

The height of the area to display.

colors Color[]

A color array.

Remarks

The color array will be transformed in managed side to a ushort BGR565 array.

Write(ushort, ushort, ushort, ushort, ushort[])

Directly write in the screen at coordinate x,y a width,height buffer of 16 bits colors.

public static void Write(ushort x, ushort y, ushort width, ushort height, ushort[] colors)

Parameters

x ushort

The x coordinate.

y ushort

The y coordinate.

width ushort

The width of the area to display.

height ushort

The height of the area to display.

colors ushort[]

A BGR565, 16 bits color array.

WritePoint(ushort, ushort, Color)

Writes a single point on the screen with the specified color.

public static void WritePoint(ushort x, ushort y, Color color)

Parameters

x ushort

The x coordinate of the point to be written.

y ushort

The y coordinate of the point to be written.

color Color

The 16-bit color value of the point to be written BGR656 format.

WritePoint(ushort, ushort, ushort)

Writes a single point on the screen with the specified color.

public static void WritePoint(ushort x, ushort y, ushort color)

Parameters

x ushort

The x coordinate of the point to be written.

y ushort

The y coordinate of the point to be written.

color ushort

The 16-bit color value of the point to be written BGR656 format.