Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.13.0 #54

Merged
merged 13 commits into from
Aug 20, 2024
21 changes: 21 additions & 0 deletions Source/BeagleBone/Validation/BeagleBone_Validation.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<AssemblyName>App</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Meadow.Linux" Version="*" />
<PackageReference Include="Meadow.Foundation" Version="*" />
<PackageReference Include="Meadow.Foundation.ICs.CAN.Mcp2515" Version="*" />
<PackageReference Include="Meadow.Foundation.Sensors.Atmospheric.Bmx280" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="app.config.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
161 changes: 161 additions & 0 deletions Source/BeagleBone/Validation/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
using Meadow;
using Meadow.Foundation.ICs.CAN;
using Meadow.Foundation.Sensors.Atmospheric;
using Meadow.Hardware;
using Meadow.Units;
using System.Threading.Tasks;

namespace Validation;

public class MeadowApp : App<BeagleBoneBlack>
{
public override async Task Run()
{
Resolver.Log.Info("Run...");

await ValidateSPI();
}

public async Task ValidateSPI()
{
Resolver.Log.Info("BeagleBone SPI stuff...");

var transceiver = new Mcp2515(
Device.CreateSpiBus(0, 1_000_000.Hertz()),
Device.Pins.GPIO_49.CreateDigitalOutputPort(),
Mcp2515.CanOscillator.Osc_8MHz);

var bus = transceiver.CreateCanBus(CanBitrate.Can_250kbps);

while (true)
{
Resolver.Log.Info("Checking bus...");

if (bus.IsFrameAvailable())
{
var frame = bus.ReadFrame();
if (frame != null)
{
Resolver.Log.Info($"Received a {frame!.GetType().Name}");
}
else
{
Resolver.Log.Info("Frame available but not readable?");
}
}
else
{
Resolver.Log.Info("No data");
}

await Task.Delay(1000);
}

}

public async Task ValidateI2C()
{
Resolver.Log.Info("BeagleBone reading BMP280 over I2C...");

var sensor = new Bmp280(Device.CreateI2cBus(Device.Pins.I2C2_SCL, Device.Pins.I2C2_SDA, Meadow.Hardware.I2cBusSpeed.Standard));
//var sensor = new Bmp280(Device.CreateI2cBus());

while (true)
{
var reading = await sensor.Read();
Resolver.Log.Info($"Temp: {reading.Temperature?.Fahrenheit:N1} F");
await Task.Delay(1000);
}

}

public async Task ValidatePWMs()
{
var ports = new[]
{
// sudo config-pin P9.22 pwm
Device.Pins.ECAPPWM0.CreatePwmPort(50.Hertz(), 0.5f),
// Device.Pins.ECAPPWM2.CreatePwmPort(50.Hertz(), 0.5f),
// Device.Pins.EHRPWM1A.CreatePwmPort(50.Hertz(), 0.5f),
// Device.Pins.EHRPWM1B.CreatePwmPort(50.Hertz(), 0.5f),
// Device.Pins.EHRPWM2A.CreatePwmPort(50.Hertz(), 0.5f),
// Device.Pins.EHRPWM2B.CreatePwmPort(50.Hertz(), 0.5f),
};

while (true)
{
foreach (var port in ports)
{
Resolver.Log.Info($"Starting {port.Pin.Name}");
port.Start();

Resolver.Log.Info($" {port.Pin.Key} {port.State} {port.Frequency.Hertz}Hz {port.DutyCycle:N1}");
}

await Task.Delay(1000);

foreach (var port in ports)
{
Resolver.Log.Info($"Stopping {port.Pin.Name}");
port.Stop();

Resolver.Log.Info($" {port.Pin.Key} {port.State} {port.Frequency.Hertz}Hz {port.DutyCycle:N1}");
}

await Task.Delay(1000);
}
}

public async Task ValidateAnalogInputs()
{
var pins = new[]
{
Device.Pins.AIN0.CreateAnalogInputPort(1),
Device.Pins.AIN1.CreateAnalogInputPort(1),
Device.Pins.AIN2.CreateAnalogInputPort(1),
Device.Pins.AIN3.CreateAnalogInputPort(1),
Device.Pins.AIN4.CreateAnalogInputPort(1),
Device.Pins.AIN5.CreateAnalogInputPort(1),
Device.Pins.AIN6.CreateAnalogInputPort(1),
};

while (true)
{
foreach (var pin in pins)
{
var voltage = await pin.Read();

Resolver.Log.Info($"{pin.Pin.Name} = {voltage.Volts:N2} V");
}

await Task.Delay(1000);
}
}

public async Task ValidateDigitalOutputs()
{
var state = false;

var pins = new[]
{
Device.Pins.GPIO_48.CreateDigitalOutputPort(state),
Device.Pins.GPIO_60.CreateDigitalOutputPort(state),
Device.Pins.GPIO_66.CreateDigitalOutputPort(state),
Device.Pins.GPIO_67.CreateDigitalOutputPort(state),
};

while (true)
{
state = !state;

foreach (var pin in pins)
{
Resolver.Log.Info($"{pin.Pin.Name} Set State = {state}");
pin.State = state;
Resolver.Log.Info($"{pin.Pin.Name} Read State = {pin.State}");
}

await Task.Delay(1000);
}
}
}
12 changes: 12 additions & 0 deletions Source/BeagleBone/Validation/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Meadow;
using System.Threading.Tasks;

