diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 376d007..5d47c3e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -90,7 +90,8 @@ tasks.register("generateManifest") { "latestVersionCode" to android.defaultConfig.versionCode, "developer" to "github.com/timklge", "description" to "Open-source extension that provides headwind direction, wind speed and other weather data fields.", - "releaseNotes" to "* Interpolate between forecasted and current weather data\n" + + "releaseNotes" to "* Fix precipitation forecast field\n" + + "* Interpolate between forecasted and current weather data\n" + "* Colorize field background instead of text\n" + "* Add OpenWeatherMap support contributed by lockevod\n" + "* Add tailwind field\n" + diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/DataStore.kt b/app/src/main/kotlin/de/timklge/karooheadwind/DataStore.kt index cfc9413..f956a63 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/DataStore.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/DataStore.kt @@ -263,6 +263,7 @@ fun lerpWeather( temperature = start.temperature + (end.temperature - start.temperature) * factor, relativeHumidity = lerpNullable(start.relativeHumidity, end.relativeHumidity, factor), precipitation = start.precipitation + (end.precipitation - start.precipitation) * factor, + precipitationProbability = lerpNullable(start.precipitationProbability, end.precipitationProbability, factor), cloudCover = lerpNullable(start.cloudCover, end.cloudCover, factor), surfacePressure = lerpNullable(start.surfacePressure, end.surfacePressure, factor), sealevelPressure = lerpNullable(start.sealevelPressure, end.sealevelPressure, factor), diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/PrecipitationForecastDataType.kt b/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/PrecipitationForecastDataType.kt index fe24e2e..39371c7 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/PrecipitationForecastDataType.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/datatypes/PrecipitationForecastDataType.kt @@ -24,6 +24,7 @@ import de.timklge.karooheadwind.TemperatureUnit import de.timklge.karooheadwind.weatherprovider.WeatherInterpretation import io.hammerhead.karooext.KarooSystemService import kotlin.math.absoluteValue +import kotlin.math.ceil import kotlin.math.roundToInt @Composable @@ -38,7 +39,7 @@ fun PrecipitationForecast( Column(modifier = GlanceModifier.fillMaxHeight().padding(1.dp).width(86.dp), horizontalAlignment = rowAlignment) { Row(modifier = GlanceModifier.defaultWeight().fillMaxWidth(), horizontalAlignment = rowAlignment, verticalAlignment = Alignment.CenterVertically) { val precipitationProbabilityText = if (precipitationProbability != null) "${precipitationProbability}% " else "" - val precipitationText = if (precipitation > 0) precipitation.toString() else "" + val precipitationText = precipitation.toString() Text( text = "${precipitationProbabilityText}${precipitationText}", style = TextStyle(color = ColorProvider(Color.Black, Color.White), fontFamily = FontFamily.Monospace, fontSize = TextUnit(24f, TextUnitType.Sp), textAlign = TextAlign.Center) @@ -97,7 +98,7 @@ class PrecipitationForecastDataType(karooSystem: KarooSystemService) : ForecastD isImperial: Boolean ) { PrecipitationForecast( - precipitation = precipitation.roundToInt().coerceAtLeast(0), + precipitation = ceil(precipitation).toInt(), precipitationProbability = precipitationProbability, distance = distance, timeLabel = timeLabel, diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/weatherprovider/openmeteo/OpenMeteoWeatherForecastData.kt b/app/src/main/kotlin/de/timklge/karooheadwind/weatherprovider/openmeteo/OpenMeteoWeatherForecastData.kt index c9c6035..72d1ffa 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/weatherprovider/openmeteo/OpenMeteoWeatherForecastData.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/weatherprovider/openmeteo/OpenMeteoWeatherForecastData.kt @@ -20,6 +20,7 @@ data class OpenMeteoWeatherForecastData( WeatherData( temperature = temperature[index], precipitation = precipitation[index], + precipitationProbability = precipitationProbability[index].toDouble(), windSpeed = windSpeed[index], windDirection = windDirection[index], windGusts = windGusts[index],