Added settings for watch debug mode and to switch the spectrum display on the watch off to save processor power.
This commit is contained in:
Binary file not shown.
@@ -113,6 +113,8 @@ public class SdDataSourcePebble extends SdDataSource {
|
||||
private int KEY_SAMPLE_FREQ = 29;
|
||||
private int KEY_RAW_DATA = 30;
|
||||
private int KEY_NUM_RAW_DATA = 31;
|
||||
private int KEY_DEBUG = 32;
|
||||
private int KEY_DISPLAY_SPECTRUM = 33;
|
||||
|
||||
// Values of the KEY_DATA_TYPE entry in a message
|
||||
private int DATA_TYPE_RESULTS = 1; // Analysis Results
|
||||
@@ -125,6 +127,8 @@ public class SdDataSourcePebble extends SdDataSource {
|
||||
private int SD_MODE_RAW = 1; // Send raw, unprocessed data to the phone.
|
||||
private int SD_MODE_FILTER = 2; // Use digital filter rather than FFT.
|
||||
|
||||
private short mDebug;
|
||||
private short mDisplaySpectrum;
|
||||
private short mDataUpdatePeriod;
|
||||
private short mMutePeriod;
|
||||
private short mManAlarmPeriod;
|
||||
@@ -265,6 +269,14 @@ public class SdDataSourcePebble extends SdDataSource {
|
||||
// Watch Settings
|
||||
String prefStr;
|
||||
|
||||
prefStr = SP.getString("PebbleDebug", "SET_FROM_XML");
|
||||
mDebug = (short) Integer.parseInt(prefStr);
|
||||
Log.v(TAG, "updatePrefs() Debug = " + mDebug);
|
||||
|
||||
prefStr = SP.getString("PebbleDisplaySpectrum", "SET_FROM_XML");
|
||||
mDisplaySpectrum = (short) Integer.parseInt(prefStr);
|
||||
Log.v(TAG, "updatePrefs() DisplaySpectrum = " + mDisplaySpectrum);
|
||||
|
||||
prefStr = SP.getString("PebbleUpdatePeriod", "SET_FROM_XML");
|
||||
mDataUpdatePeriod = (short) Integer.parseInt(prefStr);
|
||||
Log.v(TAG, "updatePrefs() DataUpdatePeriod = " + mDataUpdatePeriod);
|
||||
@@ -406,13 +418,14 @@ public class SdDataSourcePebble extends SdDataSource {
|
||||
numSamples = data.getUnsignedIntegerAsLong(KEY_NUM_RAW_DATA);
|
||||
Log.v(TAG, "numSamples = " + numSamples);
|
||||
byte[] rawDataBytes = data.getBytes(KEY_RAW_DATA);
|
||||
for (int i = 0; i < rawDataBytes.length - 6; i += 6) { // 6 bytes per sample
|
||||
int x = (rawDataBytes[i+0] & 0xff) | (rawDataBytes[i+1] << 8);
|
||||
int y = (rawDataBytes[i+2] & 0xff) | (rawDataBytes[i+3] << 8);
|
||||
int z = (rawDataBytes[i+4] & 0xff) | (rawDataBytes[i+5] << 8);
|
||||
Log.v(TAG,"x="+x+", y="+y+", z="+z);
|
||||
for (int i = 0; i < rawDataBytes.length - 4; i += 4) { // 4 bytes per sample
|
||||
int x = (rawDataBytes[i]);
|
||||
//int y = (rawDataBytes[i+2] & 0xff) | (rawDataBytes[i+3] << 8);
|
||||
//int z = (rawDataBytes[i+4] & 0xff) | (rawDataBytes[i+5] << 8);
|
||||
//Log.v(TAG,"x="+x+", y="+y+", z="+z);
|
||||
Log.v(TAG,"x="+x);
|
||||
if (nRawData < MAX_RAW_DATA) {
|
||||
rawData[nRawData] = (int)Math.sqrt(x*x+y*y+z*z);
|
||||
rawData[nRawData] = (int)Math.sqrt(x);
|
||||
} else {
|
||||
Log.i(TAG, "WARNING - rawData Buffer Full");
|
||||
}
|
||||
@@ -495,6 +508,8 @@ public class SdDataSourcePebble extends SdDataSource {
|
||||
Log.v(TAG, "sendPebblSdSettings() - preparing settings dictionary.. mSampleFreq=" + mSampleFreq);
|
||||
// Watch Settings
|
||||
final PebbleDictionary setDict = new PebbleDictionary();
|
||||
setDict.addInt16(KEY_DEBUG, mDebug);
|
||||
setDict.addInt16(KEY_DISPLAY_SPECTRUM, mDisplaySpectrum);
|
||||
setDict.addInt16(KEY_DATA_UPDATE_PERIOD, mDataUpdatePeriod);
|
||||
setDict.addInt16(KEY_MUTE_PERIOD, mMutePeriod);
|
||||
setDict.addInt16(KEY_MAN_ALARM_PERIOD, mManAlarmPeriod);
|
||||
|
||||
46
app/src/main/res/values/pebble_datasource_values.xml
Normal file
46
app/src/main/res/values/pebble_datasource_values.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Arrays used to produce list selections in pebble_datasource_prefs.xml -->
|
||||
<resources>
|
||||
<string-array name="pebble_debug_list">
|
||||
<item>"Debug OFF"</item>
|
||||
<item>"Debug ON"</item>
|
||||
</string-array>
|
||||
<string-array name="pebble_debug_values">
|
||||
<item>"0"</item>
|
||||
<item>"1"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pebble_display_spectrum_list">
|
||||
<item>"Spectrum Display OFF"</item>
|
||||
<item>"Spectrum Display ON"</item>
|
||||
</string-array>
|
||||
<string-array name="pebble_display_spectrum_values">
|
||||
<item>"0"</item>
|
||||
<item>"1"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pebble_sd_mode_list">
|
||||
<item>"Normal - OpenSeizureDetector FFT"</item>
|
||||
<item>"Raw"</item>
|
||||
<item>"Digital Filter"</item>
|
||||
</string-array>
|
||||
<string-array name="pebble_sd_mode_list_values">
|
||||
<item>"0"</item>
|
||||
<item>"1"</item>
|
||||
<item>"2"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pebble_sample_freq_list">
|
||||
<item>"100 Hz"</item>
|
||||
<item>"50 Hz"</item>
|
||||
<item>"25 Hz"</item>
|
||||
<item>"10 Hz"</item>
|
||||
</string-array>
|
||||
<string-array name="pebble_sample_freq_list_values">
|
||||
<item>"100"</item>
|
||||
<item>"50"</item>
|
||||
<item>"25"</item>
|
||||
<item>"10"</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="pebble_sample_freq_list">
|
||||
<item>"100 Hz"</item>
|
||||
<item>"50 Hz"</item>
|
||||
<item>"25 Hz"</item>
|
||||
<item>"10 Hz"</item>
|
||||
</string-array>
|
||||
<string-array name="pebble_sample_freq_list_values">
|
||||
<item>"100"</item>
|
||||
<item>"50"</item>
|
||||
<item>"25"</item>
|
||||
<item>"10"</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="pebble_sd_mode_list">
|
||||
<item>"Normal - OpenSeizureDetector FFT"</item>
|
||||
<item>"Raw"</item>
|
||||
<item>"Digital Filter"</item>
|
||||
</string-array>
|
||||
<string-array name="pebble_sd_mode_list_values">
|
||||
<item>"0"</item>
|
||||
<item>"1"</item>
|
||||
<item>"2"</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- The ListPreference data is defined in pebble_datasource_values.xml -->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="User Interface Settings">
|
||||
@@ -19,6 +20,22 @@
|
||||
android:title="Manual Alarm Period (sec)" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="Seizure Detector Settings">
|
||||
<ListPreference
|
||||
android:key="PebbleDebug"
|
||||
android:title="Seizure Detector Debug Mode"
|
||||
android:summary="Set Debug mode on or off."
|
||||
android:entries="@array/pebble_debug_list"
|
||||
android:entryValues="@array/pebble_debug_values"
|
||||
android:defaultValue="0"
|
||||
android:dialogTitle="Select Debug Mode" />
|
||||
<ListPreference
|
||||
android:key="PebbleDisplaySpectrum"
|
||||
android:title="Spectrum display Mode"
|
||||
android:summary="Set Display Spectrum mode on or off."
|
||||
android:entries="@array/pebble_display_spectrum_list"
|
||||
android:entryValues="@array/pebble_display_spectrum_values"
|
||||
android:defaultValue="0"
|
||||
android:dialogTitle="Select Display Spectrum Mode" />
|
||||
<ListPreference
|
||||
android:key="PebbleSdMode"
|
||||
android:title="Seizure Detector Mode"
|
||||
|
||||
Reference in New Issue
Block a user