 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
ArcaneKnite Grandmaster Cheater Supreme
Reputation: 2
Joined: 16 Feb 2007 Posts: 1519
|
Posted: Sat Feb 16, 2013 5:08 pm Post subject: How do you make Android wait? |
|
|
I'm trying to make a pedometer application with Android using only the accelerometer to gather data. I gathered a lot of raw data from the phone and found certain patterns to constituted a step from my gait and created 3 booleans to model how one step would look like to an accelerometer.
| Code: | public boolean beforeStep(float y)
{
if(y > 1.5 && y < 3){
return true;
}
else
{
return false;
}
}
public boolean duringStep(float y)
{
if(y > 3 && y < 5){
return true;
}
else
{
return false;
}
}
public boolean afterStep(float y)
{
if(y > 1.5 && y < 3){
return true;
}
else
{
return false;
}
} |
I tried implementing the booleans in my onSensorChanged() method like so:
| Code: | if(beforeStep(accel)){
if(duringStep(accel)){
if(afterStep(accel)){
stepCount++;
}
}
} |
but I realized that this meant that the same acceleration value was being passed into all three booleans, and as such, the program would never recognize that a single step had been taken.
How do you make android wait, say 10ms, between each boolean to allow the sensor to update it's value? Also if there is a better way to go about counting steps with acceleration data, please let me know.
|
|
| Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Sun Feb 17, 2013 11:14 pm Post subject: |
|
|
Thread.sleep, Java is Java is Java.
You're using the word boolean, but your code is measuring something with three states. You're asking about timing, which can certainly be done, but it isn't going to fix your problem. When you have a problem with your code, adding complexity is generally the worst way to troubleshoot.
One algorithm you might consider is to retain the last value and compute the rate of change. If the derivative changes sign then you've switched from upstep to downstep or vice versa (taken a half-step). You may want to add en epsilon of measurement error, depending on the sensitivity of your device and also perhaps a sanity check that the apex was in the normal range for your stride.
Without seeing more of your code, I can't really offer any other suggestions.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|