Skip to main content

Class Bh1745

Represents a BH1745 Luminance and Color Sensor

Assembly: Bh1745.dll
View Source
public class Bh1745 : ByteCommsSensorBase<(Illuminance? AmbientLight, Color? Color, bool Valid)>, IObservable<IChangeResult<(Illuminance? AmbientLight, Color? Color, bool Valid)>>, ISamplingSensor<(Illuminance? AmbientLight, Color? Color, bool Valid)>, ISensor<(Illuminance? AmbientLight, Color? Color, bool Valid)>, IDisposable, ILightSensor, ISamplingSensor<Illuminance>, ISensor<Illuminance>, ISensor, ISamplingSensor, II2cPeripheral

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

Implements:

Expand

System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>>, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>, System.IDisposable, 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, Meadow.Hardware.II2cPeripheral

Properties

Illuminance

The current Illuminance value

View Source
public Illuminance? Illuminance { get; }

InterruptReset

Interrupt reset status

View Source
public Bh1745.InterruptStatus InterruptReset { get; set; }

MeasurementTime

Gets or sets the currently set measurement time

View Source
public Bh1745.MeasurementTimeType MeasurementTime { get; set; }

IsMeasurementActive

Is the sensor actively measuring

View Source
public bool IsMeasurementActive { get; set; }

AdcGain

Gets or sets the ADC gain of the sensor

View Source
public Bh1745.AdcGainTypes AdcGain { get; set; }

InterruptSignalIsActive

Is the interrupt active

View Source
public bool InterruptSignalIsActive { get; }

LatchBehavior

Gets or sets how the interrupt pin latches

View Source
public Bh1745.LatchBehaviorTypes LatchBehavior { get; set; }

InterruptSource

Gets or sets the source channel that triggers the interrupt

View Source
public Bh1745.InterruptChannels InterruptSource { get; set; }

InterruptIsEnabled

Gets or sets whether the interrupt pin is enabled

View Source
public bool InterruptIsEnabled { get; set; }

InterruptPersistence

Gets or sets the persistence function of the interrupt

View Source
public Bh1745.InterruptTypes InterruptPersistence { get; set; }

LowerInterruptThreshold

Gets or sets the lower interrupt threshold

View Source
public ushort LowerInterruptThreshold { get; set; }

UpperInterruptThreshold

Gets or sets the upper interrupt threshold

View Source
public ushort UpperInterruptThreshold { get; set; }

CompensationMultipliers

Gets or sets the channel compensation multipliers which are used to scale the channel measurements

View Source
public Bh1745.ChannelMultipliers CompensationMultipliers { get; set; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
public byte DefaultI2cAddress { get; }

Methods

ReadSensor()

Reads data from the sensor

View Source
protected override Task<(Illuminance? AmbientLight, Color? Color, bool Valid)> ReadSensor()
Returns

System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>: The latest sensor reading### RaiseEventsAndNotify(IChangeResult<(Illuminance? AmbientLight, Color? Color, bool Valid)>) Raise events for subscribers and notify of value changes

View Source
protected override void RaiseEventsAndNotify(IChangeResult<(Illuminance? AmbientLight, Color? Color, bool Valid)> changeResult)
Parameters
TypeNameDescription
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>changeResultThe updated sensor data

Reset()

Resets the device to the default configuration On reset the sensor goes to power down mode

View Source
protected void Reset()

ReadMeasurementIsValid()

Reads whether the last measurement is valid

View Source
protected bool ReadMeasurementIsValid()
Returns

System.Boolean

ReadRedDataRegister()

Reads the red data register of the sensor

View Source
protected ushort ReadRedDataRegister()
Returns

System.UInt16

ReadGreenDataRegister()

Reads the green data register of the sensor

View Source
protected ushort ReadGreenDataRegister()
Returns

System.UInt16

ReadBlueDataRegister()

Reads the blue data register of the sensor

View Source
protected ushort ReadBlueDataRegister()
Returns

System.UInt16

ReadClearDataRegister()

Reads the clear data register of the sensor

View Source
protected ushort ReadClearDataRegister()
Returns

System.UInt16

Implements

  • System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>
  • Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Illuminance>,System.Nullable<Meadow.Color>,System.Boolean>>
  • System.IDisposable
  • 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
  • Meadow.Hardware.II2cPeripheral