diff --git a/android/aware-core/src/main/java/com/aware/Rotation.java b/android/aware-core/src/main/java/com/aware/Rotation.java index 6c98f78..e14ba38 100644 --- a/android/aware-core/src/main/java/com/aware/Rotation.java +++ b/android/aware-core/src/main/java/com/aware/Rotation.java @@ -148,17 +148,18 @@ public void run() { return; } // Otherwise, reduce queue w/ average filter. - else if (event.values.length == 3){ + else if (event.values.length == 4){ // Retrieve number of item in queue in order to calculate average long count = _avgQueue.size(); // Calculate total. - float[] acc = new float[]{0.f, 0.f, 0.f}; + float[] acc = new float[]{0.f, 0.f, 0.f, 0.f}; float[] curr = (float[]) _avgQueue.poll(); do { acc[0] += curr[0]; acc[1] += curr[1]; acc[2] += curr[2]; + acc[3] += curr[3]; curr = (float[]) _avgQueue.poll(); } while (curr != null); @@ -166,21 +167,21 @@ else if (event.values.length == 3){ mean = new float[]{ acc[0] / count, acc[1] / count, - acc[2] / count + acc[2] / count, + acc[3] / count, }; } - else if (event.values.length == 4){ + else { // Retrieve number of item in queue in order to calculate average long count = _avgQueue.size(); // Calculate total. - float[] acc = new float[]{0.f, 0.f, 0.f, 0.f}; + float[] acc = new float[]{0.f, 0.f, 0.f}; float[] curr = (float[]) _avgQueue.poll(); do { acc[0] += curr[0]; acc[1] += curr[1]; acc[2] += curr[2]; - acc[3] += curr[3]; curr = (float[]) _avgQueue.poll(); } while (curr != null); @@ -188,8 +189,7 @@ else if (event.values.length == 4){ mean = new float[]{ acc[0] / count, acc[1] / count, - acc[2] / count, - acc[3] / count, + acc[2] / count }; }