diff --git a/README-Combo.md b/README-Combo.md index b4c42f30aa..ced0a5e726 100644 --- a/README-Combo.md +++ b/README-Combo.md @@ -39,6 +39,8 @@ Limitations: pump solely through AAPS. Checking history, reservoir level etc on the pump causes no issues but should be avoided when the Bluetooth icon is displayed on the display, indicating that AAPS is communicating with the pump. +- Setting basal rates where U/h exceeds 10 are currently not supported. Values between 0.01 to 0.04 are rounded + to 0.05, values above have a granularity of 0.05 and values above 1.00 have a granularity of 0.10. Setup: - Configure pump using 360 config software. diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 3df159b876..d79b2737c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -81,6 +81,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf pumpDescription.isSetBasalProfileCapable = true; + // this applies to range >= 0.05 U/h && < 1.00 U/h, + // above 1.00 U/h step size is 0.05, + // above 10 U/h, step size is 0.1, + // the smallest non-zero amount is 0.05 U/h, so 0.00 U/h jumps to 0.05 U/h during input pumpDescription.basalStep = 0.01d; pumpDescription.basalMinimumRate = 0.0d; diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 18604cb7b6..5ca23cee05 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -283,7 +283,7 @@ public class RuffyScripter implements RuffyCommands { // the disconnected and then return the command as failed (the caller // can retry if needed). log.debug("Connection unusable (ruffy connection: " + ruffyService.isConnected() + ", " - + "time since last menu update: " + (System.currentTimeMillis() - menuLastUpdated) + " ms, " + + "time since last menu update: " + (System.currentTimeMillis() - menuLastUpdated) + " ms), " + "aborting command and attempting reconnect ..."); cmdThread.interrupt(); activeCmd.getResult().success = false; diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetBasalProfileCommand.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetBasalProfileCommand.java index a5e42014b6..61114246b8 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetBasalProfileCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/SetBasalProfileCommand.java @@ -30,6 +30,7 @@ public class SetBasalProfileCommand extends BaseCommand { scripter.verifyMenuIsDisplayed(MenuType.BASAL_1_MENU); scripter.pressCheckKey(); + Double requestedTotal = 0d; // summary screen is shown; press menu to page through hours, wraps around to summary; scripter.verifyMenuIsDisplayed(MenuType.BASAL_TOTAL); for (int i = 0; i < 24; i++) { @@ -43,6 +44,11 @@ public class SetBasalProfileCommand extends BaseCommand { scripter.verifyMenuIsDisplayed(MenuType.BASAL_SET); double requestedRate = basalProfile.hourlyRates[i]; + if (requestedRate > 0 && requestedRate < 0.05) { + log.debug("rounding requested rate of " + requestedRate + " to supported value 0.05"); + requestedRate = 0.05; + } + requestedTotal += requestedRate; long change = inputBasalRate(requestedRate); if (change != 0) { verifyDisplayedRate(requestedRate, change); @@ -57,10 +63,6 @@ public class SetBasalProfileCommand extends BaseCommand { // check total basal total on pump matches requested total Double pumpTotal = (Double) scripter.getCurrentMenu().getAttribute(MenuAttribute.BASAL_TOTAL); - Double requestedTotal = 0d; - for (int i = 0; i < 24; i++) { - requestedTotal += basalProfile.hourlyRates[i]; - } if (Math.abs(pumpTotal - requestedTotal) > 0.001) { throw new CommandException("Basal total of " + pumpTotal + " differs from requested total of " + requestedTotal); } @@ -75,11 +77,17 @@ public class SetBasalProfileCommand extends BaseCommand { private long inputBasalRate(double requestedRate) { double currentRate = scripter.readBlinkingValue(Double.class, MenuAttribute.BASAL_RATE); log.debug("Current rate: " + currentRate + ", requested: " + requestedRate); + // the pump changes steps size from 0.01 to 0.05 when crossing 1.00 U long steps = stepsToOne(currentRate) - stepsToOne(requestedRate); if (steps == 0) { return 0; } + + // edge case: 0.00 to 0.05 (or back) is one step, not 5. + if (currentRate == 0 && requestedRate > 0) steps -= 4; + else if (currentRate > 0 && requestedRate == 0) steps += 4; + log.debug("Pressing " + (steps > 0 ? "up" : "down") + " " + Math.abs(steps) + " times"); for (int i = 0; i < Math.abs(steps); i++) { scripter.verifyMenuIsDisplayed(MenuType.BASAL_SET);