Skip to content
Browse files

keep track of last time I asked for stats, if no new samples have bee…

…n added, then I don't need to recalculate the stats.
  • Loading branch information...
1 parent be15e96 commit 6364e2c1c459afa4d34cb7ba9e0d05a367250157 Marije Baalman committed Feb 16, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 app/src/com/steim/nescivi/android/gvb/SensorListener.java
View
11 app/src/com/steim/nescivi/android/gvb/SensorListener.java
@@ -33,6 +33,8 @@
private int mWindow;
private int mDim;
+ private int mLastElementStats;
+
private float [] currentValues = {(float) 0.0, (float) 0.0, (float) 0.0};
private float [][] currentStats = { {(float) 0.0, (float) 0.0, (float) 0.0}, {(float) 0.0, (float) 0.0, (float) 0.0} };
@@ -138,9 +140,14 @@ public void storeValues(float readings[]) {
float [][] getCurrentStats(){
float [][] curStats;
+ int lastEle;
synchronized (this){
- this.currentStats = mBuffer.getStats();
- curStats = this.currentStats;
+ lastEle = mBuffer.getLastElement();
+ if ( lastEle != mLastElementStats ){
+ this.currentStats = mBuffer.getStats();
+ }
+ mLastElementStats = lastEle;
+ curStats = this.currentStats;
}
return curStats;
}

0 comments on commit 6364e2c

Please sign in to comment.
Something went wrong with that request. Please try again.