Skip to content

Commit

Permalink
Merge pull request #27 from WildernessLabs/develop
Browse files Browse the repository at this point in the history
RC2
  • Loading branch information
jorgedevs authored Jan 3, 2023
2 parents c8fd344 + 0f43a72 commit 33cc89a
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 149 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
with:
repository: WildernessLabs/Meadow.Contracts
path: Meadow.Contracts
ref: ${{ env.GITHUB_REF_NAME }}
ref: develop
- name: Checkout Meadow.Units
uses: actions/checkout@v3
with:
repository: WildernessLabs/Meadow.Units
path: Meadow.Units
ref: ${{ env.GITHUB_REF_NAME }}
ref: develop
- name: Checkout Meadow.Logging
uses: actions/checkout@v3
with:
Expand Down
23 changes: 16 additions & 7 deletions Source/Meadow.ProjectLab.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sensors.Motion.Bmi270", "..
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Graphics.MicroGraphics", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Libraries_and_Frameworks\Graphics.MicroGraphics\Driver\Graphics.MicroGraphics.csproj", "{DB4C8FC0-18A8-4735-933B-D1FCE59FC1E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Logging", "..\..\Meadow.Logging\lib\Meadow.Logging.csproj", "{A01BAE24-E0E4-458D-A5BA-9C10C4224354}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Modbus", "..\..\Meadow.Modbus\src\Meadow.Modbus\Meadow.Modbus.csproj", "{2D1FC26C-C80D-42E8-92BD-25BE517AC663}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Core", "..\..\Meadow.Core\source\Meadow.Core\Meadow.Core.csproj", "{18EE7297-3E8D-4B94-B6E3-319991927D58}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Logging", "..\..\Meadow.Logging\Source\Meadow.Logging\lib\Meadow.Logging.csproj", "{E56BD47C-4997-4831-833C-EA35C83F89B7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Units", "..\..\Meadow.Units\Source\Meadow.Units\Meadow.Units.csproj", "{35B3DDB4-71EF-4A68-B242-982C71126F3E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -105,10 +107,6 @@ Global
{DB4C8FC0-18A8-4735-933B-D1FCE59FC1E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB4C8FC0-18A8-4735-933B-D1FCE59FC1E3}.Release|Any CPU.Build.0 = Release|Any CPU
{DB4C8FC0-18A8-4735-933B-D1FCE59FC1E3}.Release|Any CPU.Deploy.0 = Release|Any CPU
{A01BAE24-E0E4-458D-A5BA-9C10C4224354}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A01BAE24-E0E4-458D-A5BA-9C10C4224354}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A01BAE24-E0E4-458D-A5BA-9C10C4224354}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A01BAE24-E0E4-458D-A5BA-9C10C4224354}.Release|Any CPU.Build.0 = Release|Any CPU
{2D1FC26C-C80D-42E8-92BD-25BE517AC663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D1FC26C-C80D-42E8-92BD-25BE517AC663}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D1FC26C-C80D-42E8-92BD-25BE517AC663}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -119,6 +117,16 @@ Global
{18EE7297-3E8D-4B94-B6E3-319991927D58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18EE7297-3E8D-4B94-B6E3-319991927D58}.Release|Any CPU.Build.0 = Release|Any CPU
{18EE7297-3E8D-4B94-B6E3-319991927D58}.Release|Any CPU.Deploy.0 = Release|Any CPU
{E56BD47C-4997-4831-833C-EA35C83F89B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E56BD47C-4997-4831-833C-EA35C83F89B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E56BD47C-4997-4831-833C-EA35C83F89B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E56BD47C-4997-4831-833C-EA35C83F89B7}.Release|Any CPU.Build.0 = Release|Any CPU
{35B3DDB4-71EF-4A68-B242-982C71126F3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35B3DDB4-71EF-4A68-B242-982C71126F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35B3DDB4-71EF-4A68-B242-982C71126F3E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{35B3DDB4-71EF-4A68-B242-982C71126F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35B3DDB4-71EF-4A68-B242-982C71126F3E}.Release|Any CPU.Build.0 = Release|Any CPU
{35B3DDB4-71EF-4A68-B242-982C71126F3E}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -133,9 +141,10 @@ Global
{CD675B1D-BC88-4DB5-AF45-8079435F52CA} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
{95770BEF-6864-493C-A8DA-660D3AC582A0} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
{DB4C8FC0-18A8-4735-933B-D1FCE59FC1E3} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
{A01BAE24-E0E4-458D-A5BA-9C10C4224354} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
{2D1FC26C-C80D-42E8-92BD-25BE517AC663} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
{18EE7297-3E8D-4B94-B6E3-319991927D58} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
{E56BD47C-4997-4831-833C-EA35C83F89B7} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
{35B3DDB4-71EF-4A68-B242-982C71126F3E} = {580CAC8F-38C5-4DEA-AAEA-415F5D08982B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1A24E3C-F7F9-4EB3-8A7F-5C6AB7C2A43D}
Expand Down
6 changes: 1 addition & 5 deletions Source/Meadow.ProjectLab/Meadow.ProjectLab.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@
<PackageId>Meadow.ProjectLab</PackageId>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.ProjectLab</RepositoryUrl>
<PackageTags>Meadow.ProjectLab, Meadow, ProjectLab</PackageTags>
<Version>0.2.0</Version>
<Version>0.92.6</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Base convenience library for the Meadow ProjLab board</Description>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="" />

</ItemGroup>
<ItemGroup>
<PackageReference Include="Meadow.Contracts" Version="0.*" />
<PackageReference Include="Meadow" Version="0.*" />
<PackageReference Include="Meadow.F7" Version="0.*" />
<PackageReference Include="Meadow.Foundation" Version="0.*" />
<PackageReference Include="Meadow.Foundation.Displays.MicroGraphics" Version="0.*" />
<PackageReference Include="Meadow.Foundation.Displays.TftSpi" Version="0.*" />
<PackageReference Include="Meadow.Foundation.ICs.IOExpanders.Mcp23xxx" Version="0.*" />
<PackageReference Include="Meadow.Foundation.Sensors.Atmospheric.Bme68x" Version="0.*" />
Expand Down
58 changes: 9 additions & 49 deletions Source/Meadow.ProjectLab/ProjectLab.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Meadow.Foundation.Audio;
using Meadow.Foundation.Displays;
using Meadow.Foundation.ICs.IOExpanders;
Expand All @@ -10,6 +9,7 @@
using Meadow.Logging;
using Meadow.Modbus;
using Meadow.Units;
using System;

namespace Meadow.Devices
{
Expand Down Expand Up @@ -39,8 +39,6 @@ public ProjectLab()
{
// v2+ stuff
Mcp23008? mcp_1 = null;
Mcp23008? mcp_2 = null;
Mcp23008? mcp_Version = null;

Logger?.Debug("Initializing Project Lab...");

Expand All @@ -52,16 +50,14 @@ public ProjectLab()
throw new Exception(msg);
}

var device = Resolver.Device as IF7FeatherMeadowDevice;

if (device == null)
if (!(Resolver.Device is IF7FeatherMeadowDevice device))
{
var msg = "ProjLab Device must be an F7Feather";
Logger?.Error(msg);
throw new Exception(msg);
}

Logger?.Info("Creating comms busses...");
Logger?.Debug("Creating comms busses...");
var config = new SpiClockConfiguration(
new Frequency(48000, Frequency.UnitType.Kilohertz),
SpiClockConfiguration.Mode.Mode3);
Expand All @@ -72,11 +68,11 @@ public ProjectLab()
device.Pins.CIPO,
config);

Logger?.Info("SPI Bus instantiated");
Logger?.Debug("SPI Bus instantiated");

I2cBus = device.CreateI2cBus();

Logger?.Info("I2C Bus instantiated");
Logger?.Debug("I2C Bus instantiated");

try
{
Expand All @@ -87,58 +83,22 @@ public ProjectLab()

mcp_1 = new Mcp23008(I2cBus, address: 0x20, mcp1_int, mcp_Reset);

Logger?.Info("Mcp_1 up");
}
catch (Exception e)
{
Logger?.Trace($"Failed to create MCP1: {e.Message}, could be a v1 board");
}

IDigitalInputPort? mcp2_int = null;
try
{
if(mcp_1 != null)
{
// MCP the Second
if (device.Pins.D10.Supports<IDigitalChannelInfo>(c => c.InterruptCapable))
{
mcp2_int = device.CreateDigitalInputPort(
device.Pins.D10, InterruptMode.EdgeRising, ResistorMode.InternalPullDown);
}

mcp_2 = new Mcp23008(I2cBus, address: 0x21, mcp2_int);

Logger?.Info("Mcp_2 up");
}
}
catch (Exception e)
{
Logger?.Trace($"Failed to create MCP2: {e.Message}");
mcp2_int?.Dispose();
}

try
{
if (mcp_1 != null)
{
mcp_Version = new Mcp23008(I2cBus, address: 0x27);
Logger?.Info("Mcp_Version up");
}
Logger?.Trace("Mcp_1 up");
}
catch (Exception e)
{
Logger?.Trace($"ERR creating the MCP that has version information: {e.Message}");
Logger?.Debug($"Failed to create MCP1: {e.Message}, could be a v1 board");
}

if (mcp_1 == null)
{
Logger?.Info("Instantiating Project Lab v1 specific hardware");
Logger?.Debug("Instantiating Project Lab v1 specific hardware");
Hardware = new ProjectLabHardwareV1(device, SpiBus, I2cBus);
}
else
{
Logger?.Info("Instantiating Project Lab v2 specific hardware");
Hardware = new ProjectLabHardwareV2(device, SpiBus, I2cBus, mcp_1, mcp_2, mcp_Version);
Hardware = new ProjectLabHardwareV2(device, SpiBus, I2cBus, mcp_1);
}
}

