diff --git a/app/src/main/java/info/nightscout/android/history/PumpHistorySender.java b/app/src/main/java/info/nightscout/android/history/PumpHistorySender.java index 38c1d60f57300c62f0d02b9b1c0ca8c2e14de08c..918579f6a529ea5f2425fd5953ac88b3093b4e76 100644 --- a/app/src/main/java/info/nightscout/android/history/PumpHistorySender.java +++ b/app/src/main/java/info/nightscout/android/history/PumpHistorySender.java @@ -87,6 +87,7 @@ public class PumpHistorySender { .opt(SENDEROPT.MISC_CANNULA, dataStore.isNsEnableReservoirChange()) .opt(SENDEROPT.MISC_INSULIN, dataStore.isNsEnableInsulinChange()) .var(SENDEROPT.INSULIN_CLANGE_THRESHOLD, Integer.toString(dataStore.getNsInsulinChangeThreshold())) + .var(SENDEROPT.CANNULA_CLANGE_THRESHOLD, Integer.toString(dataStore.getNsCannulaChangeThreshold())) .opt(SENDEROPT.INSERT_BG_AS_CGM, dataStore.isNsEnableFingerBG() & dataStore.isNsEnableInsertBGasCGM()) @@ -127,6 +128,7 @@ public class PumpHistorySender { .opt(SENDEROPT.MISC_CANNULA, dataStore.isPushoverEnableConsumables() & dataStore.isNsEnableReservoirChange()) .opt(SENDEROPT.MISC_INSULIN, dataStore.isPushoverEnableConsumables() & dataStore.isNsEnableInsulinChange()) .var(SENDEROPT.INSULIN_CLANGE_THRESHOLD, Integer.toString(dataStore.getNsInsulinChangeThreshold())) + .var(SENDEROPT.CANNULA_CLANGE_THRESHOLD, Integer.toString(dataStore.getNsCannulaChangeThreshold())) .opt(SENDEROPT.ALARM_CLEARED, dataStore.isPushoverEnableCleared()) .opt(SENDEROPT.ALARM_SILENCED, dataStore.isPushoverEnableSilenced()) @@ -192,6 +194,7 @@ public class PumpHistorySender { CALIBRATION_INFO, INSERT_BG_AS_CGM, INSULIN_CLANGE_THRESHOLD, + CANNULA_CLANGE_THRESHOLD, PROFILE_OFFSET, diff --git a/app/src/main/java/info/nightscout/android/medtronic/UserLogAdapter.java b/app/src/main/java/info/nightscout/android/medtronic/UserLogAdapter.java index e3bf0a3a755bbf2b253e1eaffb00792dd26a9819..d350bab8e3645a4719bbb67c2a98848c1791cee9 100644 --- a/app/src/main/java/info/nightscout/android/medtronic/UserLogAdapter.java +++ b/app/src/main/java/info/nightscout/android/medtronic/UserLogAdapter.java @@ -49,7 +49,6 @@ public class UserLogAdapter private IconicsDrawable iHEART; private IconicsDrawable iSHARE; - private int cDefault; private int iBounds; private int iOffsetXDp; private int iOffsetYDp; @@ -144,6 +143,7 @@ public class UserLogAdapter case HISTORY: ssb.append(" * ").append(text); ssb.setSpan(new ImageSpan(iREFRESH, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + ssb.setSpan(new ForegroundColorSpan(cDEFAULT), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); break; case CGM: ssb.append(" * ").append(text); diff --git a/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpHistoryMisc.java b/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpHistoryMisc.java index 97c4debe5f8898beac81ec5fe751281764b6d861..0e791fcafc054e9823e19e56c440cec206852505 100644 --- a/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpHistoryMisc.java +++ b/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpHistoryMisc.java @@ -100,14 +100,19 @@ public class PumpHistoryMisc extends RealmObject implements PumpHistoryInterface notes = String.format("%s: %s", FormatKit.getInstance().getString(R.string.Pump), FormatKit.getInstance().getString(R.string.new_sensor_started)); - } else if (RECORDTYPE.CHANGE_BATTERY.equals(recordtype) + } + else if (RECORDTYPE.CHANGE_BATTERY.equals(recordtype) && pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_BATTERY)) { type = "Pump Battery Change"; notes = String.format("%s: %s", FormatKit.getInstance().getString(R.string.Pump), FormatKit.getInstance().getString(R.string.battery_inserted)); - } else if (RECORDTYPE.CHANGE_CANNULA.equals(recordtype) + } + else if (RECORDTYPE.CHANGE_CANNULA.equals(recordtype) && pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_CANNULA)) { + double threshold = Double.parseDouble(pumpHistorySender.senderVar(senderID, PumpHistorySender.SENDEROPT.CANNULA_CLANGE_THRESHOLD, "0")) / 1000; + // only send a CAGE event when primed amount exceeds threshold + if (delivered < threshold) return nightscoutItems; type = "Site Change"; notes = String.format("%s: %s%s%s %s (%s)", FormatKit.getInstance().getString(R.string.Pump), @@ -116,10 +121,13 @@ public class PumpHistoryMisc extends RealmObject implements PumpHistoryInterface FormatKit.getInstance().getString(R.string.Prime), FormatKit.getInstance().formatAsInsulin(delivered), FormatKit.getInstance().formatAsInsulin(remaining)); - } else if (RECORDTYPE.CHANGE_INSULIN.equals(recordtype) + } + else if (RECORDTYPE.CHANGE_INSULIN.equals(recordtype) && pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_INSULIN)) { // only send a IAGE event when insulin reservoir in pump exceeds threshold int threshold = Integer.parseInt(pumpHistorySender.senderVar(senderID, PumpHistorySender.SENDEROPT.INSULIN_CLANGE_THRESHOLD, "0")); + if (threshold == 1) threshold = 140; // 1.8ml Reservoir + else if (threshold == 2) threshold = 240; // 3.0ml Reservoir if (remaining < threshold) return nightscoutItems; type = "Insulin Change"; notes = String.format("%s: %s%s%s %s (%s)", @@ -129,7 +137,8 @@ public class PumpHistoryMisc extends RealmObject implements PumpHistoryInterface FormatKit.getInstance().getString(R.string.Prime), FormatKit.getInstance().formatAsInsulin(delivered), FormatKit.getInstance().formatAsInsulin(remaining)); - } else { + } + else { Log.e(TAG, "unknown misc event"); return nightscoutItems; } @@ -172,19 +181,28 @@ public class PumpHistoryMisc extends RealmObject implements PumpHistoryInterface if (RECORDTYPE.CHANGE_SENSOR.equals(recordtype) && pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_SENSOR)) { title = FormatKit.getInstance().getString(R.string.Sensor_Change); - } else if (RECORDTYPE.CHANGE_BATTERY.equals(recordtype) + } + else if (RECORDTYPE.CHANGE_BATTERY.equals(recordtype) && pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_BATTERY)) { title = FormatKit.getInstance().getString(R.string.Battery_Change); - } else if (RECORDTYPE.CHANGE_CANNULA.equals(recordtype) + } + else if (RECORDTYPE.CHANGE_CANNULA.equals(recordtype) && pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_CANNULA)) { + double threshold = Double.parseDouble(pumpHistorySender.senderVar(senderID, PumpHistorySender.SENDEROPT.CANNULA_CLANGE_THRESHOLD, "0")) / 1000; + // only send a CAGE event when primed amount exceeds threshold + if (delivered < threshold) return messageItems; title = FormatKit.getInstance().getString(R.string.Cannula_Change); - } else if (RECORDTYPE.CHANGE_INSULIN.equals(recordtype) + } + else if (RECORDTYPE.CHANGE_INSULIN.equals(recordtype) && pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_INSULIN)) { // only send a IAGE event when insulin reservoir in pump exceeds threshold int threshold = Integer.parseInt(pumpHistorySender.senderVar(senderID, PumpHistorySender.SENDEROPT.INSULIN_CLANGE_THRESHOLD, "0")); + if (threshold == 1) threshold = 140; // 1.8ml Reservoir + else if (threshold == 2) threshold = 240; // 3.0ml Reservoir if (remaining < threshold) return messageItems; title = FormatKit.getInstance().getString(R.string.Insulin_Change); - } else + } + else return messageItems; if (pumpHistorySender.senderOpt(senderID, PumpHistorySender.SENDEROPT.MISC_LIFETIMES)) @@ -206,7 +224,7 @@ public class PumpHistoryMisc extends RealmObject implements PumpHistoryInterface private String formatLifetimes() { StringBuilder sb = new StringBuilder( String.format("%s ", - FormatKit.getInstance().getString(R.string.Lifetimes))); + FormatKit.getInstance().getString(R.string.Lifetimes))); for (int lt = 0; lt < LIFETIMES_TOTAL; lt++) { byte days = lifetimes[lt << 1]; diff --git a/app/src/main/java/info/nightscout/android/model/store/DataStore.java b/app/src/main/java/info/nightscout/android/model/store/DataStore.java index c62c2fb2b56c7672bdaae778c29ebd0c63f5cf01..d6a30540fc2d57b57cbf8ff4bda909dc56b75c43 100644 --- a/app/src/main/java/info/nightscout/android/model/store/DataStore.java +++ b/app/src/main/java/info/nightscout/android/model/store/DataStore.java @@ -83,6 +83,7 @@ public class DataStore extends RealmObject { private boolean nsEnableSensorChange; private boolean nsEnableReservoirChange; private boolean nsEnableInsulinChange; + private int nsCannulaChangeThreshold; private int nsInsulinChangeThreshold; private boolean nsEnableBatteryChange; private boolean nsEnableLifetimes; @@ -289,6 +290,7 @@ public class DataStore extends RealmObject { nsEnableSensorChange = sharedPreferences.getBoolean("nsEnableSensorChange", true); nsEnableReservoirChange = sharedPreferences.getBoolean("nsEnableReservoirChange", true); nsEnableInsulinChange = sharedPreferences.getBoolean("nsEnableInsulinChange", false); + nsCannulaChangeThreshold = Integer.parseInt(sharedPreferences.getString("nsCannulaChangeThreshold", "0")); nsInsulinChangeThreshold = Integer.parseInt(sharedPreferences.getString("nsInsulinChangeThreshold", "0")); nsEnableBatteryChange = sharedPreferences.getBoolean("nsEnableBatteryChange", true); nsEnableLifetimes = sharedPreferences.getBoolean("nsEnableLifetimes", false); @@ -783,6 +785,10 @@ public class DataStore extends RealmObject { return nsEnableInsulinChange; } + public int getNsCannulaChangeThreshold() { + return nsCannulaChangeThreshold; + } + public int getNsInsulinChangeThreshold() { return nsInsulinChangeThreshold; } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index aa87855a72a7990d8b3a7b67bf649b2fc4a90eb6..cc5f93a4957b06ddbb7e010bf45641159011f4ef 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -20,6 +20,7 @@ <item>8|2|1|Insulin flow blocked|Estimated 0U insulin in reservoir. Change reservoir and infusion set.</item> <item>11|2|1|Replace battery now|Delivery stopped. Battery must be replaced to resume delivery.</item> <item>58|0|1|Battery Failed|Insert a new AA battery.</item> + <item>70|-1|1|Fill Cannula?|Select Fill to fill cannula or select Done if not needed.</item> <item>73|1|1|Replace battery|Battery life less than 30 minutes. To ensure insulin delivery, replace battery now.</item> <item>84|-1|1|Insert Battery|Delivery stopped. Insert a new battery now.</item> <item>100|1|1|Bolus Not Delivered|Bolus entry timed out before delivery. If bolus intended, enter values again.</item> @@ -117,7 +118,7 @@ xxx|Check settings|Startup Wizard settings complete. Check and set up your other settings. xxx|Critical pump error|Delivery stopped. Pump not working properly. Stop using pump. Remove infusion set from body. Consider other insulin treatment. See User Guide. xxx|Delivery limit exceeded|Delivery stopped. Check BG. See User Guide for more information. - xxx|Fill Cannula?|Select Fill to fill cannula or select Done if not needed. + 070|Fill Cannula?|Select Fill to fill cannula or select Done if not needed. 084|Insert battery|Delivery stopped. Insert a new battery now. 007|Insulin flow blocked|Check BG. Consider injection and testing ketones. Change reservoir and infusion set. 008|Insulin flow blocked|Check BG. Consider injection and testing ketones. Estimated 0 U insulin in reservoir. Change reservoir and infusion set. @@ -197,7 +198,7 @@ xxx|Alert|Check settings|Startup Wizard settings complete. Check and set up your other settings. xxx|Alarm|Critical pump error|Delivery stopped. Pump not working properly. Stop using pump. Remove infusion set from body. Consider other insulin treatment. See User Guide. xxx|Alarm|Delivery limit exceeded|Delivery stopped. Check BG. See User Guide for more information. - xxx|Alarm|Fill Cannula?|Select Fill to fill cannula or select Done if not needed. + 070|Alarm|Fill Cannula?|Select Fill to fill cannula or select Done if not needed. xxx|Message|High BG XXX mg/dL|Check infusion set. Check ketones. Consider insulin injection. Monitor BG. 084|Alarm|Insert battery|Delivery stopped. Insert a new battery now. 007|Alarm|Insulin flow blocked|Check BG. Consider injection and testing ketones. Change reservoir and infusion set. @@ -394,6 +395,42 @@ <item>8</item> </string-array> + <string-array name="cannula_change_threshold"> + <item>Fill Cannula</item> + <item>Prime Cannula 0.1U+</item> + <item>Prime Cannula 0.2U+</item> + <item>Prime Cannula 0.3U+</item> + <item>Prime Cannula 0.4U+</item> + <item>Prime Cannula 0.5U+</item> + <item>Prime Cannula 0.6U+</item> + <item>Prime Cannula 0.7U+</item> + <item>Prime Cannula 0.8U+</item> + <item>Prime Cannula 0.9U+</item> + <item>Prime Cannula 1.0U+</item> + <item>Prime Cannula 2.0U+</item> + <item>Prime Cannula 3.0U+</item> + <item>Prime Cannula 4.0U+</item> + <item>Prime Cannula 5.0U+</item> + </string-array> + + <string-array name="cannula_change_threshold_values" translatable="false"> + <item>0</item> + <item>100</item> + <item>200</item> + <item>300</item> + <item>400</item> + <item>500</item> + <item>600</item> + <item>700</item> + <item>800</item> + <item>900</item> + <item>1000</item> + <item>2000</item> + <item>3000</item> + <item>4000</item> + <item>5000</item> + </string-array> + <string-array name="insulin_change_threshold"> <item>New Reservoir</item> <item>1.8ml Reservoir</item> @@ -423,8 +460,8 @@ <string-array name="insulin_change_threshold_values" translatable="false"> <item>0</item> - <item>140</item> - <item>240</item> + <item>1</item> + <item>2</item> <item>100</item> <item>110</item> <item>120</item> diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 6abddb9d204205e4f865eb2d4562994aaf497c00..462824c334b07b91f7e34ce44ad4477babf4e609 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -113,12 +113,19 @@ android:key="nsEnableReservoirChange" android:defaultValue="true" android:summary="Send cannula changes to Nightscout (CAGE)"/> + <ListPreference android:title="Threshold for cannula change" + android:dependency="nsEnableReservoirChange" + android:key="nsCannulaChangeThreshold" + android:summary="%s" + android:defaultValue="0" + android:entries="@array/cannula_change_threshold" + android:entryValues="@array/cannula_change_threshold_values"/> <CheckBoxPreference android:title="Insulin Change" android:dependency="nsEnableTreatments" android:key="nsEnableInsulinChange" android:defaultValue="false" android:summary="Send insulin changes to Nightscout (IAGE)"/> - <ListPreference android:title="Threshold to activate a insulin change event" + <ListPreference android:title="Threshold for insulin change" android:dependency="nsEnableInsulinChange" android:key="nsInsulinChangeThreshold" android:summary="%s"