Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Characteristic Locus
Inheritance object ObservableBase<(Color? Color, Illuminance? AmbientLight)> SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)> PollingSensorBase<(Color? Color, Illuminance? AmbientLight)> ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)> > Apds9960
Implements IObservable<IChangeResult<(Color? Color, Illuminance? AmbientLight)>> ISamplingSensor<(Color? Color, Illuminance? AmbientLight)> ISensor<(Color? Color, Illuminance? AmbientLight)> II2cPeripheral IDisposable
Inherited Members ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>.BusComms ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>.ReadBuffer ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>.WriteBuffer ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>.Init(int, int) ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>.Dispose(bool) ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>.Dispose() PollingSensorBase<(Color? Color, Illuminance? AmbientLight)>.StartUpdating(TimeSpan?) PollingSensorBase<(Color? Color, Illuminance? AmbientLight)>.StopUpdating() SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.samplingLock SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.Updated SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.SamplingTokenSource SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.Conditions SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.IsSampling SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.UpdateInterval SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.ReadSensor() SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.RaiseEventsAndNotify(IChangeResult<(Color? Color, Illuminance? AmbientLight)>) SamplingSensorBase<(Color? Color, Illuminance? AmbientLight)>.Read() ObservableBase<(Color? Color, Illuminance? AmbientLight)>.observers ObservableBase<(Color? Color, Illuminance? AmbientLight)>.NotifyObservers(IChangeResult<(Color? Color, Illuminance? AmbientLight)>) ObservableBase<(Color? Color, Illuminance? AmbientLight)>.Subscribe(IObserver<IChangeResult<(Color? Color, Illuminance? AmbientLight)>>) ObservableBase<(Color? Color, Illuminance? AmbientLight)>.CreateObserver(Action<IChangeResult<(Color? Color, Illuminance? AmbientLight)>>, Predicate<IChangeResult<(Color? Color, Illuminance? AmbientLight)>>) object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Sensors.Motion
Assembly Apds9960.dll

Syntax

public class Apds9960 : ByteCommsSensorBase<(Color? Color, Illuminance? AmbientLight)>, IObservable<IChangeResult<(Color? Color, Illuminance? AmbientLight)>>, ISamplingSensor<(Color? Color, Illuminance? AmbientLight)>, ISensor<(Color? Color, Illuminance? AmbientLight)>, II2cPeripheral, IDisposable

Constructors

Apds9960(II2cBus, IPin?)

Create a new instance of the APDS9960 communicating over the I2C interface.

Declaration
public Apds9960(II2cBus i2cBus, IPin? interruptPin)

Parameters

Type Name Description
II2cBus i2cBus

SI2C bus object

IPin interruptPin

The interrupt pin

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Properties

AmbientLight

The current ambient light value

Declaration
public Illuminance? AmbientLight { get; }

Property Value

Type Description
Illuminance?

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Color

The current color value

Declaration
public Color? Color { get; }

Property Value

Type Description
Color?

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

DefaultI2cAddress

The default I2C address for the peripheral

Declaration
public byte DefaultI2cAddress { get; }

Property Value

Type Description
byte

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

IsDisposed

Is the object disposed

Declaration
public bool IsDisposed { get; }

Property Value

Type Description
bool

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Methods

DisableGestureSensor()

Disable gestures

Declaration
public void DisableGestureSensor()

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

DisableLightSensor()

Disable light sensor

Declaration
public void DisableLightSensor()

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

DisableProximitySensor()

Disable proximity sensor

Declaration
public void DisableProximitySensor()

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Dispose()

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

Declaration
public void Dispose()

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Dispose(bool)

Dispose of the object

Declaration
protected virtual void Dispose(bool disposing)

Parameters

Type Name Description
bool disposing

Is disposing

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

EnableGestureSensor(bool)

Starts the gesture recognition engine on the APDS-9960

Declaration
public bool EnableGestureSensor(bool interrupts)

Parameters

Type Name Description
bool interrupts

Returns

Type Description
bool

Enable interrupts for gestures

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

EnableLightSensor(bool)

Enable light sensor

Declaration
public void EnableLightSensor(bool interrupts)

Parameters

Type Name Description
bool interrupts

True to enable interrupts for light

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

EnablePower(bool)

Enable power

Declaration
public void EnablePower(bool enable)

