Merge pull request #156 from OpenSeizureDetector/V4.2.x_3dData
Use 3d data to derive vector magnitudes if magnitude data not provided
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
OpenSeizureDetector Android App - Change Log
|
OpenSeizureDetector Android App - Change Log
|
||||||
============================================
|
============================================
|
||||||
|
|
||||||
|
V4.2.3c - Uses 3d accelerometer data to calculate magnitude if vector magnitude is not sent from data source.
|
||||||
V4.2.3b - fixed latched alarms (Issue #146)
|
V4.2.3b - fixed latched alarms (Issue #146)
|
||||||
V4.2.2 - Added support for PineTime OSD Status reporting.
|
V4.2.2 - Added support for PineTime OSD Status reporting.
|
||||||
V4.2.1 - Added support for PineTime wathes using the Bluetooth Data Source
|
V4.2.1 - Added support for PineTime wathes using the Bluetooth Data Source
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:versionCode="137"
|
android:versionCode="137"
|
||||||
android:versionName="4.2.3b">
|
android:versionName="4.2.3c">
|
||||||
<!-- android:allowBackup="false" -->
|
<!-- android:allowBackup="false" -->
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ public abstract class SdDataSource {
|
|||||||
String watchFwVersion;
|
String watchFwVersion;
|
||||||
String sdVersion;
|
String sdVersion;
|
||||||
String sdName;
|
String sdName;
|
||||||
|
boolean have3dData = false;
|
||||||
JSONArray accelVals = null;
|
JSONArray accelVals = null;
|
||||||
JSONArray accelVals3D = null;
|
JSONArray accelVals3D = null;
|
||||||
Log.v(TAG, "updateFromJSON - " + jsonStr);
|
Log.v(TAG, "updateFromJSON - " + jsonStr);
|
||||||
@@ -317,6 +318,28 @@ public abstract class SdDataSource {
|
|||||||
// if we get 'null' HR (For example if the heart rate is not working)
|
// if we get 'null' HR (For example if the heart rate is not working)
|
||||||
mMute = 0;
|
mMute = 0;
|
||||||
}
|
}
|
||||||
|
//Log.d(TAG,"accelVals[0]="+accelVals.getDouble(0)+", mSdData.rawData[0]="+mSdData.rawData[0]);
|
||||||
|
try {
|
||||||
|
accelVals3D = dataObject.getJSONArray("data3D");
|
||||||
|
Log.v(TAG, "Received " + accelVals3D.length() + " acceleration 3D values, rawData Length is " + mSdData.rawData3D.length);
|
||||||
|
if (accelVals3D.length() > mSdData.rawData3D.length) {
|
||||||
|
mUtil.writeToSysLogFile("ERROR: Received " + accelVals3D.length() + " 3D acceleration values, but rawData3D storage length is "
|
||||||
|
+ mSdData.rawData3D.length);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < accelVals3D.length(); i++) {
|
||||||
|
mSdData.rawData3D[i] = accelVals3D.getDouble(i);
|
||||||
|
}
|
||||||
|
have3dData = true;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// If we get an error, just set rawData3D to zero
|
||||||
|
Log.i(TAG, "updateFromJSON - error parsing 3D data - setting it to zero");
|
||||||
|
for (int i = 0; i < mSdData.rawData3D.length; i++) {
|
||||||
|
mSdData.rawData3D[i] = 0.;
|
||||||
|
}
|
||||||
|
have3dData = false;
|
||||||
|
}
|
||||||
|
// Try to read the vector magnitude data from the JSON string.
|
||||||
|
try {
|
||||||
accelVals = dataObject.getJSONArray("data");
|
accelVals = dataObject.getJSONArray("data");
|
||||||
Log.v(TAG, "Received " + accelVals.length() + " acceleration values, rawData Length is " + mSdData.rawData.length);
|
Log.v(TAG, "Received " + accelVals.length() + " acceleration values, rawData Length is " + mSdData.rawData.length);
|
||||||
if (accelVals.length() > mSdData.rawData.length) {
|
if (accelVals.length() > mSdData.rawData.length) {
|
||||||
@@ -328,25 +351,32 @@ public abstract class SdDataSource {
|
|||||||
mSdData.rawData[i] = accelVals.getDouble(i);
|
mSdData.rawData[i] = accelVals.getDouble(i);
|
||||||
}
|
}
|
||||||
mSdData.mNsamp = accelVals.length();
|
mSdData.mNsamp = accelVals.length();
|
||||||
//Log.d(TAG,"accelVals[0]="+accelVals.getDouble(0)+", mSdData.rawData[0]="+mSdData.rawData[0]);
|
|
||||||
try {
|
|
||||||
accelVals3D = dataObject.getJSONArray("data3D");
|
|
||||||
Log.v(TAG, "Received " + accelVals3D.length() + " acceleration 3D values, rawData Length is " + mSdData.rawData3D.length);
|
|
||||||
if (accelVals3D.length() > mSdData.rawData3D.length) {
|
|
||||||
mUtil.writeToSysLogFile("ERROR: Received " + accelVals3D.length() + " 3D acceleration values, but rawData3D storage length is "
|
|
||||||
+ mSdData.rawData3D.length);
|
|
||||||
}
|
|
||||||
for (i = 0; i < accelVals3D.length(); i++) {
|
|
||||||
mSdData.rawData3D[i] = accelVals3D.getDouble(i);
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
// If we get an error, just set rawData3D to zero
|
// If we do not have vector magnitude data, calculate it from the 3d data.
|
||||||
Log.i(TAG, "updateFromJSON - error parsing 3D data - setting it to zero");
|
if (have3dData) {
|
||||||
for (i = 0; i < mSdData.rawData3D.length; i++) {
|
Log.i(TAG,"Deriving Vector Magnitudes from 3d accelerometer data");
|
||||||
mSdData.rawData3D[i] = 0.;
|
int i;
|
||||||
|
for (i = 0; i < 125; i++) {
|
||||||
|
double x, y, z;
|
||||||
|
x = mSdData.rawData3D[i*3 + 0];
|
||||||
|
y = mSdData.rawData3D[i*3 + 1];
|
||||||
|
z = mSdData.rawData3D[i*3 + 2];
|
||||||
|
mSdData.rawData[i] = Math.sqrt(x*x + y*y + z*z);
|
||||||
|
}
|
||||||
|
mSdData.mNsamp = 125;
|
||||||
|
} else {
|
||||||
|
// If we do not have vector magnitude or 3d data, set the vector magnitude array to zero.
|
||||||
|
Log.e(TAG, "ERROR - no accelerometer data received - setting it to zero");
|
||||||
|
int i;
|
||||||
|
// FIXME - assumed fixed length of array!!
|
||||||
|
for (i = 0; i < 125; i++) {
|
||||||
|
mSdData.rawData[i] = 0.0;
|
||||||
|
}
|
||||||
|
mSdData.mNsamp = 125;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mWatchAppRunningCheck = true;
|
mWatchAppRunningCheck = true;
|
||||||
doAnalysis();
|
doAnalysis();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user