Skip to content

Commit

Permalink
Remove the light sensor (not part of Clima)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Jan 13, 2025
1 parent e9cc907 commit a390224
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 58 deletions.
15 changes: 0 additions & 15 deletions Source/Meadow.Clima.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet", "..\..\MQTTnet\So
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serialization.MicroJson", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Libraries_and_Frameworks\Serialization.MicroJson\Driver\Serialization.MicroJson.csproj", "{6300EAB4-806F-4C18-8FE0-57C45A2C0C58}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sensors.Light.Veml7700", "..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Light.Veml7700\Driver\Sensors.Light.Veml7700.csproj", "{C5925D96-F9F4-4F42-AC8D-97E464252A4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -366,18 +364,6 @@ Global
{6300EAB4-806F-4C18-8FE0-57C45A2C0C58}.Release|iPhone.Build.0 = Release|Any CPU
{6300EAB4-806F-4C18-8FE0-57C45A2C0C58}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{6300EAB4-806F-4C18-8FE0-57C45A2C0C58}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Debug|iPhone.Build.0 = Debug|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Release|Any CPU.Build.0 = Release|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Release|iPhone.ActiveCfg = Release|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Release|iPhone.Build.0 = Release|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{C5925D96-F9F4-4F42-AC8D-97E464252A4D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -400,7 +386,6 @@ Global
{85DC9E85-3472-418A-8065-5EF99323E6FE} = {2889A476-F914-49E8-9F97-4CC6CA34A901}
{F6EB1347-3926-4308-BE20-70AC53BEBF1D} = {2889A476-F914-49E8-9F97-4CC6CA34A901}
{6300EAB4-806F-4C18-8FE0-57C45A2C0C58} = {2889A476-F914-49E8-9F97-4CC6CA34A901}
{C5925D96-F9F4-4F42-AC8D-97E464252A4D} = {2889A476-F914-49E8-9F97-4CC6CA34A901}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CA61E123-F783-4CB3-8EB2-099EE930ADD4}
Expand Down
13 changes: 6 additions & 7 deletions Source/Meadow.Clima/Controllers/SensorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SensorController
/// <summary>
/// Gets the interval at which sensor data is updated.
/// </summary>
public TimeSpan UpdateInterval { get; } = TimeSpan.FromSeconds(5);
public TimeSpan UpdateInterval { get; } = TimeSpan.FromSeconds(15);

/// <summary>
/// Initializes a new instance of the <see cref="SensorController"/> class.
Expand All @@ -35,39 +35,38 @@ public SensorController(IClimaHardware clima)
if (clima.TemperatureSensor is { } temperatureSensor)
{
temperatureSensor.Updated += TemperatureUpdated;
temperatureSensor.StartUpdating(TimeSpan.FromSeconds(15));
temperatureSensor.StartUpdating(UpdateInterval);
}

if (clima.BarometricPressureSensor is { } pressureSensor)
{
pressureSensor.Updated += PressureUpdated;
pressureSensor.StartUpdating(TimeSpan.FromMinutes(1));
pressureSensor.StartUpdating(UpdateInterval);
}

if (clima.HumiditySensor is { } humiditySensor)
{
humiditySensor.Updated += HumidityUpdated;
humiditySensor.StartUpdating(TimeSpan.FromMinutes(1));
humiditySensor.StartUpdating(UpdateInterval);
}

if (clima.CO2ConcentrationSensor is { } co2Sensor)
{
co2Sensor.Updated += Co2Updated;
co2Sensor.StartUpdating(TimeSpan.FromMinutes(5));
co2Sensor.StartUpdating(UpdateInterval);
}

if (clima.WindVane is { } windVane)
{
windVane.Updated += WindvaneUpdated;
windVane.StartUpdating(TimeSpan.FromSeconds(1));
windVane.StartUpdating(UpdateInterval);
}

if (clima.RainGauge is { } rainGuage)
{
rainGuage.Updated += RainGaugeUpdated;

rainGuage.StartUpdating(TimeSpan.FromMinutes(5));
rainGuage.StartUpdating(UpdateInterval);
}

if (clima.Anemometer is { } anemometer)
Expand Down
37 changes: 2 additions & 35 deletions Source/Meadow.Clima/Hardware/ClimaHardwareV4.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Meadow.Foundation;
using Meadow.Foundation.ICs.IOExpanders;
using Meadow.Foundation.Sensors.Light;
using Meadow.Foundation.ICs.IOExpanders;
using Meadow.Hardware;
using Meadow.Peripherals.Sensors.Light;
using Meadow.Units;

namespace Meadow.Devices.Clima.Hardware;

Expand All @@ -12,9 +8,6 @@ namespace Meadow.Devices.Clima.Hardware;
/// </summary>
public class ClimaHardwareV4 : ClimaHardwareV3
{
private ILightSensor? _lightSensor;
private bool _firstLightQuery = true;

/// <inheritdoc/>
public override string RevisionString => "v4.x";

Expand All @@ -26,8 +19,7 @@ public class ClimaHardwareV4 : ClimaHardwareV3
/// <param name="mcpVersion">The Mcp23008 used to read version information</param>
public ClimaHardwareV4(IF7CoreComputeMeadowDevice device, II2cBus i2cBus, Mcp23008 mcpVersion)
: base(device, i2cBus, mcpVersion)
{
}
{ }

internal override I2cConnector? CreateQwiicConnector()
{
Expand All @@ -42,29 +34,4 @@ public ClimaHardwareV4(IF7CoreComputeMeadowDevice device, II2cBus i2cBus, Mcp230
},
new I2cBusMapping(_device, 1));
}

protected override ILightSensor? GetLightSensor()
{
if (_lightSensor == null && _firstLightQuery)
{
try
{
Logger?.Trace("Creating Light sensor");
_lightSensor = new Veml7700(_device.CreateI2cBus());
if (_lightSensor is PollingSensorBase<Illuminance> pollingSensor)
{
pollingSensor.CommunicationError += (s, e) => { _lightSensor.StopUpdating(); };
}
}
catch
{
Logger?.Warn("Light sensor not found on I2C bus");
_lightSensor = null;
}

_firstLightQuery = false;
}

return _lightSensor;
}
}
1 change: 0 additions & 1 deletion Source/Meadow.Clima/Meadow.Clima.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Atmospheric.Bme68x\Driver\Sensors.Atmospheric.Bme68x.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Environmental.Scd4x\Driver\Sensors.Environmental.Scd4x.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Gnss.NeoM8\Driver\Sensors.Gnss.NeoM8.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Light.Veml7700\Driver\Sensors.Light.Veml7700.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Weather.SwitchingAnemometer\Driver\Sensors.Weather.SwitchingAnemometer.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Weather.SwitchingRainGauge\Driver\Sensors.Weather.SwitchingRainGauge.csproj" />
<ProjectReference Include="..\..\..\Meadow.Foundation\Source\Meadow.Foundation.Peripherals\Sensors.Weather.WindVane\Driver\Sensors.Weather.WindVane.csproj" />
Expand Down

0 comments on commit a390224

Please sign in to comment.