Skip to content

A tiny no-frills speedometer progressive web app based on Geolocation API, AmbientLightSensor API, and WakeLock API.

License

Notifications You must be signed in to change notification settings

bigprof-software/speedometer-pwa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

speedometer-pwa

A tiny no-frills speedometer progressive web app based on Geolocation API, AmbientLightSensor API, and WakeLock API.

test-drive-into-wall

Why?

Because the Combination Meter on my 2005 Prius is on the fritz, and I need a speedometer until I can tear apart and repair the faulty caps. :-)

How it works

The GeoLocation API has a Position interface, which contains a Coordinates object, coords. This Coordinates interface contains not only things you might expect (latitude, longitude), but also contains a property called speed, which is represents the device velocity in meters per second. Fun fact, Chrome on Android returns this prop with very little effort, at which point it's just a matter of some quick math to do the mph/kmh conversion.

Night mode

I implemented AmbientLightSensor API to enable a dark mode while driving at night. To get this working in Chrome on Android you have to enable Generic Sensor extra classes, which is behind a flag: chrome://flags#enable-generic-sensor-extra-classes

20181207-day-night-mode

Screen lock

Since M71, the WakeLock API has been enabled for testing purposes (see the current status on Chrome Platform Status). This ideally allows us to keep the screen from going into power saving mode and generally an off state. I've enabled this (you'll need M71 Chrome for Android) for testing.

Dev

Hop into the src folder and run the local web server of your choice. No specific tool required.

Build

I didn't really wrap this with build tooling, but I did crunch it down to 1.7K gzip'ed for fun using closure compiler and http-minifier. The rest is just some fancy Linux CLI jumping and sed (and I almost just used a make file instead ;-).

$ yarn install
$ yarn dist

FAQ

  1. How accurate is this?

When the dash is working on the Prius, it's pretty accurate from the looks of it. You're going to be constainted on any number of know problems with GPS (e.g., when the Coordinates.accuracy is not very good because of lock or assist issues).

  1. Why didn't you use build tools/a framework/something I like.

Didn't feel the need.

  1. Couldn't you have done this with the Generic Sensors API and the accelerometer?

Yeah, probably.

About

A tiny no-frills speedometer progressive web app based on Geolocation API, AmbientLightSensor API, and WakeLock API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 64.2%
  • CSS 23.2%
  • HTML 12.6%