public AndroidLightProbe() { _lightListener = new AndroidSensorListener(SensorType.Light, SensorDelay.Normal, null, e => { StoreDatum(new LightDatum(DateTimeOffset.UtcNow, e.Values[0])); }); }
public AndroidAccelerometerProbe() { _gravity = new float[3]; _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, SensorDelay.Normal, null, async e => { // should get x, y, and z values if (e.Values.Count != 3) { return; } // http://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-accel float alpha = 0.8f; _gravity[0] = alpha * _gravity[0] + (1 - alpha) * e.Values[0]; _gravity[1] = alpha * _gravity[1] + (1 - alpha) * e.Values[1]; _gravity[2] = alpha * _gravity[2] + (1 - alpha) * e.Values[2]; // ignore values if the sensor is stabilizing -- do this here because _gravity is the variable that is stabilizing if (Stabilizing) { return; } float xAccel = e.Values[0] - _gravity[0]; float yAccel = e.Values[1] - _gravity[1]; float zAccel = e.Values[2] - _gravity[2]; await StoreDatumAsync(new AccelerometerDatum(DateTimeOffset.UtcNow, xAccel, yAccel, zAccel)); }); }
public AndroidAmbientTemperatureProbe() { _temperatureListener = new AndroidSensorListener(SensorType.AmbientTemperature, SensorDelay.Normal, null, e => { StoreDatum(new AmbientTemperatureDatum(DateTimeOffset.UtcNow, e.Values[0])); }); }
public AndroidCompassProbe() { _rMatrix = new float[9]; _iMatrix = new float[9]; _azimuthPitchRoll = new float[3]; _magneticFieldValues = new float[3]; _magnetometerListener = new AndroidSensorListener(SensorType.MagneticField, SensorDelay.Normal, null, e => { if (e.Values != null && e.Values.Count == 3) lock (_locker) { for (int i = 0; i < 3; i++) _magneticFieldValues[i] = e.Values[i]; StoreHeading(); } }); _accelerometerValues = new float[3]; _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, SensorDelay.Normal, null, e => { if (e.Values != null && e.Values.Count == 3) lock (_locker) { for (int i = 0; i < 3; i++) _accelerometerValues[i] = e.Values[i]; StoreHeading(); } }); }
public AndroidAccelerometerProbe() { _gravity = new float[3]; _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, SensorDelay.Normal, null, e => { if (e.Values.Count != 3) { return; } // http://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-accel float alpha = 0.8f; _gravity[0] = alpha * _gravity[0] + (1 - alpha) * e.Values[0]; _gravity[1] = alpha * _gravity[1] + (1 - alpha) * e.Values[1]; _gravity[2] = alpha * _gravity[2] + (1 - alpha) * e.Values[2]; float xAccel = e.Values[0] - _gravity[0]; float yAccel = e.Values[1] - _gravity[1]; float zAccel = e.Values[2] - _gravity[2]; StoreDatum(new AccelerometerDatum(DateTimeOffset.UtcNow, xAccel, yAccel, zAccel)); }); }
public AndroidPedometerProbe() { _pedometerListener = new AndroidSensorListener(SensorType.StepCounter, async e => { await StoreDatumAsync(new PedometerDatum(DateTimeOffset.UtcNow, e.Values[0])); }); }
public AndroidAmbientTemperatureProbe() { _temperatureListener = new AndroidSensorListener(SensorType.AmbientTemperature, SensorDelay.Normal, null, async e => { await StoreDatumAsync(new AmbientTemperatureDatum(DateTimeOffset.UtcNow, e.Values[0])); }); }
public AndroidAccelerometerProbe() { _gravity = new float[3]; _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, SensorDelay.Normal, null, e => { // should get x, y, and z values if (e.Values.Count != 3) return; // http://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-accel float alpha = 0.8f; _gravity[0] = alpha * _gravity[0] + (1 - alpha) * e.Values[0]; _gravity[1] = alpha * _gravity[1] + (1 - alpha) * e.Values[1]; _gravity[2] = alpha * _gravity[2] + (1 - alpha) * e.Values[2]; // ignore values if the sensor is stabilizing -- do this here because _gravity is the variable that is stabilizing if (_stabilizing) return; float xAccel = e.Values[0] - _gravity[0]; float yAccel = e.Values[1] - _gravity[1]; float zAccel = e.Values[2] - _gravity[2]; StoreDatum(new AccelerometerDatum(DateTimeOffset.UtcNow, xAccel, yAccel, zAccel)); }); }
public AndroidAttitudeProbe() { _attitudeListener = new AndroidSensorListener(SensorType.RotationVector, async e => { // should get x, y,z, w values await StoreDatumAsync(new AttitudeDatum(DateTimeOffset.UtcNow, e.Values[0], e.Values[1], e.Values[2], e.Values[3])); }); }
public AndroidGyroscopeProbe() { _gyroscopeListener = new AndroidSensorListener(SensorType.Gyroscope, async e => { if (e.Values.Count >= 3) { await StoreDatumAsync(new GyroscopeDatum(DateTimeOffset.UtcNow, e.Values[0], e.Values[1], e.Values[2])); } }); }
public AndroidMagnetometerProbe() { _magnetometerListener = new AndroidSensorListener(SensorType.MagneticField, async e => { // should get geomagnetic strength along x, y, and z values if (e.Values.Count != 3) { return; } await StoreDatumAsync(new MagnetometerDatum(DateTimeOffset.UtcNow, e.Values[0], e.Values[1], e.Values[2])); }); }
public AndroidAltitudeProbe() { _altitudeListener = new AndroidSensorListener(SensorType.Pressure, SensorDelay.Normal, null, async e => { // http://www.srh.noaa.gov/images/epz/wxcalc/pressureAltitude.pdf double hPa = e.Values[0]; double stdPressure = 1013.25; double altitude = (1 - Math.Pow((hPa / stdPressure), 0.190284)) * 145366.45; await StoreDatumAsync(new AltitudeDatum(DateTimeOffset.UtcNow, -1, altitude)); }); }
public AndroidAltitudeProbe() { _altitudeListener = new AndroidSensorListener(SensorType.Pressure, SensorDelay.Normal, null, e => { // http://www.srh.noaa.gov/images/epz/wxcalc/pressureAltitude.pdf double hPa = e.Values[0]; double stdPressure = 1013.25; double altitude = (1 - Math.Pow((hPa / stdPressure), 0.190284)) * 145366.45; StoreDatum(new AltitudeDatum(DateTimeOffset.UtcNow, -1, altitude)); }); }
public AndroidLinearAccelerationProbe() { _linearaccelerationListener = new AndroidSensorListener(SensorType.LinearAcceleration, async e => { // should get x, y, and z values if (e.Values.Count != 3) { return; } await StoreDatumAsync(new LinearAccelerationDatum(DateTimeOffset.UtcNow, e.Values[0], e.Values[1], e.Values[2])); }); }
public AndroidAmbientTemperatureProbe() { _temperatureListener = new AndroidSensorListener(SensorType.AmbientTemperature, async e => { // looks like it's very risky to use e.Timestamp as the basis for timestamping our Datum objects. depending on the phone // manufacturer and android version, e.Timestamp will be set relative to different anchors. this makes it impossible to // compare data across sensors, phones, and android versions. using DateTimeOffset.UtcNow will cause imprecision due to // latencies between reading time and execution time of the following line of code; however, these will be small under // most conditions. one exception is when the listening probe lets the device sleep. in this case readings will be paused // until the cpu wakes up, at which time any cached readings will be delivered in bulk to sensus. each of these readings // will be timestamped with similar times by the following line of code, when in reality they originated much earlier. this // will only happen when all listening probes are configured to allow the device to sleep. await StoreDatumAsync(new AmbientTemperatureDatum(DateTimeOffset.UtcNow, e.Values[0])); }); }
public AndroidCompassProbe() { _magneticFieldValues = new float[3]; _magnetometerListener = new AndroidSensorListener(SensorType.MagneticField, null, e => { if (e.Values != null && e.Values.Count == 3) { StoreHeading(magneticFieldValues: e.Values.ToArray()); } }); _accelerometerValues = new float[3]; _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, null, e => { if (e.Values != null && e.Values.Count == 3) { StoreHeading(accelerometerValues: e.Values.ToArray()); } }); }
public AndroidAltitudeProbe() { _altitudeListener = new AndroidSensorListener(SensorType.Pressure, null, e => { // http://www.srh.noaa.gov/images/epz/wxcalc/pressureAltitude.pdf double hPa = e.Values[0]; double stdPressure = 1013.25; double altitude = (1 - Math.Pow((hPa / stdPressure), 0.190284)) * 145366.45; // looks like it's very risky to use e.Timestamp as the basis for timestamping our Datum objects. depending on the phone // manufacturer and android version, e.Timestamp will be set relative to different anchors. this makes it impossible to // compare data across sensors, phones, and android versions. using DateTimeOffset.UtcNow will cause imprecision due to // latencies between reading time and execution time of the following line of code; however, these will be small under // most conditions. one exception is when the listening probe lets the device sleep. in this case readings will be paused // until the cpu wakes up, at which time any cached readings will be delivered in bulk to sensus. each of these readings // will be timestamped with similar times by the following line of code, when in reality they originated much earlier. this // will only happen when all listening probes are configured to allow the device to sleep. StoreDatum(new AltitudeDatum(DateTimeOffset.UtcNow, -1, altitude)); }); }
public AndroidCompassProbe() { _magneticFieldValues = new float[3]; _magnetometerListener = new AndroidSensorListener(SensorType.MagneticField, SensorDelay.Normal, null, async e => { if (e.Values != null && e.Values.Count == 3) { await StoreHeadingAsync(magneticFieldValues: e.Values.ToArray()); } }); _accelerometerValues = new float[3]; _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, SensorDelay.Normal, null, async e => { if (e.Values != null && e.Values.Count == 3) { await StoreHeadingAsync(accelerometerValues: e.Values.ToArray()); } }); }
public AndroidProximityProbe() { _proximityListener = new AndroidSensorListener(SensorType.Proximity, async e => { // looks like it's very risky to use e.Timestamp as the basis for timestamping our Datum objects. depending on the phone // manufacturer and android version, e.Timestamp will be set relative to different anchors. this makes it impossible to // compare data across sensors, phones, and android versions. using DateTimeOffset.UtcNow will cause imprecision due to // latencies between reading time and execution time of the following line of code; however, these will be small under // most conditions. one exception is when the listening probe lets the device sleep. in this case readings will be paused // until the cpu wakes up, at which time any cached readings will be delivered in bulk to sensus. each of these readings // will be timestamped with similar times by the following line of code, when in reality they originated much earlier. this // will only happen when all listening probes are configured to allow the device to sleep. // from https://developer.android.com/guide/topics/sensors/sensors_position // Note: Some proximity sensors return binary values that represent "near" or "far." In this case, the sensor usually reports // its maximum range value in the far state and a lesser value in the near state. Typically, the far value is a value > 5 cm, // but this can vary from sensor to sensor. You can determine a sensor's maximum range by using the getMaximumRange() method. await StoreDatumAsync(new ProximityDatum(DateTimeOffset.UtcNow, e.Values[0], _maximumRange)); }); }
public AndroidCompassProbe() { _rMatrix = new float[9]; _iMatrix = new float[9]; _azimuthPitchRoll = new float[3]; _magneticFieldValues = new float[3]; _magnetometerListener = new AndroidSensorListener(SensorType.MagneticField, SensorDelay.Normal, null, e => { if (e.Values != null && e.Values.Count == 3) { lock (_locker) { for (int i = 0; i < 3; i++) { _magneticFieldValues[i] = e.Values[i]; } StoreHeading(); } } }); _accelerometerValues = new float[3]; _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, SensorDelay.Normal, null, e => { if (e.Values != null && e.Values.Count == 3) { lock (_locker) { for (int i = 0; i < 3; i++) { _accelerometerValues[i] = e.Values[i]; } StoreHeading(); } } }); }
public AndroidAccelerometerProbe() { _accelerometerListener = new AndroidSensorListener(SensorType.Accelerometer, null, async e => { // should get x, y, and z values if (e.Values.Count != 3 || Stabilizing) { return; } // looks like it's very risky to use e.Timestamp as the basis for timestamping our Datum objects. depending on the phone // manufacturer and android version, e.Timestamp will be set relative to different anchors. this makes it impossible to // compare data across sensors, phones, and android versions. using DateTimeOffset.UtcNow will cause imprecision due to // latencies between reading time and execution time of the following line of code; however, these will be small under // most conditions. one exception is when the listening probe lets the device sleep. in this case readings will be paused // until the cpu wakes up, at which time any cached readings will be delivered in bulk to sensus. each of these readings // will be timestamped with similar times by the following line of code, when in reality they originated much earlier. this // will only happen when all listening probes are configured to allow the device to sleep. // more detail here: https://github.com/predictive-technology-laboratory/sensus/wiki/Listening-Probe#configuration await StoreDatumAsync(new AccelerometerDatum(DateTimeOffset.UtcNow, e.Values[0] / GRAVITY, e.Values[1] / GRAVITY, e.Values[2] / GRAVITY)); }); }