Remarks

DotstarWing
Status
Source code GitHub
NuGet package

Code Example

public class MeadowApp : App<F7Micro, MeadowApp>
{
    DotstarWing dotStarWing;
    GraphicsLibrary graphics;

    public MeadowApp()
    {
        Initialize();
        DrawPixels();
        GoThroughEachPixel();
        ScrollText();
    }

    /// <remarks>NOTE: The dotstar feather by default is not connected to the SPI MOSI or SCK pins. 
    /// https://learn.adafruit.com/adafruit-dotstar-featherwing-adafruit/pinouts
    /// </remarks>
    void Initialize()
    {
        Console.WriteLine("Initialize hardware...");
        ISpiBus spiBus = Device.CreateSpiBus();
        IDigitalOutputPort spiPeriphChipSelect = Device.CreateDigitalOutputPort(Device.Pins.D04);

        dotStarWing = new DotstarWing(spiBus, spiPeriphChipSelect);

        graphics = new GraphicsLibrary(dotStarWing);
        graphics.CurrentFont = new Font4x8();

        dotStarWing.SetPenColor(Color.Blue);
        dotStarWing.Brightness = 0.1f;
    }

    void DrawPixels()
    {
        Console.WriteLine("DrawPixels...");
        dotStarWing.Clear(true);
        Thread.Sleep(1000);

        dotStarWing.DrawPixel(0, 0, Color.Red);
        dotStarWing.DrawPixel(11, 0, Color.White);
        dotStarWing.DrawPixel(0, 5, Color.Blue);
        dotStarWing.DrawPixel(11, 5, Color.Green);

        dotStarWing.Show();
    }

    void GoThroughEachPixel()
    {
        Thread.Sleep(2000);
        Console.WriteLine("Go Through Each Pixel...");
        dotStarWing.Clear(true);

        List<Color> colors = new List<Color>();
        colors.Add(Color.Red);
        colors.Add(Color.White);
        colors.Add(Color.Blue);
        colors.Add(Color.Green);
        colors.Add(Color.Yellow);
        colors.Add(Color.Purple);
        Random random = new Random();

        for (int y = 0; y< dotStarWing.Height; y++)
        {
            for(int x = 0; x < dotStarWing.Width; x++)
            {
                int rnd = random.Next(0, colors.Count);
                dotStarWing.Clear();
                dotStarWing.DrawPixel(x, y, colors[rnd]);
                dotStarWing.Show();
                Thread.Sleep(75);
            }
        }
    }

    void ScrollText()
    {
        Thread.Sleep(2000);
        Console.WriteLine("ScrollText...");

        dotStarWing.Clear();

        string text = "MEADOW";
        List<Color> colors = new List<Color>();
        colors.Add(Color.Red);
        colors.Add(Color.White);
        colors.Add(Color.Blue);
        colors.Add(Color.Green);
        colors.Add(Color.Yellow);
        colors.Add(Color.Purple);

        int x = 0;
        int colorIndex = 0;
        int scollWidth = (int)(-1 * (dotStarWing.Width + graphics.CurrentFont.Width + 8));
        int resetWidth = (int)(dotStarWing.Width + 2);

        while (true)
        {
            graphics.Clear();
            int offset = 0;
            colorIndex = 0;

            foreach (var chr in text)
            {
                graphics.DrawText(x + offset, 0, chr.ToString(), colors[colorIndex]);
                offset += graphics.CurrentFont.Width;
                colorIndex++;

                if (colorIndex >= colors.Count)
                    colorIndex = 0;
            }

            graphics.Show();

            x--;

            if (x < scollWidth)
                x = resetWidth;

            Thread.Sleep(175);
        }

    }
}
Characteristic Locus
Inheritance System.Object > DotstarWing
Namespace Meadow.Foundation.FeatherWings
Assembly DotstarWing.dll

Syntax

public class DotstarWing : DisplayBase

Constructors

DotstarWing(ISpiBus, IDigitalOutputPort)

Declaration
public DotstarWing(ISpiBus spiBus, IDigitalOutputPort chipSelect)

Parameters

Type Name Description
ISpiBus spiBus
IDigitalOutputPort chipSelect

DotstarWing(ISpiBus, IDigitalOutputPort, UInt32, PixelOrder, Boolean)

Declaration
public DotstarWing(ISpiBus spiBus, IDigitalOutputPort chipSelect, uint numberOfLeds, PixelOrder pixelOrder = null, bool autoWrite = false)

Parameters

Type Name Description
ISpiBus spiBus
IDigitalOutputPort chipSelect
System.UInt32 numberOfLeds
PixelOrder pixelOrder
System.Boolean autoWrite

Properties

Brightness

Declaration
public float Brightness { get; set; }

Property Value

Type Description
System.Single

ColorMode

Declaration
public override DisplayColorMode ColorMode { get; }

Property Value

Type Description
DisplayColorMode

Height

Declaration
public override uint Height { get; }

Property Value

Type Description
System.UInt32

Width

Declaration
public override uint Width { get; }

Property Value

Type Description
System.UInt32

Methods

Clear(Boolean)

Declaration
public override void Clear(bool updateDisplay = false)

Parameters

Type Name Description
System.Boolean updateDisplay

DrawPixel(Int32, Int32)

Declaration
public override void DrawPixel(int x, int y)

Parameters

Type Name Description
System.Int32 x
System.Int32 y

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

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

SetPenColor(Color)

Declaration
public override void SetPenColor(Color pen)

Parameters

Type Name Description
Color pen

Show()

Declaration
public override void Show()