- added battery display, should be done

This commit is contained in:
Andy Rozman 2021-03-18 00:08:04 +00:00
parent 09d7ab01fb
commit ba8c436136
6 changed files with 88 additions and 11 deletions

View file

@ -207,7 +207,7 @@ class MedtronicFragment : DaggerFragment() {
when (medtronicPumpStatus.pumpDeviceState) { when (medtronicPumpStatus.pumpDeviceState) {
null, null,
PumpDeviceState.Sleeping -> binding.pumpStatusIcon.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name()); PumpDeviceState.Sleeping -> binding.pumpStatusIcon.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
PumpDeviceState.NeverContacted, PumpDeviceState.NeverContacted,
PumpDeviceState.WakingUp, PumpDeviceState.WakingUp,
PumpDeviceState.PumpUnreachable, PumpDeviceState.PumpUnreachable,
@ -215,7 +215,7 @@ class MedtronicFragment : DaggerFragment() {
PumpDeviceState.TimeoutWhenCommunicating, PumpDeviceState.TimeoutWhenCommunicating,
PumpDeviceState.InvalidConfiguration -> binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) PumpDeviceState.InvalidConfiguration -> binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId)
PumpDeviceState.Active -> { PumpDeviceState.Active -> {
val cmd = medtronicUtil.currentCommand val cmd = medtronicUtil.currentCommand
if (cmd == null) if (cmd == null)
binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId)
@ -328,5 +328,27 @@ class MedtronicFragment : DaggerFragment() {
medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() medtronicPumpPlugin.rileyLinkService?.verifyConfiguration()
binding.errors.text = medtronicPumpStatus.errorInfo binding.errors.text = medtronicPumpStatus.errorInfo
var showRileyLinkBatteryLevel: Boolean = medtronicPumpStatus.showRileyLinkBatteryLevel
if (showRileyLinkBatteryLevel) {
binding.rlBatteryView.visibility = View.VISIBLE
binding.rlBatteryLabel.visibility = View.VISIBLE
binding.rlBatteryState.visibility = View.VISIBLE
binding.rlBatteryLayout.visibility = View.VISIBLE
binding.rlBatterySemicolon.visibility = View.VISIBLE
if (rileyLinkServiceData.batteryLevel == null) {
binding.rlBatteryState.text = " ?"
} else {
binding.rlBatteryState.text = "{fa-battery-" + rileyLinkServiceData.batteryLevel / 25 + "} " + rileyLinkServiceData.batteryLevel + "%"
}
} else {
binding.rlBatteryView.visibility = View.GONE
binding.rlBatteryLabel.visibility = View.GONE
binding.rlBatteryState.visibility = View.GONE
binding.rlBatteryLayout.visibility = View.GONE
binding.rlBatterySemicolon.visibility = View.GONE
}
} }
} }

View file

