Update measurement.js

Add conversion to gallons for non EV
This commit is contained in:
BennyDaBee 2022-06-14 08:54:02 -05:00 committed by GitHub
parent d3128f57e2
commit d918f946ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,8 @@ class Measurement {
'km', 'km',
'kPa', 'kPa',
'km/l(e)' 'km/l(e)'
// Helps with conversion to Gallons.
'lit'
]; ];
constructor(value, unit) { constructor(value, unit) {
@ -35,6 +37,8 @@ class Measurement {
case 'volts': case 'volts':
case 'Volts': case 'Volts':
return 'V'; return 'V';
case 'l':
return 'lit';
// these are states // these are states
case 'Stat': case 'Stat':
case 'N/A': case 'N/A':
@ -65,6 +69,8 @@ class Measurement {
case 'km/l(e)': case 'km/l(e)':
// km/L = (1.609344 / 3.785411784) * MPG // km/L = (1.609344 / 3.785411784) * MPG
value = _.round(value / (1.609344 / 3.785411784), 1); value = _.round(value / (1.609344 / 3.785411784), 1);
case 'lit':
value = _.round(value / 3.785411784, 1);
break; break;
} }
return value; return value;
@ -85,6 +91,8 @@ class Measurement {
return 'psi'; return 'psi';
case 'km/l(e)': case 'km/l(e)':
return 'mpg(e)'; return 'mpg(e)';
case 'lit':
return 'gal';
default: default:
return unit; return unit;
} }