Skip to content

Commit

Permalink
Merge pull request #46 from WildernessLabs/v1.5.0
Browse files Browse the repository at this point in the history
Release 1.5.0
  • Loading branch information
jorgedevs authored Nov 29, 2023
2 parents 4f31dca + 78364ed commit b5a2335
Show file tree
Hide file tree
Showing 160 changed files with 950 additions and 334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ThreeAxisDigitalAccelerometer16g : Adxl345
/// </summary>
/// <param name="i2CBus"></param>
public ThreeAxisDigitalAccelerometer16g(II2cBus i2CBus)
: base (i2CBus)
: base(i2CBus)
{ }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<ItemGroup>
<None Include=".\Readme.md" Pack="true" PackagePath=""/>
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Meadow.Foundation.Sensors.Motion.Adxl3xx" Version="*" />
<PackageReference Include="Meadow.Foundation.Sensors.Motion.Adxl3xx" Version="1.5.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Source/3-AxisDigitalAccelerometer16g/Driver/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ ThreeAxisDigitalAccelerometer16g sensor;

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

sensor = new ThreeAxisDigitalAccelerometer16g(Device.CreateI2cBus());
sensor.SetPowerState(false, false, true, false, ThreeAxisDigitalAccelerometer16g.Frequencies.TwoHz);

