-
Notifications
You must be signed in to change notification settings - Fork 4
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
d66b5b3
commit 6e9994a
Showing
8 changed files
with
265 additions
and
129 deletions.
There are no files selected for viewing
Binary file not shown.
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,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}"); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -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}"); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.