Skip to content

Commit

Permalink
WristRotationDetector
Browse files Browse the repository at this point in the history
  • Loading branch information
kazhik committed Oct 21, 2016
1 parent 2593b85 commit ff99b17
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gambarumeterlib/gambarumeterlib.iml
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-24.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-base-9.6.1" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="support-v4-24.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-24.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-tasks-9.6.1" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-9.6.1" level="project" />
</component>
Expand Down
4 changes: 2 additions & 2 deletions mobile/mobile.iml
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@
<orderEntry type="library" exported="" name="design-24.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-9.6.1" level="project" />
<orderEntry type="module" module-name="gambarumeterlib" exported="" />
<orderEntry type="library" exported="" name="play-services-wearable-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="support-v4-24.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-24.0.0" level="project" />
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,23 @@ public void load(List<SplitTimeStepCount> splits) {
}
int laptime = (int) ((data.getTimestamp() - prevTimestamp) / 1000);
yLap.add(new Entry(laptime, x));
yHeartRate.add(new Entry(data.getHeartRate(), x));

prevStepCount = data.getStepCount();
prevTimestamp = data.getTimestamp();
}

LineDataSet hrSet = this.getDefaultLineDataSet(yHeartRate,
this.context.getString(R.string.heart_rate),
this.context.getString(R.string.chart_heart_rate),
Color.RED);

LineDataSet lapSet = this.getDefaultLineDataSet(yLap,
this.context.getString(R.string.lap),
this.context.getString(R.string.chart_time),
Color.GREEN);
lapSet.setValueFormatter(new LapTimeFormatter());

LineDataSet stepSet = this.getDefaultLineDataSet(ySteps,
this.context.getString(R.string.stepLabel),
this.context.getString(R.string.chart_steps),
Color.BLUE);

List<ILineDataSet> dataSets = new ArrayList<>();
Expand Down
6 changes: 3 additions & 3 deletions mobile/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<string name="delete">削除</string>
<string name="confirm_delete">本当に削除しますか?</string>

<string name="heart_rate">心拍数</string>
<string name="chart_heart_rate">心拍数</string>

<string name="distance">距離</string>
<string name="mobile_settings">モバイル設定</string>
<string name="wear_settings">ウェアラブル設定</string>
<string name="stepLabel">歩数</string>
<string name="lap">ラップ</string>
<string name="chart_steps">歩数</string>
<string name="chart_time">ラップ</string>
<string name="chart">グラフ</string>
<string name="map">地図</string>
<string name="split_time">スプリットタイム</string>
Expand Down
6 changes: 3 additions & 3 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<string name="action_settings">Settings</string>
<string name="action_about">About this app</string>

<string name="heart_rate">Heart rate</string>

<string name="delete">Delete</string>
<string name="confirm_delete">Do you really want to delete?</string>

<string name="bpm" translatable="false">bpm</string>
<string name="steps">steps</string>
<string name="lap">Lap</string>

<string name="stepLabel">steps</string>
<string name="chart_time">time</string>
<string name="chart_heart_rate">bpm</string>
<string name="chart_steps">steps</string>

<string name="distance">distance</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class WristRotationDetector {
private int interval = 1000;
private long prevTimestamp = 0;
private float prevValue = 0;
private int counter = 0;
private static final String TAG = "WristRotationDetector";

WristRotationDetector setThreshold(float threshold) {
Expand Down Expand Up @@ -60,9 +61,12 @@ boolean onSensorEvent(long timestamp, float[] newValues) {
(timestamp - this.prevTimestamp));
this.prevTimestamp = timestamp;
this.prevValue = maxValue;

// 2nd event, not opposite move
} else if (this.hasSameSign(maxValue, this.prevValue)) {
this.counter = 0;
// 2nd event, opposite move
} else if (!this.hasSameSign(maxValue, this.prevValue)) {
this.counter++;
// 3rd event, not opposite move
} else if (this.counter > 0) {
Log.d(TAG, "onSensorEvent:" +
newValues[0] + "/" +
newValues[1] + "/" +
Expand Down
20 changes: 10 additions & 10 deletions wear/wear.iml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
Expand All @@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
Expand Down Expand Up @@ -128,8 +128,8 @@
<orderEntry type="library" exported="" name="play-services-base-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-api-mockito-common-1.6.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javassist-3.20.0-GA" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-module-junit4-common-1.6.5" level="project" />
<orderEntry type="library" exported="" name="play-services-location-9.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" />
Expand Down Expand Up @@ -161,7 +161,7 @@
<orderEntry type="library" exported="" scope="TEST" name="powermock-module-junit4-1.6.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="powermock-core-1.6.5" level="project" />
<orderEntry type="module" module-name="gambarumeterlib" exported="" />
<orderEntry type="library" exported="" name="support-v4-24.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-24.0.0" level="project" />
</component>
</module>

0 comments on commit ff99b17

Please sign in to comment.