Introduction
The java steptrigger example is extracted from the most popular open source projects, you can refer to the following example for usage.
Programming language: Java
Class/type: StepTrigger
Example#1File:
StepDetection.javaProject:
agi290/smartshop
/** This is called every INTERVAL_MS ms from the TimerTask. */
protected synchronized void updateData() {
// Get current time for time stamps
long now_ms = System.currentTimeMillis();
st.onTimerElapsed(now_ms, detector.getLastAcc(), new double[] {lastComp});
// Check if a step is detected upon data
if (detector.checkForStep()) {
// Call algorithm for navigation/updating position
st.onStepDetected(now_ms, lastComp);
}
}
Example#2File:
StepDetection.javaProject:
agi290/smartshop
@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
st.onAccelerometerDataReceived(
System.currentTimeMillis(), event.values[0], event.values[1], event.values[2]);
// just update the oldest z value
detector.addSensorValues(System.currentTimeMillis(), event.values);
break;
default:
} // switch (event.sensor.getType())
}
Example#3File:
StepDetection.javaProject:
agi290/smartshop
/* (non-Javadoc)
* @see at.fhstp.wificompass.CompassListener#onCompassChanged(float, java.lang.String)
*/
@Override
public void onCompassChanged(float azimuth, float angle, String direction) {
st.onCompassDataReceived(System.currentTimeMillis(), azimuth, 0, 0);
this.lastComp = azimuth;
}