This repository has been archived by the owner on Mar 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #26 from WildernessLabs/develop
Update 1.9.0
- Loading branch information
Showing
32 changed files
with
530 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ Source/Linux/.vs/ | |
bin/ | ||
obj/ | ||
Source/CrossPlatform/DevCamp_Avalonia_Sample/.vs/ | ||
.vs/ |
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,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> | ||
<PackageReference Include="Meadow.Linux" Version="*" /> | ||
<PackageReference Include="Meadow.Foundation.Graphics.MicroLayout" Version="*" /> | ||
<PackageReference Include="Meadow.Foundation.Displays.AsciiConsole" Version="*" /> | ||
<PackageReference Include="Meadow.Foundation.Sensors.Camera.Amg8833" Version="*" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="libmpsse.dll"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
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,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<Linux<RaspberryPi>> | ||
{ | ||
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); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Source/Linux/Cloud/CloudCommandReceiver/CloudCommandReceiver.csproj
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Meadow.Linux" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="app.config.yaml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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,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(""); | ||
} | ||
} | ||
} | ||
} | ||
} |
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,3 @@ | ||
Update: | ||
Enabled: true | ||
|
20 changes: 20 additions & 0 deletions
20
Source/Linux/Cloud/CloudEventPublisher/CloudEventPublisher.csproj
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Meadow.Linux" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="app.config.yaml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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,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); | ||
} | ||
} | ||
} |
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,3 @@ | ||
Logging: | ||
LogLevel: | ||
Default: Trace |
Oops, something went wrong.