From 17fe4df01a72ec103e452e683e7de95aa76590a6 Mon Sep 17 00:00:00 2001 From: DjBushido Date: Tue, 22 Apr 2014 18:46:09 -0400 Subject: [PATCH 1/2] Add the location found icon. --- .../res/drawable-xhdpi/ic_location_found.png | Bin 0 -> 6091 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 UNCCScavenger/res/drawable-xhdpi/ic_location_found.png diff --git a/UNCCScavenger/res/drawable-xhdpi/ic_location_found.png b/UNCCScavenger/res/drawable-xhdpi/ic_location_found.png new file mode 100644 index 0000000000000000000000000000000000000000..dfbbbc5888007d6f3a9bcc48cc65835c1a1e3746 GIT binary patch literal 6091 zcmV;+7c}UJP)69qpdjvH%!uw9!TzZM4xw8*Q}FMjLIk(MB6>Wwum3<_~}Qd@RUa zGb7<*_4Wzk0U7=s5E22y-guSQ8?N9HUEF-ffL@#|j^e26R(#HX`|`Wr#7A8AmW_60 zN&pYnfZ=c4BS%RHRv{vb@2TK8u7vOT2*LG@?{xWHf9pBOvfukVx)-C}!2H_J zb!R?!Bn52YWklvgoQXF?2X$ZgD?`Ylm<-;_ag2;zE&TmCr=T#Aea`%XKt^2&-k?qeje%s;2k#cH0ce}T`DiP@q0t5P0w5&Qqg?7Q z^T;#50AP;^NRN;)gic_t&?Ae`res_?Adewz=RxF3M9Cs#F*-43+H+v<{=S~k0g*jZ z&O?t06-oj`)RchHkgzSwfkqFsmK56wHP|F6C#?qO2?x*L_qt0p{u57rzn6s8LBz=J zBvH&G!5f4ydZ68|5y4yycUv6p8(=R-dh4J4*7N_-U;Pag9`^gZj+Z3K^ni+P-3e^; zKx?ur#7%u8Y{^s;>ZavD1h^B&R5wX$UVTHS~@3JHp!#Cq@_0ki`-kl+Lt#3M6B_a0#FaZZc zr*;;4S{D>&E<(m>M-MdGhuC8|`n`!@0>dQH2%yoHPpbXwZ^4ydhKP_Pj{q9&15b4r zk+$~U#vJG)Fy|=`zF6fIBMmCx8|bx;0NTV+-qP2ryxv?cXibS5ILwa#x^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R+gi=CTL3CFltHmos(Nb#511&3G56cayetcf`wpH*?7x_} z(Q9de{CXSJb_YOL4%IO+(m;qqP#0Pk9^_#o%=$od-@&tQQ(kg4hiM3yS ztl-)6hD*7?cWCH!jQ}dM!?+hMX)ha_U+Kly4{iEU0p}6>FN91-SH&I9c>+cvBKikD@f*Vp8ZajqJ_}@K5~cD=<#O8QC4t zGAM5zX++641#oKwd^NL)9@h0^)*s&*T=pvu&`adh~_R@S~i4ZPI`R zS`V}qX&nM-G4nizuq6Z7z#AL3#|IAt7fg)4mh1&ZT*%TFTFpJH7d@1Rh#N2M)wjWW zS~t`k6|Ez)Wd_@7rQUapx4PyWC=6p&Z&Wab8#(+siIb!dgXT4{p4xUVt9z0kJm0gH zQ$Hz1Q>okjP_8y`4Po4OmaV!q{&bMF9mFMPYCxp*mZ!QM`{s}I0T76;oa@=MPKTkd zGKr9Df$(FptpSj`qgprz?v8pU&~vGC{;!{W+e_g|J#C)cDVQF~{)^T@#d+ngNnW&r zE~P8ObY8^00|IiznI8ePArK8-C?d2bOsXyq^knUL*}wX>^~ls(9{B1Dl8ivt}?AR)8xD&&~`42z;Y@$N+2#b(ZSfeJx z=&quaHK3)3RTkJ5STO= Date: Thu, 24 Apr 2014 17:18:31 -0400 Subject: [PATCH 2/2] Add a moving average to the compass to smooth it out. --- .../edu/uncc/scavenger/CompassActivity.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java index 5e7007e..21223b2 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java @@ -11,6 +11,9 @@ package edu.uncc.scavenger; * stackoverflow.com/questions/5479753/using-orientation-sensor-to-point-towards-a-specific-location */ +import java.util.ArrayList; +import java.util.List; + import edu.uncc.scavenger.rest.RestLocation; import android.app.Activity; import android.content.Context; @@ -33,6 +36,7 @@ import android.widget.Toast; public class CompassActivity extends Activity implements SensorEventListener { final int SEARCH_PROXIMITY = 10; + final int MOVING_AVERAGE_SIZE = 10; ImageView compassRoseView, arrowView, searchImageView; Button backButton; SensorManager sManager; @@ -44,6 +48,7 @@ public class CompassActivity extends Activity implements SensorEventListener float[] gravity = new float[3]; float[] magneticField = new float[3]; float[] coordinates = new float[3]; + ArrayList rotationAverage = new ArrayList(MOVING_AVERAGE_SIZE); LocationManager locationManager; DirectionListener locationListener; Location searchLocation; @@ -160,10 +165,17 @@ public class CompassActivity extends Activity implements SensorEventListener float trueHeading = (float)(Math.toDegrees(compassValues[0]) + locationListener.getDeclination()); //Calculate bearing to search location float rotateArrow = (float) (trueHeading - locationListener.getBearing()); + // Take moving average of bearing to smooth it out + if (rotationAverage.size() == MOVING_AVERAGE_SIZE) { + rotationAverage.remove(0); + } + rotationAverage.add(rotateArrow); + float finalRotation = findAverage(rotationAverage); + //Rotate compass and arrow. Rotations must be opposite to counteract device movement compassRoseView.setRotation((long)(-1 * trueHeading)); - arrowView.setRotation((long)(-1 * rotateArrow)); + arrowView.setRotation((long)(-1 * finalRotation)); if(locationListener.getDistance() <= SEARCH_PROXIMITY) { @@ -184,4 +196,12 @@ public class CompassActivity extends Activity implements SensorEventListener // TODO Auto-generated method stub } + + private float findAverage(List list) { + float sum = 0.0f; + for (Float f : list) { + sum += f; + } + return sum / list.size(); + } }