sensor.Updated += (sender, result) =>
{
Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
$"Y:{result.New.Y.MetersPerSecondSquared:N2}," +
$"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meadow.F7" Version="*" />
<PackageReference Include="Meadow.F7" Version="1.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Driver\3-AxisDigitalAccelerometer16g.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class MeadowApp : App<F7FeatherV2>

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

sensor = new ThreeAxisDigitalAccelerometer16g(Device.CreateI2cBus());
sensor.SetPowerState(false, false, true, false, ThreeAxisDigitalAccelerometer16g.Frequencies.TwoHz);

sensor.Updated += (sender, result) =>
{
Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
$"Y:{result.New.Y.MetersPerSecondSquared:N2}," +
$"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ThreeAxisDigitalAccelerometer1_5g : Mma7660fc
/// </summary>
/// <param name="i2cBus"></param>
public ThreeAxisDigitalAccelerometer1_5g(II2cBus i2cBus)
: base (i2cBus, Addresses.Address_0x4c)
: base(i2cBus, Addresses.Address_0x4c)
{ }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<ItemGroup>
<None Include=".\Readme.md" Pack="true" PackagePath=""/>
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Meadow.Foundation.Sensors.Motion.Mma7660fc" Version="*" />
<PackageReference Include="Meadow.Foundation.Sensors.Motion.Mma7660fc" Version="1.5.0" />
</ItemGroup>
</Project>
12 changes: 7 additions & 5 deletions Source/3-AxisDigitalAccelerometer1_5g/Driver/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ ThreeAxisDigitalAccelerometer1_5g sensor;

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

// create the sensor driver
sensor = new ThreeAxisDigitalAccelerometer1_5g(Device.CreateI2cBus());

// classical .NET events can also be used:
sensor.Updated += (sender, result) => {
Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
$"Y:{result.New.Y.MetersPerSecondSquared:N2}," +
$"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]" +
$" Direction: {sensor.Direction}" +
Expand All @@ -33,9 +34,10 @@ public override Task Initialize()

// Example that uses an IObersvable subscription to only be notified when the filter is satisfied
var consumer = ThreeAxisDigitalAccelerometer1_5g.CreateObserver(
handler: result => Console.WriteLine($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"),
handler: result => Resolver.Log.Info($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"),
// only notify if there's a greater than 0.5G change in the Z direction
filter: result => {
filter: result =>
{
if (result.Old is { } old)
{ //c# 8 pattern match syntax. checks for !null and assigns var.
return (result.New - old).Z > new Acceleration(0.5, AU.Gravity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>App</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meadow.F7" Version="*" />
<PackageReference Include="Meadow.F7" Version="1.5.0" />
<ProjectReference Include="..\..\Driver\3-AxisDigitalAccelerometer1_5g.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ public class MeadowApp : App<F7FeatherV2>

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

// create the sensor driver
sensor = new ThreeAxisDigitalAccelerometer1_5g(Device.CreateI2cBus());

// classical .NET events can also be used:
sensor.Updated += (sender, result) => {
Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
$"Y:{result.New.Y.MetersPerSecondSquared:N2}," +
$"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]" +
$" Direction: {sensor.Direction}" +
Expand All @@ -33,9 +34,10 @@ public override Task Initialize()

// Example that uses an IObersvable subscription to only be notified when the filter is satisfied
var consumer = ThreeAxisDigitalAccelerometer1_5g.CreateObserver(
handler: result => Console.WriteLine($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"),
handler: result => Resolver.Log.Info($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"),
// only notify if there's a greater than 0.5G change in the Z direction
filter: result => {
filter: result =>
{
if (result.Old is { } old)
{ //c# 8 pattern match syntax. checks for !null and assigns var.
return (result.New - old).Z > new Acceleration(0.5, AU.Gravity);
Expand Down
14 changes: 7 additions & 7 deletions Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public ThreeAxisDigitalCompass(
DataOutputRates outputRate = DataOutputRates.Rate15,
SampleAmounts samplesAmount = SampleAmounts.One,
MeasurementConfigurations measurementConfig = MeasurementConfigurations.Normal)
: base (
i2cBus,
address,
gain,
measuringMode,
outputRate,
samplesAmount,
: base(
i2cBus,
address,
gain,
measuringMode,
outputRate,
samplesAmount,
measurementConfig)
{ }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<ItemGroup>
<None Include=".\Readme.md" Pack="true" PackagePath=""/>
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Meadow.Foundation.Sensors.Motion.Hmc5883" Version="*" />
<PackageReference Include="Meadow.Foundation.Sensors.Motion.Hmc5883" Version="1.5.0" />
</ItemGroup>
</Project>
14 changes: 8 additions & 6 deletions Source/3-AxisDigitalCompass/Driver/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@ ThreeAxisDigitalCompass sensor;

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

sensor = new ThreeAxisDigitalCompass(Device.CreateI2cBus());

sensor.Updated += (sender, result) => {
Console.WriteLine($"Direction: [X:{result.New.X:N2}," +
sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($"Direction: [X:{result.New.X:N2}," +
$"Y:{result.New.Y:N2}," +
$"Z:{result.New.Z:N2}]");

Console.WriteLine($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees");
Resolver.Log.Info($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees");
};

var consumer = Hmc5883.CreateObserver(
handler: result =>
{
Console.WriteLine($"Observer: [x] changed by threshold; " +
Resolver.Log.Info($"Observer: [x] changed by threshold; " +
$"new [x]: X:{Hmc5883.DirectionToHeading(result.New):N2}, " +
$"old: X:{((result.Old != null) ? Hmc5883.DirectionToHeading(result.Old.Value) : "n/a"):N2} degrees");
},
filter: result => {
filter: result =>
{
if (result.Old is { } old)
{ //c# 8 pattern match syntax. checks for !null and assigns var.
return (Hmc5883.DirectionToHeading(result.New - old) > new Azimuth(5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meadow.F7" Version="*" />
<PackageReference Include="Meadow.F7" Version="1.5.0" />
<ProjectReference Include="..\..\Driver\3-AxisDigitalCompass.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@ public class MeadowApp : App<F7FeatherV2>

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

sensor = new ThreeAxisDigitalCompass(Device.CreateI2cBus());

sensor.Updated += (sender, result) => {
Console.WriteLine($"Direction: [X:{result.New.X:N2}," +
sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($"Direction: [X:{result.New.X:N2}," +
$"Y:{result.New.Y:N2}," +
$"Z:{result.New.Z:N2}]");
Console.WriteLine($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees");
Resolver.Log.Info($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees");
};

var consumer = Hmc5883.CreateObserver(
handler: result =>
{
Console.WriteLine($"Observer: [x] changed by threshold; " +
Resolver.Log.Info($"Observer: [x] changed by threshold; " +
$"new [x]: X:{Hmc5883.DirectionToHeading(result.New):N2}, " +
$"old: X:{((result.Old != null) ? Hmc5883.DirectionToHeading(result.Old.Value) : "n/a"):N2} degrees");
},
filter: result => {
filter: result =>
{
if (result.Old is { } old)
{ //c# 8 pattern match syntax. checks for !null and assigns var.
return (Hmc5883.DirectionToHeading(result.New - old) > new Azimuth(5));
Expand Down
86 changes: 86 additions & 0 deletions Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using Meadow.Foundation.Relays;
using Meadow.Hardware;
using Meadow.Peripherals.Relays;

namespace Meadow.Foundation.Grove.Relays
{
/// <summary>
/// Represents a Grove Four Channel Spdt Relay
/// </summary>
public partial class FourChannelSpdtRelay : II2cPeripheral
{
/// <summary>
/// The relays
/// </summary>
public readonly Relay[] Relays = new Relay[4];

/// <inheritdoc/>
public byte DefaultI2cAddress => 0x12;

/// <summary>
/// The digital output ports for the relays
/// </summary>
protected readonly IDigitalOutputPort[] ports = new IDigitalOutputPort[4];

private readonly Stm32Expander ioExpander;

/// <summary>
/// Creates a new FourChannelSpdtRelay driver
/// </summary>
/// <param name="i2cBus">The I2C bus the peripheral is connected to</param>
/// <param name="address">The bus address of the peripheral</param>
public FourChannelSpdtRelay(II2cBus i2cBus, byte address = 0x11)
{
ioExpander = new Stm32Expander(i2cBus, address);

Initialize();
}

void Initialize()
{
ports[0] = ioExpander.Pins.SW1.CreateDigitalOutputPort(false);
ports[1] = ioExpander.Pins.SW2.CreateDigitalOutputPort(false);
ports[2] = ioExpander.Pins.SW3.CreateDigitalOutputPort(false);
ports[3] = ioExpander.Pins.SW4.CreateDigitalOutputPort(false);

Relays[0] = new Relay(ports[0], RelayType.NormallyOpen);
Relays[1] = new Relay(ports[1], RelayType.NormallyOpen);
Relays[2] = new Relay(ports[2], RelayType.NormallyOpen);
Relays[3] = new Relay(ports[3], RelayType.NormallyOpen);
}

/// <summary>
/// Get the firmware version
/// </summary>
/// <returns>The firmware version as a byte</returns>
public byte GetFirmwareVersion()
{
return ioExpander.GetFirmwareVersion();
}

/// <summary>
/// Set a new I2C address
/// </summary>
/// <param name="address"></param>
public void SetI2cAddress(byte address)
{
ioExpander.SetI2cAddress(address);
}

/// <summary>
/// Convenience method to turn all outputs off
/// </summary>
public void SetAllOff()
{
ioExpander.SetAllOff();
}

/// <summary>
/// Convenience method to turn all outputs on
/// </summary>
public void SetAllOn()
{
ioExpander.SetAllOn();
}
}
}
30 changes: 30 additions & 0 deletions Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Authors>Wilderness Labs, Inc</Authors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>netstandard2.1</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputType>Library</OutputType>
<AssemblyName>4ChannelSpdtRelay</AssemblyName>
<Company>Wilderness Labs, Inc</Company>
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/</PackageProjectUrl>
<PackageId>Meadow.Foundation.Grove.Relays.4ChannelSpdtRelay</PackageId>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.Foundation.Grove</RepositoryUrl>
<PackageTags>Meadow.Foundation,Grove,relay,relays,spdt</PackageTags>
<Version>0.1.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Grove I2C 4-Channel SPDT Relay</Description>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>
<ItemGroup>
<None Include=".\Readme.md" Pack="true" PackagePath="" />
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meadow.Foundation" Version="1.5.0" />
</ItemGroup>
</Project>
Loading

0 comments on commit b5a2335

Please sign in to comment.