From a3a76f9e1b03949c1a2617f6269d7384a90a3ed1 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 17 Nov 2024 13:09:35 -0500 Subject: [PATCH] getConsumedGramsRemainder --- firmware/controllers/algo/trip_odometer.h | 4 ++++ firmware/controllers/lua/lua_hooks.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/firmware/controllers/algo/trip_odometer.h b/firmware/controllers/algo/trip_odometer.h index 7a70fe08ad..b6eb553c70 100644 --- a/firmware/controllers/algo/trip_odometer.h +++ b/firmware/controllers/algo/trip_odometer.h @@ -8,6 +8,10 @@ public: void consumeFuel(float grams, efitick_t nowNt); uint32_t getConsumedGrams() const; + // in case if integer number of grams moves too slow + float getConsumedGramsRemainder() const { + return m_consumedRemainder; + } float getConsumptionGramPerSecond() const; uint32_t getDistanceMeters() const; uint32_t getIgnitionOnTime() const; diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index 96d2d34e85..472917afef 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -705,6 +705,10 @@ void configureRusefiLuaHooks(lua_State* lState) { lua_pushnumber(l, engine->module()->getConsumedGrams()); return 1; }); + lua_register(lState, "getConsumedGramsRemainder", [](lua_State* l) { + lua_pushnumber(l, engine->module()->getConsumedGramsRemainder()); + return 1; + }); lua_register(lState, "getConsumptionGramPerSecond", [](lua_State* l) { lua_pushnumber(l, engine->module()->getConsumptionGramPerSecond()); return 1;