Skip to content

Commit

Permalink
Merge pull request #873 from WildernessLabs/contracts
Browse files Browse the repository at this point in the history
Update DO sensors to match new interfaces
  • Loading branch information
jorgedevs authored Jan 1, 2024
2 parents 95dfe06 + a90d988 commit 1f53967
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Meadow.Foundation.Sensors.Environmental;
/// <summary>
/// Atlas Scientific Analog Gravity Dissolved Oxygen Meter
/// </summary>
public partial class AtlasScientificGravityDOMeter : SamplingSensorBase<double>, IDissolvedOxygenSensor
public partial class AtlasScientificGravityDOMeter : SamplingSensorBase<double>, IDissolvedOxygenSaturationSensor
{
/// <summary>
/// The calibration value for the sensor in air
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Meadow.Hardware;
using Meadow.Peripherals.Sensors.Environmental;
using Meadow.Units;
using System;
using System.Threading.Tasks;
Expand All @@ -8,7 +9,7 @@ namespace Meadow.Foundation.Sensors.Environmental;
/// <summary>
/// DFRobot Analog Gravity Dissolved Oxygen Meter
/// </summary>
public partial class DFRobotGravityDOMeter : SamplingSensorBase<ConcentrationInWater> //, IDissolvedOxygenSensor
public partial class DFRobotGravityDOMeter : SamplingSensorBase<ConcentrationInWater>, IDissolvedOxygenConcentrationSensor
{
/// <summary>
/// The current water temperature (default 25C)
Expand All @@ -28,7 +29,7 @@ public partial class DFRobotGravityDOMeter : SamplingSensorBase<ConcentrationInW
/// <summary>
/// Last concentration value read from the sensor
/// </summary>
public ConcentrationInWater? ConcentrationInWater { get; protected set; }
public ConcentrationInWater? Concentration { get; protected set; }

/// <summary>
/// The disolved oxygen lookup table for temperature values from 0 to 40 degrees C
Expand Down Expand Up @@ -65,9 +66,9 @@ public DFRobotGravityDOMeter(IAnalogInputPort analogInputPort)
ChangeResult<ConcentrationInWater> changeResult = new()
{
New = VoltageToConcentration(result.New),
Old = ConcentrationInWater
Old = Concentration
};
ConcentrationInWater = changeResult.New;
Concentration = changeResult.New;
RaiseEventsAndNotify(changeResult);
}
)
Expand All @@ -91,7 +92,7 @@ protected override async Task<ConcentrationInWater> ReadSensor()
{
var voltage = await AnalogInputPort.Read();
var newConcentration = VoltageToConcentration(voltage);
ConcentrationInWater = newConcentration;
Concentration = newConcentration;
return newConcentration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class Ens160 :
ByteCommsSensorBase<(Concentration? CO2Concentration,
Concentration? EthanolConcentration,
Concentration? TVOCConcentration)>,
IConcentrationSensor, II2cPeripheral
ICO2ConcentrationSensor, II2cPeripheral
{
private event EventHandler<IChangeResult<Concentration>> _concentrationHandlers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace Meadow.Foundation.Sensors.Environmental
/// <summary>
/// Represents an IonScience MiniPID2 analog photoionisation (PID) Volatile Organic Compounds (VOC) sensor
/// </summary>
public partial class MiniPID2 : SamplingSensorBase<Concentration>, IConcentrationSensor, IDisposable
public partial class MiniPID2 : SamplingSensorBase<Concentration>, IVOCConcentrationSensor, IDisposable
{
/// <summary>
/// The current VOC concentration value
/// </summary>
public Concentration? Concentration { get; protected set; }
public Concentration? VOCConcentration { get; protected set; }

/// <summary>
/// The MiniPID2 device type
Expand Down Expand Up @@ -118,9 +118,9 @@ static SensorCalibration GetCalibration(int airOffsetLow, int airOffsetHigh, dou
ChangeResult<Concentration> changeResult = new()
{
New = VoltageToConcentration(result.New),
Old = Concentration
Old = VOCConcentration
};
Concentration = changeResult.New;
VOCConcentration = changeResult.New;
RaiseEventsAndNotify(changeResult);
}
)
Expand All @@ -136,7 +136,7 @@ protected override async Task<Concentration> ReadSensor()
{
var voltage = await AnalogInputPort.Read();
var newConcentration = VoltageToConcentration(voltage);
Concentration = newConcentration;
VOCConcentration = newConcentration;
return newConcentration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract partial class Scd4xBase
: ByteCommsSensorBase<(Concentration? Concentration,
Units.Temperature? Temperature,
RelativeHumidity? Humidity)>,
ITemperatureSensor, IHumiditySensor, IConcentrationSensor, II2cPeripheral
ITemperatureSensor, IHumiditySensor, ICO2ConcentrationSensor, II2cPeripheral
{
private event EventHandler<IChangeResult<Units.Temperature>> _temperatureHandlers;
private event EventHandler<IChangeResult<RelativeHumidity>> _humidityHandlers;
Expand All @@ -43,7 +43,7 @@ event EventHandler<IChangeResult<Concentration>> ISamplingSensor<Concentration>.
/// <summary>
/// The current C02 concentration value
/// </summary>
public Concentration? Concentration => Conditions.Concentration;
public Concentration? CO2Concentration => Conditions.Concentration;

/// <summary>
/// The current temperature
Expand Down

0 comments on commit 1f53967

Please sign in to comment.