diff --git a/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java b/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java index 25d6eea7e8..4d519b4669 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java @@ -19,6 +19,8 @@ public class PumpState { */ public String errorMsg; public boolean suspended; + public boolean lowBattery; + public int insulinState; public PumpState tbrActive(boolean tbrActive) { this.tbrActive = tbrActive; @@ -59,6 +61,8 @@ public class PumpState { ", tbrRemainingDuration=" + tbrRemainingDuration + ", errorMsg=" + errorMsg + ", suspended=" + suspended + + ", lowBattery=" + lowBattery + + ", insulinState=" + insulinState + ", timestamp=" + timestamp + '}'; } diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 1da4b681f4..10db8fe0ac 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -458,6 +458,8 @@ public class RuffyScripter { state.tbrRemainingDuration = durationMenuTime.getHour() * 60 + durationMenuTime.getMinute(); state.tbrRate = ((double) menu.getAttribute(MenuAttribute.BASAL_RATE)); } + state.lowBattery = ((boolean) menu.getAttribute(MenuAttribute.LOW_BATTERY)); + state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE)); // TODO v2, read current base basal rate, which is shown center when no TBR is active. // Check if that holds true when an extended bolus is running. // Add a field to PumpStatus, rather than renaming/overloading tbrRate to mean @@ -466,6 +468,8 @@ public class RuffyScripter { state.errorMsg = (String) menu.getAttribute(MenuAttribute.MESSAGE); } else if (menuType == MenuType.STOP) { state.suspended = true; + state.lowBattery = ((boolean) menu.getAttribute(MenuAttribute.LOW_BATTERY)); + state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE)); } else { StringBuilder sb = new StringBuilder(); for (MenuAttribute menuAttribute : menu.attributes()) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index 5469e8e0b8..b8dcb1a777 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.PumpCombo; import android.app.Activity; +import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; @@ -47,6 +48,9 @@ public class ComboFragment extends Fragment implements View.OnClickListener { private TextView lastCmdResultText; private TextView tbrCapabilityText; + private TextView pumpstateBatteryText; + private TextView insulinstateText; + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -67,6 +71,8 @@ public class ComboFragment extends Fragment implements View.OnClickListener { lastCmdTimeText = (TextView) view.findViewById(R.id.combo_last_command_time); lastCmdResultText = (TextView) view.findViewById(R.id.combo_last_command_result); tbrCapabilityText = (TextView) view.findViewById(R.id.combo_tbr_capability); + pumpstateBatteryText = (TextView) view.findViewById(R.id.combo_pumpstate_battery); + insulinstateText = (TextView) view.findViewById(R.id.combo_insulinstate); refresh.setOnClickListener(this); updateCapabilities.setOnClickListener(this); @@ -114,7 +120,7 @@ public class ComboFragment extends Fragment implements View.OnClickListener { activity.runOnUiThread(new Runnable() { @Override public void run() { - updateCapabilities.setText("{fa-bluetooth}"); + updateCapabilities.setText("{fa-bluetooth spin}"); } }); @@ -172,6 +178,25 @@ public class ComboFragment extends Fragment implements View.OnClickListener { } else { lastCmdResultText.setText(""); } + if(getPlugin().pumpState.lowBattery){ + pumpstateBatteryText.setText("{fa-battery-empty}"); + pumpstateBatteryText.setTextColor(Color.RED); + } else { + pumpstateBatteryText.setText("{fa-battery-three-quarters}"); + pumpstateBatteryText.setTextColor(Color.WHITE); + } + switch (getPlugin().pumpState.insulinState){ + case 0: insulinstateText.setText("ok"); + insulinstateText.setTextColor(Color.WHITE); + break; + case 1: insulinstateText.setText("low"); + insulinstateText.setTextColor(Color.YELLOW); + break; + case 2: insulinstateText.setText("empty"); + insulinstateText.setTextColor(Color.RED); + break; + } + } tbrCapabilityText.setText(getPlugin().getPumpDescription().maxTempPercent + "%"); diff --git a/app/src/main/res/layout/combopump_fragment.xml b/app/src/main/res/layout/combopump_fragment.xml index 5e7a352127..0ac36b1a42 100644 --- a/app/src/main/res/layout/combopump_fragment.xml +++ b/app/src/main/res/layout/combopump_fragment.xml @@ -427,7 +427,96 @@ android:text="{fa-bluetooth-b}" /> + + + + + + + + + + + + + + + + + + + + + +