diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/Extensions.kt b/app/src/main/kotlin/de/timklge/karooheadwind/Extensions.kt index 4a241c8..63754e1 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/Extensions.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/Extensions.kt @@ -28,7 +28,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.scan @@ -40,7 +39,6 @@ import kotlinx.serialization.json.Json import java.time.Duration import kotlin.math.abs import kotlin.math.absoluteValue -import kotlin.math.roundToInt import kotlin.time.Duration.Companion.seconds val jsonWithUnknownKeys = Json { ignoreUnknownKeys = true } @@ -203,14 +201,10 @@ fun KarooSystemService.getRelativeHeadingFlow(context: Context): Flow { } } -fun Double.lerp(target: Double, alpha: Double): Double { - return this + (target - this) * alpha -} - fun KarooSystemService.getHeadingFlow(): Flow { //return flowOf(20.0) - return streamDataFlow("TYPE_LOCATION_ID") + return streamDataFlow(DataType.Type.LOCATION) .mapNotNull { (it as? StreamState.Streaming)?.dataPoint?.values } .map { values -> val heading = values[DataType.Field.LOC_BEARING] @@ -218,7 +212,7 @@ fun KarooSystemService.getHeadingFlow(): Flow { heading ?: 0.0 } .distinctUntilChanged() - .scan(emptyList()) { acc, value -> + .scan(emptyList()) { acc, value -> /* Average over 3 values */ val newAcc = acc + value if (newAcc.size > 3) newAcc.drop(1) else newAcc } @@ -229,7 +223,7 @@ fun KarooSystemService.getHeadingFlow(): Flow { fun KarooSystemService.getGpsCoordinateFlow(): Flow { // return flowOf(GpsCoordinates(52.5164069,13.3784)) - return streamDataFlow("TYPE_LOCATION_ID") + return streamDataFlow(DataType.Type.LOCATION) .mapNotNull { (it as? StreamState.Streaming)?.dataPoint?.values } .mapNotNull { values -> val lat = values[DataType.Field.LOC_LATITUDE] diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/HeadwindDirectionDataType.kt b/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/HeadwindDirectionDataType.kt index d1e9f75..62649a0 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/HeadwindDirectionDataType.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/HeadwindDirectionDataType.kt @@ -77,7 +77,7 @@ class HeadwindDirectionDataType( val baseBitmap = BitmapFactory.decodeResource( context.resources, - de.timklge.karooheadwind.R.drawable.arrow + de.timklge.karooheadwind.R.drawable.circle ) val configJob = CoroutineScope(Dispatchers.IO).launch { diff --git a/app/src/main/res/drawable/circle.png b/app/src/main/res/drawable/circle.png new file mode 100755 index 0000000..cadf6ca Binary files /dev/null and b/app/src/main/res/drawable/circle.png differ