diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js
index c2db0f270b..bb620bf5c9 100644
--- a/app/src/main/assets/OpenAPSSMB/determine-basal.js
+++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js
@@ -995,8 +995,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
// eventual BG is at/above target
// if iob is over max, just cancel any temps
- // if we're not here because of SMB, eventual BG is at/above target
- if (! (microBolusAllowed && rT.COB)) {
+ if ( eventualBG >= max_bg ) {
rT.reason += "Eventual BG " + convert_bg(eventualBG, profile) + " >= " + convert_bg(max_bg, profile) + ", ";
}
if (iob_data.iob > max_iob) {
@@ -1047,20 +1046,27 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
// if IOB covers more than COB, limit maxBolus to 30m of basal
} else if ( iob_data.iob > mealInsulinReq && iob_data.iob > 0 ) {
console.error("IOB",iob_data.iob,"> COB",meal_data.mealCOB+"; mealInsulinReq =",mealInsulinReq);
- maxBolus = round( profile.current_basal * 30 / 60 ,1);
+ if (profile.maxUAMSMBBasalMinutes) {
+ console.error("profile.maxUAMSMBBasalMinutes:",profile.maxUAMSMBBasalMinutes,"profile.current_basal:",profile.current_basal);
+ maxBolus = round( profile.current_basal * profile.maxUAMSMBBasalMinutes / 60 ,1);
+ } else {
+ console.error("profile.maxUAMSMBBasalMinutes undefined: defaulting to 30m");
+ maxBolus = round( profile.current_basal * 30 / 60 ,1);
+ }
} else {
console.error("profile.maxSMBBasalMinutes:",profile.maxSMBBasalMinutes,"profile.current_basal:",profile.current_basal);
maxBolus = round( profile.current_basal * profile.maxSMBBasalMinutes / 60 ,1);
}
- // bolus 1/2 the insulinReq, up to maxBolus, rounding down to nearest 0.1U
- microBolus = Math.floor(Math.min(insulinReq/2,maxBolus)*10)/10;
+ // bolus 1/2 the insulinReq, up to maxBolus, rounding down to nearest bolus increment
+ var roundSMBTo = 1 / profile.bolus_increment;
+ microBolus = Math.floor(Math.min(insulinReq/2,maxBolus)*roundSMBTo)/roundSMBTo;
// calculate a long enough zero temp to eventually correct back up to target
var smbTarget = target_bg;
var worstCaseInsulinReq = (smbTarget - (naive_eventualBG + minIOBPredBG)/2 ) / sens;
var durationReq = round(60*worstCaseInsulinReq / profile.current_basal);
// if insulinReq > 0 but not enough for a microBolus, don't set an SMB zero temp
- if (insulinReq > 0 && microBolus < 0.1) {
+ if (insulinReq > 0 && microBolus < profile.bolus_increment) {
durationReq = 0;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java
index 09f2148f7f..bea67358b4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java
@@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSMA.LoggerCallback;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.SP;
import info.nightscout.androidaps.utils.SafeParse;
+import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
public class DetermineBasalAdapterSMBJS {
private static Logger log = LoggerFactory.getLogger(L.APS);
@@ -217,7 +218,8 @@ public class DetermineBasalAdapterSMBJS {
) throws JSONException {
String units = profile.getUnits();
-
+ Double bolusincrement = SP.getDouble("key_bolus_increment", SMBDefaults.bolus_increment);
+ Double pumpbolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
mProfile = new JSONObject();
mProfile.put("max_iob", maxIob);
@@ -264,6 +266,12 @@ public class DetermineBasalAdapterSMBJS {
mProfile.put("enableSMB_always", smbEnabled && SP.getBoolean(R.string.key_enableSMB_always, false) && advancedFiltering);
mProfile.put("enableSMB_after_carbs", smbEnabled && SP.getBoolean(R.string.key_enableSMB_after_carbs, false) && advancedFiltering);
mProfile.put("maxSMBBasalMinutes", SP.getInt(R.string.key_smbmaxminutes, SMBDefaults.maxSMBBasalMinutes));
+ mProfile.put("maxUAMSMBBasalMinutes", SP.getInt("key_uamsmbmaxminutes", SMBDefaults.maxUAMSMBBasalMinutes));
+ if (bolusincrement < pumpbolusstep){
+ //the bolus incrument is less than what the pump can support (by pump settings or pump restriction), set to value supported by the pump
+ bolusincrement = pumpbolusstep;
+ }
+ mProfile.put("bolus_increment", bolusincrement);
mProfile.put("carbsReqThreshold", SMBDefaults.carbsReqThreshold);
mProfile.put("current_basal", basalrate);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java
index f6b8f20233..0c129e998e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java
@@ -56,9 +56,11 @@ public class SMBDefaults {
//public final static boolean enableSMB_after_carbs = false; // enable supermicrobolus for 6h after carbs, even with 0 COB
//public final static boolean allowSMB_with_high_temptarget = false; // allow supermicrobolus (if otherwise enabled) even with high temp targets
public final static int maxSMBBasalMinutes = 30; // maximum minutes of basal that can be delivered as a single SMB with uncovered COB
+ public final static int maxUAMSMBBasalMinutes = 30; // maximum minutes of basal that can be delivered as a single SMB when IOB exceeds COB
// curve:"rapid-acting" // Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp)
// useCustomPeakTime:false // allows changing insulinPeakTime
// insulinPeakTime:75 // number of minutes after a bolus activity peaks. defaults to 55m for Fiasp if useCustomPeakTime: false
public final static int carbsReqThreshold = 1; // grams of carbsReq to trigger a pushover
// offline_hotspot:false // enabled an offline-only local wifi hotspot if no Internet available
+ public final static double bolus_increment = 0.1; // minimum bolus that can be delivered as an SMB
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0c03b2d54b..25b3e40a9a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -840,6 +840,10 @@
Show delta with one more decimal place
45 60 75 90 105 120
Max minutes of basal to limit SMB to
+ 45 60 75 90 105 120
+ Max minutes of basal to limit SMB to for UAM
+ bolus_increment
+ Minimum bolus that can be delivered as an SMB
Unsupported pump firmware
Send BG data to xDrip+
dexcomg5_xdripupload
diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml
index 63d007d1cb..d165c12fc2 100644
--- a/app/src/main/res/xml/pref_openapssmb.xml
+++ b/app/src/main/res/xml/pref_openapssmb.xml
@@ -79,6 +79,33 @@
validate:minNumber="15"
validate:testType="numericRange" />
+
+
+
+
+
-
\ No newline at end of file
+