From 3709c43168ff22c0ed734fc9b24dd6d0fee59446 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Thu, 10 Aug 2023 20:25:57 -0700 Subject: [PATCH 1/4] Add missing external project references --- Source/FeatherWings.sln | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/Source/FeatherWings.sln b/Source/FeatherWings.sln index 35fddc9..ad06a87 100644 --- a/Source/FeatherWings.sln +++ b/Source/FeatherWings.sln @@ -95,6 +95,26 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Displays.Ssd130x", "..\..\M EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Foundation.Core", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Core\Meadow.Foundation.Core.csproj", "{694940BF-DBE9-4650-AD84-6B69C5D6088A}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NeoPixelWing", "NeoPixelWing", "{746A2619-CBF1-47E2-A5C2-06DD8FCBB439}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoPixelWing", "NeoPixelWing\Driver\NeoPixelWing.csproj", "{2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Leds.Ws2812", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Leds.Ws2812\Driver\Leds.Ws2812.csproj", "{238778FF-05AC-4A4C-A9DE-C4A3CCA09A34}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{9D07325E-A887-47FF-9D2F-47070B1F3D57}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeoPixelWing_Sample", "NeoPixelWing\Sample\NeoPixelWing_Sample\NeoPixelWing_Sample.csproj", "{CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Core", "..\..\Meadow.Core\source\Meadow.Core\Meadow.Core.csproj", "{D9938C19-2DA9-4AAE-87DF-19AACFAFD617}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Units", "..\..\Meadow.Units\Source\Meadow.Units\Meadow.Units.csproj", "{C91D75E5-D668-466A-A89D-970BE8228ECB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Contracts", "..\..\Meadow.Contracts\Source\Meadow.Contracts\Meadow.Contracts.csproj", "{0B716A9F-9461-4750-B68E-3739E473ACBA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Logging", "..\..\Meadow.Logging\Source\Meadow.Logging\lib\Meadow.Logging.csproj", "{3BFD6004-9E9B-4EB0-B81F-FA1A7D52DB3F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Displays.Led.FourteenSegment", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Displays.Led.FourteenSegment\Driver\Displays.Led.FourteenSegment.csproj", "{C84DE610-D39A-42DC-9153-F8884DE3869F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -275,6 +295,52 @@ Global {694940BF-DBE9-4650-AD84-6B69C5D6088A}.Release|Any CPU.ActiveCfg = Release|Any CPU {694940BF-DBE9-4650-AD84-6B69C5D6088A}.Release|Any CPU.Build.0 = Release|Any CPU {694940BF-DBE9-4650-AD84-6B69C5D6088A}.Release|Any CPU.Deploy.0 = Release|Any CPU + {2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B}.Release|Any CPU.Build.0 = Release|Any CPU + {2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B}.Release|Any CPU.Deploy.0 = Release|Any CPU + {238778FF-05AC-4A4C-A9DE-C4A3CCA09A34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {238778FF-05AC-4A4C-A9DE-C4A3CCA09A34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {238778FF-05AC-4A4C-A9DE-C4A3CCA09A34}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {238778FF-05AC-4A4C-A9DE-C4A3CCA09A34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {238778FF-05AC-4A4C-A9DE-C4A3CCA09A34}.Release|Any CPU.Build.0 = Release|Any CPU + {238778FF-05AC-4A4C-A9DE-C4A3CCA09A34}.Release|Any CPU.Deploy.0 = Release|Any CPU + {CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9}.Release|Any CPU.Build.0 = Release|Any CPU + {CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9}.Release|Any CPU.Deploy.0 = Release|Any CPU + {D9938C19-2DA9-4AAE-87DF-19AACFAFD617}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9938C19-2DA9-4AAE-87DF-19AACFAFD617}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9938C19-2DA9-4AAE-87DF-19AACFAFD617}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {D9938C19-2DA9-4AAE-87DF-19AACFAFD617}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9938C19-2DA9-4AAE-87DF-19AACFAFD617}.Release|Any CPU.Build.0 = Release|Any CPU + {D9938C19-2DA9-4AAE-87DF-19AACFAFD617}.Release|Any CPU.Deploy.0 = Release|Any CPU + {C91D75E5-D668-466A-A89D-970BE8228ECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C91D75E5-D668-466A-A89D-970BE8228ECB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C91D75E5-D668-466A-A89D-970BE8228ECB}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {C91D75E5-D668-466A-A89D-970BE8228ECB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C91D75E5-D668-466A-A89D-970BE8228ECB}.Release|Any CPU.Build.0 = Release|Any CPU + {C91D75E5-D668-466A-A89D-970BE8228ECB}.Release|Any CPU.Deploy.0 = Release|Any CPU + {0B716A9F-9461-4750-B68E-3739E473ACBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B716A9F-9461-4750-B68E-3739E473ACBA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B716A9F-9461-4750-B68E-3739E473ACBA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {0B716A9F-9461-4750-B68E-3739E473ACBA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B716A9F-9461-4750-B68E-3739E473ACBA}.Release|Any CPU.Build.0 = Release|Any CPU + {0B716A9F-9461-4750-B68E-3739E473ACBA}.Release|Any CPU.Deploy.0 = Release|Any CPU + {3BFD6004-9E9B-4EB0-B81F-FA1A7D52DB3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3BFD6004-9E9B-4EB0-B81F-FA1A7D52DB3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3BFD6004-9E9B-4EB0-B81F-FA1A7D52DB3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BFD6004-9E9B-4EB0-B81F-FA1A7D52DB3F}.Release|Any CPU.Build.0 = Release|Any CPU + {C84DE610-D39A-42DC-9153-F8884DE3869F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C84DE610-D39A-42DC-9153-F8884DE3869F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C84DE610-D39A-42DC-9153-F8884DE3869F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {C84DE610-D39A-42DC-9153-F8884DE3869F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C84DE610-D39A-42DC-9153-F8884DE3869F}.Release|Any CPU.Build.0 = Release|Any CPU + {C84DE610-D39A-42DC-9153-F8884DE3869F}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -317,6 +383,15 @@ Global {B7159B77-A8B2-42B3-80B8-A62DEA13AB31} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} {EF231FE5-3C87-469F-B5D9-065C32AA993D} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} {694940BF-DBE9-4650-AD84-6B69C5D6088A} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} + {2A3BEBFE-65AC-4F11-BB7A-CD0EA2A1FD0B} = {746A2619-CBF1-47E2-A5C2-06DD8FCBB439} + {238778FF-05AC-4A4C-A9DE-C4A3CCA09A34} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} + {9D07325E-A887-47FF-9D2F-47070B1F3D57} = {746A2619-CBF1-47E2-A5C2-06DD8FCBB439} + {CE05E44F-1A05-4AE8-9C98-AE6B73A2AEE9} = {9D07325E-A887-47FF-9D2F-47070B1F3D57} + {D9938C19-2DA9-4AAE-87DF-19AACFAFD617} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} + {C91D75E5-D668-466A-A89D-970BE8228ECB} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} + {0B716A9F-9461-4750-B68E-3739E473ACBA} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} + {3BFD6004-9E9B-4EB0-B81F-FA1A7D52DB3F} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} + {C84DE610-D39A-42DC-9153-F8884DE3869F} = {BB1A7E97-4559-459B-BDF8-4ED41758AB29} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {673CD5FD-E4C7-48D7-85EA-3CB6FAD87939} From a12e95b7c6019cbbcd7c3697aee8d892afe6b4f5 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Thu, 10 Aug 2023 20:28:10 -0700 Subject: [PATCH 2/4] denugetize projects --- Source/CharlieWing/Driver/CharlieWing.csproj | 4 ++-- .../Samples/CharlieWing_Sample/CharlieWing_Sample.csproj | 4 ++-- Source/DotstarWing/Driver/DotstarWing.csproj | 2 +- .../Samples/DotstarWing_Sample/DotstarWing_Sample.csproj | 4 ++-- Source/GPSWing/Driver/GPSWing.csproj | 6 ++++-- Source/GPSWing/Samples/GPSWing_Sample/GPSWing_Sample.csproj | 4 ++-- .../Samples/KeyboardWing_Sample/KeyboardWing_Sample.csproj | 2 +- .../LedMatrix8x16Wing_Sample.csproj | 4 ++-- Source/MotorWing/Driver/MotorWing.csproj | 2 +- .../Sample/MotorWing_Sample/MotorWing_Sample.csproj | 2 +- Source/OLED128x32Wing/Driver/OLED128x32Wing.csproj | 5 ++--- .../OLED128x32Wing_Sample/OLED128x32Wing_Sample.csproj | 2 +- Source/ServoWing/Driver/ServoWing.csproj | 4 ++-- .../Sample/ServoWing_Sample/ServoWing_Sample.csproj | 2 +- 14 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Source/CharlieWing/Driver/CharlieWing.csproj b/Source/CharlieWing/Driver/CharlieWing.csproj index 558f4e4..0fea4cc 100644 --- a/Source/CharlieWing/Driver/CharlieWing.csproj +++ b/Source/CharlieWing/Driver/CharlieWing.csproj @@ -1,4 +1,4 @@ - + true icon.png @@ -19,6 +19,6 @@ - + diff --git a/Source/CharlieWing/Samples/CharlieWing_Sample/CharlieWing_Sample.csproj b/Source/CharlieWing/Samples/CharlieWing_Sample/CharlieWing_Sample.csproj index e84facb..aec2eda 100644 --- a/Source/CharlieWing/Samples/CharlieWing_Sample/CharlieWing_Sample.csproj +++ b/Source/CharlieWing/Samples/CharlieWing_Sample/CharlieWing_Sample.csproj @@ -6,8 +6,8 @@ App - - + + diff --git a/Source/DotstarWing/Driver/DotstarWing.csproj b/Source/DotstarWing/Driver/DotstarWing.csproj index e7e2cc5..c3b4e73 100644 --- a/Source/DotstarWing/Driver/DotstarWing.csproj +++ b/Source/DotstarWing/Driver/DotstarWing.csproj @@ -19,6 +19,6 @@ - + diff --git a/Source/DotstarWing/Samples/DotstarWing_Sample/DotstarWing_Sample.csproj b/Source/DotstarWing/Samples/DotstarWing_Sample/DotstarWing_Sample.csproj index 276cde6..c2a71ff 100644 --- a/Source/DotstarWing/Samples/DotstarWing_Sample/DotstarWing_Sample.csproj +++ b/Source/DotstarWing/Samples/DotstarWing_Sample/DotstarWing_Sample.csproj @@ -6,8 +6,8 @@ App - - + + diff --git a/Source/GPSWing/Driver/GPSWing.csproj b/Source/GPSWing/Driver/GPSWing.csproj index 68dff1c..79c1274 100644 --- a/Source/GPSWing/Driver/GPSWing.csproj +++ b/Source/GPSWing/Driver/GPSWing.csproj @@ -1,4 +1,4 @@ - + true icon.png @@ -17,6 +17,8 @@ - + + + diff --git a/Source/GPSWing/Samples/GPSWing_Sample/GPSWing_Sample.csproj b/Source/GPSWing/Samples/GPSWing_Sample/GPSWing_Sample.csproj index 7f7de43..81c4936 100644 --- a/Source/GPSWing/Samples/GPSWing_Sample/GPSWing_Sample.csproj +++ b/Source/GPSWing/Samples/GPSWing_Sample/GPSWing_Sample.csproj @@ -6,7 +6,7 @@ App - - + + diff --git a/Source/KeyboardWing/Samples/KeyboardWing_Sample/KeyboardWing_Sample.csproj b/Source/KeyboardWing/Samples/KeyboardWing_Sample/KeyboardWing_Sample.csproj index e66b360..3fc45dc 100644 --- a/Source/KeyboardWing/Samples/KeyboardWing_Sample/KeyboardWing_Sample.csproj +++ b/Source/KeyboardWing/Samples/KeyboardWing_Sample/KeyboardWing_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj b/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj index a2bbc54..26cc4c0 100644 --- a/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj +++ b/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj @@ -6,8 +6,8 @@ App - - + + diff --git a/Source/MotorWing/Driver/MotorWing.csproj b/Source/MotorWing/Driver/MotorWing.csproj index b9ddf57..00f1461 100644 --- a/Source/MotorWing/Driver/MotorWing.csproj +++ b/Source/MotorWing/Driver/MotorWing.csproj @@ -19,6 +19,6 @@ - + diff --git a/Source/MotorWing/Sample/MotorWing_Sample/MotorWing_Sample.csproj b/Source/MotorWing/Sample/MotorWing_Sample/MotorWing_Sample.csproj index a489b02..017574b 100644 --- a/Source/MotorWing/Sample/MotorWing_Sample/MotorWing_Sample.csproj +++ b/Source/MotorWing/Sample/MotorWing_Sample/MotorWing_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/OLED128x32Wing/Driver/OLED128x32Wing.csproj b/Source/OLED128x32Wing/Driver/OLED128x32Wing.csproj index 7559945..c9055ec 100644 --- a/Source/OLED128x32Wing/Driver/OLED128x32Wing.csproj +++ b/Source/OLED128x32Wing/Driver/OLED128x32Wing.csproj @@ -1,4 +1,4 @@ - + true icon.png @@ -19,7 +19,6 @@ - - + diff --git a/Source/OLED128x32Wing/Sample/OLED128x32Wing_Sample/OLED128x32Wing_Sample.csproj b/Source/OLED128x32Wing/Sample/OLED128x32Wing_Sample/OLED128x32Wing_Sample.csproj index 71eddcf..2a029fb 100644 --- a/Source/OLED128x32Wing/Sample/OLED128x32Wing_Sample/OLED128x32Wing_Sample.csproj +++ b/Source/OLED128x32Wing/Sample/OLED128x32Wing_Sample/OLED128x32Wing_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/ServoWing/Driver/ServoWing.csproj b/Source/ServoWing/Driver/ServoWing.csproj index 33fdfb0..a2b85b0 100644 --- a/Source/ServoWing/Driver/ServoWing.csproj +++ b/Source/ServoWing/Driver/ServoWing.csproj @@ -19,7 +19,7 @@ - - + + diff --git a/Source/ServoWing/Sample/ServoWing_Sample/ServoWing_Sample.csproj b/Source/ServoWing/Sample/ServoWing_Sample/ServoWing_Sample.csproj index be1973c..e202137 100644 --- a/Source/ServoWing/Sample/ServoWing_Sample/ServoWing_Sample.csproj +++ b/Source/ServoWing/Sample/ServoWing_Sample/ServoWing_Sample.csproj @@ -6,7 +6,7 @@ App - + From 305ef33ef9a9762f5b5bf8cc1d5adcd15d3572f7 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Thu, 10 Aug 2023 20:28:30 -0700 Subject: [PATCH 3/4] Add NeoPixel wing sample and driver --- Source/NeoPixelWing/Driver/NeoPixelWing.cs | 167 ++++++++++++++++++ .../NeoPixelWing/Driver/NeoPixelWing.csproj | 26 +++ .../Sample/NeoPixelWing_Sample/MeadowApp.cs | 42 +++++ .../NeoPixelWing_Sample.csproj | 12 ++ 4 files changed, 247 insertions(+) create mode 100644 Source/NeoPixelWing/Driver/NeoPixelWing.cs create mode 100644 Source/NeoPixelWing/Driver/NeoPixelWing.csproj create mode 100644 Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs create mode 100644 Source/NeoPixelWing/Sample/NeoPixelWing_Sample/NeoPixelWing_Sample.csproj diff --git a/Source/NeoPixelWing/Driver/NeoPixelWing.cs b/Source/NeoPixelWing/Driver/NeoPixelWing.cs new file mode 100644 index 0000000..2af8473 --- /dev/null +++ b/Source/NeoPixelWing/Driver/NeoPixelWing.cs @@ -0,0 +1,167 @@ +using Meadow.Foundation.Graphics; +using Meadow.Foundation.Graphics.Buffers; +using Meadow.Foundation.Leds; +using Meadow.Hardware; +using System; + +namespace Meadow.Foundation.FeatherWings +{ + /// + /// Represents Adafruits NeoPixel FeatherWing + /// + public class NeoPixelWing : IGraphicsDisplay + { + /// + /// Color mode of display + /// + public ColorMode ColorMode => ColorMode.Format24bppGrb888; + + /// + /// Width of display in pixels + /// + public int Width => 8; + + /// + /// Height of display in pixels + /// + public int Height => 4; + + /// + /// The pixel buffer that represents the offscreen buffer + /// Not implemented for this driver + /// + public IPixelBuffer PixelBuffer { get; protected set; } + + /// + /// Color modes supported by the device + /// + public ColorMode SupportedColorModes => ColorMode.Format24bppRgb888; + + /// + /// Returns Ws2812 instance + /// + public Ws2812 Leds { get; protected set; } + + /// + /// Creates a NeoPixelWing driver instance + /// + /// The SPI bus connected to the wing + /// The chip select pin + public NeoPixelWing(ISpiBus spiBus, IPin chipSelectPin) + { + Leds = new Ws2812(spiBus, chipSelectPin, 32); + PixelBuffer = new BufferRgb888(8, 4); + } + + /// + /// Clear the display buffer + /// + /// Force a display update if true, false to clear the buffer + public void Clear(bool updateDisplay = false) + { + PixelBuffer.Clear(); + + if(updateDisplay) + { + Show(); + } + } + + /// + /// Turn on an RGB LED with the specified color on (x,y) coordinates + /// + /// The x position in pixels 0 indexed from the left + /// The y position in pixels 0 indexed from the top + /// The color to draw normalized to black/off or white/on + public void DrawPixel(int x, int y, Color color) + { + PixelBuffer.SetPixel(x, y, color); + } + + /// + /// Turn on a LED on (x,y) coordinates + /// + /// The x position in pixels 0 indexed from the left + /// The y position in pixels 0 indexed from the top + /// Led is on if true, off if false + public void DrawPixel(int x, int y, bool colored) + { + DrawPixel(x, y, colored ? Color.White : Color.Black); + } + + /// + /// Invert the color of the pixel at the given location + /// + /// The x position in pixels 0 indexed from the left + /// The y position in pixels 0 indexed from the top + public void InvertPixel(int x, int y) + { + PixelBuffer?.InvertPixel(x, y); + } + + /// + /// Draw a buffer to the display + /// + /// The x position in pixels 0 indexed from the left + /// The y position in pixels 0 indexed from the top + /// The display buffer to draw to the CharlieWing + public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer) + { + PixelBuffer.WriteBuffer(x, y, displayBuffer); + } + + /// + /// Fill the display buffer to a normalized color + /// + /// The clear color which will be normalized to black/off or white/on + /// Force a display update if true, false to clear the buffer + public void Fill(Color fillColor, bool updateDisplay = false) + { + PixelBuffer.Fill(fillColor); + + if(updateDisplay) + { Show(); } + } + + /// + /// Fill the display + /// + /// The x position in pixels 0 indexed from the left + /// The y position in pixels 0 indexed from the top + /// The width to fill in pixels + /// The height to fill in pixels + /// The fillColor color which will be normalized to black/off or white/on + public void Fill(int x, int y, int width, int height, Color fillColor) + { + PixelBuffer.Fill(height, x, y, width, fillColor); + } + + /// + /// Update the display from the offscreen buffer + /// + 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(); + } + + /// + /// Update a region of the display from the offscreen buffer + /// + /// The left bounding position in pixels + /// The top bounding position in pixels + /// The right bounding position in pixels + /// The bottom bounding position in pixels + public void Show(int left, int top, int right, int bottom) + { + Show(); + } + } +} \ No newline at end of file diff --git a/Source/NeoPixelWing/Driver/NeoPixelWing.csproj b/Source/NeoPixelWing/Driver/NeoPixelWing.csproj new file mode 100644 index 0000000..eee0c3a --- /dev/null +++ b/Source/NeoPixelWing/Driver/NeoPixelWing.csproj @@ -0,0 +1,26 @@ + + + true + icon.png + Wilderness Labs, Inc + netstandard2.1 + Library + NeoPixelWing + Wilderness Labs, Inc + http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/ + Meadow.Foundation.FeatherWings.NeoPixelWing + https://github.com/WildernessLabs/Meadow.Foundation.FeatherWings + Meadow.Foundation,FeatherWing,NeoPixel,WS2812 + 0.1.0 + true + AdaFruit NeoPixel FeatherWing + + + + + + + + + + diff --git a/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs b/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs new file mode 100644 index 0000000..180ae7c --- /dev/null +++ b/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs @@ -0,0 +1,42 @@ +using Meadow; +using Meadow.Devices; +using Meadow.Foundation; +using Meadow.Foundation.FeatherWings; +using Meadow.Foundation.Graphics; +using System; +using System.Threading.Tasks; + +namespace FeatherWings.NeoPixel_Sample +{ + public class MeadowApp : App + { + // + + NeoPixelWing neoWing; + MicroGraphics graphics; + + public override Task Initialize() + { + Console.WriteLine("Initializing ..."); + + neoWing = new NeoPixelWing(Device.CreateSpiBus(), Device.Pins.D10); + + graphics = new MicroGraphics(neoWing); + + return Task.CompletedTask; + } + + public override Task Run() + { + // graphics.Clear(); + + graphics.DrawRectangle(0, 0, 8, 4, Color.Red.WithBrightness(0.1), false); + + graphics.Show(); + + return Task.CompletedTask; + } + + // + } +} \ No newline at end of file diff --git a/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/NeoPixelWing_Sample.csproj b/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/NeoPixelWing_Sample.csproj new file mode 100644 index 0000000..e7441d5 --- /dev/null +++ b/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/NeoPixelWing_Sample.csproj @@ -0,0 +1,12 @@ + + + netstandard2.1 + true + Library + App + + + + + + From 4da1e0432216af40621c8c5b6af11cd098f7315d Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Thu, 10 Aug 2023 20:35:16 -0700 Subject: [PATCH 4/4] cleanup --- .../LedMatrix8x16Wing_Sample.csproj | 2 +- Source/NeoPixelWing/Driver/NeoPixelWing.cs | 5 ++--- Source/NeoPixelWing/Driver/NeoPixelWing.csproj | 3 +-- .../NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs | 6 +++--- Source/OLED128x32Wing/Driver/OLED128x32Wing.cs | 8 ++++---- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj b/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj index 26cc4c0..c843966 100644 --- a/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj +++ b/Source/LedMatrix8x16Wing/Samples/LedMatrix8x16Wing_Sample/LedMatrix8x16Wing_Sample.csproj @@ -7,7 +7,7 @@ - + diff --git a/Source/NeoPixelWing/Driver/NeoPixelWing.cs b/Source/NeoPixelWing/Driver/NeoPixelWing.cs index 2af8473..766ee25 100644 --- a/Source/NeoPixelWing/Driver/NeoPixelWing.cs +++ b/Source/NeoPixelWing/Driver/NeoPixelWing.cs @@ -46,10 +46,9 @@ public class NeoPixelWing : IGraphicsDisplay /// Creates a NeoPixelWing driver instance /// /// The SPI bus connected to the wing - /// The chip select pin - public NeoPixelWing(ISpiBus spiBus, IPin chipSelectPin) + public NeoPixelWing(ISpiBus spiBus) { - Leds = new Ws2812(spiBus, chipSelectPin, 32); + Leds = new Ws2812(spiBus, 32); PixelBuffer = new BufferRgb888(8, 4); } diff --git a/Source/NeoPixelWing/Driver/NeoPixelWing.csproj b/Source/NeoPixelWing/Driver/NeoPixelWing.csproj index eee0c3a..b080bb8 100644 --- a/Source/NeoPixelWing/Driver/NeoPixelWing.csproj +++ b/Source/NeoPixelWing/Driver/NeoPixelWing.csproj @@ -1,4 +1,4 @@ - + true icon.png @@ -19,7 +19,6 @@ - diff --git a/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs b/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs index 180ae7c..3e53ff6 100644 --- a/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs +++ b/Source/NeoPixelWing/Sample/NeoPixelWing_Sample/MeadowApp.cs @@ -19,7 +19,7 @@ public override Task Initialize() { Console.WriteLine("Initializing ..."); - neoWing = new NeoPixelWing(Device.CreateSpiBus(), Device.Pins.D10); + neoWing = new NeoPixelWing(Device.CreateSpiBus()); graphics = new MicroGraphics(neoWing); @@ -28,9 +28,9 @@ public override Task Initialize() public override Task Run() { - // graphics.Clear(); + graphics.Clear(); - graphics.DrawRectangle(0, 0, 8, 4, Color.Red.WithBrightness(0.1), false); + graphics.DrawRectangle(0, 0, 8, 4, false); graphics.Show(); diff --git a/Source/OLED128x32Wing/Driver/OLED128x32Wing.cs b/Source/OLED128x32Wing/Driver/OLED128x32Wing.cs index a4b7c87..a3860e9 100644 --- a/Source/OLED128x32Wing/Driver/OLED128x32Wing.cs +++ b/Source/OLED128x32Wing/Driver/OLED128x32Wing.cs @@ -36,7 +36,7 @@ public class OLED128x32Wing /// The digital port for button A /// The digital port for button B /// The digital port for button C - public OLED128x32Wing(II2cBus i2cBus, IDigitalInputPort portA, IDigitalInputPort portB, IDigitalInputPort portC) + public OLED128x32Wing(II2cBus i2cBus, IDigitalInterruptPort portA, IDigitalInterruptPort portB, IDigitalInterruptPort portC) { Display = new Ssd1306(i2cBus, (byte)Ssd1306.Addresses.Default, Ssd1306.DisplayType.OLED128x32); @@ -54,9 +54,9 @@ public OLED128x32Wing(II2cBus i2cBus, IDigitalInputPort portA, IDigitalInputPort /// The pin used for button C public OLED128x32Wing(II2cBus i2cBus, IPin pinA, IPin pinB, IPin pinC) : this(i2cBus, - pinA.CreateDigitalInputPort(InterruptMode.EdgeBoth, ResistorMode.InternalPullUp), - pinB.CreateDigitalInputPort(InterruptMode.EdgeBoth, ResistorMode.InternalPullUp), - pinC.CreateDigitalInputPort(InterruptMode.EdgeBoth, ResistorMode.InternalPullUp)) + pinA.CreateDigitalInterruptPort(InterruptMode.EdgeBoth, ResistorMode.InternalPullUp), + pinB.CreateDigitalInterruptPort(InterruptMode.EdgeBoth, ResistorMode.InternalPullUp), + pinC.CreateDigitalInterruptPort(InterruptMode.EdgeBoth, ResistorMode.InternalPullUp)) { } } } \ No newline at end of file