Skip to content

Commit

Permalink
Merge pull request #752 from WildernessLabs/v1.3.0
Browse files Browse the repository at this point in the history
V1.3.0
  • Loading branch information
jorgedevs authored Aug 29, 2023
2 parents 84f6960 + 8b17c36 commit 8f555f9
Show file tree
Hide file tree
Showing 312 changed files with 7,449 additions and 756 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Main Build

on:
workflow_dispatch:
pull_request:
push:
branches: [ main ]

jobs:
build:

runs-on: windows-latest

steps:

- name: Checkout Meadow.Foundation
uses: actions/checkout@v3
with:
path: Meadow.Foundation
ref: main

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version:
7.0.x

- name: Build Meadow Foundation
run: dotnet build -c Release Meadow.Foundation/Source/Meadow.Foundation.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Meadow;
using Meadow.Devices;
using Meadow.Foundation.Motors;
using Meadow.Hardware;
using System.Threading.Tasks;

namespace Motor.BidirectionalDcMotor_Sample;

public class MeadowApp : App<F7FeatherV2>
{
//<!=SNIP=>

private BidirectionalDcMotor motor;

public override Task Initialize()
{
Resolver.Log.Info("Initializing...");

IDigitalOutputPort motorA;
IDigitalOutputPort motorB;

motorA = Device.Pins.D00.CreateDigitalOutputPort(false);
motorB = Device.Pins.D01.CreateDigitalOutputPort(false);

motor = new BidirectionalDcMotor(motorA, motorB);

return Task.CompletedTask;
}

public override async Task Run()
{
Resolver.Log.Info("Test Motor...");

while (true)
{
// Motor clockwise
motor.Clockwise();
await Task.Delay(1000);

// Motor Stop
motor.Stop();
await Task.Delay(500);

// Motor counter clockwise
motor.CounterClockwise();
await Task.Delay(1000);

// Motor Stop
motor.Stop();
await Task.Delay(500);
}
}

//<!=SNOP=>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.Foundation</RepositoryUrl>
<Company>Wilderness Labs, Inc</Company>
<Authors>Wilderness Labs, Inc</Authors>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<AssemblyName>App</AssemblyName>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meadow.F7" Version="*" />
<PackageReference Include="Meadow.Foundation" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="meadow.config.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MonoControl:
Options: --jit
5 changes: 4 additions & 1 deletion Source/Meadow.Foundation.Core/Meadow.Foundation.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Authors>Wilderness Labs, Inc</Authors>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
Expand All @@ -18,9 +20,10 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Description>Core peripheral drivers for Wilderness Labs Meadow</Description>
<Nullable>enable</Nullable>
<LangVersion>9.0</LangVersion>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Include=".\Readme.md" Pack="true" PackagePath=""/>
<None Include="..\..\Source\icon.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
Expand Down
59 changes: 59 additions & 0 deletions Source/Meadow.Foundation.Core/Motors/BidirectionalDcMotor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Meadow.Hardware;

namespace Meadow.Foundation.Motors;

/// <summary>
/// A generic DC motor whose direction is dictated by two outputs (i.e. a pair of polarity relays)
/// </summary>
public class BidirectionalDcMotor
{
private IDigitalOutputPort _outputA;
private IDigitalOutputPort _outputB;
private bool _energizeHigh;

/// <summary>
/// Gets the current run state of the motor (true == running)
/// </summary>
public bool IsRunning => _outputB.State != _outputB.State;

/// <summary>
/// Creates an instance of an BiDirectionalDcMotor
/// </summary>
/// <param name="outputA">The IDigitalOutputPort driving control relay A</param>
/// <param name="outputB">The IDigitalOutputPort driving control relay B</param>
/// <param name="energizeHigh">True if the relay control is positive logic, false if it's inverse logic</param>
public BidirectionalDcMotor(
IDigitalOutputPort outputA,
IDigitalOutputPort outputB,
bool energizeHigh = true)
{
_outputA = outputA;
_outputB = outputB;
_energizeHigh = energizeHigh;
}

/// <summary>
/// Stop turning the motor
/// </summary>
public void Stop()
{
_outputA.State = _outputB.State = _energizeHigh ? false : true;
}

/// <summary>
/// Start turning the motor clockwise
/// </summary>
public void Clockwise()
{
_outputA.State = !(_outputB.State = _energizeHigh ? true : false);
}

/// <summary>
/// Start turning the motor counter/anti clockwise
/// </summary>
public void CounterClockwise()
{
_outputA.State = !(_outputB.State = _energizeHigh ? false : true);
}

}
Loading

0 comments on commit 8f555f9

Please sign in to comment.