Merge pull request #143 from AdrianLxM/deltasx

Settings for deltas
This commit is contained in:
Milos Kozak 2017-01-24 10:59:10 +01:00 committed by GitHub
commit 044547b594
7 changed files with 49 additions and 13 deletions

View file

@ -53,7 +53,7 @@ public class Constants {
// Very Hard Limits Ranges
// First value is the Lowest and second value is the Highest a Limit can define
public static final int[] VERY_HARD_LIMIT_MIN_BG = {72,180};
public static final int[] VERY_HARD_LIMIT_MAX_BG = {99,270};
public static final int[] VERY_HARD_LIMIT_MAX_BG = {90,270};
public static final int[] VERY_HARD_LIMIT_TARGET_BG = {80,200};
// Very Hard Limits Ranges for Temp Targets

View file

@ -104,6 +104,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
if (Config.SMSCOMMUNICATORENABLED)
addPreferencesFromResource(R.xml.pref_smscommunicator);
addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_advanced);
initSummary(getPreferenceScreen());
}

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.data;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.text.Html;
import android.text.Spanned;
@ -25,6 +27,7 @@ public class GlucoseStatus {
public double short_avgdelta = 0d;
public double long_avgdelta = 0d;
@Override
public String toString() {
return MainApp.sResources.getString(R.string.glucose) + " " + DecimalFormatter.to0Decimal(glucose) + " mg/dl\n" +
@ -54,6 +57,8 @@ public class GlucoseStatus {
@Nullable
public static GlucoseStatus getGlucoseStatusData() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainApp.instance());
// load 45min
long fromtime = (long) (new Date().getTime() - 60 * 1000L * 45);
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
@ -104,8 +109,15 @@ public class GlucoseStatus {
GlucoseStatus status = new GlucoseStatus();
status.glucose = now.value;
status.delta = average(last_deltas);
status.short_avgdelta = average(short_deltas);
if(prefs.getBoolean("always_use_shortavg",false) || last_deltas.isEmpty()){
status.delta = status.short_avgdelta;
} else {
status.delta = average(last_deltas);
}
status.long_avgdelta = average(long_deltas);
status.avgdelta = status.short_avgdelta; // for OpenAPS MA

View file

@ -448,4 +448,8 @@
<string name="wear_shortname">WEAR</string>
<string name="smscommunicator_shortname">SMS</string>
<string name="short_tabtitles">Shorten tab titles</string>
<string name="prefs_delta_title">Delta Settings</string>
<string name="always_use_shortavg">Always use short average delta instead of simple delta</string>
<string name="always_use_shortavg_summary">Useful when data from unfiltered sources like xDrip gets noisy.</string>
<string name="advancedsettings_title">Advanced Settings</string>
</resources>

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="advanced"
android:title="@string/advancedsettings_title">
<PreferenceScreen
android:title="@string/advancedsettings_title">
<PreferenceCategory
android:title="@string/nightscout">
<SwitchPreference
android:defaultValue="false"
android:key="ns_upload_only"
android:title="@string/ns_upload_only"
android:summary="@string/ns_upload_only_summary"/>
<SwitchPreference
android:defaultValue="false"
android:key="ns_sync_use_absolute"
android:title="@string/ns_sync_use_absolute_title" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/openapsma">
<SwitchPreference
android:defaultValue="false"
android:key="always_use_shortavg"
android:title="@string/always_use_shortavg"
android:summary="@string/always_use_shortavg_summary"/>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -8,16 +8,6 @@
android:defaultValue="false"
android:key="syncprofiletopump"
android:title="@string/syncprofiletopump_title" />
<SwitchPreference
android:defaultValue="false"
android:key="ns_upload_only"
android:title="@string/ns_upload_only"
android:summary="@string/ns_upload_only_summary"/>
<SwitchPreference
android:defaultValue="false"
android:key="ns_sync_use_absolute"
android:title="@string/ns_sync_use_absolute_title" />
</PreferenceCategory>
</PreferenceScreen>

View file

@ -31,5 +31,4 @@
android:numeric="decimal"
android:title="@string/openapsma_maxiob_summary" />
</PreferenceCategory>
</PreferenceScreen>