-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from WildernessLabs/neopixelwing
Neopixelwing + denugetize
- Loading branch information
Showing
20 changed files
with
348 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
using Meadow.Foundation.Graphics; | ||
using Meadow.Foundation.Graphics.Buffers; | ||
using Meadow.Foundation.Leds; | ||
using Meadow.Hardware; | ||
using System; | ||
|
||
namespace Meadow.Foundation.FeatherWings | ||
{ | ||
/// <summary> | ||
/// Represents Adafruits NeoPixel FeatherWing | ||
/// </summary> | ||
public class NeoPixelWing : IGraphicsDisplay | ||
{ | ||
/// <summary> | ||
/// Color mode of display | ||
/// </summary> | ||
public ColorMode ColorMode => ColorMode.Format24bppGrb888; | ||
|
||
/// <summary> | ||
/// Width of display in pixels | ||
/// </summary> | ||
public int Width => 8; | ||
|
||
/// <summary> | ||
/// Height of display in pixels | ||
/// </summary> | ||
public int Height => 4; | ||
|
||
/// <summary> | ||
/// The pixel buffer that represents the offscreen buffer | ||
/// Not implemented for this driver | ||
/// </summary> | ||
public IPixelBuffer PixelBuffer { get; protected set; } | ||
|
||
/// <summary> | ||
/// Color modes supported by the device | ||
/// </summary> | ||
public ColorMode SupportedColorModes => ColorMode.Format24bppRgb888; | ||
|
||
/// <summary> | ||
/// Returns Ws2812 instance | ||
/// </summary> | ||
public Ws2812 Leds { get; protected set; } | ||
|
||
/// <summary> | ||
/// Creates a NeoPixelWing driver instance | ||
/// </summary> | ||
/// <param name="spiBus">The SPI bus connected to the wing</param> | ||
public NeoPixelWing(ISpiBus spiBus) | ||
{ | ||
Leds = new Ws2812(spiBus, 32); | ||
PixelBuffer = new BufferRgb888(8, 4); | ||
} | ||
|
||
/// <summary> | ||
/// Clear the display buffer | ||
/// </summary> | ||
/// <param name="updateDisplay">Force a display update if true, false to clear the buffer</param> | ||
public void Clear(bool updateDisplay = false) | ||
{ | ||
PixelBuffer.Clear(); | ||
|
||
if(updateDisplay) | ||
{ | ||
Show(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Turn on an RGB LED with the specified color on (x,y) coordinates | ||
/// </summary> | ||
/// <param name="x">The x position in pixels 0 indexed from the left</param> | ||
/// <param name="y">The y position in pixels 0 indexed from the top</param> | ||
/// <param name="color">The color to draw normalized to black/off or white/on</param> | ||
public void DrawPixel(int x, int y, Color color) | ||
{ | ||
PixelBuffer.SetPixel(x, y, color); | ||
} | ||
|
||
/// <summary> | ||
/// Turn on a LED on (x,y) coordinates | ||
/// </summary> | ||
/// <param name="x">The x position in pixels 0 indexed from the left</param> | ||
/// <param name="y">The y position in pixels 0 indexed from the top</param> | ||
/// <param name="colored">Led is on if true, off if false</param> | ||
public void DrawPixel(int x, int y, bool colored) | ||
{ | ||
DrawPixel(x, y, colored ? Color.White : Color.Black); | ||
} | ||
|
||
/// <summary> | ||
/// Invert the color of the pixel at the given location | ||
/// </summary> | ||
/// <param name="x">The x position in pixels 0 indexed from the left</param> | ||
/// <param name="y">The y position in pixels 0 indexed from the top</param> | ||
public void InvertPixel(int x, int y) | ||
{ | ||
PixelBuffer?.InvertPixel(x, y); | ||
} | ||
|
||
/// <summary> | ||
/// Draw a buffer to the display | ||
/// </summary> | ||
/// <param name="x">The x position in pixels 0 indexed from the left</param> | ||
/// <param name="y">The y position in pixels 0 indexed from the top</param> | ||
/// <param name="displayBuffer">The display buffer to draw to the CharlieWing</param> | ||
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer) | ||
{ | ||
PixelBuffer.WriteBuffer(x, y, displayBuffer); | ||
} | ||
|
||
/// <summary> | ||
/// Fill the display buffer to a normalized color | ||
/// </summary> | ||
/// <param name="fillColor">The clear color which will be normalized to black/off or white/on</param> | ||
/// <param name="updateDisplay">Force a display update if true, false to clear the buffer</param> | ||
public void Fill(Color fillColor, bool updateDisplay = false) | ||
{ | ||
PixelBuffer.Fill(fillColor); | ||
|
||
if(updateDisplay) | ||
{ Show(); } | ||
} | ||
|
||
/// <summary> | ||
/// Fill the display | ||
/// </summary> | ||
/// <param name="x">The x position in pixels 0 indexed from the left</param> | ||
/// <param name="y">The y position in pixels 0 indexed from the top</param> | ||
/// <param name="width">The width to fill in pixels</param> | ||
/// <param name="height">The height to fill in pixels</param> | ||
/// <param name="fillColor">The fillColor color which will be normalized to black/off or white/on</param> | ||
public void Fill(int x, int y, int width, int height, Color fillColor) | ||
{ | ||
PixelBuffer.Fill(height, x, y, width, fillColor); | ||
} | ||
|
||
/// <summary> | ||
/// Update the display from the offscreen buffer | ||
/// </summary> | ||
public void Show() | ||
{ | ||
for(int i = 0; i < PixelBuffer.Width; i++) | ||
{ | ||
for(int j = 0; j < PixelBuffer.Height; j++) | ||
{ | ||
Leds.SetLed(i + j * Width, PixelBuffer.GetPixel(i, j)); | ||
} | ||
} | ||
|
||
Leds.Show(); | ||
} | ||
|
||
/// <summary> | ||
/// Update a region of the display from the offscreen buffer | ||
/// </summary> | ||
/// <param name="left">The left bounding position in pixels</param> | ||
/// <param name="top">The top bounding position in pixels</param> | ||
/// <param name="right">The right bounding position in pixels</param> | ||
/// <param name="bottom">The bottom bounding position in pixels</param> | ||
public void Show(int left, int top, int right, int bottom) | ||
{ | ||
Show(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Meadow.Sdk/1.1.0"> | ||
<PropertyGroup> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PackageIcon>icon.png</PackageIcon> | ||
<Authors>Wilderness Labs, Inc</Authors> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<AssemblyName>NeoPixelWing</AssemblyName> | ||
<Company>Wilderness Labs, Inc</Company> | ||
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/</PackageProjectUrl> | ||
<PackageId>Meadow.Foundation.FeatherWings.NeoPixelWing</PackageId> | ||
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.Foundation.FeatherWings</RepositoryUrl> | ||
<PackageTags>Meadow.Foundation,FeatherWing,NeoPixel,WS2812</PackageTags> | ||
<Version>0.1.0</Version> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Description>AdaFruit NeoPixel FeatherWing</Description> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include="..\..\icon.png" Pack="true" PackagePath="" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Libraries_and_Frameworks\Graphics.MicroGraphics\Driver\Graphics.MicroGraphics.csproj" /> | ||
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Leds.Ws2812\Driver\Leds.Ws2812.csproj" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.