* Made another attempt to improve the current fuel consumption calculation.
authorUrban Wallasch <urban.wallasch@freenet.de>
Sun, 4 Aug 2019 13:33:39 +0000 (15:33 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Sun, 4 Aug 2019 13:33:39 +0000 (15:33 +0200)
dash.html

index bd89a62827e427a583df41d47f5a043af1a0aa80..c8aacd33006fd13d1514f4371b6c2f91fbb9e99e 100644 (file)
--- a/dash.html
+++ b/dash.html
@@ -294,15 +294,20 @@ function update_cb() {
 
     // current fuel consumption:
     if ( last_fuel != tele.fuel && last_odometer != tele.odometer ) {
-      var fcons;
       if ( last_fuel > 0 && last_odometer > 0 )
-        fcons = (last_fuel - tele.fuel) * 100 / (tele.odometer - last_odometer);
-      else
-        fcons = -1;
-      fuel_cons.innerHTML = fcons < 0 ? '-' : fcons.toFixed(1);
+        fuel_cons.innerHTML = ((last_fuel-tele.fuel)*100 / (tele.odometer-last_odometer)).toFixed(1);
       last_fuel = tele.fuel;
       last_odometer = tele.odometer;
     }
+    else if ( tele.speed > 1 && tele.throttle_eff < 0.01 && tele.clutch_eff < 0.1 ) {
+      fuel_cons.innerHTML = '0';
+    }
+    else if ( tele.speed < 0.1 ) {
+      fuel_cons.innerHTML = tele.rpm < 0.1 ? '-' : '∞';
+    }
+    else {
+      // keep last displayed value
+    }
 
     // average fuel consumption:
     fuel_avg.innerHTML = (tele.fuel_avg * 100).toFixed(1);