namespace Validation;

public class Program
{
public static async Task Main(string[] args)
{
await MeadowOS.Start(args);
}
}
7 changes: 7 additions & 0 deletions Source/BeagleBone/Validation/app.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Lifecycle:
RestartOnAppFailure: false

Logging:
LogLevel:
# Trace, Debug, Information, Warning, or Error
Default: Trace
5 changes: 5 additions & 0 deletions Source/Juego/Eyeball/Eyeball.Juego/Eyeball.Juego.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
<PackageReference Include="Meadow.Juego" Version="*" />
<ProjectReference Include="..\Eyeball.Core\Eyeball.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions Source/Juego/Eyeball/Eyeball.Juego/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
5 changes: 5 additions & 0 deletions Source/Juego/FallingSand/FallingSand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@
<ItemGroup>
<PackageReference Include="Meadow.Juego" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions Source/Juego/FallingSand/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
3 changes: 3 additions & 0 deletions Source/Juego/Froggit/Froggit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PackageReference Include="Meadow.Juego" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 2 additions & 0 deletions Source/Juego/Froggit/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
3 changes: 3 additions & 0 deletions Source/Juego/GameOfLife/GameOfLife.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PackageReference Include="Meadow.Juego" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 2 additions & 0 deletions Source/Juego/GameOfLife/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
3 changes: 3 additions & 0 deletions Source/Juego/Snake/Snake.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PackageReference Include="Meadow.Juego" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 2 additions & 0 deletions Source/Juego/Snake/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
3 changes: 3 additions & 0 deletions Source/Juego/Span4/Span4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PackageReference Include="Meadow.Juego" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 2 additions & 0 deletions Source/Juego/Span4/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
3 changes: 3 additions & 0 deletions Source/Juego/Starfield/Starfield.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PackageReference Include="Meadow.Juego" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 2 additions & 0 deletions Source/Juego/Starfield/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
3 changes: 3 additions & 0 deletions Source/Juego/Tetraminoes/Tetraminos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PackageReference Include="Meadow.Juego" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="app.build.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 2 additions & 0 deletions Source/Juego/Tetraminoes/app.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deploy:
NoLink: [ Juego ]
4 changes: 2 additions & 2 deletions Source/Meadow F7/Blinky/BlinkyCS/BlinkyCS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meadow.F7" Version="*" />
<PackageReference Include="Meadow.Foundation" Version="*" />
<PackageReference Include="Meadow.F7" Version="*" />
<PackageReference Include="Meadow.Foundation" Version="*" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions Source/Meadow F7/Network/Cell_Basics/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ void CellAdapter_NetworkDisconnected(INetworkAdapter sender, NetworkDisconnectio
Console.WriteLine("Cell network disconnected!");
}

void CellAdapter_NetworkConnectFailed(INetworkAdapter sender)
{
Console.WriteLine("Cell network connect failed!");
}

void CellAdapter_NetworkConnecting(INetworkAdapter sender)
{
Console.WriteLine("Cell network connecting!");
}

async Task GetWebPageViaHttpClient(string uri)
{
Console.WriteLine($"Requesting {uri} - {DateTime.Now}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="MeadowApp.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meadow.Desktop" Version="*" />
<PackageReference Include="Meadow.Foundation.ICs.IOExpanders.Ftxxxx" Version="*" />
</ItemGroup>
</Project>
<ItemGroup>
<PackageReference Include="Meadow.Desktop" Version="*" />
<PackageReference Include="Meadow.Foundation.ICs.IOExpanders.Ftxxxx" Version="*" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions Source/Meadow.Desktop/HMI_Views/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public override Task Initialize()
//var views = new CultivarView(Device.Display);
//var views = new ProjectLabDemoView(Device.Display);
//var views = new AtmosphericHMI(Device.Display);
var views = new WifiWeatherV2(Device.Display);
//var views = new WifiWeatherV2(Device.Display);
var views = new HistogramView(Device.Display);

_ = Task.Run(() =>
{
Thread.Sleep(2000);
views.Run();
_ = views.Run();
});

return Task.CompletedTask;
Expand Down
2 changes: 1 addition & 1 deletion Source/Meadow.Desktop/HMI_Views/Views/CultivarView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace HMI_Views.Views;

public class CultivarView
{
DisplayScreen screen;
private DisplayScreen screen;

private readonly Image imgWifi = Image.LoadFromResource("HMI_Views.Resources.img-wifi.bmp");
private readonly Image imgSync = Image.LoadFromResource("HMI_Views.Resources.img-sync.bmp");
Expand Down
Loading
Loading