LIVE cartercole.net --:--:-- UTC

// 04 RESTRICTED

dash

SWIFT KOTLIN ANDROID AUTO ACCESS RESTRICTED

A GPS speedometer and trip recorder meant to sit on a car's dashboard. The iPhone app shows speed, heading, altitude and g-force, records each trip's distance, moving time, top speed, peak g and route, and has a HUD mode that flips the display so it reads correctly reflected off the windshield. Points marked on the map work as timing gates: drive through one and Dash announces your speed there and keeps the fastest pass. A Kotlin port draws the same dashboard on a car's own screen through Android Auto.

Points and courses

Tap MARK and the spot you are on becomes a point; a long press on the map drops one anywhere. Each point is a circle, 50 m in radius by default and anywhere from 25 to 500 m. A pass is reported at the closest approach, after the car has gone by, with the speed worked out between the fixes on either side of the point. Entering the circle would be too early: on a fast road with a big circle that can be many seconds before the point itself.

The path between consecutive fixes is tested, not only the fixes, because at speed two fixes can land on either side of a small circle with neither inside it. Fixes more than 15 s apart, or that imply more than 120 m/s, are not joined into a path. A point re-arms only once a fix is 1.25 radii away, so GPS jitter at the edge cannot count one pass twice. Each point keeps its pass count, its last pass and its fastest, and the first pass only sets the baseline.

A saved trip can become a course: points every so many metres along its route (no closer than 100 m, no more than 150 points), previewed before they are added and deleted together. Drive the route again and each point reports the speed through it.

The trip maths

Speed comes from the GPS, or from distance over time when the GPS reports none, and anything under 0.6 m/s (about 1.3 mph) counts as stopped, so drift while parked adds no distance. A jump faster than about 270 mph is thrown out, the route keeps a point every 8 m, and a trip shorter than 20 m is not saved. G-force comes from the motion sensor at 10 Hz, lightly smoothed. Location runs in the background only while a trip is recording, and the screen stays on while the app is open.

On a car screen

The Android TripManager is a line-for-line port of the iOS one with no Android types in it, so it runs under JVM unit tests. One renderer draws the dashboard onto any Canvas: the phone screen and the navigation surface Android Auto hands to navigation-category apps. The car draws its own Start, Pause, Stop, unit and HUD buttons over it from the Car App Library. Rendering uses a software canvas on purpose, because a hardware canvas handed frames over asynchronously and a surface destroyed mid-frame crashed the app.

Stated honestly