Expand Down
20 changes: 10 additions & 10 deletions Source/Meadow.ProjectLab/ProjectLabHardwareBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ public abstract class ProjectLabHardwareBase : IProjectLabHardware

public ProjectLabHardwareBase(IF7FeatherMeadowDevice device, ISpiBus spiBus, II2cBus i2cBus)
{
this.SpiBus = spiBus;
this.I2cBus = i2cBus;
SpiBus = spiBus;
I2cBus = i2cBus;

//==== Initialize the shared/common stuff
try
{
Logger?.Info("Instantiating light sensor.");
Logger?.Trace("Instantiating light sensor");
LightSensor = new Bh1750(
i2cBus: I2cBus,
measuringMode: Bh1750.MeasuringModes.ContinuouslyHighResolutionMode, // the various modes take differing amounts of time.
lightTransmittance: 0.5, // lower this to increase sensitivity, for instance, if it's behind a semi opaque window
address: (byte)Bh1750.Addresses.Address_0x23);
Logger?.Info("Light sensor up.");
Logger?.Trace("Light sensor up");
}
catch (Exception ex)
{
Expand All @@ -92,9 +92,9 @@ public ProjectLabHardwareBase(IF7FeatherMeadowDevice device, ISpiBus spiBus, II2

try
{
Logger?.Info("Instantiating environmental sensor.");
Logger?.Trace("Instantiating environmental sensor");
EnvironmentalSensor = new Bme688(I2cBus, (byte)Bme688.Addresses.Address_0x76);
Logger?.Info("Environmental sensor up.");
Logger?.Trace("Environmental sensor up");
}
catch (Exception ex)
{
Expand All @@ -103,9 +103,9 @@ public ProjectLabHardwareBase(IF7FeatherMeadowDevice device, ISpiBus spiBus, II2

try
{
Logger?.Info("Instantiating speaker.");
Logger?.Trace("Instantiating speaker");
Speaker = new PiezoSpeaker(device, device.Pins.D11);
Logger?.Info("Speaker up.");
Logger?.Trace("Speaker up");
}
catch (Exception ex)
{
Expand All @@ -114,9 +114,9 @@ public ProjectLabHardwareBase(IF7FeatherMeadowDevice device, ISpiBus spiBus, II2

try
{
Logger?.Info("Instantiating motion sensor.");
Logger?.Trace("Instantiating motion sensor");
MotionSensor = new Bmi270(I2cBus);
Logger?.Info("Motion sensor up.");
Logger?.Trace("Motion sensor up");
}
catch (Exception ex)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/Meadow.ProjectLab/ProjectLabHardwareV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ProjectLabHardwareV1(IF7FeatherMeadowDevice device, ISpiBus spiBus, II2cB
: base(device, spiBus, i2cBus)
{
//---- create our display
Logger?.Info("Instantiating display.");
Logger?.Trace("Instantiating display");
Display = new St7789(
device: device,
spiBus: SpiBus,
Expand All @@ -47,12 +47,12 @@ public ProjectLabHardwareV1(IF7FeatherMeadowDevice device, ISpiBus spiBus, II2cB
colorMode: ColorType.Format16bppRgb565);

//---- buttons
Logger?.Info("Instantiating buttons.");
Logger?.Trace("Instantiating buttons");
LeftButton = GetPushButton(device, device.Pins.D10);
RightButton = GetPushButton(device, device.Pins.D05);
UpButton = GetPushButton(device, device.Pins.D15);
DownButton = GetPushButton(device, device.Pins.D02);
Logger?.Info("Buttons up.");
Logger?.Trace("Buttons up");
}

public override string RevisionString => revision;
Expand Down
Loading

0 comments on commit 33cc89a

Please sign in to comment.