Skip to content

Commit 7769126

Browse files
eriedclaude
andcommitted
feat(hud): GPS speed metric renders on the HUD overlay
Phone GPS speed already rode the wire (HudState.gpsSpeedKmh with gpsSource="PHONE") but the HUD threw it away and the overlay-metric enum had no GPS_SPEED key, so a GPS speed element did nothing on the HUD. Add GPS_SPEED to both StudioMetric copies (byte-identical key), a gpsSpeedKmh field on the phone and HUD WheelData, map the phone GPS speed through the HUD adapter, and merge it into the studio editor preview. No protocol bump - speed was already sent. Localized the picker label across 18 locales. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GADLyChheAoMX9dQbRgRnH
1 parent aaf6d00 commit 7769126

25 files changed

Lines changed: 37 additions & 1 deletion

File tree

app/src/main/java/com/eried/eucplanet/data/model/WheelData.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ data class WheelData(
2828
* or -1 when none is paired / no fresh sample. Merged in like the battery /
2929
* lat / long above so an overlay or HUD element can show it. */
3030
val externalGpsSpeedKmh: Float = -1f,
31+
/** Ground speed in km/h from the PHONE's fused GPS, or -1 when no fix.
32+
* Distinct from externalGpsSpeedKmh (a paired box); merged in like lat/long
33+
* so an overlay / HUD element can show the phone GPS speed. */
34+
val gpsSpeedKmh: Float = -1f,
3135
/** Phone IMU acceleration magnitude in g, 0 for trips recorded before this. */
3236
val gForce: Float = 0f,
3337
/** Phone IMU lateral acceleration in g (+right). 0 for trips recorded before this. */

app/src/main/java/com/eried/eucplanet/ui/studio/OverlayStudioViewModel.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ class OverlayStudioViewModel @Inject constructor(
164164
val extFresh = ext != null && System.currentTimeMillis() - ext.timestamp < 5_000L
165165
val extBattery = if (extFresh) (ext!!.batteryPercent ?: -1) else -1
166166
val extSpeed = if (extFresh) ext!!.speedKmh else -1f
167-
val withGps = if (loc != null) data.copy(latitude = loc.latitude, longitude = loc.longitude) else data
167+
val withGps = if (loc != null) data.copy(
168+
latitude = loc.latitude, longitude = loc.longitude,
169+
gpsSpeedKmh = if (loc.hasSpeed()) loc.speed * 3.6f else -1f
170+
) else data
168171
withGps.copy(externalGpsBatteryPercent = extBattery, externalGpsSpeedKmh = extSpeed)
169172
}.stateIn(viewModelScope, SharingStarted.Eagerly, WheelData())
170173

app/src/main/java/com/eried/eucplanet/ui/studio/StudioMetric.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum class StudioMetric(
4848
EXTERNAL_GPS_BATTERY("EXT_GPS_BATTERY", "Ext GPS battery", StudioMetricKind.PLAIN, "%", 0, 100f, { it.externalGpsBatteryPercent.toFloat() }),
4949
EXTERNAL_GPS_SPEED("EXT_GPS_SPEED", "Ext GPS speed", StudioMetricKind.SPEED, "", 1, 60f, { it.externalGpsSpeedKmh.coerceAtLeast(0f) }),
5050
TIRE_PRESSURE("TIRE_PRESSURE", "Tire pressure", StudioMetricKind.PRESSURE, "", 1, 50f, { it.tirePressureKpa }),
51+
GPS_SPEED("GPS_SPEED", "GPS speed", StudioMetricKind.SPEED, "", 1, 60f, { it.gpsSpeedKmh.coerceAtLeast(0f) }),
5152
// A lat/lng pair shown as text (not a scalar), so it only makes sense on a
5253
// text value element. extract is a placeholder; formatted() renders the pair.
5354
GPS("GPS", "GPS coordinates", StudioMetricKind.PLAIN, "", 0, 1f, { 0f }, textOnly = true);
@@ -113,5 +114,6 @@ fun StudioMetric.displayName(): String = when (this) {
113114
StudioMetric.EXTERNAL_GPS_BATTERY -> stringResource(R.string.studio_metric_external_gps_battery)
114115
StudioMetric.EXTERNAL_GPS_SPEED -> stringResource(R.string.studio_metric_external_gps_speed)
115116
StudioMetric.TIRE_PRESSURE -> stringResource(R.string.studio_metric_tire_pressure)
117+
StudioMetric.GPS_SPEED -> stringResource(R.string.studio_metric_gps_speed)
116118
StudioMetric.GPS -> stringResource(R.string.studio_metric_gps)
117119
}

app/src/main/res/values-b+es+419/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,7 @@
13931393
<string name="studio_metric_g_force">G-Force</string>
13941394
<string name="studio_metric_external_gps_battery">Batería GPS ext.</string>
13951395
<string name="studio_metric_external_gps_speed">Vel. GPS ext.</string>
1396+
<string name="studio_metric_gps_speed">Velocidad GPS</string>
13961397
<string name="studio_metric_gps">Coordenadas GPS</string>
13971398

13981399
<!-- Studio misc -->

app/src/main/res/values-da/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,7 @@
13801380
<string name="studio_metric_g_force">G-Force</string>
13811381
<string name="studio_metric_external_gps_battery">Ekst. GPS-batteri</string>
13821382
<string name="studio_metric_external_gps_speed">Ext. GPS-fart</string>
1383+
<string name="studio_metric_gps_speed">GPS-fart</string>
13831384
<string name="studio_metric_gps">GPS-koordinater</string>
13841385

13851386
<!-- Navigator -->

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,7 @@
13911391
<string name="studio_metric_g_force">G-Force</string>
13921392
<string name="studio_metric_external_gps_battery">Ext. GPS-Akku</string>
13931393
<string name="studio_metric_external_gps_speed">Ext. GPS-Tempo</string>
1394+
<string name="studio_metric_gps_speed">GPS-Tempo</string>
13941395
<string name="studio_metric_gps">GPS-Koordinaten</string>
13951396

13961397
<!-- Studio misc -->

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,7 @@
13791379
<string name="studio_metric_g_force">G-Force</string>
13801380
<string name="studio_metric_external_gps_battery">Batería GPS ext.</string>
13811381
<string name="studio_metric_external_gps_speed">Vel. GPS ext.</string>
1382+
<string name="studio_metric_gps_speed">Velocidad GPS</string>
13821383
<string name="studio_metric_gps">Coordenadas GPS</string>
13831384

13841385
<!-- Navigator -->

app/src/main/res/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@
14181418
<string name="studio_metric_g_force">G-Force</string>
14191419
<string name="studio_metric_external_gps_battery">Batterie GPS ext.</string>
14201420
<string name="studio_metric_external_gps_speed">Vitesse GPS ext.</string>
1421+
<string name="studio_metric_gps_speed">Vitesse GPS</string>
14211422
<string name="studio_metric_gps">Coordonnées GPS</string>
14221423

14231424
<!-- Studio: overwrite preset -->

app/src/main/res/values-it/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@
935935
<string name="studio_metric_g_force">G-Force</string>
936936
<string name="studio_metric_external_gps_battery">Batteria GPS est.</string>
937937
<string name="studio_metric_external_gps_speed">Vel. GPS est.</string>
938+
<string name="studio_metric_gps_speed">Velocità GPS</string>
938939
<string name="studio_metric_gps">Coordinate GPS</string>
939940
<string name="studio_metric_odometer">Contachilometri</string>
940941
<string name="studio_metric_pitch">Beccheggio</string>

app/src/main/res/values-ja/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,7 @@
13761376
<string name="studio_metric_g_force">G フォース</string>
13771377
<string name="studio_metric_external_gps_battery">外部GPSバッテリー</string>
13781378
<string name="studio_metric_external_gps_speed">外部GPS速度</string>
1379+
<string name="studio_metric_gps_speed">GPS速度</string>
13791380
<string name="studio_metric_gps">GPS 座標</string>
13801381

13811382
<!-- Navigator -->

0 commit comments

Comments
 (0)