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

B6.5 updates - WIP - samples need lifecycle updates #359

Merged
merged 16 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
using System;
using System.Threading.Tasks;
using Meadow;
using Meadow;
using Meadow.Devices;
using Meadow.Foundation.Audio;
using Meadow.Units;
using System;
using System.Threading.Tasks;

namespace Audio.PiezoSpeaker_Sample
{
public class MeadowApp : App<F7FeatherV2, MeadowApp>
public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>

protected PiezoSpeaker piezoSpeaker;

public MeadowApp()
public override Task Initialize()
{
Console.WriteLine("Initializing...");

piezoSpeaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D05));
piezoSpeaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D05, new Frequency(100, Frequency.UnitType.Hertz)));

_ = PlayTriad();
return Task.CompletedTask;
}

async Task PlayTriad()
public override async Task Run()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Playing A major triad starting at A4");
await piezoSpeaker.PlayTone(440, 500); //A
await piezoSpeaker.PlayTone(554.37f, 500); //C#
await piezoSpeaker.PlayTone(659.25f, 500); //E
await piezoSpeaker.PlayTone(new Frequency(440, Frequency.UnitType.Hertz), 500); //A
await piezoSpeaker.PlayTone(new Frequency(554.37f, Frequency.UnitType.Hertz), 500); //C#
await piezoSpeaker.PlayTone(new Frequency(659.25f, Frequency.UnitType.Hertz), 500); //E

await Task.Delay(2500);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
using System;
using System.Threading;
using Meadow;
using Meadow;
using Meadow.Devices;
using Meadow.Foundation.Generators;
using Meadow.Hardware;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Generators.SoftPwmPort_Sample
{
public class MeadowApp : App<F7FeatherV2, MeadowApp>
public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>

protected SoftPwmPort softPwmPort;

public MeadowApp()
public override Task Initialize()
{
Console.WriteLine("Initializing...");

IDigitalOutputPort digiOut = Device.CreateDigitalOutputPort(Device.Pins.D00);
softPwmPort = new SoftPwmPort(digiOut);

softPwmPort = new SoftPwmPort(digiOut);

return Task.CompletedTask;
}

public override Task Run()
{
TestSoftPwmPort();
return Task.CompletedTask;
}

protected void TestSoftPwmPort()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
using Meadow.Foundation.Leds;
using Meadow.Hardware;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Leds.LedBarGraph_Sample
{
public class MeadowApp : App<F7FeatherV2, MeadowApp>
public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>

LedBarGraph ledBarGraph;

public MeadowApp()
public override Task Initialize()
{
Console.WriteLine("Initializing...");

Expand All @@ -34,10 +34,10 @@ public MeadowApp()

ledBarGraph = new LedBarGraph(Device, pins);

TestLedBarGraph();
return Task.CompletedTask;
}

protected void TestLedBarGraph()
public override async Task Run()
{
Console.WriteLine("TestLedBarGraph...");

Expand All @@ -49,47 +49,47 @@ protected void TestLedBarGraph()
for (int i = 0; i < ledBarGraph.Count; i++)
{
ledBarGraph.SetLed(i, true);
Thread.Sleep(1000);
await Task.Delay(1000);
ledBarGraph.SetLed(i, false);
}

Thread.Sleep(1000);
await Task.Delay(1000);

Console.WriteLine("Turning them on using Percentage...");
while (percentage < 1)
{
percentage += 0.10m;
Console.WriteLine($"{percentage}");
ledBarGraph.Percentage = (float) Math.Min(1.0m, percentage);
Thread.Sleep(500);
await Task.Delay(1000);
}

Thread.Sleep(1000);
await Task.Delay(1000);

Console.WriteLine("Turning them off using Percentage...");
while (percentage > 0)
{
percentage -= 0.10m;
Console.WriteLine($"{percentage}");
ledBarGraph.Percentage = (float) Math.Max(0.0m, percentage);
Thread.Sleep(500);
await Task.Delay(1000);
}

Thread.Sleep(1000);
await Task.Delay(1000);

Console.WriteLine("Blinking for 3 seconds...");
ledBarGraph.StartBlink();
Thread.Sleep(3000);
await Task.Delay(3000);
ledBarGraph.Stop();

Thread.Sleep(1000);
await Task.Delay(1000);

Console.WriteLine("Blinking for 3 seconds...");
ledBarGraph.StartBlink(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
Thread.Sleep(3000);
await Task.Delay(3000);
ledBarGraph.Stop();

Thread.Sleep(1000);
await Task.Delay(1000);
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
26 changes: 13 additions & 13 deletions Source/Meadow.Foundation.Core.Samples/Leds.Led_Sample/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
using Meadow.Foundation.Leds;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Leds.Led_Sample
{
public class MeadowApp : App<F7FeatherV2, MeadowApp>
public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>

readonly List<Led> leds;
List<Led> leds;

public MeadowApp()
public override Task Initialize()
{
var onRgbLed = new RgbLed(
device: Device,
Expand Down Expand Up @@ -44,10 +44,10 @@ public MeadowApp()

onRgbLed.SetColor(RgbLed.Colors.Green);

TestLeds();
return Task.CompletedTask;
}

protected void TestLeds()
public override async Task Run()
{
Console.WriteLine("TestLeds...");

Expand All @@ -57,37 +57,37 @@ protected void TestLeds()
foreach (var led in leds)
{
led.IsOn = true;
Thread.Sleep(100);
await Task.Delay(100);
}

Thread.Sleep(1000);
await Task.Delay(1000);

Console.WriteLine("Turning off each led every 100ms");
foreach (var led in leds)
{
led.IsOn = false;
Thread.Sleep(100);
await Task.Delay(100);
}

Thread.Sleep(1000);
await Task.Delay(1000);

Console.WriteLine("Blinking the LEDs for a second each");
foreach (var led in leds)
{
led.StartBlink();
Thread.Sleep(3000);
await Task.Delay(3000);
led.Stop();
}

Console.WriteLine("Blinking the LEDs for a second each with on (1s) and off (1s)");
foreach (var led in leds)
{
led.StartBlink(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
Thread.Sleep(3000);
await Task.Delay(3000);
led.Stop();
}

Thread.Sleep(3000);
await Task.Delay(3000);
}
}

Expand Down
17 changes: 0 additions & 17 deletions Source/Meadow.Foundation.Core.Samples/Leds.Led_Sample/Program.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
Loading