Skip to content

Commit

Permalink
Merge pull request #63 from WildernessLabs/develop
Browse files Browse the repository at this point in the history
Updates for B6.4
  • Loading branch information
adrianstevens authored May 30, 2022
2 parents 7bf7509 + f4529f3 commit 866fa4d
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Meadow.CSharp.Library.Template/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;

namespace MeadowLibary
namespace MeadowLibrary
{
public class Class1
{
}
}
}
15 changes: 7 additions & 8 deletions Meadow.CSharp.Template/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

namespace $safeprojectname$
{
// Change F7MicroV2 to F7Micro for V1.x boards
public class MeadowApp : App<F7MicroV2, MeadowApp>
// Change F7FeatherV2 to F7FeatherV1 for V1.x boards
public class MeadowApp : App<F7FeatherV2, MeadowApp>
{
RgbPwmLed onboardLed;

public MeadowApp()
{
Initialize();
CycleColors(1000);
CycleColors(TimeSpan.FromMilliseconds(1000));
}

void Initialize()
Expand All @@ -26,11 +26,10 @@ void Initialize()
redPwmPin: Device.Pins.OnboardLedRed,
greenPwmPin: Device.Pins.OnboardLedGreen,
bluePwmPin: Device.Pins.OnboardLedBlue,
3.3f, 3.3f, 3.3f,
Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode);
}

void CycleColors(int duration)
void CycleColors(TimeSpan duration)
{
Console.WriteLine("Cycle colors...");

Expand All @@ -51,14 +50,14 @@ void CycleColors(int duration)
}
}

void ShowColorPulse(Color color, int duration = 1000)
void ShowColorPulse(Color color, TimeSpan duration)
{
onboardLed.StartPulse(color, (duration / 2));
onboardLed.StartPulse(color, duration / 2);
Thread.Sleep(duration);
onboardLed.Stop();
}

