Add 3 second, 10 second moving averages for power balance data source (#61)
Some checks failed
Build / build (push) Failing after 7m15s
Some checks failed
Build / build (push) Failing after 7m15s
This commit is contained in:
parent
4c5b6aac15
commit
2a02a8e649
@ -188,7 +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()
|
||||
SelectedSource.POWER_BALANCE -> streamBalance(PedalBalanceSmoothing.RAW)
|
||||
SelectedSource.POWER_BALANCE_3S -> streamBalance(PedalBalanceSmoothing.SMOOTHED_3S)
|
||||
SelectedSource.POWER_BALANCE_10S -> streamBalance(PedalBalanceSmoothing.SMOOTHED_10S)
|
||||
SelectedSource.FRONT_GEAR -> streamGears(Gears.FRONT)
|
||||
SelectedSource.REAR_GEAR -> streamGears(Gears.REAR)
|
||||
SelectedSource.NONE -> {}
|
||||
@ -207,10 +209,10 @@ class Window(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun streamBalance() {
|
||||
private suspend fun streamBalance(smoothing: PedalBalanceSmoothing) {
|
||||
data class StreamData(val powerBalanceLeft: Double?, val power: Double?)
|
||||
|
||||
karooSystem.streamDataFlow(DataType.Type.PEDAL_POWER_BALANCE)
|
||||
karooSystem.streamDataFlow(smoothing.dataTypeId)
|
||||
.map {
|
||||
val values = (it as? StreamState.Streaming)?.dataPoint?.values
|
||||
|
||||
@ -605,6 +607,12 @@ class Window(
|
||||
SMOOTHED_10S(DataType.Type.SMOOTHED_10S_AVERAGE_POWER),
|
||||
}
|
||||
|
||||
enum class PedalBalanceSmoothing(val dataTypeId: String){
|
||||
RAW(DataType.Type.PEDAL_POWER_BALANCE),
|
||||
SMOOTHED_3S(DataType.Type.SMOOTHED_3S_AVERAGE_PEDAL_POWER_BALANCE),
|
||||
SMOOTHED_10S(DataType.Type.SMOOTHED_10S_AVERAGE_PEDAL_POWER_BALANCE),
|
||||
}
|
||||
|
||||
private suspend fun streamPower(source: SelectedSource, smoothed: PowerStreamSmoothing) {
|
||||
val powerFlow = karooSystem.streamDataFlow(smoothed.dataTypeId)
|
||||
.map { (it as? StreamState.Streaming)?.dataPoint?.singleValue }
|
||||
|
||||
@ -90,6 +90,8 @@ enum class SelectedSource(val id: String, val labelResId: Int) {
|
||||
CADENCE_3S("cadence_3s", R.string.source_cadence_3s),
|
||||
GRADE("grade", R.string.source_grade),
|
||||
POWER_BALANCE("power_balance", R.string.source_power_balance),
|
||||
POWER_BALANCE_3S("power_balance_3s", R.string.source_power_balance_3s),
|
||||
POWER_BALANCE_10S("power_balance_10s", R.string.source_power_balance_10s),
|
||||
ROUTE_PROGRESS("route_progress", R.string.source_route_progress),
|
||||
REMAINING_ROUTE("route_progress_remaining", R.string.source_route_remaining),
|
||||
FRONT_GEAR("front_gear", R.string.source_front_gear),
|
||||
|
||||
@ -47,6 +47,8 @@
|
||||
<string name="source_cadence_3s">Trittfrequenz (3 Sek. Ø)</string>
|
||||
<string name="source_grade">Steigung</string>
|
||||
<string name="source_power_balance">Leistungsbalance</string>
|
||||
<string name="source_power_balance_3s">Leistungsbalance (3 Sek. Ø)</string>
|
||||
<string name="source_power_balance_10s">Leistungsbalance (10 Sek. Ø)</string>
|
||||
<string name="source_route_progress">Routenfortschritt</string>
|
||||
<string name="source_route_remaining">Verbleibende Route</string>
|
||||
<string name="source_front_gear">Vorderer Gang</string>
|
||||
|
||||
@ -47,6 +47,8 @@
|
||||
<string name="source_cadence_3s">Cadence (3 sec avg)</string>
|
||||
<string name="source_grade">Grade</string>
|
||||
<string name="source_power_balance">Power Balance</string>
|
||||
<string name="source_power_balance_3s">Power Balance (3 sec avg)</string>
|
||||
<string name="source_power_balance_10s">Power Balance (10 sec avg)</string>
|
||||
<string name="source_route_progress">Route Progress</string>
|
||||
<string name="source_route_remaining">Route Remaining</string>
|
||||
<string name="source_front_gear">Front Gear</string>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user