diff --git a/Source/Meadow.Foundation.Core/Sensors/Spatial/IDistanceSensor.cs b/Source/Meadow.Foundation.Core/Sensors/Spatial/IDistanceSensor.cs
deleted file mode 100644
index aac03490dc..0000000000
--- a/Source/Meadow.Foundation.Core/Sensors/Spatial/IDistanceSensor.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-namespace Meadow.Foundation.Sensors.Spatial
-{
- ///
- /// Interface for distance sensors
- ///
- public interface IDistanceSensor
- {
- ///
- /// Distance from sensor to object
- ///
- Units.Length Distance { get; }
- }
-}
diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Analog.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Analog.cs
index 044ea63c88..0259fa5982 100644
--- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Analog.cs
+++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Analog.cs
@@ -44,10 +44,10 @@ void AnalogInitialize()
ChangeResult changeResult = new ChangeResult()
{
New = await ReadSensorAnalog(),
- Old = Length,
+ Old = Distance,
};
// save state
- Length = changeResult.New;
+ Distance = changeResult.New;
// notify
RaiseEventsAndNotify(changeResult);
}
diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Serial.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Serial.cs
index 70e2dec92d..2d66b539f6 100644
--- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Serial.cs
+++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.Serial.cs
@@ -28,7 +28,7 @@ public MaxBotix(ISerialMessagePort serialMessage, SensorType sensor)
Length ReadSensorSerial()
{ //I think we'll just cache it for serial
- return Length.Value;
+ return Distance.Value;
}
private void SerialMessagePort_MessageReceived(object sender, SerialMessageData e)
@@ -53,10 +53,10 @@ private void SerialMessagePort_MessageReceived(object sender, SerialMessageData
ChangeResult changeResult = new ChangeResult()
{
New = new Length(value, units),
- Old = Length,
+ Old = Distance,
};
// save state
- Length = changeResult.New;
+ Distance = changeResult.New;
// notify
RaiseEventsAndNotify(changeResult);
}
diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.cs
index 7a644c87ea..7512c8234c 100644
--- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.cs
+++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Driver/MaxBotix.cs
@@ -1,28 +1,29 @@
-using Meadow.Units;
+using Meadow.Peripherals.Sensors;
+using Meadow.Units;
using System;
using System.Threading.Tasks;
namespace Meadow.Foundation.Sensors.Distance
{
- public partial class MaxBotix : ByteCommsSensorBase
+ public partial class MaxBotix : ByteCommsSensorBase, IRangeFinder
{
///
/// Raised when the value of the reading changes.
///
- public event EventHandler> LengthUpdated = delegate { };
+ public event EventHandler> DistanceUpdated = delegate { };
///
/// Distance from sensor to object
///
- public Length? Length { get; protected set; }
+ public Length? Distance { get; protected set; }
///
/// voltage common collector (VCC) typically 3.3V
///
public double VCC { get; set; } = 3.3;
- CommunicationType communication;
- SensorType sensorType;
+ readonly CommunicationType communication;
+ readonly SensorType sensorType;
///
/// Read the distance from the sensor
@@ -46,7 +47,7 @@ protected override async Task ReadSensor()
///
protected override void RaiseEventsAndNotify(IChangeResult changeResult)
{
- LengthUpdated?.Invoke(this, changeResult);
+ DistanceUpdated?.Invoke(this, changeResult);
base.RaiseEventsAndNotify(changeResult);
}
diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Samples/MaxBotix_Sample/MeadowApp.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Samples/MaxBotix_Sample/MeadowApp.cs
index 79b62e1bfe..930bfd6a10 100644
--- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Samples/MaxBotix_Sample/MeadowApp.cs
+++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.MaxBotix/Samples/MaxBotix_Sample/MeadowApp.cs
@@ -46,12 +46,12 @@ public MeadowApp()
maxBotix.Subscribe(consumer);
- maxBotix.LengthUpdated += MaxBotix_LengthUpdated;
+ maxBotix.DistanceUpdated += MaxBotix_DistanceUpdated;
maxBotix.StartUpdating(new TimeSpan(0, 0, 1));
}
- private void MaxBotix_LengthUpdated(object sender, IChangeResult e)
+ private void MaxBotix_DistanceUpdated(object sender, IChangeResult e)
{
Console.WriteLine($"Length: {e.New.Centimeters}cm");
}
diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Mb10x0/Driver/Mb10x0.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Mb10x0/Driver/Mb10x0.cs
index 50f50f5bd1..e06862b580 100644
--- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Mb10x0/Driver/Mb10x0.cs
+++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Mb10x0/Driver/Mb10x0.cs
@@ -7,7 +7,7 @@
namespace Meadow.Foundation.Sensors.Distance
{
- // TODO: why is `DistanceUpdated` never invoked? is this sensor done?
+ // In progress and not working - DistanceUpdated currently is never called
public class Mb10x0 : SensorBase, IRangeFinder
{
//==== events
diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Sfsr02/Driver/Sfsr02.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Sfsr02/Driver/Sfsr02.cs
index 4e5d108a12..004453b08e 100644
--- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Sfsr02/Driver/Sfsr02.cs
+++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Sfsr02/Driver/Sfsr02.cs
@@ -12,22 +12,21 @@ namespace Meadow.Foundation.Sensors.Distance
///
public class Sfsr02: SensorBase, IRangeFinder
{
- //==== events
///
/// Raised when an received a rebound trigger signal
///
public event EventHandler> DistanceUpdated;
- //==== internals
///
/// Trigger/Echo Pin
///
protected IBiDirectionalPort triggerEchoPort;
+ ///
+ /// Start time
+ ///
protected long tickStart;
-
- //==== properties
///
/// Returns current distance
///
diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Vl53l0x/Driver/Vl53l0x.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Vl53l0x/Driver/Vl53l0x.cs
index 280326ccae..e579e479be 100644
--- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Vl53l0x/Driver/Vl53l0x.cs
+++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Vl53l0x/Driver/Vl53l0x.cs
@@ -12,8 +12,14 @@ namespace Meadow.Foundation.Sensors.Distance
///
public partial class Vl53l0x : ByteCommsSensorBase, IRangeFinder
{
+ ///
+ /// Distance updated event
+ ///
public event EventHandler> DistanceUpdated = delegate { };
+ ///
+ /// Is the hardware shutdown / off
+ ///
public bool IsShutdown
{
get
@@ -48,6 +54,12 @@ public bool IsShutdown
byte stopVariable;
+ ///
+ /// Creates a new Vl53l0x object
+ ///
+ /// Meadow device
+ /// I2C bus
+ /// I2C address
public Vl53l0x(
IDigitalOutputController device, II2cBus i2cBus,
byte address = (byte)Addresses.Default)
@@ -55,9 +67,14 @@ public Vl53l0x(
{
}
+ ///
+ /// Creates a new Vl53l0x object
+ ///
+ /// Meadow device
/// I2C bus
+ /// Shutdown pin
/// VL53L0X address
- /// Unit of measure
+
public Vl53l0x(
IDigitalOutputController device, II2cBus i2cBus, IPin shutdownPin,
byte address = (byte)Addresses.Default)
@@ -69,6 +86,10 @@ public Vl53l0x(
Initialize().Wait();
}
+ ///
+ /// Raise distance change event and notify subscribers
+ ///
+ ///
protected override void RaiseEventsAndNotify(IChangeResult changeResult)
{
DistanceUpdated?.Invoke(this, changeResult);
@@ -101,8 +122,6 @@ protected async Task Initialize()
Peripheral.WriteRegister(0xFF, 0x00);
Peripheral.WriteRegister(0x80, 0x00);
- //var configControl = (byte)(Read((byte)Register.MsrcConfigControl) | 0x12);
-
Peripheral.WriteRegister((byte)Register.SystemSequenceConfig, 0xFF);
var spadInfo = GetSpadInfo();
int spadCount = spadInfo.Item1;