Class Hcsr04
HCSR04 Distance Sensor - driver not complete
Assembly: Hcsr04.dll
View Source
public class Hcsr04 : SamplingSensorBase<Length>, IObservable<IChangeResult<Length>>, IRangeFinder, ISamplingSensor<Length>, ISensor<Length>, ISensor, ISamplingSensor, IDisposable
Inheritance: System.Object
-> Meadow.Foundation.ObservableBase<UNIT>
Derived:
Meadow.Foundation.ICs.IOExpanders.SerialWombatBase.Hcsr04
Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.Length>>
, Meadow.Peripherals.Sensors.Distance.IRangeFinder
, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Length>
, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Length>
, Meadow.Peripherals.Sensors.ISensor
, Meadow.Peripherals.Sensors.ISamplingSensor
, System.IDisposable
Properties
Distance
Returns current distance
View Source
public Length? Distance { get; protected set; }
MinimumDistance
Minimum valid distance in cm
View Source
public double MinimumDistance { get; }
MaximumDistance
Maximum valid distance in cm
View Source
public double MaximumDistance { get; }
IsDisposed
Is the object disposed
View Source
public bool IsDisposed { get; }
Fields
triggerPort
Port for trigger Pin
View Source
protected IDigitalOutputPort? triggerPort
echoPort
Port for echo Pin
View Source
protected IDigitalInterruptPort? echoPort
Methods
MeasureDistance()
Sends a trigger signal
View Source
public virtual void MeasureDistance()
ReadSensor()
Reads data from the sensor
View Source
protected override Task<Length> ReadSensor()
Returns
System.Threading.Tasks.Task<Meadow.Units.Length>
: The latest sensor reading### StartUpdating(TimeSpan?)
Starts continuously sampling the sensor
View Source
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
Type | Name |
---|---|
System.Nullable<System.TimeSpan> | updateInterval |
StopUpdating()
Stops sampling the sensor
View Source
public override void StopUpdating()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
public void Dispose()
Dispose(bool)
Dispose of the object
View Source
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Implements
System.IObservable<Meadow.IChangeResult<Meadow.Units.Length>>
Meadow.Peripherals.Sensors.Distance.IRangeFinder
Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Length>
Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Length>
Meadow.Peripherals.Sensors.ISensor
Meadow.Peripherals.Sensors.ISamplingSensor
System.IDisposable