Characteristic | Locus |
---|---|
Inheritance | object > Sh110x > Sh1106 > Sh1107 |
Implements | IGraphicsDisplay ISpiPeripheral II2cPeripheral IDisposable |
Inherited Members | object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() |
Namespace | Meadow.Foundation.Displays |
Assembly | Sh110x.dll |
Syntax
public abstract class Sh110x : IGraphicsDisplay, ISpiPeripheral, II2cPeripheral, IDisposable
Constructors
Sh110x(II2cBus, byte, int, int)
Create a new Sh110x object
Declaration
public Sh110x(II2cBus i2cBus, byte address, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | I2C bus connected to display |
byte | address | I2C address |
int | width | Display width in pixels |
int | height | Display height in pixels |
Sh110x(ISpiBus, IDigitalOutputPort?, IDigitalOutputPort, IDigitalOutputPort, int, int)
Create a new Sh110x display object
Declaration
public Sh110x(ISpiBus spiBus, IDigitalOutputPort? chipSelectPort, IDigitalOutputPort dataCommandPort, IDigitalOutputPort resetPort, int width, int height)
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 |
int | width | Display width in pixels |
int | height | Display height in pixels |
Sh110x(ISpiBus, IPin?, IPin, IPin, int, int)
Create a new Sh110x object
Declaration
public Sh110x(ISpiBus spiBus, IPin? chipSelectPin, IPin dcPin, IPin resetPin, int width, int height)
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 |
int | width | Display width in pixels |
int | height | Display height in pixels |
Fields
commandBuffer
Display command buffer
Declaration
protected Memory<byte> commandBuffer
Field Value
Type | Description |
---|---|
Memory<byte> |
connectionType
The connection type (I2C or SPI)
Declaration
protected Sh110x.ConnectionType connectionType
Field Value
Type | Description |
---|---|
Sh110x.ConnectionType |
i2cComms
I2C Communication bus used to communicate with the peripheral
Declaration
protected readonly II2cCommunications? i2cComms
Field Value
Type | Description |
---|---|
II2cCommunications |
spiComms
SPI Communication bus used to communicate with the peripheral
Declaration
protected ISpiCommunications? spiComms
Field Value
Type | Description |
---|---|
ISpiCommunications |
Properties
ColorMode
The display color mode - 1 bit per pixel monochrome
Declaration
public ColorMode ColorMode { get; }
Property Value
Type | Description |
---|---|
ColorMode |
DefaultI2cAddress
The default I2C address for the peripheral
Declaration
public byte DefaultI2cAddress { get; }
Property Value
Type | Description |
---|---|
byte |
DefaultSpiBusMode
The default SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode DefaultSpiBusMode { get; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
DefaultSpiBusSpeed
The default SPI bus speed for the device
Declaration
public Frequency DefaultSpiBusSpeed { get; }
Property Value
Type | Description |
---|---|
Frequency |
Height
The display height in pixels
Declaration
public int Height { get; protected set; }
Property Value
Type | Description |
---|---|
int |
IsDisposed
Is the object disposed
Declaration
public bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
bool |
PixelBuffer
The buffer the holds the pixel data for the display
Declaration
public IPixelBuffer PixelBuffer { get; }
Property Value
Type | Description |
---|---|
IPixelBuffer |
SpiBusMode
The SPI bus mode for the device
Declaration
public SpiClockConfiguration.Mode SpiBusMode { get; set; }
Property Value
Type | Description |
---|---|
SpiClockConfiguration.Mode |
SpiBusSpeed
The SPI bus speed for the device
Declaration
public Frequency SpiBusSpeed { get; set; }
Property Value
Type | Description |
---|---|
Frequency |
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; protected set; }
Property Value
Type | Description |
---|---|
int |
Methods
Clear(bool)
Clear the display buffer
Declaration
public void Clear(bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
bool | updateDisplay | Immediately update the display when true |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(bool)
Dispose of the object
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Is disposing |
DrawPixel(int, int, Color)
Draw pixel at a location
Declaration
public void DrawPixel(int x, int y, Color color)
Parameters
Type | Name | Description |
---|---|---|
int | x | Abscissa of the pixel to the set / reset |
int | y | Ordinate of the pixel to the set / reset |
Color | color | Any color = turn on pixel, black = turn off pixel |
DrawPixel(int, int, bool)
Draw pixel at a location
Declaration
public void DrawPixel(int x, int y, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
int | x | Abscissa of the pixel to the set / reset |
int | y | Ordinate of the pixel to the set / reset |
bool | enabled | True = turn on pixel, false = turn off pixel |
Fill(Color, bool)
Fill display buffer with a color
Declaration
public void Fill(Color clearColor, bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
Color | clearColor | The fill color |
bool | updateDisplay | If true, update display |
Fill(int, int, int, int, Color)
Fill with a color
Declaration
public void Fill(int x, int y, int width, int height, Color color)
Parameters
Type | Name | Description |
---|---|---|
int | x | X start position in pixels |
int | y | Y start position in pixels |
int | width | Width in pixels |
int | height | Height in pixels |
Color | color | The fill color |
Initialize()
Initialize the display
Declaration
protected abstract void Initialize()
InvertDisplay(bool)
Invert the entire display (true) or return to normal mode (false)
Declaration
public void InvertDisplay(bool invert)
Parameters
Type | Name | Description |
---|---|---|
bool | invert |
InvertPixel(int, int)
Invert a pixel at a location
Declaration
public void InvertPixel(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
int | x | Abscissa of the pixel to the set / reset |
int | y | Ordinate of the pixel to the set / reset |
PowerSaveMode()
Set display into power saving mode
Declaration
public void PowerSaveMode()
Reset()
Reset for SPI displays
Declaration
protected void Reset()
SetContrast(byte)
Set the display contrast
Declaration
public void SetContrast(byte contrast)
Parameters
Type | Name | Description |
---|---|---|
byte | contrast | The contrast value (0-63) |
SetDisplayOffset(byte)
This varies between manufactures If the display is misaligned, try 0 and 0x40
Declaration
public void SetDisplayOffset(byte offset)
Parameters
Type | Name | Description |
---|---|---|
byte | offset |
Show()
Send the internal pixel buffer to display
Declaration
public void Show()
Show(int, int, int, int)
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 |
---|---|---|
int | left | Left bounds in pixels |
int | top | Top bounds in pixels |
int | right | Right bounds in pixels |
int | bottom | Bottom bounds in pixels |
StartScrolling(ScrollDirection)
Start the display scrolling in the specified direction.
Declaration
public void StartScrolling(Sh110x.ScrollDirection direction)
Parameters
Type | Name | Description |
---|---|---|
Sh110x.ScrollDirection | direction | Direction that the display should scroll |
StartScrolling(ScrollDirection, byte, byte)
Start the display scrolling
Declaration
public void StartScrolling(Sh110x.ScrollDirection direction, byte startPage, byte endPage)
Parameters
Type | Name | Description |
---|---|---|
Sh110x.ScrollDirection | direction | Direction that the display should scroll |
byte | startPage | Start page for the scroll |
byte | endPage | End page 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(int, int, IPixelBuffer)
Write a buffer to the display offscreen buffer
Declaration
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)
Parameters
Type | Name | Description |
---|---|---|
int | x | The x position in pixels to write the buffer |
int | y | The y position in pixels to write the buffer |
IPixelBuffer | displayBuffer | The buffer to write |