Merge branch 'omnipod_eros_dev' into omnipod_eros_dev_upstream_merge
This commit is contained in:
commit
ed70fab9fa
2 changed files with 27 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview
|
package info.nightscout.androidaps.plugins.general.overview
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
|
@ -8,6 +9,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.WarnColors
|
import info.nightscout.androidaps.utils.WarnColors
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -35,7 +37,11 @@ class StatusLightHandler @Inject constructor(
|
||||||
handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
|
handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
|
||||||
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
|
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
|
||||||
if (!config.NSCLIENT) {
|
if (!config.NSCLIENT) {
|
||||||
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
|
if (pump.model() == PumpType.Insulet_Omnipod) {
|
||||||
|
handleOmnipodReservoirLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
|
||||||
|
} else {
|
||||||
|
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
|
||||||
|
}
|
||||||
if (bgSource.sensorBatteryLevel != -1)
|
if (bgSource.sensorBatteryLevel != -1)
|
||||||
handleLevel(careportal_sensorbatterylevel, R.string.key_statuslights_sbat_critical, 5.0, R.string.key_statuslights_sbat_warning, 20.0, bgSource.sensorBatteryLevel.toDouble(), "%")
|
handleLevel(careportal_sensorbatterylevel, R.string.key_statuslights_sbat_critical, 5.0, R.string.key_statuslights_sbat_warning, 20.0, bgSource.sensorBatteryLevel.toDouble(), "%")
|
||||||
else
|
else
|
||||||
|
@ -64,4 +70,18 @@ class StatusLightHandler @Inject constructor(
|
||||||
view?.text = " " + DecimalFormatter.to0Decimal(level) + units
|
view?.text = " " + DecimalFormatter.to0Decimal(level) + units
|
||||||
warnColors.setColorInverse(view, level, resWarn, resUrgent)
|
warnColors.setColorInverse(view, level, resWarn, resUrgent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleOmnipodReservoirLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String) {
|
||||||
|
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
|
||||||
|
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
|
||||||
|
if (level > OmnipodConstants.MAX_RESERVOIR_READING) {
|
||||||
|
@Suppress("SetTextI18n")
|
||||||
|
view?.text = " 50+$units"
|
||||||
|
view?.setTextColor(Color.WHITE)
|
||||||
|
} else {
|
||||||
|
@Suppress("SetTextI18n")
|
||||||
|
view?.text = " " + DecimalFormatter.to0Decimal(level) + units
|
||||||
|
warnColors.setColorInverse(view, level, resWarn, resUrgent)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -75,6 +75,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.util.TimeUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.util.TimeUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodActiveAlertsChanged;
|
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodActiveAlertsChanged;
|
||||||
|
@ -117,6 +118,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
private static final long RILEY_LINK_CONNECT_TIMEOUT_MILLIS = 3 * 60 * 1000L; // 3 minutes
|
private static final long RILEY_LINK_CONNECT_TIMEOUT_MILLIS = 3 * 60 * 1000L; // 3 minutes
|
||||||
private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1000L; // 1 minute
|
private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1000L; // 1 minute
|
||||||
public static final int STARTUP_STATUS_REQUEST_TRIES = 2;
|
public static final int STARTUP_STATUS_REQUEST_TRIES = 2;
|
||||||
|
public static final double RESERVOIR_OVER_50_UNITS_DEFAULT = 75.0;
|
||||||
|
|
||||||
private final PodStateManager podStateManager;
|
private final PodStateManager podStateManager;
|
||||||
private final RileyLinkServiceData rileyLinkServiceData;
|
private final RileyLinkServiceData rileyLinkServiceData;
|
||||||
|
@ -602,7 +604,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
return 0.0d;
|
return 0.0d;
|
||||||
}
|
}
|
||||||
Double reservoirLevel = podStateManager.getReservoirLevel();
|
Double reservoirLevel = podStateManager.getReservoirLevel();
|
||||||
return reservoirLevel == null ? 75.0 : reservoirLevel;
|
// Omnipod only reports reservoir level when it's 50 units or less.
|
||||||
|
// When it's over 50 units, we don't know, so return some default over 50 units
|
||||||
|
return reservoirLevel == null ? RESERVOIR_OVER_50_UNITS_DEFAULT : reservoirLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -789,7 +793,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
||||||
}
|
}
|
||||||
ret += "Reserv: " + DecimalFormatter.to0Decimal(getReservoirLevel()) + "U\n";
|
ret += "Reserv: " + (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+U" : DecimalFormatter.to0Decimal(getReservoirLevel()) + "U") + "\n";
|
||||||
ret += "Batt: " + getBatteryLevel();
|
ret += "Batt: " + getBatteryLevel();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue