Android accelerometer values return back to zero, causing problems -


here's code:

      float x;        @override       public void onsensorchanged(sensorevent event) {      if(event.values[0] > .2){         x = -1*(math.round(event.values[0]));                    centerx = centerx +(x*10);     }      else if(event.values[0] < -.2){         x =  -1*math.round(event.values[0]);         centerx = centerx +(x*10);     }     mcustomdrawableview.invalidate();        y = math.round(event.values[1]);      if(event.values[2] > .4){         z = event.values[2];         }     } 

i'm using accelerometer move vertical line , forth. centerx top , bottom point of vertical line. i'm trying make if move device right, line move left , it's still in same position, if in physical world (think of augmented reality).

i'm using values given out of sensorevent arithmetic move center line. problem accelerometer values go when move advice 5, decrease 4 3 2 1 0 stop moving. so, line kind of bounces side , returns original center. i'm looking way rid of "bounce," , have line stay in it's new position. ideas?


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -