Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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
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)>, IDisposable, II2cPeripheral
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
Properties
AmbientLight
The current abient light value
Declaration
public Illuminance? AmbientLight { get; }
Property Value
Type | Description |
---|---|
Illuminance? |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
Color
The current color value
Declaration
public Color? Color { get; }
Property Value
Type | Description |
---|---|
Color? |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
DefaultI2cAddress
The default I2C address for the peripheral
Declaration
public byte DefaultI2cAddress { get; }
Property Value
Type | Description |
---|---|
byte |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
Methods
DisableGestureSensor()
Disable gestures
Declaration
public void DisableGestureSensor()
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
DisableLightSensor()
Disable light sensor
Declaration
public void DisableLightSensor()
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
DisableProximitySensor()
Disable proximity sensor
Declaration
public void DisableProximitySensor()
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
GetLEDDrive()
Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor
Declaration
public byte GetLEDDrive()
Returns
Type | Description |
---|---|
byte |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
GetProxIntHighThresh()
Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor
Declaration
public byte GetProxIntHighThresh()
Returns
Type | Description |
---|---|
byte |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
GetProxIntLowThresh()
Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor
Declaration
public byte GetProxIntLowThresh()
Returns
Type | Description |
---|---|
byte |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
GetProximityGain()
Represents the APDS9960 Proximity, Light, RGB, and Gesture Sensor
Declaration
public byte GetProximityGain()
Returns
Type | Description |
---|---|
byte |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
IsGestureAvailable()
Is a gesture reading available
Declaration
public bool IsGestureAvailable()
Returns
Type | Description |
---|---|
bool | True if available |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
RaiseEventsAndNotify(IChangeResult<(Color? Color, Illuminance? AmbientLight)>)
Raise events for subcribers 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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
ReadAmbientLight()
Read ambient light value
Declaration
protected ushort ReadAmbientLight()
Returns
Type | Description |
---|---|
ushort |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
ReadBlueLight()
Read blue light value
Declaration
protected ushort ReadBlueLight()
Returns
Type | Description |
---|---|
ushort |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
ReadGesture()
Read the current gesure
Declaration
public Apds9960.Direction ReadGesture()
Returns
Type | Description |
---|---|
Apds9960.Direction | The direction |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
ReadProximity()
Read proximity
Declaration
public byte ReadProximity()
Returns
Type | Description |
---|---|
byte |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
ReadRedLight()
Read red light value
Declaration
protected ushort ReadRedLight()
Returns
Type | Description |
---|---|
ushort |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
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 | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}
ColorUpdated
Raised when the color value changes
Declaration
public event EventHandler<IChangeResult<Color>> ColorUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Color>> |
Remarks
Apds9960 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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");
}