Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from WildernessLabs/feature/grid-eye
Browse files Browse the repository at this point in the history
Feature/grid eye
  • Loading branch information
ctacke authored Jan 19, 2024
2 parents 64fb3af + 7b76219 commit f8e3374
Show file tree
Hide file tree
Showing 14 changed files with 486 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/develop-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Source/Linux/.vs/
bin/
obj/
Source/CrossPlatform/DevCamp_Avalonia_Sample/.vs/
.vs/
20 changes: 20 additions & 0 deletions Source/Linux/Amg8833_Sample/Amg8833_Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>App</AssemblyName>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Meadow.Core\source\implementations\linux\Meadow.Linux\Meadow.Linux.csproj" />
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Libraries_and_Frameworks\Graphics.MicroLayout\Driver\Graphics.MicroLayout.csproj" />
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Displays.AsciiConsole\Driver\Displays.AsciiConsole.csproj" />
<ProjectReference Include="..\..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Camera.Amg8833\Driver\Sensors.Camera.Amg8833.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="libmpsse.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
93 changes: 93 additions & 0 deletions Source/Linux/Amg8833_Sample/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using Meadow;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;
using Meadow.Foundation.Graphics.MicroLayout;
using Meadow.Foundation.Sensors.Camera;
using Meadow.Pinouts;

public class MeadowApp : App<Linux<RaspberryPi>>
{
private IGraphicsDisplay _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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Meadow.Core\source\implementations\linux\Meadow.Linux\Meadow.Linux.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="app.config.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
70 changes: 70 additions & 0 deletions Source/Linux/Cloud/CloudCommandReceiver/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -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<Linux<WSL2>>
{
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<MyCommand>(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("");
}
}
}
}
}
3 changes: 3 additions & 0 deletions Source/Linux/Cloud/CloudCommandReceiver/app.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Update:
Enabled: true

20 changes: 20 additions & 0 deletions Source/Linux/Cloud/CloudEventPublisher/CloudEventPublisher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Meadow.Core\source\implementations\linux\Meadow.Linux\Meadow.Linux.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="app.config.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
59 changes: 59 additions & 0 deletions Source/Linux/Cloud/CloudEventPublisher/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Meadow;
using Meadow.Cloud;
using Meadow.Logging;
using Meadow.Pinouts;

public class MeadowApp : App<Linux<WSL2>>
{
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);
}
}
}
3 changes: 3 additions & 0 deletions Source/Linux/Cloud/CloudEventPublisher/app.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Logging:
LogLevel:
Default: Trace
56 changes: 56 additions & 0 deletions Source/Linux/Meadow.Linux.Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ 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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -203,6 +219,38 @@ 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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -235,6 +283,14 @@ 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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E3F002EA-1A25-487F-9A5D-93D1E7EC6E31}
Expand Down
Loading

0 comments on commit f8e3374

Please sign in to comment.