Remarks
St7565 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
MicroGraphics graphics;
public override Task Initialize()
{
Resolver.Log.Info("Initializing...");
var sT7565 = new St7565
(
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 |
Namespace | Meadow.Foundation.Displays |
Assembly | St7565.dll |
Syntax
public class St7565 : IGraphicsDisplay
Constructors
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 |
St7565(ISpiBus, IPin, IPin, IPin, Int32, Int32)
Create a new ST7565 object
Declaration
public St7565(ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, int width = 128, int height = 64)
Parameters
Type | Name | Description |
---|---|---|
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 |
Properties
ColorMode
The display color mode - 1 bit per pixel monochrome
Declaration
public ColorMode ColorMode { get; }
Property Value
Type | Description |
---|---|
ColorMode |
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 |
SupportedColorModes
The Color mode supported by the display
Declaration
public ColorMode SupportedColorModes { get; }
Property Value
Type | Description |
---|---|
ColorMode |
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)
Fill display buffer with a color
Declaration
public void Fill(Color clearColor, bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
Color | clearColor | The fill color |
System.Boolean | updateDisplay | If true, update display |
Fill(Int32, Int32, Int32, Int32, Color)
Fill with a color
Declaration
public void Fill(int x, int y, int width, int height, Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | X start position in pixels |
System.Int32 | y | Y start position in pixels |
System.Int32 | width | Width in pixels |
System.Int32 | height | Height in pixels |
Color | color | The fill 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()
Set display into power saving mode
Declaration
public void PowerSaveMode()
SetContrast(Byte)
Set the display contrast
Declaration
public void SetContrast(byte contrast)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | contrast | The contrast value (0-63) |
Show()
Send the internal pixel buffer to display
Declaration
public void Show()
Show(Int32, Int32, Int32, Int32)
Update a region of the display from the offscreen buffer
Declaration
public void Show(int left, int top, int right, int bottom)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | left | Left bounds in pixels |
System.Int32 | top | Top bounds in pixels |
System.Int32 | right | Right bounds in pixels |
System.Int32 | bottom | Bottom bounds in pixels |
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)
Write a buffer to the display offscreen buffer
Declaration
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x position in pixels to write the buffer |
System.Int32 | y | The y position in pixels to write the buffer |
IPixelBuffer | displayBuffer | The buffer to write |