Parameters

Type Name Description
bool enable

True to enable, false to disable

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

EnableProximitySensor(bool)

Enable proximity sensor

Declaration
public void EnableProximitySensor(bool interrupts)

Parameters

Type Name Description
bool interrupts

True to enable interrupts for proximity

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

GetLEDDrive()

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public byte GetLEDDrive()

Returns

Type Description
byte

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

GetProxIntHighThresh()

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public byte GetProxIntHighThresh()

Returns

Type Description
byte

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

GetProxIntLowThresh()

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public byte GetProxIntLowThresh()

Returns

Type Description
byte

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

GetProximityGain()

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public byte GetProximityGain()

Returns

Type Description
byte

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

IsGestureAvailable()

Is a gesture reading available

Declaration
public bool IsGestureAvailable()

Returns

Type Description
bool

True if available

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

RaiseEventsAndNotify(IChangeResult<(Color? Color, Illuminance? AmbientLight)>)

Raise events for subscribers and notify of value changes

Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Color? Color, Illuminance? AmbientLight)> changeResult)

Parameters

Type Name Description
IChangeResult<(Color? Color, Illuminance? AmbientLight)> changeResult

The updated sensor data

Overrides

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

ReadAmbientLight()

Read ambient light value

Declaration
protected ushort ReadAmbientLight()

Returns

Type Description
ushort

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

ReadBlueLight()

Read blue light value

Declaration
protected ushort ReadBlueLight()

Returns

Type Description
ushort

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

ReadGesture()

Read the current gesture

Declaration
public Apds9960.Direction ReadGesture()

Returns

Type Description
Apds9960.Direction

The direction

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Exceptions

Type Condition
Exception

Throws if reading gesture data failed

ReadGreenLight()

Read green light value

Declaration
protected ushort ReadGreenLight()

Returns

Type Description
ushort

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

ReadProximity()

Read proximity

Declaration
public byte ReadProximity()

Returns

Type Description
byte

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

ReadRedLight()

Read red light value

Declaration
protected ushort ReadRedLight()

Returns

Type Description
ushort

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

ReadSensor()

Reads data from the sensor

Declaration
protected override Task<(Color? Color, Illuminance? AmbientLight)> ReadSensor()

Returns

Type Description
Task<(Color? Color, Illuminance? AmbientLight)>

The latest sensor reading

Overrides

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

SetLEDDrive(byte)

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public bool SetLEDDrive(byte drive)

Parameters

Type Name Description
byte drive

Returns

Type Description
bool

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

SetProxIntHighThresh(byte)

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public void SetProxIntHighThresh(byte threshold)

Parameters

Type Name Description
byte threshold

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

SetProxIntLowThresh(byte)

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public void SetProxIntLowThresh(byte threshold)

Parameters

Type Name Description
byte threshold

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

SetProximityGain(byte)

Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor

Declaration
public void SetProximityGain(byte drive)

Parameters

Type Name Description
byte drive

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

Events

AmbientLightUpdated

Raised when the ambient light value changes

Declaration
public event EventHandler<IChangeResult<Illuminance>> AmbientLightUpdated

Event Type

Type Description
EventHandler<IChangeResult<Illuminance>>

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub

ColorUpdated

Raised when the color value changes

Declaration
public event EventHandler<IChangeResult<Color>> ColorUpdated

Event Type

Type Description
EventHandler<IChangeResult<Color>>

Remarks

Apds9960
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Motion.Apds9960

Code Example

Apds9960 sensor;

public MeadowApp()
{
    Console.WriteLine("Initializing...");

    // configure our sensor on the I2C Bus
    var i2c = Device.CreateI2cBus();
    sensor = new Apds9960(Device, i2c, Device.Pins.D00);
    
    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"  Ambient Light: {result.New.AmbientLight?.Lux:N2}Lux");
        Console.WriteLine($"  Color: {result.New.Color:N2}Lux");
    };

    //==== enable the features we want
    sensor.EnableLightSensor(false);

    //==== one-off read
    ReadConditions().Wait();

    // start updating continuously
    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

protected async Task ReadConditions()
{
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Ambient Light: {result.AmbientLight?.Lux:N2}Lux");
    Console.WriteLine($"  Color: {result.Color:N2}Lux");
}

Sample project(s) available on GitHub