diff --git a/Source/Meadow.Foundation.Core.Samples/Sensors.Light.AnalogLightSensor_Sample/MeadowApp.cs b/Source/Meadow.Foundation.Core.Samples/Sensors.Light.AnalogLightSensor_Sample/MeadowApp.cs index 0c9e659ba6..94fc8510e8 100644 --- a/Source/Meadow.Foundation.Core.Samples/Sensors.Light.AnalogLightSensor_Sample/MeadowApp.cs +++ b/Source/Meadow.Foundation.Core.Samples/Sensors.Light.AnalogLightSensor_Sample/MeadowApp.cs @@ -54,7 +54,7 @@ public override Task Initialize() protected async Task ReadIlluminance() { var illuminance = await analogLightSensor.Read(); - Console.WriteLine($"Initial lux: {illuminance.Lux:N2} lux"); + Console.WriteLine($"Initial lux: {illuminance.Value.Lux:N2} lux"); } // diff --git a/Source/Meadow.Foundation.Core.Samples/Sensors.Temperature.AnalogTemperature_Sample/MeadowApp.cs b/Source/Meadow.Foundation.Core.Samples/Sensors.Temperature.AnalogTemperature_Sample/MeadowApp.cs index 03ce2d7546..fc136d4186 100644 --- a/Source/Meadow.Foundation.Core.Samples/Sensors.Temperature.AnalogTemperature_Sample/MeadowApp.cs +++ b/Source/Meadow.Foundation.Core.Samples/Sensors.Temperature.AnalogTemperature_Sample/MeadowApp.cs @@ -57,7 +57,7 @@ public override Task Initialize() protected async Task ReadTemp() { var temperature = await analogTemperature.Read(); - Console.WriteLine($"Initial temp: {temperature.Celsius:N2}C"); + Console.WriteLine($"Initial temp: {temperature.Value.Celsius:N2}C"); } // diff --git a/Source/Meadow.Foundation.Core/SamplingSensorBase.cs b/Source/Meadow.Foundation.Core/SamplingSensorBase.cs index e971991d42..9ab2a4065d 100644 --- a/Source/Meadow.Foundation.Core/SamplingSensorBase.cs +++ b/Source/Meadow.Foundation.Core/SamplingSensorBase.cs @@ -1,5 +1,5 @@ -using System; -using System.Collections.Generic; +using Meadow.Peripherals.Sensors; +using System; using System.Threading; using System.Threading.Tasks; @@ -10,7 +10,7 @@ namespace Meadow.Foundation /// /// public abstract class SamplingSensorBase - : SensorBase + : SensorBase, ISamplingSensor where UNIT : struct { /// diff --git a/Source/Meadow.Foundation.Core/SensorBase.cs b/Source/Meadow.Foundation.Core/SensorBase.cs index 2203e8e969..74974fa539 100644 --- a/Source/Meadow.Foundation.Core/SensorBase.cs +++ b/Source/Meadow.Foundation.Core/SensorBase.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; diff --git a/Source/Meadow.Foundation.Core/Sensors/Light/AnalogLightSensor.cs b/Source/Meadow.Foundation.Core/Sensors/Light/AnalogLightSensor.cs index 0aa444fcc5..964f958b67 100644 --- a/Source/Meadow.Foundation.Core/Sensors/Light/AnalogLightSensor.cs +++ b/Source/Meadow.Foundation.Core/Sensors/Light/AnalogLightSensor.cs @@ -92,21 +92,22 @@ public AnalogLightSensor(IAnalogInputPort analogInputPort, ) ); } - + + /// + /// Convenience method to get the current sensor readings. For frequent reads, use + /// StartSampling() and StopSampling() in conjunction with the SampleBuffer. + /// + public async Task Read() + => new Illuminance?(await ReadSensor()); + /// /// Convenience method to get the current luminance. For frequent reads, use /// StartSampling() and StopSampling() in conjunction with the SampleBuffer. /// protected override async Task ReadSensor() { - // read the voltage Voltage voltage = await AnalogInputPort.Read(); - - // convert and save to our temp property for later retreival - illuminance = VoltageToLuminance(voltage); - - // return - return illuminance; + return illuminance = VoltageToLuminance(voltage); } /// diff --git a/Source/Meadow.Foundation.Core/Sensors/Temperature/AnalogTemperature.cs b/Source/Meadow.Foundation.Core/Sensors/Temperature/AnalogTemperature.cs index 6bd2eb2dbc..e5af2e39e7 100644 --- a/Source/Meadow.Foundation.Core/Sensors/Temperature/AnalogTemperature.cs +++ b/Source/Meadow.Foundation.Core/Sensors/Temperature/AnalogTemperature.cs @@ -198,6 +198,13 @@ public AnalogTemperature(IAnalogInputPort analogInputPort, ); } + /// + /// Convenience method to get the current sensor readings. For frequent reads, use + /// StartSampling() and StopSampling() in conjunction with the SampleBuffer. + /// + public async Task Read() + => new Units.Temperature?(await ReadSensor()); + /// /// Convenience method to get the current temperature. For frequent reads, use /// StartSampling() and StopSampling() in conjunction with the SampleBuffer. diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.AdafruitMPRLS/Driver/AdafruitMPRLS.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.AdafruitMPRLS/Driver/AdafruitMPRLS.cs index 4ed58b11a1..cba00fa71d 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.AdafruitMPRLS/Driver/AdafruitMPRLS.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.AdafruitMPRLS/Driver/AdafruitMPRLS.cs @@ -135,5 +135,8 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Pressure? Pressure, return conditions; }); } + + async Task ISamplingSensor.Read() + => (await ReadSensor()).Pressure.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme280/Driver/Bme280.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme280/Driver/Bme280.cs index 4df3fcd993..4bd3d41553 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme280/Driver/Bme280.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme280/Driver/Bme280.cs @@ -439,5 +439,14 @@ public override void StartUpdating(TimeSpan? updateInterval = null) base.StartUpdating(updateInterval); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Pressure.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme68x/Driver/Bme68x.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme68x/Driver/Bme68x.cs index 57179f151c..5e98814642 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme68x/Driver/Bme68x.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme68x/Driver/Bme68x.cs @@ -582,5 +582,14 @@ byte CalculateHeaterDuration(TimeSpan duration) } return durationValue; } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Pressure.Value; } } diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp085/Driver/Bmp085.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp085/Driver/Bmp085.cs index 4ddc146595..20003ae62f 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp085/Driver/Bmp085.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp085/Driver/Bmp085.cs @@ -224,5 +224,11 @@ private short ReadShort(byte address) return (short)((ReadBuffer.Span[0] << 8) | ReadBuffer.Span[1]); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Pressure.Value; } } diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp180/Driver/Bmp180.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp180/Driver/Bmp180.cs index 5f35b299c0..c137940f91 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp180/Driver/Bmp180.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bmp180/Driver/Bmp180.cs @@ -231,5 +231,11 @@ private short ReadShort(byte address) return (short)((ReadBuffer.Span[0] << 8) | ReadBuffer.Span[1]); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Pressure.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ccs811/Driver/Ccs811.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ccs811/Driver/Ccs811.cs index b38723ab25..fb5e972796 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ccs811/Driver/Ccs811.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ccs811/Driver/Ccs811.cs @@ -185,5 +185,8 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Concentration? Co2, base.RaiseEventsAndNotify(changeResult); } + + async Task ISamplingSensor.Read() + => (await Read()).Voc.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Dhtxx/Driver/DhtBase.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Dhtxx/Driver/DhtBase.cs index 10e96e0b91..19874693d9 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Dhtxx/Driver/DhtBase.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Dhtxx/Driver/DhtBase.cs @@ -149,5 +149,11 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T return Task.FromResult(conditions); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Hih6130/Driver/Hih6130.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Hih6130/Driver/Hih6130.cs index 77121b644b..db5d60f66e 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Hih6130/Driver/Hih6130.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Hih6130/Driver/Hih6130.cs @@ -94,5 +94,11 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T return conditions; } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Htu2xd/Driver/Htux1dBase.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Htu2xd/Driver/Htux1dBase.cs index 213beb4091..fb8c716802 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Htu2xd/Driver/Htux1dBase.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Htu2xd/Driver/Htux1dBase.cs @@ -2,6 +2,7 @@ using Meadow.Peripherals.Sensors; using Meadow.Units; using System; +using System.Threading.Tasks; namespace Meadow.Foundation.Sensors.Atmospheric { @@ -24,7 +25,7 @@ public enum Addresses : byte /// Abstract HTDx1D base class for HTU21D and HTU31D /// public abstract class Htux1dBase : - ByteCommsSensorBase<(Meadow.Units.Temperature? Temperature, RelativeHumidity? Humidity)>, + ByteCommsSensorBase<(Units.Temperature? Temperature, RelativeHumidity? Humidity)>, ITemperatureSensor, IHumiditySensor { /// @@ -84,5 +85,11 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T } base.RaiseEventsAndNotify(changeResult); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl115A2/Driver/Mpl115a2.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl115A2/Driver/Mpl115a2.cs index 70b230550a..747d54c59b 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl115A2/Driver/Mpl115a2.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl115A2/Driver/Mpl115a2.cs @@ -163,5 +163,11 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T return conditions; }); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Pressure.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl3115a2/Driver/Mpl3115a2.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl3115a2/Driver/Mpl3115a2.cs index aadc953631..7f6d16cf50 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl3115a2/Driver/Mpl3115a2.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Mpl3115a2/Driver/Mpl3115a2.cs @@ -211,5 +211,11 @@ public void Reset() data |= 0x04; Peripheral?.WriteRegister(Registers.Control1, data); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Pressure.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ms5611/Driver/Ms5611.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ms5611/Driver/Ms5611.cs index ec7c29515e..2070dec308 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ms5611/Driver/Ms5611.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Ms5611/Driver/Ms5611.cs @@ -131,5 +131,11 @@ int ReadPressure() return result; } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Pressure.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht31D/Driver/Sht31d.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht31D/Driver/Sht31d.cs index 694c958385..3e153ade28 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht31D/Driver/Sht31d.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht31D/Driver/Sht31d.cs @@ -84,5 +84,11 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T return Task.FromResult<(Units.Temperature? Temperature, RelativeHumidity? Humidity)>(conditions); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht4x/Driver/Sht4x.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht4x/Driver/Sht4x.cs index 1b8f6efad7..17bebe93c2 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht4x/Driver/Sht4x.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Sht4x/Driver/Sht4x.cs @@ -127,5 +127,11 @@ protected int GetDelayForPrecision(Precision precision) return conditions; }); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Si70xx/Driver/Si70xx.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Si70xx/Driver/Si70xx.cs index 371f92b509..6f0ae05603 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Si70xx/Driver/Si70xx.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Si70xx/Driver/Si70xx.cs @@ -214,5 +214,11 @@ void SetResolution(SensorResolution resolution) //Request a write to user register Peripheral?.WriteRegister((byte)Register.USER_REG_1, register); //Write the new resolution bits } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Th02/Driver/Th02.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Th02/Driver/Th02.cs index b618f3a031..bbabab701c 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Th02/Driver/Th02.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Th02/Driver/Th02.cs @@ -106,5 +106,11 @@ protected override void RaiseEventsAndNotify(IChangeResult<(Units.Temperature? T return conditions; }); } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Humidity.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hcsr04/Driver/Hcsr04.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hcsr04/Driver/Hcsr04.cs index c22ab50b01..527937b018 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hcsr04/Driver/Hcsr04.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hcsr04/Driver/Hcsr04.cs @@ -8,7 +8,7 @@ namespace Meadow.Foundation.Sensors.Distance { /// - /// HCSR04 Distance Sensor + /// HCSR04 Distance Sensor - driver not complete /// public class Hcsr04 : SensorBase, IRangeFinder { @@ -142,5 +142,16 @@ protected override void RaiseEventsAndNotify(IChangeResult changeResult) DistanceUpdated?.Invoke(this, changeResult); base.RaiseEventsAndNotify(changeResult); } + + public void StartUpdating(TimeSpan? updateInterval = null) + { + //ToDo + throw new NotImplementedException(); + } + + public void StopUpdating() + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hysrf05/Driver/Hysrf05.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hysrf05/Driver/Hysrf05.cs index 3a9dfefb8a..b670b629f1 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hysrf05/Driver/Hysrf05.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Hysrf05/Driver/Hysrf05.cs @@ -8,7 +8,7 @@ namespace Meadow.Foundation.Sensors.Distance { /// - /// HYSRF05 Distance Sensor + /// HYSRF05 Distance Sensor- driver not complete /// public class Hysrf05: SensorBase, IRangeFinder { @@ -140,5 +140,16 @@ protected override void RaiseEventsAndNotify(IChangeResult changeResult) DistanceUpdated?.Invoke(this, changeResult); base.RaiseEventsAndNotify(changeResult); } + + public void StartUpdating(TimeSpan? updateInterval = null) + { + //ToDo + throw new NotImplementedException(); + } + + public void StopUpdating() + { + throw new NotImplementedException(); + } } } \ No newline at end of file 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 e61eaf20df..2e8f22cfec 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Sfsr02/Driver/Sfsr02.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Distance.Sfsr02/Driver/Sfsr02.cs @@ -8,7 +8,7 @@ namespace Meadow.Foundation.Sensors.Distance { /// - /// Sfsr02 Distance Sensor + /// Sfsr02 Distance Sensor- driver not complete /// public class Sfsr02: SensorBase, IRangeFinder { @@ -136,5 +136,16 @@ protected override void RaiseEventsAndNotify(IChangeResult changeResult) DistanceUpdated?.Invoke(this, changeResult); base.RaiseEventsAndNotify(changeResult); } + + public void StartUpdating(TimeSpan? updateInterval = null) + { + //ToDo + throw new NotImplementedException(); + } + + public void StopUpdating() + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Light.AnalogSolarGauge/Driver/AnalogSolarGauge.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Light.AnalogSolarGauge/Driver/AnalogSolarGauge.cs index 16c0956c85..ad31edfc94 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Light.AnalogSolarGauge/Driver/AnalogSolarGauge.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Light.AnalogSolarGauge/Driver/AnalogSolarGauge.cs @@ -12,7 +12,7 @@ namespace Meadow.Foundation.Sensors.Light /// Driver to measure solar panel input /// public class AnalogSolarGauge : SensorBase, - ISolarIntensityGauge, ISensor + ISolarIntensityGauge { /// /// Raised when the solar intensity changes diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Light.Bh1745/Driver/Bh1745.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Light.Bh1745/Driver/Bh1745.cs index 9edc29957c..42ad1668f9 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Light.Bh1745/Driver/Bh1745.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Light.Bh1745/Driver/Bh1745.cs @@ -1,4 +1,5 @@ using Meadow.Hardware; +using Meadow.Peripherals.Sensors; using Meadow.Peripherals.Sensors.Light; using Meadow.Units; using System; @@ -369,5 +370,7 @@ protected bool ReadMeasurementIsValid() /// protected ushort ReadClearDataRegister() => Peripheral.ReadRegisterAsUShort(Registers.CLEAR_DATA); + async Task ISamplingSensor.Read() + => (await Read()).AmbientLight.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tcs3472x/Driver/Tcs3472x.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tcs3472x/Driver/Tcs3472x.cs index 960de0176f..d471680d0f 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tcs3472x/Driver/Tcs3472x.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tcs3472x/Driver/Tcs3472x.cs @@ -2,6 +2,7 @@ using System.Threading; using System.Threading.Tasks; using Meadow.Hardware; +using Meadow.Peripherals.Sensors; using Meadow.Peripherals.Sensors.Light; using Meadow.Units; @@ -254,10 +255,12 @@ protected bool IsValidData() return ((Registers)(status & (byte)Registers.STATUS_AVALID) == Registers.STATUS_AVALID); } - ushort I2cRead16(Registers reg) { return Peripheral.ReadRegisterAsUShort((byte)(Registers.COMMAND_BIT | reg), ByteOrder.BigEndian); } + + async Task ISamplingSensor.Read() + => (await Read()).AmbientLight.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tsl2591/Driver/Tsl2591.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tsl2591/Driver/Tsl2591.cs index 2468f801af..963a740deb 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tsl2591/Driver/Tsl2591.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Light.Tsl2591/Driver/Tsl2591.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Meadow.Hardware; +using Meadow.Peripherals.Sensors; using Meadow.Peripherals.Sensors.Light; using Meadow.Units; using IU = Meadow.Units.Illuminance.UnitType; @@ -14,8 +15,7 @@ namespace Meadow.Foundation.Sensors.Light /// public partial class Tsl2591 : ByteCommsSensorBase<(Illuminance? FullSpectrum, Illuminance? Infrared, Illuminance? VisibleLight, Illuminance? Integrated)>, - ILightSensor, - IDisposable + ILightSensor, IDisposable { /// /// Raised when Full Spectrum Illuminance value changes @@ -250,5 +250,8 @@ private double GainMultiplier(GainFactor gain) } return g; } + + async Task ISamplingSensor.Read() + => (await Read()).FullSpectrum.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Capacitive/Driver/Capacitive.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Capacitive/Driver/Capacitive.cs index 613c966f24..64c3a862f1 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Capacitive/Driver/Capacitive.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Capacitive/Driver/Capacitive.cs @@ -95,7 +95,7 @@ protected override async Task ReadSensor() /// /// Starts continuously sampling the sensor /// - public void StartUpdating(TimeSpan updateInterval) + public void StartUpdating(TimeSpan? updateInterval) { AnalogInputPort.StartUpdating(updateInterval); } diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Driver/Fc28.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Driver/Fc28.cs index b137f069ae..b4a47c0529 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Driver/Fc28.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Driver/Fc28.cs @@ -107,8 +107,10 @@ protected override async Task ReadSensor() /// /// Starts continuously sampling the sensor /// - public void StartUpdating() + public void StartUpdating(TimeSpan? updateInterval) { + UpdateInterval = updateInterval.Value; + lock (samplingLock) { if (IsSampling) { return; } diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Samples/Fc28_Sample/MeadowApp.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Samples/Fc28_Sample/MeadowApp.cs index 9488ea956a..da1e78752d 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Samples/Fc28_Sample/MeadowApp.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Moisture.Fc28/Samples/Fc28_Sample/MeadowApp.cs @@ -50,7 +50,7 @@ public async override Task Run() var moisture = await fc28.Read(); Console.WriteLine($"Moisture Value { moisture}"); - fc28.StartUpdating(); + fc28.StartUpdating(TimeSpan.FromMilliseconds(5000)); } // diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Adxl3xxBase.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Adxl3xxBase.cs index 52b5c0f11c..965774b40f 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Adxl3xxBase.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Adxl3xxBase.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Meadow.Foundation.Spatial; using Meadow.Hardware; +using Meadow.Peripherals.Sensors; using Meadow.Peripherals.Sensors.Motion; using Meadow.Units; diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Drivers/Adxl362.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Drivers/Adxl362.cs index 4cb94b3e82..567ba3e5f9 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Drivers/Adxl362.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Adxl3xx/Driver/Drivers/Adxl362.cs @@ -556,5 +556,11 @@ private void DisplayRegisters() DebugInformation.DisplayRegisters(Registers.X_AXIS_8BITS, ReadBuffer.Span[2..].ToArray()); } + + async Task ISamplingSensor.Read() + => (await Read()).Acceleration3D.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Bno055/Driver/Bno055.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Bno055/Driver/Bno055.cs index 63845d585f..31a164a35d 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Bno055/Driver/Bno055.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Bno055/Driver/Bno055.cs @@ -463,5 +463,14 @@ public void DisplayRegisters() Console.WriteLine("== /REGISTERS ======================================================================="); } + + async Task ISamplingSensor.Read() + => (await Read()).AngularVelocity3D.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Acceleration3D.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mag3110/Driver/Mag3110.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mag3110/Driver/Mag3110.cs index e9b9617d73..69b0e6192c 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mag3110/Driver/Mag3110.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mag3110/Driver/Mag3110.cs @@ -1,5 +1,6 @@ using Meadow.Hardware; using Meadow.Peripherals.Sensors; +using Meadow.Peripherals.Sensors.Motion; using Meadow.Units; using System; using System.Threading.Tasks; @@ -17,7 +18,7 @@ namespace Meadow.Foundation.Sensors.Motion /// public partial class Mag3110 : ByteCommsSensorBase<(MagneticField3D? MagneticField3D, Units.Temperature? Temperature)>, - ITemperatureSensor + ITemperatureSensor, IMagetometer { /// /// Raised when the magnetic field value changes @@ -218,5 +219,11 @@ private void DigitalInputPortChanged(object sender, DigitalPortResult e) OnReadingComplete(readings); }*/ } + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + + async Task ISamplingSensor.Read() + => (await Read()).MagneticField3D.Value; } } \ No newline at end of file diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mpu6050/Driver/Mpu6050.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mpu6050/Driver/Mpu6050.cs index 6e0498ce75..9cf9946a42 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mpu6050/Driver/Mpu6050.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Motion.Mpu6050/Driver/Mpu6050.cs @@ -171,5 +171,15 @@ private float ScaleAndOffset(Span data, int index, float scale, float offs return (s * scale) + offset; } } + + async Task ISamplingSensor.Read() + => (await Read()).AngularVelocity3D.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Acceleration3D.Value; + + async Task ISamplingSensor.Read() + => (await Read()).Temperature.Value; + } } diff --git a/Source/Meadow.Foundation.Peripherals/Sensors.Weather.WindVane/Driver/WindVane.cs b/Source/Meadow.Foundation.Peripherals/Sensors.Weather.WindVane/Driver/WindVane.cs index d1bec1d5c0..62c1fe3f21 100644 --- a/Source/Meadow.Foundation.Peripherals/Sensors.Weather.WindVane/Driver/WindVane.cs +++ b/Source/Meadow.Foundation.Peripherals/Sensors.Weather.WindVane/Driver/WindVane.cs @@ -99,7 +99,7 @@ void Initialize(IDictionary azimuthVoltages) /// wait between readings. This value influences how often `*Updated` /// events are raised and `IObservable` consumers are notified. /// The default is 5 seconds. - public void StartUpdating(TimeSpan updateInterval) + public void StartUpdating(TimeSpan? updateInterval) { // thread safety lock (samplingLock)