Skip to content

Commit 6651a10

Browse files
author
xf
committed
完成计步算法更换
1 parent 2ddcf48 commit 6651a10

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/src/main/java/com/base/basepedo/service/StepDcretor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class StepDcretor implements SensorEventListener {
4141
//上次传感器的值
4242
float gravityOld = 0;
4343
//动态阈值需要动态的数据,这个值用于这些动态数据的阈值
44-
final float initialValue = (float) 1.8;
44+
final float initialValue = (float) 1.7;
4545
//初始阈值
4646
float ThreadValue = (float) 2.0;
4747

@@ -257,10 +257,10 @@ public void DetectorNewStep(float values) {
257257
if (DetectorPeak(values, gravityOld)) {
258258
timeOfLastPeak = timeOfThisPeak;
259259
timeOfNow = System.currentTimeMillis();
260-
if (timeOfNow - timeOfLastPeak >= 250
260+
if (timeOfNow - timeOfLastPeak >= 200
261261
&& (peakOfWave - valleyOfWave >= ThreadValue) && timeOfNow - timeOfLastPeak <= 2000) {
262262
timeOfThisPeak = timeOfNow;
263-
/*
263+
/*
264264
* 更新界面的处理,不涉及到算法
265265
* 一般在通知更新界面之前,增加下面处理,为了处理无效运动:
266266
* 1.连续记录10才开始计步
@@ -270,7 +270,7 @@ public void DetectorNewStep(float values) {
270270

271271
preStep();
272272
}
273-
if (timeOfNow - timeOfLastPeak >= 250
273+
if (timeOfNow - timeOfLastPeak >= 200
274274
&& (peakOfWave - valleyOfWave >= initialValue)) {
275275
timeOfThisPeak = timeOfNow;
276276
ThreadValue = Peak_Valley_Thread(peakOfWave - valleyOfWave);
@@ -303,7 +303,7 @@ public boolean DetectorPeak(float newValue, float oldValue) {
303303
}
304304

305305
if (!isDirectionUp && lastStatus
306-
&& (continueUpFormerCount >= 2 || oldValue >= 15)) {
306+
&& (continueUpFormerCount >= 2 && oldValue >= 11.76 && oldValue < 19.6)) {
307307
peakOfWave = oldValue;
308308
return true;
309309
} else if (!lastStatus && isDirectionUp) {

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
8+
classpath 'com.android.tools.build:gradle:2.0.0-alpha7'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

0 commit comments

Comments
 (0)