Remarks

St7565
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Displays.St7565

Code Example

MicroGraphics graphics;

public override Task Initialize()
{
    Console.WriteLine("Initializing...");

    var sT7565 = new St7565
    (
        device: Device,
        spiBus: Device.CreateSpiBus(),
        chipSelectPin: Device.Pins.D02,
        dcPin: Device.Pins.D00,
        resetPin: Device.Pins.D01,
        width: 128,
        height: 64
    );

    graphics = new MicroGraphics(sT7565);
    graphics.CurrentFont = new Font8x8();

    return base.Initialize();
}

public override Task Run()
{
    graphics.Clear();
    graphics.DrawTriangle(10, 10, 50, 50, 10, 50, Meadow.Foundation.Color.Red);
    graphics.DrawRectangle(20, 15, 40, 20, Meadow.Foundation.Color.Yellow, true);
    graphics.DrawText(5, 5, "ST7565");
    graphics.Show();

    return base.Run();
}

Sample project(s) available on GitHub

Wiring Example

To wire a ST7565 to your Meadow board, connect the following:

ST7565 Meadow Pin
LEDA GND
GND GND
VCC 3V3
SDA MOSI
SCL SCK
A0 D00
RST D01
CS D02

Characteristic Locus
Inheritance System.Object > St7565
Implements IGraphicsDisplay
Namespace Meadow.Foundation.Displays
Assembly St7565.dll

Syntax

public class St7565 : object, IGraphicsDisplay

Constructors

St7565(IMeadowDevice, ISpiBus, IPin, IPin, IPin, Int32, Int32)

Create a new ST7565 object

Declaration
public St7565(IMeadowDevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, int width = 128, int height = 64)

Parameters

Type Name Description
IMeadowDevice device

Meadow device

ISpiBus spiBus

SPI bus connected to display

IPin chipSelectPin

Chip select pin

IPin dcPin

Data command pin

IPin resetPin

Reset pin

System.Int32 width

Width of display in pixels

System.Int32 height

Height of display in pixels

St7565(ISpiBus, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, Int32, Int32)

Create a new St7565 display object

Declaration
public St7565(ISpiBus spiBus, IDigitalOutputPort chipSelectPort, IDigitalOutputPort dataCommandPort, IDigitalOutputPort resetPort, int width = 128, int height = 64)

Parameters

Type Name Description
ISpiBus spiBus

SPI bus connected to display

IDigitalOutputPort chipSelectPort

Chip select output port

IDigitalOutputPort dataCommandPort

Data command output port

IDigitalOutputPort resetPort

Reset output port

System.Int32 width

Width of display in pixels

System.Int32 height

Height of display in pixels

Fields

chipSelectPort

Declaration
protected IDigitalOutputPort chipSelectPort

Field Value

Type Description
IDigitalOutputPort

Command

Declaration
protected const bool Command = null

Field Value

Type Description
System.Boolean

ContrastHigh

Declaration
public const uint ContrastHigh = null

Field Value

Type Description
System.UInt32

ContrastLow

Declaration
public const uint ContrastLow = null

Field Value

Type Description
System.UInt32

ContrastMedium

Declaration
public const uint ContrastMedium = null

Field Value

Type Description
System.UInt32

Data

Declaration
protected const bool Data = null

Field Value

Type Description
System.Boolean

dataCommandPort

Declaration
protected IDigitalOutputPort dataCommandPort

Field Value

Type Description
IDigitalOutputPort

imageBuffer

Declaration
protected Buffer1bpp imageBuffer

Field Value

Type Description
Buffer1bpp

pageBuffer

Declaration
protected byte[] pageBuffer

Field Value

Type Description
System.Byte[]

PageSize

Declaration
protected const int PageSize = null

Field Value

Type Description
System.Int32

resetPort

Declaration
protected IDigitalOutputPort resetPort

Field Value

Type Description
IDigitalOutputPort

spiPerihperal

SPI peripheral object

Declaration
protected ISpiPeripheral spiPerihperal

Field Value

Type Description
ISpiPeripheral

StartColumnOffset

Declaration
protected const int StartColumnOffset = null

