-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1107 from WildernessLabs/feature/potentiometer
Feature/potentiometer
- Loading branch information
Showing
35 changed files
with
607 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
Source/Meadow.Foundation.Core/Simulation/Ports/SimulatedDigitalOutputPort.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Meadow.Hardware; | ||
|
||
namespace Meadow.Foundation.Sensors; | ||
|
||
public class SimulatedDigitalOutputPort : IDigitalOutputPort | ||
{ | ||
private bool state; | ||
|
||
public bool InitialState { get; } | ||
public string Name { get; } | ||
|
||
public SimulatedDigitalOutputPort(string name, bool initialState) | ||
{ | ||
Name = name; | ||
InitialState = state = initialState; | ||
} | ||
|
||
public virtual bool State | ||
{ | ||
get => state; | ||
set | ||
{ | ||
state = value; | ||
Resolver.Log.Info($"Output {Name} = {State}"); | ||
} | ||
} | ||
|
||
public IDigitalChannelInfo? Channel => null; | ||
Check warning on line 28 in Source/Meadow.Foundation.Core/Simulation/Ports/SimulatedDigitalOutputPort.cs GitHub Actions / build
|
||
public IPin? Pin => null; | ||
Check warning on line 29 in Source/Meadow.Foundation.Core/Simulation/Ports/SimulatedDigitalOutputPort.cs GitHub Actions / build
|
||
|
||
public void Dispose() | ||
{ | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
Source/Meadow.Foundation.Core/Simulation/Ports/SimulatedDigitalSignalAnalyzer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Meadow.Hardware; | ||
using Meadow.Units; | ||
|
||
namespace Meadow.Foundation.Sensors; | ||
|
||
public class SimulatedDigitalSignalAnalyzer : IDigitalSignalAnalyzer | ||
{ | ||
private Frequency frequency; | ||
private double dutyCycle = 0.5; | ||
private ulong count; | ||
|
||
public SimulatedDigitalSignalAnalyzer(Frequency frequency) | ||
{ | ||
this.frequency = frequency; | ||
} | ||
|
||
public void SetDutyCycle(double dutyCycle) | ||
{ | ||
this.dutyCycle = dutyCycle; | ||
} | ||
|
||
public double GetDutyCycle() | ||
{ | ||
return dutyCycle; | ||
} | ||
|
||
public void SetFrequency(Frequency frequency) | ||
{ | ||
this.frequency = frequency; | ||
} | ||
|
||
public Frequency GetFrequency() | ||
{ | ||
return frequency; | ||
} | ||
|
||
public Frequency GetMeanFrequency() | ||
{ | ||
return frequency; | ||
} | ||
|
||
public void SetCount(ulong count) | ||
{ | ||
this.count = count; | ||
} | ||
|
||
public ulong GetCount() | ||
{ | ||
return count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
Source/Meadow.Foundation.Core/Simulation/Sensors/SimulatedHallEffectFlowSensor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Meadow.Peripherals.Sensors; | ||
using Meadow.Units; | ||
using System.Threading.Tasks; | ||
|
||
namespace Meadow.Foundation.Sensors; | ||
|
||
public class SimulatedHallEffectFlowSensor : IVolumetricFlowSensor | ||
{ | ||
private SimulatedDigitalSignalAnalyzer _analyzer; | ||
private double _flowCoefficient; | ||
|
||
public SimulatedHallEffectFlowSensor(Frequency simulatedPulseFrequency, double flowCoefficient = 80d) | ||
{ | ||
_flowCoefficient = flowCoefficient; | ||
_analyzer = new SimulatedDigitalSignalAnalyzer(simulatedPulseFrequency); | ||
} | ||
|
||
public void SetSignalFrequency(Frequency frequency) | ||
{ | ||
_analyzer.SetFrequency(frequency); | ||
} | ||
|
||
public VolumetricFlow Flow => new VolumetricFlow( | ||
_analyzer.GetFrequency().Hertz / _flowCoefficient, | ||
VolumetricFlow.UnitType.LitersPerMinute); | ||
|
||
public Task<VolumetricFlow> Read() | ||
{ | ||
return Task.FromResult(Flow); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Source/Meadow.Foundation.Peripherals/Sensors.Flow.HallEffect/Driver/Drivers/Gr105.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Meadow.Hardware; | ||
|
||
namespace Meadow.Peripherals.Sensors.Flow; | ||
|
||
/// <summary> | ||
/// Driver for the GR-105 Hall effect water flow sensor. | ||
/// </summary> | ||
/// <remarks> | ||
/// Configures the sensor with its factory calibration values: | ||
/// - Scale factor: 5.5 Hz per L/min | ||
/// </remarks> | ||
public class Gr105 : HallEffectBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the GR-105 flow sensor. | ||
/// </summary> | ||
/// <param name="pin">The digital input pin connected to the sensor's signal line.</param> | ||
public Gr105(IPin pin) | ||
: base(pin, 5.5d) | ||
{ | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Source/Meadow.Foundation.Peripherals/Sensors.Flow.HallEffect/Driver/Drivers/Gr201.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Meadow.Hardware; | ||
|
||
namespace Meadow.Peripherals.Sensors.Flow; | ||
|
||
/// <summary> | ||
/// Driver for the GR-201 Hall effect water flow sensor. | ||
/// </summary> | ||
/// <remarks> | ||
/// Configures the sensor with its factory calibration values: | ||
/// - Scale factor: 7.5 Hz per L/min | ||
/// </remarks> | ||
public class Gr201 : HallEffectBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the GR-201 flow sensor. | ||
/// </summary> | ||
/// <param name="pin">The digital input pin connected to the sensor's signal line.</param> | ||
public Gr201(IPin pin) | ||
: base(pin, 7.5d) | ||
{ | ||
} | ||
} |
Oops, something went wrong.