From 6703bca2f2de3abecd05da8fef7399082da4290e Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Tue, 31 Oct 2023 12:57:14 -0700 Subject: [PATCH] Update Readmes --- .../Displays.Tm1637/Driver/Readme.md | 2 +- .../Driver/Readme.md | 15 +++-- .../Motors.Stepper.A4988/Driver/Readme.md | 2 +- .../Motors.Stepper.Em542s/Driver/Readme.md | 60 +++++++++++++++++++ 4 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 Source/Meadow.Foundation.Peripherals/Motors.Stepper.Em542s/Driver/Readme.md diff --git a/Source/Meadow.Foundation.Peripherals/Displays.Tm1637/Driver/Readme.md b/Source/Meadow.Foundation.Peripherals/Displays.Tm1637/Driver/Readme.md index c639f73a62..8b3c1bc0b4 100644 --- a/Source/Meadow.Foundation.Peripherals/Displays.Tm1637/Driver/Readme.md +++ b/Source/Meadow.Foundation.Peripherals/Displays.Tm1637/Driver/Readme.md @@ -19,7 +19,7 @@ public override Task Initialize() { Resolver.Log.Info("Initialize..."); - display = new Tm1637(Device, Device.Pins.D02, Device.Pins.D01); + display = new Tm1637(Device.Pins.D02, Device.Pins.D01); display.Brightness = 7; display.ScreenOn = true; diff --git a/Source/Meadow.Foundation.Peripherals/Motors.ElectronicSpeedController/Driver/Readme.md b/Source/Meadow.Foundation.Peripherals/Motors.ElectronicSpeedController/Driver/Readme.md index 6a0e7cc773..1842e86c25 100644 --- a/Source/Meadow.Foundation.Peripherals/Motors.ElectronicSpeedController/Driver/Readme.md +++ b/Source/Meadow.Foundation.Peripherals/Motors.ElectronicSpeedController/Driver/Readme.md @@ -13,12 +13,11 @@ To view all Wilderness Labs open-source projects, including samples, visit [gith ## Usage ```csharp -readonly Frequency frequency = new Frequency(50, Frequency.UnitType.Hertz); -const float armMs = 0.5f; -const float powerIncrement = 0.05f; - -ElectronicSpeedController esc; -RotaryEncoderWithButton rotary; +private readonly Frequency frequency = new Frequency(50, Frequency.UnitType.Hertz); +private const float armMs = 0.5f; +private const float powerIncrement = 0.05f; +private ElectronicSpeedController esc; +private RotaryEncoderWithButton rotary; public override Task Initialize() { @@ -44,7 +43,7 @@ private void RotaryRotated(object sender, RotaryChangeResult e) esc.Power += (e.New == RotationDirection.Clockwise) ? powerIncrement : -powerIncrement; DisplayPowerOnLed(esc.Power); - Resolver.Log.Info($"New Power: {esc.Power * (float)100:n0}%"); + Resolver.Log.Info($"New Power: {esc.Power * 100:n0}%"); } /// @@ -52,7 +51,7 @@ private void RotaryRotated(object sender, RotaryChangeResult e) /// blue @ `0%`, and a proportional mix, in between those speeds. /// /// -void DisplayPowerOnLed(float power) +private void DisplayPowerOnLed(float power) { // `0.0` - `1.0` int r = (int)ExtensionMethods.Map(power, 0f, 1f, 0f, 255f); diff --git a/Source/Meadow.Foundation.Peripherals/Motors.Stepper.A4988/Driver/Readme.md b/Source/Meadow.Foundation.Peripherals/Motors.Stepper.A4988/Driver/Readme.md index 936f673571..21cb9d9149 100644 --- a/Source/Meadow.Foundation.Peripherals/Motors.Stepper.A4988/Driver/Readme.md +++ b/Source/Meadow.Foundation.Peripherals/Motors.Stepper.A4988/Driver/Readme.md @@ -13,7 +13,7 @@ To view all Wilderness Labs open-source projects, including samples, visit [gith ## Usage ```csharp -A4988 a4988; +private A4988 a4988; public override Task Initialize() { diff --git a/Source/Meadow.Foundation.Peripherals/Motors.Stepper.Em542s/Driver/Readme.md b/Source/Meadow.Foundation.Peripherals/Motors.Stepper.Em542s/Driver/Readme.md new file mode 100644 index 0000000000..ed112ac938 --- /dev/null +++ b/Source/Meadow.Foundation.Peripherals/Motors.Stepper.Em542s/Driver/Readme.md @@ -0,0 +1,60 @@ +# Meadow.Foundation.Motors.Stepper.Em542s + +**The Leadshine EM542S Stepper Motor Drive** + +The **Em542s** library is designed for the [Wilderness Labs](www.wildernesslabs.co) Meadow .NET IoT platform and is part of [Meadow.Foundation](https://developer.wildernesslabs.co/Meadow/Meadow.Foundation/). + +The **Meadow.Foundation** peripherals library is an open-source repository of drivers and libraries that streamline and simplify adding hardware to your C# .NET Meadow IoT application. + +For more information on developing for Meadow, visit [developer.wildernesslabs.co](http://developer.wildernesslabs.co/). + +To view all Wilderness Labs open-source projects, including samples, visit [github.com/wildernesslabs](https://github.com/wildernesslabs/). + +## Usage + +```csharp +private IStepperMotor stepper; + +public override Task Initialize() +{ + stepper = new Em542s( + Device.Pins.D15.CreateDigitalOutputPort(), + Device.Pins.D14.CreateDigitalOutputPort(), + inverseLogic: true); + + return base.Initialize(); +} + +public override Task Run() +{ + var direction = RotationDirection.Clockwise; + + // max rate for this drive + var rate = new Meadow.Units.Frequency(200, Meadow.Units.Frequency.UnitType.Kilohertz); + + while (true) + { + Resolver.Log.Info($"{direction}"); + + stepper.Rotate(360f, direction, rate); + Thread.Sleep(1000); + + direction = direction switch + { + RotationDirection.CounterClockwise => RotationDirection.Clockwise, + _ => RotationDirection.CounterClockwise + }; + } +} + +``` +## How to Contribute + +- **Found a bug?** [Report an issue](https://github.com/WildernessLabs/Meadow_Issues/issues) +- Have a **feature idea or driver request?** [Open a new feature request](https://github.com/WildernessLabs/Meadow_Issues/issues) +- Want to **contribute code?** Fork the [Meadow.Foundation](https://github.com/WildernessLabs/Meadow.Foundation) repository and submit a pull request against the `develop` branch + + +## Need Help? + +If you have questions or need assistance, please join the Wilderness Labs [community on Slack](http://slackinvite.wildernesslabs.co/).