-
Notifications
You must be signed in to change notification settings - Fork 68
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 #752 from WildernessLabs/v1.3.0
V1.3.0
- Loading branch information
Showing
312 changed files
with
7,449 additions
and
756 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
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 |
55 changes: 55 additions & 0 deletions
55
Source/Meadow.Foundation.Core.Samples/Motor.BidirectionalDcMotor_Sample/MeadowApp.cs
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,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=> | ||
} |
21 changes: 21 additions & 0 deletions
21
...n.Core.Samples/Motor.BidirectionalDcMotor_Sample/Motor.BidirectionalDcMotor_Sample.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,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> |
2 changes: 2 additions & 0 deletions
2
Source/Meadow.Foundation.Core.Samples/Motor.BidirectionalDcMotor_Sample/meadow.config.yaml
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,2 @@ | ||
MonoControl: | ||
Options: --jit |
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
59 changes: 59 additions & 0 deletions
59
Source/Meadow.Foundation.Core/Motors/BidirectionalDcMotor.cs
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.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); | ||
} | ||
|
||
} |
Oops, something went wrong.