diff --git a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java index ad9b0acecf..c4caf2f1af 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java @@ -131,7 +131,7 @@ public class GlucoseStatus { status.short_avgdelta = average(short_deltas); - if (prefs.getBoolean("always_use_shortavg", false) || last_deltas.isEmpty()) { + if (last_deltas.isEmpty()) { status.delta = status.short_avgdelta; } else { status.delta = average(last_deltas); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index e2c7f20284..4ce3cd61b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -243,7 +243,12 @@ public class DetermineBasalAdapterAMAJS { mGlucoseStatus = new V8Object(mV8rt); mGlucoseStatus.add("glucose", glucoseStatus.glucose); - mGlucoseStatus.add("delta", glucoseStatus.delta); + + if(SP.getBoolean("always_use_shortavg", false)){ + mGlucoseStatus.add("delta", glucoseStatus.short_avgdelta); + } else { + mGlucoseStatus.add("delta", glucoseStatus.delta); + } mGlucoseStatus.add("short_avgdelta", glucoseStatus.short_avgdelta); mGlucoseStatus.add("long_avgdelta", glucoseStatus.long_avgdelta); mV8rt.add(PARAM_glucoseStatus, mGlucoseStatus); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java index 75f87021c5..ee0a00b802 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java @@ -19,6 +19,7 @@ import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; +import info.nightscout.utils.SP; public class DetermineBasalAdapterMAJS { private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterMAJS.class); @@ -251,7 +252,11 @@ public class DetermineBasalAdapterMAJS { mIobData.add("hightempinsulin", iobData.hightempinsulin); mGlucoseStatus.add("glucose", glucoseStatus.glucose); - mGlucoseStatus.add("delta", glucoseStatus.delta); + if(SP.getBoolean("always_use_shortavg", false)){ + mGlucoseStatus.add("delta", glucoseStatus.short_avgdelta); + } else { + mGlucoseStatus.add("delta", glucoseStatus.delta); + } mGlucoseStatus.add("avgdelta", glucoseStatus.avgdelta); mMealData.add("carbs", mealData.carbs);