@ -14,25 +14,24 @@ import javax.inject.Singleton;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus; import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType; import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType; import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP; import info.nightscout.androidaps.utils.sharedPreferences.SP;
/** /**
* Created by andy on 4/28/18. * Created by andy on 4/28/18.
*/ */
@Singleton @Singleton
public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump.common.data.PumpStatus { public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump.common.data.PumpStatus {
private final ResourceHelper resourceHelper; private final ResourceHelper resourceHelper;
private final SP sp; private final SP sp;
@ -44,6 +43,7 @@ public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump
public String pumpFrequency = null; public String pumpFrequency = null;
public Double maxBolus; public Double maxBolus;
public Double maxBasal; public Double maxBasal;
public boolean showRileyLinkBatteryLevel;
// statuses // statuses
private PumpDeviceState pumpDeviceState = PumpDeviceState.NeverContacted; private PumpDeviceState pumpDeviceState = PumpDeviceState.NeverContacted;
@ -62,9 +62,9 @@ public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump
@Inject @Inject
public MedtronicPumpStatus(ResourceHelper resourceHelper, public MedtronicPumpStatus(ResourceHelper resourceHelper,
SP sp, SP sp,
RxBusWrapper rxBus, RxBusWrapper rxBus,
RileyLinkUtil rileyLinkUtil RileyLinkUtil rileyLinkUtil
) { ) {
super(PumpType.Medtronic_522_722); super(PumpType.Medtronic_522_722);
this.resourceHelper = resourceHelper; this.resourceHelper = resourceHelper;

View file

@ -317,6 +317,8 @@ public class RileyLinkMedtronicService extends RileyLinkService {
//boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(resourceHelper.gs(R.string.common_on)); //boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(resourceHelper.gs(R.string.common_on));
//MedtronicHistoryData.doubleBolusDebug = bolusDebug; //MedtronicHistoryData.doubleBolusDebug = bolusDebug;
medtronicPumpStatus.showRileyLinkBatteryLevel = sp.getBoolean(RileyLinkConst.Prefs.ShowBatteryLevel, false);
reconfigureService(forceRileyLinkAddressRenewal); reconfigureService(forceRileyLinkAddressRenewal);
return true; return true;

View file

@ -86,6 +86,58 @@
</LinearLayout> </LinearLayout>
<View
android:id="@+id/rl_battery_view"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/list_delimiter" />
<LinearLayout
android:id="@+id/rl_battery_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/rl_battery_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/rl_battery_label"
android:textSize="14sp" />
<TextView
android:id="@+id/rl_battery_semicolon"
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":"
android:textSize="14sp" />
<com.joanzapata.iconify.widget.IconTextView
android:id="@+id/rl_battery_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:text=""
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"

View file

@ -48,7 +48,8 @@
<string name="medtronic_pump_battery_nimh">NiMH (Extended view)</string> <string name="medtronic_pump_battery_nimh">NiMH (Extended view)</string>
<string name="medtronic_bolus_debugging">Bolus/Treatments Debugging</string> <string name="medtronic_bolus_debugging">Bolus/Treatments Debugging</string>
<!-- MDT Fragment -->
<string name="rl_battery_label">RileyLink Battery</string>
<!-- MDT Errors --> <!-- MDT Errors -->
<string name="medtronic_errors">Errors</string> <string name="medtronic_errors">Errors</string>
@ -79,8 +80,6 @@
<string name="medtronic_pump_history">Medtronic Pump History</string> <string name="medtronic_pump_history">Medtronic Pump History</string>
<!-- <string name="medtronic_cmd_profile_not_set">Remote Basal profile setting is not supported. Please modify Basal profile on your pump manually.</string> --> <!-- <string name="medtronic_cmd_profile_not_set">Remote Basal profile setting is not supported. Please modify Basal profile on your pump manually.</string> -->
<string name="medtronic_cmd_cancel_bolus_not_supported">You cancelled Bolus, after it was already set on Pump. Since Medtronic Pump doesn\'t support cancel, you will need to manually cancel it. Put the Pump into Suspend mode and then do Resume (if you still want to cancel). Application will pick up changes, on next update (in less than 5 minutes).</string> <string name="medtronic_cmd_cancel_bolus_not_supported">You cancelled Bolus, after it was already set on Pump. Since Medtronic Pump doesn\'t support cancel, you will need to manually cancel it. Put the Pump into Suspend mode and then do Resume (if you still want to cancel). Application will pick up changes, on next update (in less than 5 minutes).</string>
<string name="medtronic_cmd_cant_read_tbr">Could not read current TBR.</string> <string name="medtronic_cmd_cant_read_tbr">Could not read current TBR.</string>
@ -117,6 +116,7 @@
<string name="set_neutral_temps_title">Set neutral temp basals</string> <string name="set_neutral_temps_title">Set neutral temp basals</string>
<string name="set_neutral_temps_summary">If enabled, it will cancel a temporary basal before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour.</string> <string name="set_neutral_temps_summary">If enabled, it will cancel a temporary basal before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour.</string>
<string name="sixdigitnumber" translatable="false">^\\d{6}</string> <string name="sixdigitnumber" translatable="false">^\\d{6}</string>
</resources> </resources>

View file

@ -37,6 +37,7 @@ public class RileyLinkConst {
public static final String LastGoodDeviceCommunicationTime = Prefix + "lastGoodDeviceCommunicationTime"; public static final String LastGoodDeviceCommunicationTime = Prefix + "lastGoodDeviceCommunicationTime";
public static final String LastGoodDeviceFrequency = Prefix + "LastGoodDeviceFrequency"; public static final String LastGoodDeviceFrequency = Prefix + "LastGoodDeviceFrequency";
public static final int Encoding = R.string.key_medtronic_encoding; public static final int Encoding = R.string.key_medtronic_encoding;
public static final int ShowBatteryLevel = R.string.key_riley_link_show_battery_level;
} }
public static class IPC { public static class IPC {