From 3cc2aa12c771e4bb6294d9e81951bd895870b152 Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Sun, 4 Aug 2019 15:33:39 +0200 Subject: [PATCH] * Made another attempt to improve the current fuel consumption calculation. --- dash.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/dash.html b/dash.html index bd89a62..c8aacd3 100644 --- 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); -- 2.30.2