Settings for deltas
This commit is contained in:
parent
da2739f7b7
commit
3a43858948
3 changed files with 31 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
@ -25,6 +27,7 @@ public class GlucoseStatus {
|
||||||
public double short_avgdelta = 0d;
|
public double short_avgdelta = 0d;
|
||||||
public double long_avgdelta = 0d;
|
public double long_avgdelta = 0d;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return MainApp.sResources.getString(R.string.glucose) + " " + DecimalFormatter.to0Decimal(glucose) + " mg/dl\n" +
|
return MainApp.sResources.getString(R.string.glucose) + " " + DecimalFormatter.to0Decimal(glucose) + " mg/dl\n" +
|
||||||
|
@ -54,6 +57,8 @@ public class GlucoseStatus {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static GlucoseStatus getGlucoseStatusData() {
|
public static GlucoseStatus getGlucoseStatusData() {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainApp.instance());
|
||||||
|
|
||||||
// load 45min
|
// load 45min
|
||||||
long fromtime = (long) (new Date().getTime() - 60 * 1000L * 45);
|
long fromtime = (long) (new Date().getTime() - 60 * 1000L * 45);
|
||||||
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
||||||
|
@ -104,8 +109,15 @@ public class GlucoseStatus {
|
||||||
|
|
||||||
GlucoseStatus status = new GlucoseStatus();
|
GlucoseStatus status = new GlucoseStatus();
|
||||||
status.glucose = now.value;
|
status.glucose = now.value;
|
||||||
status.delta = average(last_deltas);
|
|
||||||
status.short_avgdelta = average(short_deltas);
|
status.short_avgdelta = average(short_deltas);
|
||||||
|
|
||||||
|
if(prefs.getBoolean("always_use_shortavg",false) || (last_deltas.isEmpty() && prefs.getBoolean("default_to_shortavg",false))){
|
||||||
|
status.delta = status.short_avgdelta;
|
||||||
|
} else {
|
||||||
|
status.delta = average(last_deltas);
|
||||||
|
}
|
||||||
|
|
||||||
status.long_avgdelta = average(long_deltas);
|
status.long_avgdelta = average(long_deltas);
|
||||||
status.avgdelta = status.short_avgdelta; // for OpenAPS MA
|
status.avgdelta = status.short_avgdelta; // for OpenAPS MA
|
||||||
|
|
||||||
|
|
|
@ -448,4 +448,9 @@
|
||||||
<string name="wear_shortname">WEAR</string>
|
<string name="wear_shortname">WEAR</string>
|
||||||
<string name="smscommunicator_shortname">SMS</string>
|
<string name="smscommunicator_shortname">SMS</string>
|
||||||
<string name="short_tabtitles">Shorten tab titles</string>
|
<string name="short_tabtitles">Shorten tab titles</string>
|
||||||
|
<string name="prefs_delta_title">Delta Settings</string>
|
||||||
|
<string name="default_to_shortavg">Default to short average delta</string>
|
||||||
|
<string name="default_to_shortavg_summary">Use short average delta when simple delta cannot be computed.</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>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -30,6 +30,18 @@
|
||||||
android:key="openapsma_max_iob"
|
android:key="openapsma_max_iob"
|
||||||
android:numeric="decimal"
|
android:numeric="decimal"
|
||||||
android:title="@string/openapsma_maxiob_summary" />
|
android:title="@string/openapsma_maxiob_summary" />
|
||||||
|
<PreferenceScreen
|
||||||
|
android:title="@string/prefs_delta_title">
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="default_to_shortavg"
|
||||||
|
android:title="@string/default_to_shortavg"
|
||||||
|
android:summary="@string/default_to_shortavg_summary"/>
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="always_use_shortavg"
|
||||||
|
android:title="@string/always_use_shortavg"
|
||||||
|
android:summary="@string/always_use_shortavg_summary"/>
|
||||||
|
</PreferenceScreen>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in a new issue