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++ } }