diff --git a/.github/workflows/develop-ci.yml b/.github/workflows/develop-ci.yml index 14dab17..569f0f4 100644 --- a/.github/workflows/develop-ci.yml +++ b/.github/workflows/develop-ci.yml @@ -77,7 +77,7 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: - 7.0.x + 8.0.x - name: Install MAUI Workload run: dotnet workload install maui --ignore-failed-sources diff --git a/.gitignore b/.gitignore index d9ae7d1..a801fb4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ Source/Linux/.vs/ bin/ obj/ Source/CrossPlatform/DevCamp_Avalonia_Sample/.vs/ +.vs/ diff --git a/Source/CrossPlatform/MauiMeadow/App.xaml.cs b/Source/CrossPlatform/MauiMeadow/App.xaml.cs index 4cd88a6..8c15b75 100644 --- a/Source/CrossPlatform/MauiMeadow/App.xaml.cs +++ b/Source/CrossPlatform/MauiMeadow/App.xaml.cs @@ -1,7 +1,7 @@ using Meadow; using Meadow.Foundation.Displays; -using Meadow.Foundation.Graphics; using Meadow.Foundation.ICs.IOExpanders; +using Meadow.Peripherals.Displays; using Meadow.UI; namespace MauiMeadow @@ -18,9 +18,9 @@ public App() MainPage = new AppShell(); } - protected Task MeadowInitialize() + protected Task MeadowInitialize() { - var expander = new Ft232h(); + var expander = FtdiExpanderCollection.Devices[0]; var display = new Gc9a01 ( @@ -30,7 +30,7 @@ protected Task MeadowInitialize() resetPin: expander.Pins.C2 ); - Resolver.Services.Add(display); + Resolver.Services.Add(display); return Task.CompletedTask; } diff --git a/Source/CrossPlatform/MauiMeadow/ViewModels/MainPageViewModel.cs b/Source/CrossPlatform/MauiMeadow/ViewModels/MainPageViewModel.cs index bf1665a..9e2d5ce 100644 --- a/Source/CrossPlatform/MauiMeadow/ViewModels/MainPageViewModel.cs +++ b/Source/CrossPlatform/MauiMeadow/ViewModels/MainPageViewModel.cs @@ -1,5 +1,6 @@ using Meadow; using Meadow.Foundation.Graphics; +using Meadow.Peripherals.Displays; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Input; @@ -10,7 +11,7 @@ public class MainPageViewModel : INotifyPropertyChanged { private MicroGraphics graphics; - private IGraphicsDisplay _display; + private IPixelDisplay _display; public ICommand CountCommand { get; set; } @@ -27,7 +28,7 @@ private async Task WaitForDisplay() { while (_display == null) { - _display = Resolver.Services.Get(); + _display = Resolver.Services.Get(); await Task.Delay(100); } diff --git a/Source/Linux/Amg8833_Sample/Amg8833_Sample.csproj b/Source/Linux/Amg8833_Sample/Amg8833_Sample.csproj new file mode 100644 index 0000000..284a0c4 --- /dev/null +++ b/Source/Linux/Amg8833_Sample/Amg8833_Sample.csproj @@ -0,0 +1,20 @@ + + + Exe + net8.0 + enable + App + enable + + + + + + + + + + PreserveNewest + + + diff --git a/Source/Linux/Amg8833_Sample/MeadowApp.cs b/Source/Linux/Amg8833_Sample/MeadowApp.cs new file mode 100644 index 0000000..8096f5f --- /dev/null +++ b/Source/Linux/Amg8833_Sample/MeadowApp.cs @@ -0,0 +1,93 @@ +using Meadow; +using Meadow.Foundation.Displays; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Foundation.Sensors.Camera; +using Meadow.Peripherals.Displays; +using Meadow.Pinouts; + +public class MeadowApp : App> +{ + private IPixelDisplay _display; + private DisplayScreen _screen; + private Amg8833 _camera; + private Box[] _pixelBoxes; + + public static async Task Main(string[] args) + { + await MeadowOS.Start(args); + } + + public override Task Initialize() + { + Console.WriteLine("Creating Outputs"); + + _display = new AsciiConsoleDisplay(8 * 4, 8 * 3); // each "pixel" will be 4x3 + + var i2c = Device.CreateI2cBus(); + _camera = new Amg8833(i2c); + + CreateLayout(); + + return base.Initialize(); + } + + private void CreateLayout() + { + _pixelBoxes = new Box[64]; + _screen = new DisplayScreen(_display); + var x = 0; + var y = 0; + var boxSize = 4; + for (var i = 0; i < _pixelBoxes.Length; i++) + { + _pixelBoxes[i] = new Box(x, y, 4, 3) + { + ForeColor = Color.Blue + }; + + _screen.Controls.Add(_pixelBoxes[i]); + + if (i % 8 == 7) + { + x = 0; + y += 3; + } + else + { + x += boxSize; + } + } + } + + public override async Task Run() + { + var t = 0; + + while (true) + { + var pixels = _camera.ReadPixels(); + + _screen.BeginUpdate(); + + for (var i = 0; i < pixels.Length; i++) + { + var color = pixels[i].Celsius switch + { + < 20 => Color.Black, + < 22 => Color.DarkViolet, + < 24 => Color.DarkBlue, + < 26 => Color.DarkGreen, + < 28 => Color.DarkOrange, + < 30 => Color.Yellow, + _ => Color.White + }; + + _pixelBoxes[i].ForeColor = color; + } + + _screen.EndUpdate(); + + await Task.Delay(100); + } + } +} \ No newline at end of file diff --git a/Source/Linux/Cloud/CloudCommandReceiver/CloudCommandReceiver.csproj b/Source/Linux/Cloud/CloudCommandReceiver/CloudCommandReceiver.csproj new file mode 100644 index 0000000..c3c817d --- /dev/null +++ b/Source/Linux/Cloud/CloudCommandReceiver/CloudCommandReceiver.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + PreserveNewest + + + + diff --git a/Source/Linux/Cloud/CloudCommandReceiver/MeadowApp.cs b/Source/Linux/Cloud/CloudCommandReceiver/MeadowApp.cs new file mode 100644 index 0000000..5edb737 --- /dev/null +++ b/Source/Linux/Cloud/CloudCommandReceiver/MeadowApp.cs @@ -0,0 +1,70 @@ +using Meadow; +using Meadow.Cloud; +using Meadow.Logging; +using Meadow.Pinouts; + +public class MyCommand : IMeadowCommand +{ + public bool Enabled { get; set; } + public string? DisplayText { get; set; } +} + +public class MeadowApp : App> +{ + public static async Task Main(string[] args) + { + await MeadowOS.Start(args); + } + + private DateTimeOffset _startTime; + + public override Task Initialize() + { + _startTime = DateTimeOffset.UtcNow; + + Resolver.Log.AddProvider(new DebugLogProvider()); + + Resolver.CommandService?.Subscribe(HandleMyCommandReceived); + + return base.Initialize(); + } + + private void OnCloudServiceError(object? sender, string e) + { + Resolver.Log.Info($"CLOUD ERROR: {e}"); + } + + private void HandleMyCommandReceived(MyCommand command) + { + TickEnabled = command.Enabled; + + if (command.DisplayText != null && command.DisplayText.Length > 0) + { + Resolver.Log.Info($"{Environment.NewLine}{command.DisplayText}"); + Tick = 1; + } + } + + private int Tick { get; set; } + private bool TickEnabled { get; set; } = true; + + public override async Task Run() + { + Tick = 1; + + while (true) + { + await Task.Delay(1000); + + if (TickEnabled) + { + Console.Write("."); + + if (Tick++ % 10 == 0) + { + Console.WriteLine(""); + } + } + } + } +} \ No newline at end of file diff --git a/Source/Linux/Cloud/CloudCommandReceiver/app.config.yaml b/Source/Linux/Cloud/CloudCommandReceiver/app.config.yaml new file mode 100644 index 0000000..1be72ad --- /dev/null +++ b/Source/Linux/Cloud/CloudCommandReceiver/app.config.yaml @@ -0,0 +1,3 @@ +Update: + Enabled: true + diff --git a/Source/Linux/Cloud/CloudEventPublisher/CloudEventPublisher.csproj b/Source/Linux/Cloud/CloudEventPublisher/CloudEventPublisher.csproj new file mode 100644 index 0000000..b4feb37 --- /dev/null +++ b/Source/Linux/Cloud/CloudEventPublisher/CloudEventPublisher.csproj @@ -0,0 +1,20 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + PreserveNewest + + + + diff --git a/Source/Linux/Cloud/CloudEventPublisher/MeadowApp.cs b/Source/Linux/Cloud/CloudEventPublisher/MeadowApp.cs new file mode 100644 index 0000000..8ab68be --- /dev/null +++ b/Source/Linux/Cloud/CloudEventPublisher/MeadowApp.cs @@ -0,0 +1,59 @@ +using Meadow; +using Meadow.Cloud; +using Meadow.Logging; +using Meadow.Pinouts; + +public class MeadowApp : App> +{ + public static async Task Main(string[] args) + { + await MeadowOS.Start(args); + } + + private DateTimeOffset _startTime; + + public override Task Initialize() + { + _startTime = DateTimeOffset.UtcNow; + + Resolver.Log.AddProvider(new DebugLogProvider()); + Resolver.MeadowCloudService.ServiceError += OnCloudServiceError; + + return base.Initialize(); + } + + private void OnCloudServiceError(object? sender, string e) + { + Console.WriteLine($"CLOUD ERROR: {e}"); + } + + public override async Task Run() + { + var eventNumber = 20; + + while (true) + { + var @event = new CloudEvent + { + Measurements = new() + { + { "uptime", DateTime.UtcNow - _startTime }, + { "eventNumber", eventNumber++ }, + { "text", "foo bar" } + } + }; + + try + { + Console.WriteLine($"Sending event to Meadow.Cloud..."); + await Resolver.MeadowCloudService.SendEvent(@event); + } + catch (Exception ex) + { + Resolver.Log.Error($"ERROR: {ex.Message}"); + } + + await Task.Delay(10000); + } + } +} \ No newline at end of file diff --git a/Source/Linux/Cloud/CloudEventPublisher/app.config.yaml b/Source/Linux/Cloud/CloudEventPublisher/app.config.yaml new file mode 100644 index 0000000..54dd36c --- /dev/null +++ b/Source/Linux/Cloud/CloudEventPublisher/app.config.yaml @@ -0,0 +1,3 @@ +Logging: + LogLevel: + Default: Trace diff --git a/Source/Linux/Meadow.Linux.Samples.sln b/Source/Linux/Meadow.Linux.Samples.sln index e867b36..a91914a 100644 --- a/Source/Linux/Meadow.Linux.Samples.sln +++ b/Source/Linux/Meadow.Linux.Samples.sln @@ -65,6 +65,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sensors.Motion.Bno055", ".. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaMeadow", "..\CrossPlatform\Avalonia_Sample\AvaloniaMeadow.csproj", "{FF4324CA-2EDC-4F0D-A288-8811C2407F4D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amg8833_Sample", "Amg8833_Sample\Amg8833_Sample.csproj", "{18FB77AD-CD17-4CE7-8910-74653F669F80}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Graphics.MicroLayout", "..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Libraries_and_Frameworks\Graphics.MicroLayout\Driver\Graphics.MicroLayout.csproj", "{7A319A27-53DF-4E78-8151-7DD5A43C25DD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sensors.Camera.Amg8833", "..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Camera.Amg8833\Driver\Sensors.Camera.Amg8833.csproj", "{9AAEEFC1-E3D6-487B-A129-B7F77E049FF5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Displays.AsciiConsole", "..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Displays.AsciiConsole\Driver\Displays.AsciiConsole.csproj", "{D83E4426-7B1A-4C3F-BA12-13079F76518D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Avalonia", "..\..\..\Meadow.Core\source\ui\Meadow.Avalonia\Meadow.Avalonia.csproj", "{1FC7DFBF-512B-47C8-871F-6313046691EC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CloudEventPublisher", "Cloud\CloudEventPublisher\CloudEventPublisher.csproj", "{0CB462BC-EC1D-4EE2-BDB8-884CA9308F30}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cloud", "Cloud", "{7E2108C1-60C2-45AF-8C00-29275D81AB50}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CloudCommandReceiver", "Cloud\CloudCommandReceiver\CloudCommandReceiver.csproj", "{1B5A6F9A-D905-454F-895D-C7A06FD98D7B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Foundation.Core", "..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Core\Meadow.Foundation.Core.csproj", "{DEC506C7-85AC-4381-AECA-B71E7CA03D05}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -203,6 +221,44 @@ Global {FF4324CA-2EDC-4F0D-A288-8811C2407F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU {FF4324CA-2EDC-4F0D-A288-8811C2407F4D}.Release|Any CPU.ActiveCfg = Release|Any CPU {FF4324CA-2EDC-4F0D-A288-8811C2407F4D}.Release|Any CPU.Build.0 = Release|Any CPU + {18FB77AD-CD17-4CE7-8910-74653F669F80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18FB77AD-CD17-4CE7-8910-74653F669F80}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18FB77AD-CD17-4CE7-8910-74653F669F80}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18FB77AD-CD17-4CE7-8910-74653F669F80}.Release|Any CPU.Build.0 = Release|Any CPU + {7A319A27-53DF-4E78-8151-7DD5A43C25DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A319A27-53DF-4E78-8151-7DD5A43C25DD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A319A27-53DF-4E78-8151-7DD5A43C25DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A319A27-53DF-4E78-8151-7DD5A43C25DD}.Release|Any CPU.Build.0 = Release|Any CPU + {9AAEEFC1-E3D6-487B-A129-B7F77E049FF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9AAEEFC1-E3D6-487B-A129-B7F77E049FF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9AAEEFC1-E3D6-487B-A129-B7F77E049FF5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {9AAEEFC1-E3D6-487B-A129-B7F77E049FF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9AAEEFC1-E3D6-487B-A129-B7F77E049FF5}.Release|Any CPU.Build.0 = Release|Any CPU + {9AAEEFC1-E3D6-487B-A129-B7F77E049FF5}.Release|Any CPU.Deploy.0 = Release|Any CPU + {D83E4426-7B1A-4C3F-BA12-13079F76518D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D83E4426-7B1A-4C3F-BA12-13079F76518D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D83E4426-7B1A-4C3F-BA12-13079F76518D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {D83E4426-7B1A-4C3F-BA12-13079F76518D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D83E4426-7B1A-4C3F-BA12-13079F76518D}.Release|Any CPU.Build.0 = Release|Any CPU + {D83E4426-7B1A-4C3F-BA12-13079F76518D}.Release|Any CPU.Deploy.0 = Release|Any CPU + {1FC7DFBF-512B-47C8-871F-6313046691EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1FC7DFBF-512B-47C8-871F-6313046691EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1FC7DFBF-512B-47C8-871F-6313046691EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1FC7DFBF-512B-47C8-871F-6313046691EC}.Release|Any CPU.Build.0 = Release|Any CPU + {0CB462BC-EC1D-4EE2-BDB8-884CA9308F30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CB462BC-EC1D-4EE2-BDB8-884CA9308F30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0CB462BC-EC1D-4EE2-BDB8-884CA9308F30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CB462BC-EC1D-4EE2-BDB8-884CA9308F30}.Release|Any CPU.Build.0 = Release|Any CPU + {1B5A6F9A-D905-454F-895D-C7A06FD98D7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B5A6F9A-D905-454F-895D-C7A06FD98D7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B5A6F9A-D905-454F-895D-C7A06FD98D7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1B5A6F9A-D905-454F-895D-C7A06FD98D7B}.Release|Any CPU.Build.0 = Release|Any CPU + {DEC506C7-85AC-4381-AECA-B71E7CA03D05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DEC506C7-85AC-4381-AECA-B71E7CA03D05}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DEC506C7-85AC-4381-AECA-B71E7CA03D05}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {DEC506C7-85AC-4381-AECA-B71E7CA03D05}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DEC506C7-85AC-4381-AECA-B71E7CA03D05}.Release|Any CPU.Build.0 = Release|Any CPU + {DEC506C7-85AC-4381-AECA-B71E7CA03D05}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -235,6 +291,15 @@ Global {A683EF04-975A-4F1B-A522-86422D679DE0} = {0E9EB1DB-A564-465B-9CE9-5E1CDD7306C6} {75D6B661-29CF-454A-95C2-EA497714111B} = {0E9EB1DB-A564-465B-9CE9-5E1CDD7306C6} {FF4324CA-2EDC-4F0D-A288-8811C2407F4D} = {17BB45E4-7B9D-4A90-84B4-E37260E362B2} + {18FB77AD-CD17-4CE7-8910-74653F669F80} = {17BB45E4-7B9D-4A90-84B4-E37260E362B2} + {7A319A27-53DF-4E78-8151-7DD5A43C25DD} = {0E9EB1DB-A564-465B-9CE9-5E1CDD7306C6} + {9AAEEFC1-E3D6-487B-A129-B7F77E049FF5} = {0E9EB1DB-A564-465B-9CE9-5E1CDD7306C6} + {D83E4426-7B1A-4C3F-BA12-13079F76518D} = {0E9EB1DB-A564-465B-9CE9-5E1CDD7306C6} + {1FC7DFBF-512B-47C8-871F-6313046691EC} = {0E9EB1DB-A564-465B-9CE9-5E1CDD7306C6} + {0CB462BC-EC1D-4EE2-BDB8-884CA9308F30} = {7E2108C1-60C2-45AF-8C00-29275D81AB50} + {7E2108C1-60C2-45AF-8C00-29275D81AB50} = {AF3F2B7E-D0AC-4418-8E9E-5515874092C7} + {1B5A6F9A-D905-454F-895D-C7A06FD98D7B} = {7E2108C1-60C2-45AF-8C00-29275D81AB50} + {DEC506C7-85AC-4381-AECA-B71E7CA03D05} = {0E9EB1DB-A564-465B-9CE9-5E1CDD7306C6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E3F002EA-1A25-487F-9A5D-93D1E7EC6E31} diff --git a/Source/Linux/ST7789_Sample/MeadowApp.cs b/Source/Linux/ST7789_Sample/MeadowApp.cs index 04a9923..928e808 100644 --- a/Source/Linux/ST7789_Sample/MeadowApp.cs +++ b/Source/Linux/ST7789_Sample/MeadowApp.cs @@ -411,11 +411,11 @@ void ColorFontTest() _graphics.Clear(); - _graphics.DrawTriangle(120, 20, 200, 100, 120, 100, Meadow.Foundation.Color.Red, false); + _graphics.DrawTriangle(120, 20, 200, 100, 120, 100, Meadow.Color.Red, false); - _graphics.DrawRectangle(140, 30, 40, 90, Meadow.Foundation.Color.Yellow, false); + _graphics.DrawRectangle(140, 30, 40, 90, Meadow.Color.Yellow, false); - _graphics.DrawCircle(160, 80, 40, Meadow.Foundation.Color.Cyan, false); + _graphics.DrawCircle(160, 80, 40, Meadow.Color.Cyan, false); int indent = 5; int spacing = 14; @@ -423,25 +423,25 @@ void ColorFontTest() _graphics.DrawText(indent, y, "Meadow F7 SPI ST7789!!"); - _graphics.DrawText(indent, y += spacing, "Red", Meadow.Foundation.Color.Red); + _graphics.DrawText(indent, y += spacing, "Red", Color.Red); - _graphics.DrawText(indent, y += spacing, "Purple", Meadow.Foundation.Color.Purple); + _graphics.DrawText(indent, y += spacing, "Purple", Color.Purple); - _graphics.DrawText(indent, y += spacing, "BlueViolet", Meadow.Foundation.Color.BlueViolet); + _graphics.DrawText(indent, y += spacing, "BlueViolet", Color.BlueViolet); - _graphics.DrawText(indent, y += spacing, "Blue", Meadow.Foundation.Color.Blue); + _graphics.DrawText(indent, y += spacing, "Blue", Color.Blue); - _graphics.DrawText(indent, y += spacing, "Cyan", Meadow.Foundation.Color.Cyan); + _graphics.DrawText(indent, y += spacing, "Cyan", Color.Cyan); - _graphics.DrawText(indent, y += spacing, "LawnGreen", Meadow.Foundation.Color.LawnGreen); + _graphics.DrawText(indent, y += spacing, "LawnGreen", Color.LawnGreen); - _graphics.DrawText(indent, y += spacing, "GreenYellow", Meadow.Foundation.Color.GreenYellow); + _graphics.DrawText(indent, y += spacing, "GreenYellow", Color.GreenYellow); - _graphics.DrawText(indent, y += spacing, "Yellow", Meadow.Foundation.Color.Yellow); + _graphics.DrawText(indent, y += spacing, "Yellow", Color.Yellow); - _graphics.DrawText(indent, y += spacing, "Orange", Meadow.Foundation.Color.Orange); + _graphics.DrawText(indent, y += spacing, "Orange", Color.Orange); - _graphics.DrawText(indent, y += spacing, "Brown", Meadow.Foundation.Color.Brown); + _graphics.DrawText(indent, y += spacing, "Brown", Color.Brown); _graphics.Show(); diff --git a/Source/Windows/Amg8833Camera/Amg8833Camera.csproj b/Source/Windows/Amg8833Camera/Amg8833Camera.csproj new file mode 100644 index 0000000..4bf3eeb --- /dev/null +++ b/Source/Windows/Amg8833Camera/Amg8833Camera.csproj @@ -0,0 +1,20 @@ + + + Exe + net8.0-windows + enable + enable + + + + + + + + + + + PreserveNewest + + + diff --git a/Source/Windows/Amg8833Camera/MeadowApp.cs b/Source/Windows/Amg8833Camera/MeadowApp.cs new file mode 100644 index 0000000..667f8ec --- /dev/null +++ b/Source/Windows/Amg8833Camera/MeadowApp.cs @@ -0,0 +1,102 @@ +using Meadow; +using Meadow.Foundation.Displays; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Foundation.ICs.IOExpanders; +using Meadow.Foundation.Sensors.Camera; +using System.Windows.Forms; + +public class MeadowApp : App +{ + private FtdiExpander _ft232h; + private WinFormsDisplay _display; + private DisplayScreen _screen; + private Amg8833 _camera; + private Box[] _pixelBoxes; + + public static async Task Main(string[] args) + { + await MeadowOS.Start(args); + } + + public override Task Initialize() + { + Console.WriteLine("Creating Outputs"); + + _display = new WinFormsDisplay(320, 480); + + _ft232h = FtdiExpanderCollection.Devices[0]; + var bus = _ft232h.CreateI2cBus(); + _camera = new Amg8833(bus); + + CreateLayout(); + + return base.Initialize(); + } + + private void CreateLayout() + { + _pixelBoxes = new Box[64]; + _screen = new DisplayScreen(_display); + var x = 0; + var y = 0; + var boxSize = 40; + for (var i = 0; i < _pixelBoxes.Length; i++) + { + _pixelBoxes[i] = new Box(x, y, boxSize, boxSize) + { + ForeColor = Color.Blue + }; + + _screen.Controls.Add(_pixelBoxes[i]); + + if (i % 8 == 7) + { + x = 0; + y += boxSize; + } + else + { + x += boxSize; + } + } + } + + public override Task Run() + { + _ = Task.Run(async () => + { + await Task.Delay(1000); + + while (true) + { + var pixels = _camera.ReadPixels(); + + _screen.BeginUpdate(); + + for (var i = 0; i < pixels.Length; i++) + { + var color = pixels[i].Celsius switch + { + < 20 => Color.Black, + < 22 => Color.DarkViolet, + < 24 => Color.DarkBlue, + < 26 => Color.DarkGreen, + < 28 => Color.DarkOrange, + < 30 => Color.Yellow, + _ => Color.White + }; + + _pixelBoxes[i].ForeColor = color; + } + + _screen.EndUpdate(); + + await Task.Delay(100); + } + }); + + Application.Run(_display); + + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/Source/Windows/AvaloniaMeadow/App.axaml.cs b/Source/Windows/AvaloniaMeadow/App.axaml.cs index 6e8c9f0..dfba2d6 100644 --- a/Source/Windows/AvaloniaMeadow/App.axaml.cs +++ b/Source/Windows/AvaloniaMeadow/App.axaml.cs @@ -36,7 +36,7 @@ public override void Initialize() public override Task MeadowInitialize() { - var expander = new Ft232h(); + var expander = FtdiExpanderCollection.Devices[0]; var bme680 = new Bme680(expander.CreateSpiBus(), expander.Pins.C7); Resolver.Services.Add(bme680); diff --git a/Source/Windows/Blinky/MeadowApp.cs b/Source/Windows/Blinky/MeadowApp.cs index f0cc985..51794c7 100644 --- a/Source/Windows/Blinky/MeadowApp.cs +++ b/Source/Windows/Blinky/MeadowApp.cs @@ -11,7 +11,7 @@ public override Task Initialize() { Console.WriteLine("Creating Outputs"); - var expander = new Ft232h(); + var expander = FtdiExpanderCollection.Devices[0]; rgbLed = new RgbLed( expander.Pins.C2, diff --git a/Source/Windows/CharacterDisplaySample/MeadowApp.cs b/Source/Windows/CharacterDisplaySample/MeadowApp.cs index 17c02ac..c5feb0a 100644 --- a/Source/Windows/CharacterDisplaySample/MeadowApp.cs +++ b/Source/Windows/CharacterDisplaySample/MeadowApp.cs @@ -10,7 +10,7 @@ public override Task Initialize() { Console.WriteLine("Creating Outputs"); - var expander = new Ft232h(); + var expander = FtdiExpanderCollection.Devices[0]; display = new CharacterDisplay ( diff --git a/Source/Windows/DigitalOutputPort/MeadowApp.cs b/Source/Windows/DigitalOutputPort/MeadowApp.cs index 94c061d..1c0a43b 100644 --- a/Source/Windows/DigitalOutputPort/MeadowApp.cs +++ b/Source/Windows/DigitalOutputPort/MeadowApp.cs @@ -4,7 +4,7 @@ public class MeadowApp : App { - private Ft232h _expander = new Ft232h(); + private FtdiExpander _expander = FtdiExpanderCollection.Devices[0]; private IDigitalOutputPort _c0; public static async Task Main(string[] args) diff --git a/Source/Windows/I2C/MeadowApp.cs b/Source/Windows/I2C/MeadowApp.cs index a9eb05a..2b0ce7e 100644 --- a/Source/Windows/I2C/MeadowApp.cs +++ b/Source/Windows/I2C/MeadowApp.cs @@ -5,7 +5,7 @@ public class MeadowApp : App { - private Ft232h _expander = new Ft232h(); + private FtdiExpander _expander = FtdiExpanderCollection.Devices[0]; private Bno055 _bno; private Mpu6050 _mpu; diff --git a/Source/Windows/Max7219/MeadowApp.cs b/Source/Windows/Max7219/MeadowApp.cs index 34797c1..2c9e30c 100644 --- a/Source/Windows/Max7219/MeadowApp.cs +++ b/Source/Windows/Max7219/MeadowApp.cs @@ -1,12 +1,11 @@ using Meadow; -using Meadow.Foundation; using Meadow.Foundation.Displays; using Meadow.Foundation.Graphics; using Meadow.Foundation.ICs.IOExpanders; public class MeadowApp : App { - private Ft232h _expander = new Ft232h(); + private FtdiExpander _expander = FtdiExpanderCollection.Devices[0]; private Max7219 _display; private MicroGraphics _graphics; diff --git a/Source/Windows/Meadow.Windows.Samples.sln b/Source/Windows/Meadow.Windows.Samples.sln index db0e32d..6c7ccd2 100644 --- a/Source/Windows/Meadow.Windows.Samples.sln +++ b/Source/Windows/Meadow.Windows.Samples.sln @@ -37,6 +37,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsMeadow", "WinForms\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaMeadow", "AvaloniaMeadow\AvaloniaMeadow.csproj", "{61E745AB-452C-433E-AAAC-C06DA6A9CA0A}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amg8833Camera", "Amg8833Camera\Amg8833Camera.csproj", "{5D5B4A50-D50F-488B-9B14-6DEDBB3CE25D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sensors", "Sensors", "{7767CC6F-1548-49C7-BC3B-CC7C202A2901}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -100,6 +104,10 @@ Global {61E745AB-452C-433E-AAAC-C06DA6A9CA0A}.Debug|Any CPU.Build.0 = Debug|Any CPU {61E745AB-452C-433E-AAAC-C06DA6A9CA0A}.Release|Any CPU.ActiveCfg = Release|Any CPU {61E745AB-452C-433E-AAAC-C06DA6A9CA0A}.Release|Any CPU.Build.0 = Release|Any CPU + {5D5B4A50-D50F-488B-9B14-6DEDBB3CE25D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D5B4A50-D50F-488B-9B14-6DEDBB3CE25D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D5B4A50-D50F-488B-9B14-6DEDBB3CE25D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D5B4A50-D50F-488B-9B14-6DEDBB3CE25D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -119,6 +127,7 @@ Global {24B33019-6D9D-476C-94AE-7273C9A6B470} = {41090F56-F79B-44A1-BD13-2C6305A08D7D} {D6DBF6C2-2EBE-4C85-8B9B-BAEB1ED20E68} = {58C4412D-464A-4AB5-ACC8-72B446780173} {61E745AB-452C-433E-AAAC-C06DA6A9CA0A} = {58C4412D-464A-4AB5-ACC8-72B446780173} + {5D5B4A50-D50F-488B-9B14-6DEDBB3CE25D} = {7767CC6F-1548-49C7-BC3B-CC7C202A2901} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E3F002EA-1A25-487F-9A5D-93D1E7EC6E31} diff --git a/Source/Windows/SPI/MeadowApp.cs b/Source/Windows/SPI/MeadowApp.cs index b849167..0955812 100644 --- a/Source/Windows/SPI/MeadowApp.cs +++ b/Source/Windows/SPI/MeadowApp.cs @@ -1,12 +1,11 @@ using Meadow; -using Meadow.Foundation; using Meadow.Foundation.Displays; -using Meadow.Foundation.Graphics; using Meadow.Foundation.ICs.IOExpanders; +using Meadow.Peripherals.Displays; public class MeadowApp : App { - private Ft232h _expander = new Ft232h(); + private FtdiExpander _expander = FtdiExpanderCollection.Devices[0]; private St7789 _display; public static async Task Main(string[] args) diff --git a/Source/Windows/WifiWeather/MeadowApp.cs b/Source/Windows/WifiWeather/MeadowApp.cs index efcb97f..5e9356d 100644 --- a/Source/Windows/WifiWeather/MeadowApp.cs +++ b/Source/Windows/WifiWeather/MeadowApp.cs @@ -13,7 +13,7 @@ public override Task Initialize() { Console.WriteLine("Creating Outputs"); - var expander = new Ft232h(); + var expander = FtdiExpanderCollection.Devices[0]; var display = new Ili9488 ( diff --git a/Source/Windows/WifiWeather/Views/DisplayView.cs b/Source/Windows/WifiWeather/Views/DisplayView.cs index 8c8d6ee..3be207a 100644 --- a/Source/Windows/WifiWeather/Views/DisplayView.cs +++ b/Source/Windows/WifiWeather/Views/DisplayView.cs @@ -1,5 +1,6 @@ using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; namespace WifiWeather.Views { @@ -40,7 +41,7 @@ public class DisplayView Font12x16 font12X16 = new Font12x16(); Font8x16 font8X16 = new Font8x16(); - public DisplayView(IGraphicsDisplay display) + public DisplayView(IPixelDisplay display) { DisplayScreen = new DisplayScreen(display) { diff --git a/Source/Windows/WinForms/Views/AtmosphericHMI.cs b/Source/Windows/WinForms/Views/AtmosphericHMI.cs index 4358c97..59bfa1a 100644 --- a/Source/Windows/WinForms/Views/AtmosphericHMI.cs +++ b/Source/Windows/WinForms/Views/AtmosphericHMI.cs @@ -1,5 +1,6 @@ using Meadow.Foundation.Graphics; using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; using System; using System.Threading.Tasks; @@ -25,7 +26,7 @@ public class AtmosphericHMI Font12x20 font12X20 = new Font12x20(); - public AtmosphericHMI(IGraphicsDisplay display) + public AtmosphericHMI(IPixelDisplay display) { DisplayScreen = new DisplayScreen(display) { diff --git a/Source/Windows/WinForms/Views/CultivarView.cs b/Source/Windows/WinForms/Views/CultivarView.cs index 7c6fa71..0bdf2bd 100644 --- a/Source/Windows/WinForms/Views/CultivarView.cs +++ b/Source/Windows/WinForms/Views/CultivarView.cs @@ -1,5 +1,6 @@ using Meadow.Foundation.Graphics; using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; using System; using System.Threading.Tasks; @@ -37,7 +38,7 @@ public class CultivarView protected Picture ledHeater { get; set; } - public CultivarView(IGraphicsDisplay _display) + public CultivarView(IPixelDisplay _display) { screen = new DisplayScreen(_display); diff --git a/Source/Windows/WinForms/Views/HomeWidget.cs b/Source/Windows/WinForms/Views/HomeWidget.cs index 5695683..d7b759f 100644 --- a/Source/Windows/WinForms/Views/HomeWidget.cs +++ b/Source/Windows/WinForms/Views/HomeWidget.cs @@ -1,6 +1,7 @@ using Meadow; using Meadow.Foundation.Graphics; using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; using System; using System.Threading.Tasks; @@ -45,7 +46,7 @@ public class HomeWidget Font12x20 font12X20 = new Font12x20(); Font6x8 font6x8 = new Font6x8(); - public HomeWidget(IGraphicsDisplay display) + public HomeWidget(IPixelDisplay display) { DisplayScreen = new DisplayScreen(display) { diff --git a/Source/Windows/WinForms/Views/ProjectLabDemoView.cs b/Source/Windows/WinForms/Views/ProjectLabDemoView.cs index e465051..42df0ae 100644 --- a/Source/Windows/WinForms/Views/ProjectLabDemoView.cs +++ b/Source/Windows/WinForms/Views/ProjectLabDemoView.cs @@ -1,5 +1,6 @@ using Meadow.Foundation.Graphics; using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; using System; using System.Threading.Tasks; @@ -92,7 +93,7 @@ internal class ProjectLabDemoView private Font8x16 font8x16 = new Font8x16(); private Font6x8 font6x8 = new Font6x8(); - public ProjectLabDemoView(IGraphicsDisplay display) + public ProjectLabDemoView(IPixelDisplay display) { DisplayScreen = new DisplayScreen(display) { diff --git a/Source/Windows/WinForms/Views/WiFiWeather.cs b/Source/Windows/WinForms/Views/WiFiWeather.cs index 1c05c3b..29e4da3 100644 --- a/Source/Windows/WinForms/Views/WiFiWeather.cs +++ b/Source/Windows/WinForms/Views/WiFiWeather.cs @@ -1,5 +1,6 @@ using Meadow.Foundation.Graphics; using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; using System; using System.Threading.Tasks; @@ -42,7 +43,7 @@ public class WiFiWeather Font12x16 font12X16 = new Font12x16(); Font8x16 font8X16 = new Font8x16(); - public WiFiWeather(IGraphicsDisplay display) + public WiFiWeather(IPixelDisplay display) { DisplayScreen = new DisplayScreen(display) { diff --git a/Source/Windows/WinForms/Views/WifiWeatherV2.cs b/Source/Windows/WinForms/Views/WifiWeatherV2.cs index d4cbf30..a419d79 100644 --- a/Source/Windows/WinForms/Views/WifiWeatherV2.cs +++ b/Source/Windows/WinForms/Views/WifiWeatherV2.cs @@ -1,6 +1,7 @@ using Meadow; using Meadow.Foundation.Graphics; using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -56,7 +57,7 @@ internal class WifiWeatherV2 protected Label Sunrise { get; set; } protected Label Sunset { get; set; } - public WifiWeatherV2(IGraphicsDisplay display) + public WifiWeatherV2(IPixelDisplay display) { DisplayScreen = new DisplayScreen(display) {