Skip to main content

Class AnalogLightSensor

Represents an analog light sensor

Assembly: Meadow.Foundation.dll​
View Source​
Declaration
public class AnalogLightSensor : SamplingSensorBase<Illuminance>, IObservable<IChangeResult<Illuminance>>, ILightSensor, ISamplingSensor<Illuminance>, ISensor<Illuminance>, ISensor, ISamplingSensor, IDisposable

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT>

Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.Illuminance>>, Meadow.Peripherals.Sensors.Light.ILightSensor, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Illuminance>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Illuminance>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, System.IDisposable

Properties​

AnalogInputPort​

Analog port connected to sensor

View Source​
Declaration
protected IAnalogInputPort AnalogInputPort { get; }

LuminanceCalibration​

Illuminance sensor calibration

View Source​
Declaration
public AnalogLightSensor.Calibration LuminanceCalibration { get; protected set; }

Illuminance​

Current illuminance value read by sensor

View Source​
Declaration
public Illuminance? Illuminance { get; }

IsDisposed​

Is the object disposed

View Source​
Declaration
public bool IsDisposed { get; }

Methods​

ReadSensor()​

Convenience method to get the current luminance. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer.

View Source​
Declaration
protected override Task<Illuminance> ReadSensor()
Returns​

System.Threading.Tasks.Task<Meadow.Units.Illuminance>

StartUpdating(TimeSpan?)​

Starts continuously sampling the sensor.

This method also starts raising Changed events and IObservable subscribers getting notified. Use the readIntervalDuration parameter to specify how often events and notifications are raised/sent.

View Source​
Declaration
public override void StartUpdating(TimeSpan? updateInterval)
Parameters​
TypeNameDescription
System.Nullable<System.TimeSpan>updateIntervalA TimeSpan that specifies how long to
 wait between readings. This value influences how often `*Updated`
events are raised and `IObservable` consumers are notified.
The default is 5 seconds. |

StopUpdating()​

Stops sampling the temperature.

View Source​
Declaration
public override void StopUpdating()

VoltageToLuminance(Voltage)​

Converts a voltage value to a level in centimeters, based on the current calibration values.

View Source​
Declaration
protected Illuminance VoltageToLuminance(Voltage voltage)
Returns​

Meadow.Units.Illuminance

Parameters​
TypeName
Meadow.Units.Voltagevoltage

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.Illuminance>>
  • Meadow.Peripherals.Sensors.Light.ILightSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Illuminance>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Illuminance>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • System.IDisposable