Class Apds9960
Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor
Assembly: Apds9960.dll
View Source
public class Apds9960 : ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>, IObservable<IChangeResult<(Color? Color, Illuminance? AmbientLight)>>, ISamplingSensor<(Color? Color, Illuminance? AmbientLight)>, ISensor<(Color? Color, Illuminance? AmbientLight)>, ISensor, ISamplingSensor, II2cPeripheral, IDisposable
Inheritance: System.Object
-> Meadow.Foundation.ObservableBase<UNIT>
Implements:
System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>>>
, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>>
, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>>
, Meadow.Peripherals.Sensors.ISensor
, Meadow.Peripherals.Sensors.ISamplingSensor
, Meadow.Hardware.II2cPeripheral
, System.IDisposable
Properties
DefaultI2cAddress
The default I2C address for the peripheral
View Source
public byte DefaultI2cAddress { get; }
IsDisposed
Is the object disposed
View Source
public bool IsDisposed { get; }
Color
The current color value
View Source
public Color? Color { get; }
AmbientLight
The current ambient light value
View Source
public Illuminance? AmbientLight { get; }
Methods
ReadSensor()
Reads data from the sensor
View Source
protected override Task<(Color? Color, Illuminance? AmbientLight)> ReadSensor()
Returns
System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>>
: The latest sensor reading### RaiseEventsAndNotify(IChangeResult<(Color? Color, Illuminance? AmbientLight)>)
Raise events for subscribers and notify of value changes
View Source
protected override void RaiseEventsAndNotify(IChangeResult<(Color? Color, Illuminance? AmbientLight)> changeResult)
Parameters
Type | Name | Description |
---|---|---|
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>> | changeResult | The updated sensor data |
EnableLightSensor(bool)
Enable light sensor
View Source
public void EnableLightSensor(bool interrupts)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | interrupts | True to enable interrupts for light |
DisableLightSensor()
Disable light sensor
View Source
public void DisableLightSensor()
EnableProximitySensor(bool)
Enable proximity sensor
View Source
public void EnableProximitySensor(bool interrupts)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | interrupts | True to enable interrupts for proximity |
DisableProximitySensor()
Disable proximity sensor
View Source
public void DisableProximitySensor()
EnableGestureSensor(bool)
Starts the gesture recognition engine on the APDS-9960
View Source
public bool EnableGestureSensor(bool interrupts)
Returns
System.Boolean
: Enable interrupts for gestures
Parameters
Type | Name |
---|---|
System.Boolean | interrupts |
DisableGestureSensor()
Disable gestures
View Source
public void DisableGestureSensor()
IsGestureAvailable()
Is a gesture reading available
View Source
public bool IsGestureAvailable()
Returns
System.Boolean
: True if available### ReadGesture()
Read the current gesture
View Source
public Apds9960.Direction ReadGesture()
Returns
Meadow.Foundation.Sensors.Motion.Apds9960.Direction: The direction
Exceptions
System.Exception
Throws if reading gesture data failed
EnablePower(bool)
Enable power
View Source
public void EnablePower(bool enable)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | enable | True to enable, false to disable |
ReadAmbientLight()
Read ambient light value
View Source
protected ushort ReadAmbientLight()
Returns
System.UInt16
ReadRedLight()
Read red light value
View Source
protected ushort ReadRedLight()
Returns
System.UInt16
ReadGreenLight()
Read green light value
View Source
protected ushort ReadGreenLight()
Returns
System.UInt16
ReadBlueLight()
Read blue light value
View Source
protected ushort ReadBlueLight()
Returns
System.UInt16
ReadProximity()
Read proximity
View Source
public byte ReadProximity()
Returns
System.Byte
GetProxIntLowThresh()
View Source
public byte GetProxIntLowThresh()
Returns
System.Byte
SetProxIntLowThresh(byte)
View Source
public void SetProxIntLowThresh(byte threshold)
Parameters
Type | Name |
---|---|
System.Byte | threshold |
GetProxIntHighThresh()
View Source
public byte GetProxIntHighThresh()
Returns
System.Byte
SetProxIntHighThresh(byte)
View Source
public void SetProxIntHighThresh(byte threshold)
Parameters
Type | Name |
---|---|
System.Byte | threshold |
GetLEDDrive()
View Source
public byte GetLEDDrive()
Returns
System.Byte
SetLEDDrive(byte)
View Source
public bool SetLEDDrive(byte drive)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Byte | drive |
GetProximityGain()
View Source
public byte GetProximityGain()
Returns
System.Byte
SetProximityGain(byte)
View Source
public void SetProximityGain(byte drive)
Parameters
Type | Name |
---|---|
System.Byte | drive |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
public override void Dispose()
Dispose(bool)
Dispose of the object
View Source
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Events
AmbientLightUpdated
Raised when the ambient light value changes
View Source
public event EventHandler<IChangeResult<Illuminance>> AmbientLightUpdated
Event Type
System.EventHandler<Meadow.IChangeResult<Meadow.Units.Illuminance>>
ColorUpdated
Raised when the color value changes
View Source
public event EventHandler<IChangeResult<Color>> ColorUpdated
Event Type
System.EventHandler<Meadow.IChangeResult<Meadow.Color>>
Implements
System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>>>
Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>>
Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Color>,System.Nullable<Meadow.Units.Illuminance>>>
Meadow.Peripherals.Sensors.ISensor
Meadow.Peripherals.Sensors.ISamplingSensor
Meadow.Hardware.II2cPeripheral
System.IDisposable