Skip to main content

Class Hcsr04

HCSR04 Distance Sensor - driver not complete

Assembly: Hcsr04.dll
View Source
Declaration
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
Declaration
public Length? Distance { get; protected set; }

MinimumDistance

Minimum valid distance in cm

View Source
Declaration
public double MinimumDistance { get; }

MaximumDistance

Maximum valid distance in cm

View Source
Declaration
public double MaximumDistance { get; }

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

Fields

triggerPort

Port for trigger Pin

View Source
Declaration
protected IDigitalOutputPort? triggerPort

echoPort

Port for echo Pin

View Source
Declaration
protected IDigitalInterruptPort? echoPort

Methods

MeasureDistance()

Sends a trigger signal

View Source
Declaration
public virtual void MeasureDistance()

ReadSensor()

Reads data from the sensor

View Source
Declaration
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
Declaration
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
TypeName
System.Nullable<System.TimeSpan>updateInterval

StopUpdating()

Stops sampling the sensor

View Source
Declaration
public override void StopUpdating()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs 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