Remarks
Yx5300 | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
RgbPwmLed onboardLed;
Ssd1327 display;
GraphicsLibrary graphics;
public MeadowApp()
{
Initialize();
Console.WriteLine("Init complete");
onboardLed.SetColor(Color.Green);
display.Clear();
for (int i = 0; i < 32; i++)
{
display.DrawPixel(i, i, true);
}
Console.WriteLine("Simple line");
display.Show();
Thread.Sleep(2000);
graphics.Clear();
for(int i = 10; i > 0; i--)
{
graphics.DrawText(0, i * 12, "SSD1327", Color.FromRgb(i * 0.1, i * 0.1, i * 0.1));
}
Console.WriteLine("Show Text");
graphics.Show();
Thread.Sleep(5000);
TestDisplay();
Console.WriteLine("Finished");
}
void TestDisplay()
{
while (true)
{
PolarLineTest();
Thread.Sleep(5000);
RoundRectTest();
Thread.Sleep(5000);
QuadrantTest();
Thread.Sleep(5000);
ColorFontTest();
Thread.Sleep(5000);
}
onboardLed.SetColor(Color.Red);
}
void Initialize()
{
Console.WriteLine("Initialize display...");
var spiBus = Device.CreateSpiBus();
display = new Ssd1327(
device: Device,
spiBus: spiBus,
chipSelectPin: Device.Pins.D02,
dcPin: Device.Pins.D01, resetPin:
Device.Pins.D00);
display.SetContrast(60);
graphics = new GraphicsLibrary(display);
graphics.CurrentFont = new Font8x12();
Console.WriteLine("Initialize led...");
onboardLed = new RgbPwmLed(device: Device,
redPwmPin: Device.Pins.OnboardLedRed,
greenPwmPin: Device.Pins.OnboardLedGreen,
bluePwmPin: Device.Pins.OnboardLedBlue,
3.3f, 3.3f, 3.3f,
Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode);
}
void PolarLineTest()
{
graphics.Clear();
graphics.Stroke = 1;
for (int i = 0; i < 270; i += 12)
{
graphics.DrawLine(64, 64, 60, (float)(i * Math.PI / 180), Color.White);
}
graphics.Show();
}
void RoundRectTest()
{
graphics.Clear();
graphics.Stroke = 1;
graphics.DrawRoundedRectangle(10, 10, 100, 100, 10, Color.Orange, false);
graphics.DrawRoundedRectangle(20, 20, 100, 60, 20, Color.Blue, true);
graphics.Show();
}
void QuadrantTest()
{
graphics.Clear();
graphics.DrawCircleQuadrant(64, 64, 60, 0, Color.Yellow, true);
graphics.DrawCircleQuadrant(64, 64, 60, 1, Color.Blue, true);
graphics.DrawCircleQuadrant(64, 64, 60, 2, Color.Cyan, true);
graphics.DrawCircleQuadrant(64, 64, 60, 3, Color.LawnGreen, true);
graphics.Show();
}
void ColorFontTest()
{
graphics.CurrentFont = new Font8x12();
graphics.Clear();
graphics.DrawTriangle(120, 20, 200, 100, 120, 100, Meadow.Foundation.Color.Red, false);
graphics.DrawRectangle(140, 30, 40, 90, Meadow.Foundation.Color.Yellow, false);
graphics.DrawCircle(160, 80, 40, Meadow.Foundation.Color.Cyan, false);
int indent = 5;
int spacing = 14;
int y = indent;
graphics.DrawText(indent, y, "Meadow + SSD1327!!");
graphics.DrawText(indent, y += spacing, "Red", Meadow.Foundation.Color.Red);
graphics.DrawText(indent, y += spacing, "Purple", Meadow.Foundation.Color.Purple);
graphics.DrawText(indent, y += spacing, "BlueViolet", Meadow.Foundation.Color.BlueViolet);
graphics.DrawText(indent, y += spacing, "Blue", Meadow.Foundation.Color.Blue);
graphics.DrawText(indent, y += spacing, "Cyan", Meadow.Foundation.Color.Cyan);
graphics.DrawText(indent, y += spacing, "LawnGreen", Meadow.Foundation.Color.LawnGreen);
graphics.DrawText(indent, y += spacing, "GreenYellow", Meadow.Foundation.Color.GreenYellow);
graphics.DrawText(indent, y += spacing, "Yellow", Meadow.Foundation.Color.Yellow);
graphics.DrawText(indent, y += spacing, "Orange", Meadow.Foundation.Color.Orange);
graphics.DrawText(indent, y += spacing, "Brown", Meadow.Foundation.Color.Brown);
graphics.Show();
Console.WriteLine("Show complete");
}
}
Sample projects available on GitHub
Wiring Example
To wire a Ssd1327 to your Meadow board, connect the following:
Ssd1327 | Meadow Pin |
---|---|
GND | GND |
VCC | 3V3 |
SCL | SCK |
SDA | MOSI |
RESET | D00 |
DC | D01 |
CS | D02 |
Characteristic | Locus |
---|---|
Inheritance | System.Object DisplayBase > Ssd1327 |
Inherited Members | DisplayBase.IgnoreOutOfBoundsPixels |
Namespace | Meadow.Foundation.Displays |
Assembly | Ssd1327.dll |
Syntax
public class Ssd1327 : DisplayBase
Constructors
Ssd1327(IIODevice, ISpiBus, IPin, IPin, IPin)
Declaration
public Ssd1327(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | |
ISpiBus | spiBus | |
IPin | chipSelectPin | |
IPin | dcPin | |
IPin | resetPin |
Fields
chipSelectPort
Declaration
protected IDigitalOutputPort chipSelectPort
Field Value
Type | Description |
---|---|
IDigitalOutputPort |
Command
Declaration
protected const bool Command = false
Field Value
Type | Description |
---|---|
System.Boolean |
currentPen
Declaration
protected byte currentPen
Field Value
Type | Description |
---|---|
System.Byte |
Data
Declaration
protected const bool Data = true
Field Value
Type | Description |
---|---|
System.Boolean |
dataCommandPort
Declaration
protected IDigitalOutputPort dataCommandPort
Field Value
Type | Description |
---|---|
IDigitalOutputPort |
resetPort
Declaration
protected IDigitalOutputPort resetPort
Field Value
Type | Description |
---|---|
IDigitalOutputPort |
spiBuffer
Declaration
protected readonly byte[] spiBuffer
Field Value
Type | Description |
---|---|
System.Byte[] |
spiBus
Declaration
protected SpiBus spiBus
Field Value
Type | Description |
---|---|
SpiBus |
spiPeripheral
Declaration
protected ISpiPeripheral spiPeripheral
Field Value
Type | Description |
---|---|
ISpiPeripheral |
spiReceive
Declaration
protected readonly byte[] spiReceive
Field Value
Type | Description |
---|---|
System.Byte[] |
xMax
Declaration
protected uint xMax
Field Value
Type | Description |
---|---|
System.UInt32 |
xMin
Declaration
protected uint xMin
Field Value
Type | Description |
---|---|
System.UInt32 |
yMax
Declaration
protected uint yMax
Field Value
Type | Description |
---|---|
System.UInt32 |
yMin
Declaration
protected uint yMin
Field Value
Type | Description |
---|---|
System.UInt32 |
Properties
ColorMode
Declaration
public override DisplayBase.DisplayColorMode ColorMode { get; }
Property Value
Type | Description |
---|---|
DisplayBase.DisplayColorMode |
Overrides
Height
Declaration
public override uint Height { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Overrides
Width
Declaration
public override uint Width { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Overrides
Methods
Clear(Boolean)
Declaration
public override void Clear(bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | updateDisplay |
Overrides
DrawPixel(Int32, Int32)
Declaration
public override void DrawPixel(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y |
Overrides
DrawPixel(Int32, Int32, Color)
Declaration
public override void DrawPixel(int x, int y, Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y | |
Color | color |
Overrides
DrawPixel(Int32, Int32, Boolean)
Declaration
public override void DrawPixel(int x, int y, bool colored)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y | |
System.Boolean | colored |
Overrides
DrawPixel(Int32, Int32, Byte)
Declaration
public void DrawPixel(int x, int y, byte gray)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y | |
System.Byte | gray |
FillBuffer()
Declaration
public void FillBuffer()
Initialize()
Declaration
protected void Initialize()
InvertPixel(Int32, Int32)
Declaration
public override void InvertPixel(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y |
Overrides
SendCommand(Byte)
Declaration
protected void SendCommand(byte command)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | command |
SendData(Byte)
Declaration
protected void SendData(byte data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | data |
SendData(Byte[])
Declaration
protected void SendData(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data |
SendData(Int32)
Declaration
protected void SendData(int data)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | data |
SetContrast(Byte)
Declaration
public void SetContrast(byte contrast)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | contrast |
SetPenColor(Color)
Declaration
public override void SetPenColor(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color |
Overrides
Show()
Declaration
public override void Show()
Overrides
Write(Byte)
Declaration
protected void Write(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value |
Write(Byte[])
Declaration
protected void Write(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data |