Field Value

Type Description
System.Int32

Properties

ColorMode

The display color mode - 1 bit per pixel monochrome

Declaration
public ColorType ColorMode { get; }

Property Value

Type Description
ColorType

Height

The display height in pixels

Declaration
public int Height { get; }

Property Value

Type Description
System.Int32

PixelBuffer

The buffer the holds the pixel data for the display

Declaration
public IPixelBuffer PixelBuffer { get; }

Property Value

Type Description
IPixelBuffer

Width

The display width in pixels

Declaration
public int Width { get; }

Property Value

Type Description
System.Int32

Methods

Clear(Boolean)

Clear the display buffer

Declaration
public void Clear(bool updateDisplay = false)

Parameters

Type Name Description
System.Boolean updateDisplay

Immediately update the display when true

DrawPixel(Int32, Int32, Color)

Draw pixel at a location

Declaration
public void DrawPixel(int x, int y, Color color)

Parameters

Type Name Description
System.Int32 x

Abscissa of the pixel to the set / reset

System.Int32 y

Ordinate of the pixel to the set / reset

Color color

Any color = turn on pixel, black = turn off pixel

DrawPixel(Int32, Int32, Boolean)

Draw pixel at a location

Declaration
public void DrawPixel(int x, int y, bool enabled)

Parameters

Type Name Description
System.Int32 x

Abscissa of the pixel to the set / reset

System.Int32 y

Ordinate of the pixel to the set / reset

System.Boolean enabled

True = turn on pixel, false = turn off pixel

Fill(Color, Boolean)

Declaration
public void Fill(Color clearColor, bool updateDisplay = false)

Parameters

Type Name Description
Color clearColor
System.Boolean updateDisplay

Fill(Int32, Int32, Int32, Int32, Color)

Declaration
public void Fill(int x, int y, int width, int height, Color color)

Parameters

Type Name Description
System.Int32 x
System.Int32 y
System.Int32 width
System.Int32 height
Color color

InvertDisplay(Boolean)

Invert the entire display (true) or return to normal mode (false).

Declaration
public void InvertDisplay(bool cmd)

Parameters

Type Name Description
System.Boolean cmd

InvertPixel(Int32, Int32)

Invert a pixel at a location

Declaration
public void InvertPixel(int x, int y)

Parameters

Type Name Description
System.Int32 x

Abscissa of the pixel to the set / reset

System.Int32 y

Ordinate of the pixel to the set / reset

PowerSaveMode()

Declaration
public void PowerSaveMode()

SetContrast(UInt32)

Declaration
public void SetContrast(uint contrast)

Parameters

Type Name Description
System.UInt32 contrast

Show()

Send the internal pixel buffer to display

Declaration
public void Show()

Show(Int32, Int32, Int32, Int32)

Declaration
public void Show(int left, int top, int right, int bottom)

Parameters

Type Name Description
System.Int32 left
System.Int32 top
System.Int32 right
System.Int32 bottom

StartScrolling(St7565.ScrollDirection)

Start the display scrollling in the specified direction.

Declaration
public void StartScrolling(St7565.ScrollDirection direction)

Parameters

Type Name Description
St7565.ScrollDirection direction

Direction that the display should scroll

StartScrolling(St7565.ScrollDirection, Byte, Byte)

Start the display scrolling

Declaration
public void StartScrolling(St7565.ScrollDirection direction, byte startPage, byte endPage)

Parameters

Type Name Description
St7565.ScrollDirection direction

Direction that the display should scroll

System.Byte startPage

Start page for the scroll

System.Byte endPage

End oage for the scroll

Remarks

In most cases setting startPage to 0x00 and endPage to 0xff will achieve an acceptable scrolling effect

StopScrolling()

Turn off scrolling

Declaration
public void StopScrolling()

Remarks

Datasheet states that scrolling must be turned off before changing the scroll direction in order to prevent RAM corruption

WriteBuffer(Int32, Int32, IPixelBuffer)

Declaration
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)

Parameters

Type Name Description
System.Int32 x
System.Int32 y
IPixelBuffer displayBuffer