DeviceSensorReading Class

A reading of a sensor of the device (https://w3c.github.io/sensors/#sensor-reading), given to DeviceSensor.Update. Create it with the factory method of the shape of the sensor: DeviceSensorReading.FromXyz (the motion sensors and the magnetometer), DeviceSensorReading.FromUncalibratedMagnetometer, DeviceSensorReading.FromIlluminance, DeviceSensorReading.FromProximity or DeviceSensorReading.FromEulerAngles (the orientation sensors). The documents see the values quantized as the specifications require (e.g. the accelerations rounded to 0.1 m/s², the illuminance to 50 lux).

public sealed class DeviceSensorReading

Properties

NameDescription
AlphaGets the rotation around the Z axis in degrees, in [0, 360) (orientation sensors), or null.
BetaGets the rotation around the X axis in degrees, in [-180, 180) (orientation sensors), or null.
DistanceGets the distance to the closest object in cm (proximity sensor), or null.
GammaGets the rotation around the Y axis in degrees, in [-90, 90) (orientation sensors), or null.
IlluminanceGets the illuminance in lux (ambient light sensor), or null.
MaxGets the maximum sensing range in cm (proximity sensor), or null.
NearGets whether an object is near (proximity sensor), or null.
XGets the value along the X axis (the acceleration, the angular velocity or the magnetic field), or null.
XBiasGets the hard iron distortion correction along the X axis (uncalibrated magnetometer), or null.
YGets the value along the Y axis, or null.
YBiasGets the hard iron distortion correction along the Y axis (uncalibrated magnetometer), or null.
ZGets the value along the Z axis, or null.
ZBiasGets the hard iron distortion correction along the Z axis (uncalibrated magnetometer), or null.

Gets the rotation around the Z axis in degrees, in [0, 360) (orientation sensors), or null.

public double? Alpha { get; }

Property value

double?

Gets the rotation around the X axis in degrees, in [-180, 180) (orientation sensors), or null.

public double? Beta { get; }

Property value

double?

Gets the distance to the closest object in cm (proximity sensor), or null.

public double? Distance { get; }

Property value

double?

Gets the rotation around the Y axis in degrees, in [-90, 90) (orientation sensors), or null.

public double? Gamma { get; }

Property value

double?

Gets the illuminance in lux (ambient light sensor), or null.

public double? Illuminance { get; }

Property value

double?

Gets the maximum sensing range in cm (proximity sensor), or null.

public double? Max { get; }

Property value

double?

Gets whether an object is near (proximity sensor), or null.

public bool? Near { get; }

Property value

bool?

Gets the value along the X axis (the acceleration, the angular velocity or the magnetic field), or null.

public double? X { get; }

Property value

double?

Gets the hard iron distortion correction along the X axis (uncalibrated magnetometer), or null.

public double? XBias { get; }

Property value

double?

Gets the value along the Y axis, or null.

public double? Y { get; }

Property value

double?

Gets the hard iron distortion correction along the Y axis (uncalibrated magnetometer), or null.

public double? YBias { get; }

Property value

double?

Gets the value along the Z axis, or null.

public double? Z { get; }

Property value

double?

Gets the hard iron distortion correction along the Z axis (uncalibrated magnetometer), or null.

public double? ZBias { get; }

Property value

double?

Methods

NameDescription
FromEulerAngles(double, double, double)Creates a reading of an orientation sensor (https://w3c.github.io/deviceorientation/#parse-orientation-data-reading), as intrinsic Tait-Bryan angles Z - X' - Y'' in degrees.
FromIlluminance(double)Creates a reading of the ambient light sensor (https://w3c.github.io/ambient-light/#ambient-light-reading-parsing-algorithm), in lux.
FromProximity(double, double, bool)Creates a reading of the proximity sensor (https://w3c.github.io/proximity/#proximity-reading-parsing-algorithm), in cm.
FromUncalibratedMagnetometer(double, double, double, double, double, double)Creates a reading of the uncalibrated magnetometer (https://w3c.github.io/magnetometer/#uncalibrated-magnetometer-reading-parsing-algorithm), in µT.
FromXyz(double, double, double)Creates a reading of three values along the axes (https://w3c.github.io/sensors/#parse-xyz-reading): the acceleration in m/s² (accelerometer, linear acceleration, gravity), the angular velocity in rad/s (gyroscope), or the magnetic field in µT (magnetometer).

FromEulerAngles(double, double, double)

DeviceSensorProvider.cs

Creates a reading of an orientation sensor (https://w3c.github.io/deviceorientation/#parse-orientation-data-reading), as intrinsic Tait-Bryan angles Z - X' - Y'' in degrees.

public static DeviceSensorReading FromEulerAngles(double alpha, double beta, double gamma)

Parameters

alpha double
The rotation around the Z axis, in [0, 360).
beta double
The rotation around the X' axis, in [-180, 180).
gamma double
The rotation around the Y'' axis, in [-90, 90).

Returns

DeviceSensorReading

FromIlluminance(double)

DeviceSensorProvider.cs

Creates a reading of the ambient light sensor (https://w3c.github.io/ambient-light/#ambient-light-reading-parsing-algorithm), in lux.

public static DeviceSensorReading FromIlluminance(double illuminance)

Parameters

illuminance double

Returns

DeviceSensorReading

FromProximity(double, double, bool)

DeviceSensorProvider.cs

Creates a reading of the proximity sensor (https://w3c.github.io/proximity/#proximity-reading-parsing-algorithm), in cm.

public static DeviceSensorReading FromProximity(double distance, double max, bool near)

Parameters

distance double
max double
near bool

Returns

DeviceSensorReading

FromUncalibratedMagnetometer(double, double, double, double, double, double)

DeviceSensorProvider.cs

Creates a reading of the uncalibrated magnetometer (https://w3c.github.io/magnetometer/#uncalibrated-magnetometer-reading-parsing-algorithm), in µT.

public static DeviceSensorReading FromUncalibratedMagnetometer(double x, double y, double z, double xBias, double yBias, double zBias)

Parameters

x double
y double
z double
xBias double
yBias double
zBias double

Returns

DeviceSensorReading

FromXyz(double, double, double)

DeviceSensorProvider.cs

Creates a reading of three values along the axes (https://w3c.github.io/sensors/#parse-xyz-reading): the acceleration in m/s² (accelerometer, linear acceleration, gravity), the angular velocity in rad/s (gyroscope), or the magnetic field in µT (magnetometer).

public static DeviceSensorReading FromXyz(double x, double y, double z)