Skip to content

Commit

Permalink
move microsecond conversion to Tools class
Browse files Browse the repository at this point in the history
  • Loading branch information
ruleant committed Apr 6, 2014
1 parent 3ef073a commit bfb174a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/java/com/github/ruleant/getback_gps/lib/GeoOrientation.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ public class GeoOrientation implements SensorEventListener {
*/
private static final long TIMESTAMP_EXPIRE = 5000 * Tools.MILLI_IN_NANO;

/**
* Microsecond to nanosecond conversion rate.
*/
private static final long MICRO_IN_NANO = 1000;

/**
* Sensor update rate in microseconds.
*/
Expand Down Expand Up @@ -159,7 +154,7 @@ public final void setAcceleration(final SensorEvent event) {
if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER
// reject values that arrive sooner than the update rate
|| (event.timestamp - mAccelerometerTimestamp)
< SENSOR_UPDATE_RATE * MICRO_IN_NANO) {
< SENSOR_UPDATE_RATE * Tools.MICRO_IN_NANO) {
return;
}
mAccelerometerValues
Expand All @@ -180,7 +175,7 @@ public final void setMagneticField(final SensorEvent event) {
if (event.sensor.getType() != Sensor.TYPE_MAGNETIC_FIELD
// reject values that arrive sooner than the update rate
|| (event.timestamp - mMagneticFieldTimestamp)
< SENSOR_UPDATE_RATE * MICRO_IN_NANO) {
< SENSOR_UPDATE_RATE * Tools.MICRO_IN_NANO) {
return;
}
mMagneticFieldValues
Expand All @@ -201,7 +196,7 @@ public final void setOrientation(final SensorEvent event) {
if (event.sensor.getType() != Sensor.TYPE_ORIENTATION
// reject values that arrive sooner than the update rate
|| (event.timestamp - mOrientationTimestamp)
< SENSOR_UPDATE_RATE * MICRO_IN_NANO) {
< SENSOR_UPDATE_RATE * Tools.MICRO_IN_NANO) {
return;
}
mOrientation = event.values[0];
Expand Down
5 changes: 5 additions & 0 deletions src/java/com/github/ruleant/getback_gps/lib/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public class Tools {
*/
public static final long MILLI_IN_NANO = 1000000;

/**
* Microsecond to nanosecond conversion rate.
*/
public static final long MICRO_IN_NANO = 1000;

/**
* Hidden constructor, to prevent instantiating.
*/
Expand Down

0 comments on commit bfb174a

Please sign in to comment.