From f0495768fb102e98a718dc3901d8c0bec8a44533 Mon Sep 17 00:00:00 2001 From: timklge <2026103+timklge@users.noreply.github.com> Date: Mon, 18 Aug 2025 18:00:50 +0200 Subject: [PATCH] Fix smoothing options for pedal balance source (#62) --- app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt b/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt index bc3ff1f..71d9043 100644 --- a/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt +++ b/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt @@ -188,9 +188,9 @@ class Window( SelectedSource.ROUTE_PROGRESS -> streamRouteProgress(SelectedSource.ROUTE_PROGRESS, ::getRouteProgress) SelectedSource.REMAINING_ROUTE -> streamRouteProgress(SelectedSource.REMAINING_ROUTE, ::getRemainingRouteProgress) SelectedSource.GRADE -> streamGrade() - SelectedSource.POWER_BALANCE -> streamBalance(PedalBalanceSmoothing.RAW) - SelectedSource.POWER_BALANCE_3S -> streamBalance(PedalBalanceSmoothing.SMOOTHED_3S) - SelectedSource.POWER_BALANCE_10S -> streamBalance(PedalBalanceSmoothing.SMOOTHED_10S) + SelectedSource.POWER_BALANCE -> streamBalance(PedalBalanceSmoothing.RAW, SelectedSource.POWER_BALANCE) + SelectedSource.POWER_BALANCE_3S -> streamBalance(PedalBalanceSmoothing.SMOOTHED_3S, SelectedSource.POWER_BALANCE_3S) + SelectedSource.POWER_BALANCE_10S -> streamBalance(PedalBalanceSmoothing.SMOOTHED_10S, SelectedSource.POWER_BALANCE_10S) SelectedSource.FRONT_GEAR -> streamGears(Gears.FRONT) SelectedSource.REAR_GEAR -> streamGears(Gears.REAR) SelectedSource.NONE -> {} @@ -209,7 +209,7 @@ class Window( } } - private suspend fun streamBalance(smoothing: PedalBalanceSmoothing) { + private suspend fun streamBalance(smoothing: PedalBalanceSmoothing, selectedSource: SelectedSource) { data class StreamData(val powerBalanceLeft: Double?, val power: Double?) karooSystem.streamDataFlow(smoothing.dataTypeId) @@ -221,7 +221,7 @@ class Window( .distinctUntilChanged() .throttle(1_000).collect { streamData -> val powerBalanceLeft = streamData.powerBalanceLeft - val powerbarsWithBalanceSource = powerbars.values.filter { it.source == SelectedSource.POWER_BALANCE } + val powerbarsWithBalanceSource = powerbars.values.filter { it.source == selectedSource } powerbarsWithBalanceSource.forEach { powerbar -> powerbar.drawMode = ProgressBarDrawMode.CENTER_OUT