Medtrum: Do not spam event bus on bolus progress
This commit is contained in:
parent
bface2a24d
commit
5945aa40ab
|
@ -420,6 +420,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
var communicationLost = false
|
var communicationLost = false
|
||||||
var connectionRetryCounter = 0
|
var connectionRetryCounter = 0
|
||||||
var checkTime = medtrumPump.bolusProgressLastTimeStamp
|
var checkTime = medtrumPump.bolusProgressLastTimeStamp
|
||||||
|
var lastSentBolusAmount: Double? = null
|
||||||
|
|
||||||
while (!medtrumPump.bolusStopped && !medtrumPump.bolusDone && !communicationLost) {
|
while (!medtrumPump.bolusStopped && !medtrumPump.bolusDone && !communicationLost) {
|
||||||
SystemClock.sleep(100)
|
SystemClock.sleep(100)
|
||||||
|
@ -436,10 +437,15 @@ class MedtrumService : DaggerService(), BLECommCallback {
|
||||||
disconnect("Communication stopped")
|
disconnect("Communication stopped")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
val currentBolusAmount = medtrumPump.bolusingTreatment?.insulin
|
||||||
|
|
||||||
|
if (currentBolusAmount != null && currentBolusAmount != lastSentBolusAmount) {
|
||||||
bolusingEvent.t = medtrumPump.bolusingTreatment
|
bolusingEvent.t = medtrumPump.bolusingTreatment
|
||||||
bolusingEvent.status = rh.gs(info.nightscout.pump.common.R.string.bolus_delivered_so_far, medtrumPump.bolusingTreatment?.insulin, medtrumPump.bolusAmountToBeDelivered)
|
bolusingEvent.status = rh.gs(info.nightscout.pump.common.R.string.bolus_delivered_so_far, medtrumPump.bolusingTreatment?.insulin, medtrumPump.bolusAmountToBeDelivered)
|
||||||
bolusingEvent.percent = round((medtrumPump.bolusingTreatment?.insulin?.div(medtrumPump.bolusAmountToBeDelivered) ?: 0.0) * 100).toInt() - 1
|
bolusingEvent.percent = round(currentBolusAmount.div(medtrumPump.bolusAmountToBeDelivered) * 100).toInt() - 1
|
||||||
rxBus.send(bolusingEvent)
|
rxBus.send(bolusingEvent)
|
||||||
|
lastSentBolusAmount = currentBolusAmount
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue