From 16a3b74f503266977c426d3b3a83d32dc95d84f6 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Sat, 10 Dec 2022 19:18:30 +0100 Subject: [PATCH] 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 --- .../info/nightscout/comboctl/main/Pump.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt index 9b4ee858ea..68c7de77eb 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt @@ -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++ } }