comboctl-main: Fix getBasalProfile() progress report and screen counting
The previous behavior was reading the profile correctly, but the progress report was off by one factor. Also, blinking screens were considered as separate ones, causing the short button press based fallback to kick in unnecessarily often because that blinking screen behavior caused the main long button press based reading loop to miss the last profile factor. Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
parent
e06ecaa7d8
commit
16a3b74f50
1 changed files with 11 additions and 6 deletions
|
@ -2743,8 +2743,6 @@ class Pump(
|
|||
)
|
||||
}
|
||||
|
||||
numObservedScreens++
|
||||
|
||||
val factorIndexOnScreen = parsedScreen.beginTime.hour
|
||||
|
||||
// numUnits null means the basal profile factor
|
||||
|
@ -2752,6 +2750,11 @@ class Pump(
|
|||
if (parsedScreen.numUnits == null)
|
||||
return@longPressRTButtonUntil LongPressRTButtonsCommand.ContinuePressingButton
|
||||
|
||||
// Increase this _after_ checking for a blinking screen
|
||||
// to not accidentally count the blinking and non-blinking
|
||||
// screens as two separate ones.
|
||||
numObservedScreens++
|
||||
|
||||
// If the factor in the profile is >= 0,
|
||||
// it means it was already read earlier.
|
||||
if (basalProfileFactors[factorIndexOnScreen] >= 0)
|
||||
|
@ -2759,14 +2762,16 @@ class Pump(
|
|||
|
||||
val factor = parsedScreen.numUnits
|
||||
basalProfileFactors[factorIndexOnScreen] = factor
|
||||
logger(LogLevel.DEBUG) { "Got basal profile factor #$factorIndexOnScreen : $factor" }
|
||||
|
||||
numRetrievedFactors++
|
||||
logger(LogLevel.DEBUG) {
|
||||
"Got basal profile factor #$factorIndexOnScreen : $factor; $numRetrievedFactors factor(s) read and $numObservedScreens screen(s) observed thus far"
|
||||
}
|
||||
|
||||
getBasalProfileReporter.setCurrentProgressStage(
|
||||
RTCommandProgressStage.GettingBasalProfile(numRetrievedFactors)
|
||||
)
|
||||
|
||||
numRetrievedFactors++
|
||||
|
||||
return@longPressRTButtonUntil if (numObservedScreens >= NUM_COMBO_BASAL_PROFILE_FACTORS)
|
||||
LongPressRTButtonsCommand.ReleaseButton
|
||||
else
|
||||
|
@ -2819,10 +2824,10 @@ class Pump(
|
|||
}
|
||||
}
|
||||
|
||||
numRetrievedFactors++
|
||||
getBasalProfileReporter.setCurrentProgressStage(
|
||||
RTCommandProgressStage.GettingBasalProfile(numRetrievedFactors)
|
||||
)
|
||||
numRetrievedFactors++
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue