diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/app/src/main/java/info/nightscout/androidaps/data/Profile.java
index ea662e434d..157427598d 100644
--- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java
+++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java
@@ -17,6 +17,9 @@ import java.util.TimeZone;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.PumpDescription;
+import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@@ -327,8 +330,27 @@ public class Profile {
}
public Double getBasal(Integer timeAsSeconds) {
- if (basal_v == null)
+ if (basal_v == null) {
basal_v = convertToSparseArray(basal);
+ // Check for minimal basal value
+ PumpInterface pump = ConfigBuilderPlugin.getActivePump();
+ if (pump != null) {
+ PumpDescription description = pump.getPumpDescription();
+ for (int i = 0; i < basal_v.size(); i++) {
+ if (basal_v.valueAt(i) < description.basalMinimumRate) {
+ basal_v.setValueAt(i, description.basalMinimumRate);
+ MainApp.bus().post(new EventNewNotification(new Notification(Notification.MINIMAL_BASAL_VALUE_REPLACED, MainApp.sResources.getString(R.string.minimalbasalvaluereplaced), Notification.NORMAL)));
+ }
+ }
+ return getValueToTime(basal_v, timeAsSeconds);
+ } else {
+ // if pump not available (at start)
+ // do not store converted array
+ Double value = getValueToTime(basal_v, timeAsSeconds);
+ basal_v = null;
+ return value;
+ }
+ }
return getValueToTime(basal_v, timeAsSeconds);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java
index 30f6fdd328..e54ff80772 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java
@@ -56,6 +56,7 @@ public class Notification {
public static final int PUMP_UNREACHABLE = 26;
public static final int BG_READINGS_MISSED = 27;
public static final int UNSUPPORTED_FIRMWARE = 28;
+ public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
public int id;
public Date date;
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f2aa76486c..50fba4b94a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -788,5 +788,6 @@
dexcomg5_xdripupload
In xDrip+ select 640g/Eversense data source
NSClient BG
+ Basal value replaced by minimal supported value