-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f31dca
commit 78364ed
Showing
160 changed files
with
950 additions
and
334 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,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
30
Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.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,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> |
Oops, something went wrong.