public void startSampling(final SensorEventListener listener) { samples.clear(); Sensor accelerometer = sensor.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); calibrationStartTime = System.currentTimeMillis(); sensor.registerListener(listener, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); }
private void updateSlidingWindow() { if (samples.size() == WINDOW_SIZE) { double min = Collections.min(samples); double max = Collections.max(samples); double mean = mean(samples); double stdDev = standardDeviation(samples); displayElapsedTime(); addInstance(min, max, mean, stdDev, activityLabel); saveInstances(); discardOverlap(); } }
public void onSensorChanged(final SensorEvent event) { samples.add(readSensorData(event)); updateSlidingWindow(); }
private void discardOverlap() { for (int i = 0; i < OVERLAP_SIZE; i++) { samples.removeFirst(); } }