Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IGasResistanceSensor interface #858

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Meadow.Hardware;
using Meadow.Peripherals.Sensors;
using Meadow.Peripherals.Sensors.Atmospheric;
using Meadow.Peripherals.Sensors.Environmental;
using Meadow.Units;
using Meadow.Utilities;
using System;
Expand All @@ -22,16 +23,12 @@
RelativeHumidity? Humidity,
Pressure? Pressure,
Resistance? GasResistance)>,
ITemperatureSensor, IHumiditySensor, IBarometricPressureSensor, ISpiPeripheral, II2cPeripheral, IDisposable
ITemperatureSensor, IHumiditySensor, IBarometricPressureSensor, IGasResistanceSensor, ISpiPeripheral, II2cPeripheral, IDisposable

Check failure on line 26 in Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme68x/Driver/Bme68x.cs

View workflow job for this annotation

GitHub Actions / build

'Bme68x' does not implement interface member 'IGasResistanceSensor.Resistance'

Check failure on line 26 in Source/Meadow.Foundation.Peripherals/Sensors.Atmospheric.Bme68x/Driver/Bme68x.cs

View workflow job for this annotation

GitHub Actions / build

'Bme68x' does not implement interface member 'IGasResistanceSensor.Resistance'
{
private event EventHandler<IChangeResult<Units.Temperature>> _temperatureHandlers;
private event EventHandler<IChangeResult<RelativeHumidity>> _humidityHandlers;
private event EventHandler<IChangeResult<Pressure>> _pressureHandlers;

/// <summary>
/// Raised when the gas resistance value changes
/// </summary>
public event EventHandler<IChangeResult<Resistance>> GasResistanceUpdated = default!;
private event EventHandler<IChangeResult<Units.Temperature>> _temperatureHandlers = default!;
private event EventHandler<IChangeResult<RelativeHumidity>> _humidityHandlers = default!;
private event EventHandler<IChangeResult<Pressure>> _pressureHandlers = default!;
private event EventHandler<IChangeResult<Resistance>> _gasResistanceHandlers = default!;

/// <summary>
/// The temperature oversampling mode
Expand Down Expand Up @@ -292,6 +289,12 @@
remove => _pressureHandlers -= value;
}

event EventHandler<IChangeResult<Resistance>> ISamplingSensor<Resistance>.Updated
{
add => _gasResistanceHandlers += value;
remove => _gasResistanceHandlers -= value;
}

/// <summary>
/// Initialize the sensor
/// </summary>
Expand Down Expand Up @@ -430,7 +433,7 @@
}
if (changeResult.New.GasResistance is { } gasResistance)
{
GasResistanceUpdated?.Invoke(this, new ChangeResult<Resistance>(gasResistance, changeResult.Old?.GasResistance));
_gasResistanceHandlers?.Invoke(this, new ChangeResult<Resistance>(gasResistance, changeResult.Old?.GasResistance));
}
base.RaiseEventsAndNotify(changeResult);
}
Expand Down Expand Up @@ -669,5 +672,8 @@

async Task<Pressure> ISensor<Pressure>.Read()
=> (await Read()).Pressure!.Value;

async Task<Resistance> ISensor<Resistance>.Read()
=> (await Read()).GasResistance!.Value;
}
}
Loading