void ShowColor(Color color, int duration = 1000)
void ShowColor(Color color, TimeSpan duration)
{
Console.WriteLine($"Color: {color}");
onboardLed.SetColor(color);
Expand Down
43 changes: 21 additions & 22 deletions Meadow.FSharp.Template/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,36 @@ open Meadow.Foundation.Leds
open Meadow.Foundation

type MeadowApp() =
// Change F7MicroV2 to F7Micro for V1.x boards
inherit App<F7MicroV2, MeadowApp>()
// Change F7FeatherV2 to F7FeatherV1 for V1.x boards
inherit App<F7FeatherV2, MeadowApp>()

do Console.WriteLine "Init with FSharp!"
let led = new RgbPwmLed(MeadowApp.Device, MeadowApp.Device.Pins.OnboardLedRed,MeadowApp.Device.Pins.OnboardLedGreen, MeadowApp.Device.Pins.OnboardLedBlue,3.3f,3.3f,3.3f,Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode)
do Console.WriteLine "Initialize hardware... [F#]"
let led = new RgbPwmLed(MeadowApp.Device, MeadowApp.Device.Pins.OnboardLedRed,MeadowApp.Device.Pins.OnboardLedGreen, MeadowApp.Device.Pins.OnboardLedBlue,Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode)

let ShowcolorPulses color duration =
led.StartPulse(color, (duration / 2)) |> ignore
Threading.Thread.Sleep (int duration) |> ignore
let ShowColorPulse (color : Color) (duration : TimeSpan) =
led.StartPulse(color, duration.Divide(2)) |> ignore
Threading.Thread.Sleep (duration) |> ignore
led.Stop |> ignore

let cyclecolors duration =
let cyclecolors (duration : TimeSpan) =
while true do
ShowcolorPulses Color.Blue duration
ShowcolorPulses Color.Cyan duration
ShowcolorPulses Color.Green duration
ShowcolorPulses Color.GreenYellow duration
ShowcolorPulses Color.Yellow duration
ShowcolorPulses Color.Orange duration
ShowcolorPulses Color.OrangeRed duration
ShowcolorPulses Color.Red duration
ShowcolorPulses Color.MediumVioletRed duration
ShowcolorPulses Color.Purple duration
ShowcolorPulses Color.Magenta duration
ShowcolorPulses Color.Pink duration
ShowColorPulse Color.Blue duration
ShowColorPulse Color.Cyan duration
ShowColorPulse Color.Green duration
ShowColorPulse Color.GreenYellow duration
ShowColorPulse Color.Yellow duration
ShowColorPulse Color.Orange duration
ShowColorPulse Color.OrangeRed duration
ShowColorPulse Color.Red duration
ShowColorPulse Color.MediumVioletRed duration
ShowColorPulse Color.Purple duration
ShowColorPulse Color.Magenta duration
ShowColorPulse Color.Pink duration

do cyclecolors 1000
do cyclecolors (TimeSpan.FromSeconds(1))

[<EntryPoint>]
let main argv =
Console.WriteLine "Hello World from F#!"
let app = new MeadowApp()
Threading.Thread.Sleep (System.Threading.Timeout.Infinite)
0 // return an integer exit code
49 changes: 22 additions & 27 deletions Meadow.VBNet.Template/MeadowApp.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,53 @@ Imports Meadow.Foundation
Imports Meadow.Foundation.Leds

Public Class MeadowApp
'Change F7MicroV2 to F7Micro for V1.x boards'
Inherits App(Of F7MicroV2, MeadowApp)
'Change F7FeatherV2 to F7FeatherV1 for V1.x boards'
Inherits App(Of F7FeatherV2, MeadowApp)

Private Dim onboardLed as RgbPwmLed
Private onboardLed As RgbPwmLed

Public Sub New()
MyBase.New

Console.WriteLine("Hello VB.NET!")

Initialize()
CycleColors(1000)
CycleColors(TimeSpan.FromMilliseconds(1000))

End Sub

Private Sub Initialize()
Console.WriteLine("Initialize hardware...")
Console.WriteLine("Initialize hardware... [VB.NET]")

onboardLed = new RgbPwmLed (Device,
onboardLed = New RgbPwmLed(Device,
Device.Pins.OnboardLedRed,
Device.Pins.OnboardLedGreen,
Device.Pins.OnboardLedBlue,
3.3f, 3.3f, 3.3f,
Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode)



End Sub

Private Sub CycleColors(ByVal duration As Integer)
Private Sub CycleColors(ByVal duration As TimeSpan)
Console.WriteLine("Cycle colors...")

While true
While True
ShowColorPulse(Color.Blue, duration)
ShowColorPulse(Color.Cyan, duration)
ShowColorPulse(Color.Green, duration)
ShowColorPulse(Color.GreenYellow, duration)
ShowColorPulse(Color.Yellow, duration)
ShowColorPulse(Color.Orange, duration)
ShowColorPulse(Color.OrangeRed, duration)
ShowColorPulse(Color.Red, duration)
ShowColorPulse(Color.MediumVioletRed, duration)
ShowColorPulse(Color.Purple, duration)
ShowColorPulse(Color.Magenta, duration)
ShowColorPulse(Color.Pink, duration)
ShowColorPulse(Color.Cyan, duration)
ShowColorPulse(Color.Green, duration)
ShowColorPulse(Color.GreenYellow, duration)
ShowColorPulse(Color.Yellow, duration)
ShowColorPulse(Color.Orange, duration)
ShowColorPulse(Color.OrangeRed, duration)
ShowColorPulse(Color.Red, duration)
ShowColorPulse(Color.MediumVioletRed, duration)
ShowColorPulse(Color.Purple, duration)
ShowColorPulse(Color.Magenta, duration)
ShowColorPulse(Color.Pink, duration)
End While

End Sub

Private Sub ShowColorPulse(ByVal color As Color, ByVal duration As Integer)
onboardLed.StartPulse(color, duration/2)
Private Sub ShowColorPulse(ByVal color As Color, ByVal duration As TimeSpan)
onboardLed.StartPulse(color, duration / 2)
Thread.Sleep(duration)
End Sub

End Class
End Class
4 changes: 1 addition & 3 deletions Meadow.VBNet.Template/Program.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ Imports System.Threading
Public Class Program

Public Shared Sub Main()
Console.WriteLine("Hello very modern world!")

Dim app as New MeadowApp
Dim app As New MeadowApp

Thread.Sleep(Timeout.Infinite)
End Sub
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="VS_Meadow_Extension.ProjectType..fe358059-9487-4fe7-a01a-4b67b8231321" Version="0.19.0" Language="en-US" Publisher="Wilderness Labs" />
<Identity Id="VS_Meadow_Extension.ProjectType..fe358059-9487-4fe7-a01a-4b67b8231321" Version="0.19.2" Language="en-US" Publisher="Wilderness Labs" />
<DisplayName>VS 2019 Tools for Meadow</DisplayName>
<Description xml:space="preserve">Tools for developing Meadow applications</Description>
<Icon>wildernesslabs_icon.png</Icon>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="VS_Meadow_Extension.2022.d5eb772d-2173-4795-b60b-67929a9bf12d" Version="0.19.0" Language="en-US" Publisher="Wilderness Labs" />
<Identity Id="VS_Meadow_Extension.2022.d5eb772d-2173-4795-b60b-67929a9bf12d" Version="0.19.2" Language="en-US" Publisher="Wilderness Labs" />
<DisplayName>VS 2022 Tools for Meadow</DisplayName>
<Description xml:space="preserve">Tools for developing Meadow applications</Description>
<Icon>wildernesslabs_icon.png</Icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static Task<IMeadowDevice> GetMeadowSerialDeviceAsync(ILogger logger = nu

if (string.IsNullOrEmpty(settings.DeviceTarget))
{
throw new Exception("Device has not been selected. Hit Ctrl+Shift+M to access the Device list.");
throw new Exception("Meadow device has not been selected. Select your device using the Meadow Device Selector on the toolbar.");
}

return MeadowDeviceManager.GetMeadowForSerialPort(settings.DeviceTarget, logger: logger);
Expand Down

0 comments on commit 866fa4d

Please sign in to comment.