Skip to content

Commit

Permalink
V2 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Oct 17, 2023
1 parent d66b5b3 commit 6e9994a
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 129 deletions.
Binary file added Hardware/Design Files/Schematic_v2.b.pdf
Binary file not shown.
39 changes: 35 additions & 4 deletions Source/GnssTracker/GnssTracker.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Meadow.Logging;
using Meadow;
using Meadow;
using Meadow.Hardware;
using Meadow.Logging;
using System;

namespace WildernessLabs.Hardware.GnssTracker
Expand All @@ -14,8 +15,11 @@ private GnssTracker() { }
public static IGnssTrackerHardware Create()
{
IGnssTrackerHardware hardware;

Logger? logger = Resolver.Log;

II2cBus i2cBus;

logger?.Debug("Initializing GnssTracker...");

var device = Resolver.Device;
Expand All @@ -27,10 +31,37 @@ public static IGnssTrackerHardware Create()
throw new Exception(msg);
}

try
{
logger?.Debug("Initializing I2CBus");

i2cBus = Resolver.Device.CreateI2cBus();

logger?.Debug("Initializing I2CBus initialized");
}
catch (Exception e)
{
logger?.Error($"Err initializing I2CBus: {e.Message}");
throw;
}


if (device is IF7CoreComputeMeadowDevice { } ccm)
{
logger?.Info("Instantiating GnssTracker v1 hardware");
hardware = new GnssTrackerHardwareV1(ccm);
try
{
i2cBus.Write(0x68, new byte[] { 0 });
logger?.Info("Instantiating GnssTracker v2 hardware");
hardware = new GnssTrackerHardwareV2(ccm, i2cBus);
}
catch
{
logger?.Info("Instantiating GnssTracker v1 hardware");
hardware = new GnssTrackerHardwareV1(ccm, i2cBus);
}



}
else
{
Expand Down
4 changes: 3 additions & 1 deletion Source/GnssTracker/GnssTracker.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Meadow.Sdk/1.1.0">
<Project Sdk="Meadow.Sdk/1.1.0">
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>icon.png</PackageIcon>
Expand Down Expand Up @@ -26,6 +26,8 @@
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Core\Meadow.Foundation.Core.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Displays.ePaper\Driver\Displays.ePaper.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Atmospheric.Bme68x\Driver\Sensors.Atmospheric.Bme68x.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Environmental.Scd4x\Driver\Sensors.Environmental.Scd4x.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Gnss.NeoM8\Driver\Sensors.Gnss.NeoM8.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Motion.Bmi270\Driver\Sensors.Motion.Bmi270.csproj" />
</ItemGroup>
</Project>
137 changes: 137 additions & 0 deletions Source/GnssTracker/GnssTrackerHardareBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using Meadow;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;
using Meadow.Foundation.Leds;
using Meadow.Foundation.Sensors.Accelerometers;
using Meadow.Foundation.Sensors.Atmospheric;
using Meadow.Foundation.Sensors.Environmental;
using Meadow.Foundation.Sensors.Gnss;
using Meadow.Hardware;
using Meadow.Logging;
using Meadow.Units;
using System;

namespace WildernessLabs.Hardware.GnssTracker
{
/// <summary>
/// Represents a Gnss Tracker Hardware base class
/// </summary>
public abstract class GnssTrackerHardwareBase : IGnssTrackerHardware
{
/// <inheritdoc/>
protected Logger Log = Resolver.Log;

/// <inheritdoc/>
public II2cBus? I2cBus { get; protected set; }

/// <inheritdoc/>
public ISpiBus? SpiBus { get; protected set; }

/// <inheritdoc/>
public PwmLed? OnboardLed { get; protected set; }

/// <inheritdoc/>
public Bme688? AtmosphericSensor { get; protected set; }

/// <inheritdoc/>
public NeoM8? Gnss { get; protected set; }

/// <inheritdoc/>
public abstract Scd40? EnvironmentalSensor { get; protected set; }

/// <inheritdoc/>
public abstract Bmi270? MotionSensor { get; protected set; }

/// <inheritdoc/>
public IGraphicsDisplay? Display { get; protected set; }

/// <inheritdoc/>
public IAnalogInputPort? SolarVoltageInput { get; protected set; }

/// <summary>
/// Create a new GnssTrackerHardware base object
/// </summary>
/// <param name="device"></param>
public GnssTrackerHardwareBase(IF7CoreComputeMeadowDevice device, II2cBus i2cBus)
{
Log.Debug("Initialize hardware...");
I2cBus = i2cBus;

try
{
Log.Debug("Initializing Onboard LED");

OnboardLed = new PwmLed(device.Pins.D20, TypicalForwardVoltage.Green);

Log.Debug("Onboard LED initialized");
}
catch (Exception e)
{
Log.Error($"Err initializing onboard LED: {e.Message}");
}

try
{
Log.Debug("Initializing BME688");

AtmosphericSensor = new Bme688(I2cBus, (byte)Bme688.Addresses.Address_0x76);

Log.Debug("BME688 initialized");
}
catch (Exception e)
{
Log.Error($"Err initializing BME688: {e.Message}");
}

try
{
Resolver.Log.Debug("Initializing GNSS");

Gnss = new NeoM8(device, device.PlatformOS.GetSerialPortName("COM4"), device.Pins.D09, device.Pins.D11);

Resolver.Log.Debug("GNSS initialized");
}
catch (Exception e)
{
Resolver.Log.Error($"Err initializing GNSS: {e.Message}");
}

try
{
Resolver.Log.Debug("Initializing ePaper Display");

var config = new SpiClockConfiguration(new Frequency(48000, Frequency.UnitType.Kilohertz), SpiClockConfiguration.Mode.Mode0);
SpiBus = device.CreateSpiBus(
device.Pins.SCK,
device.Pins.COPI,
device.Pins.CIPO,
config);
Display = new Ssd1680(
spiBus: SpiBus,
chipSelectPin: device.Pins.D02,
dcPin: device.Pins.D03,
resetPin: device.Pins.D04,
busyPin: device.Pins.D05,
width: 122,
height: 250);

Resolver.Log.Debug("ePaper Display initialized");
}
catch (Exception e)
{
Resolver.Log.Error($"Err initializing ePaper Display: {e.Message}");
}

try
{
Resolver.Log.Debug("Instantiating Solar Voltage Input");
SolarVoltageInput = device.Pins.A00.CreateAnalogInputPort(5);
Resolver.Log.Debug("Solar Voltage Input up");
}
catch (Exception ex)
{
Resolver.Log.Error($"Unabled to create the Switching Anemometer: {ex.Message}");
}
}
}
}
134 changes: 10 additions & 124 deletions Source/GnssTracker/GnssTrackerHardwareV1.cs
Original file line number Diff line number Diff line change
@@ -1,142 +1,28 @@
using Meadow;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;
using Meadow.Foundation.Leds;
using Meadow.Foundation.Sensors.Atmospheric;
using Meadow.Foundation.Sensors.Gnss;
using Meadow.Foundation.Sensors.Accelerometers;
using Meadow.Foundation.Sensors.Environmental;
using Meadow.Hardware;
using Meadow.Logging;
using Meadow.Units;
using System;

namespace WildernessLabs.Hardware.GnssTracker
{
/// <summary>
/// Represents a Gnss Tracker Hardware V1
/// </summary>
public class GnssTrackerHardwareV1 : IGnssTrackerHardware
public class GnssTrackerHardwareV1 : GnssTrackerHardwareBase
{
protected Logger Log = Resolver.Log;
/// <inheritdoc/>
public override Scd40? EnvironmentalSensor { get => throw new System.NotImplementedException(); protected set => throw new System.NotImplementedException(); }

/// <summary>
/// Gets the I2C Bus
/// </summary>
public II2cBus? I2cBus { get; protected set; }

/// <summary>
/// Gets the SPI Bus
/// </summary>
public ISpiBus? SpiBus { get; protected set; }

/// <summary>
/// Gets the PWM LED
/// </summary>
public PwmLed? OnboardLed { get; protected set; }

/// <summary>
/// Gets the BME688 atmospheric sensor
/// </summary>
public Bme688? AtmosphericSensor { get; protected set; }

/// <summary>
/// The Neo GNSS sensor
/// </summary>
public NeoM8? Gnss { get; protected set; }

/// <summary>
/// Gets the e-paper display
/// </summary>
public IGraphicsDisplay? Display { get; protected set; }

/// <summary>
/// Gets the Solar Voltage Input
/// </summary>
public IAnalogInputPort? SolarVoltageInput { get; protected set; }
/// <inheritdoc/>
public override Bmi270? MotionSensor { get => throw new System.NotImplementedException(); protected set => throw new System.NotImplementedException(); }

/// <summary>
/// Create a new GnssTrackerHardwareV1 object
/// </summary>
/// <param name="device"></param>
public GnssTrackerHardwareV1(IF7CoreComputeMeadowDevice device)
/// <param name="device">The Meadow device</param>
/// <param name="i2cBus">The I2C bus</param>
public GnssTrackerHardwareV1(IF7CoreComputeMeadowDevice device, II2cBus i2cBus) : base(device, i2cBus)
{
Log.Debug("Initialize hardware...");

try
{
Log.Debug("Initializing Onboard LED");

OnboardLed = new PwmLed(device.Pins.D20, TypicalForwardVoltage.Green);

Log.Debug("Onboard LED initialized");
}
catch (Exception e)
{
Log.Error($"Err initializing onboard LED: {e.Message}");
}

try
{
Log.Debug("Initializing BME688");

I2cBus = device.CreateI2cBus();
AtmosphericSensor = new Bme688(I2cBus, (byte)Bme688.Addresses.Address_0x76);

Log.Debug("BME688 initialized");
}
catch (Exception e)
{
Log.Error($"Err initializing BME688: {e.Message}");
}

try
{
Resolver.Log.Debug("Initializing GNSS");

Gnss = new NeoM8(device, device.PlatformOS.GetSerialPortName("COM4"), device.Pins.D09, device.Pins.D11);

Resolver.Log.Debug("GNSS initialized");
}
catch (Exception e)
{
Resolver.Log.Error($"Err initializing GNSS: {e.Message}");
}

try
{
Resolver.Log.Debug("Initializing ePaper Display");

var config = new SpiClockConfiguration(new Frequency(48000, Frequency.UnitType.Kilohertz), SpiClockConfiguration.Mode.Mode0);
SpiBus = device.CreateSpiBus(
device.Pins.SCK,
device.Pins.COPI,
device.Pins.CIPO,
config);
Display = new Ssd1680(
spiBus: SpiBus,
chipSelectPin: device.Pins.D02,
dcPin: device.Pins.D03,
resetPin: device.Pins.D04,
busyPin: device.Pins.D05,
width: 122,
height: 250);

Resolver.Log.Debug("ePaper Display initialized");
}
catch (Exception e)
{
Resolver.Log.Error($"Err initializing ePaper Display: {e.Message}");
}

try
{
Resolver.Log.Debug("Instantiating Solar Voltage Input");
SolarVoltageInput = device.Pins.A00.CreateAnalogInputPort(5);
Resolver.Log.Debug("Solar Voltage Input up");
}
catch (Exception ex)
{
Resolver.Log.Error($"Unabled to create the Switching Anemometer: {ex.Message}");
}
}
}
}
Loading

0 comments on commit 6e9994a

Please sign in to comment.