From c66dcaf45472ccc442dc9521a8565269320ee543 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 4 Jan 2022 23:15:03 -0500 Subject: [PATCH] LUA read ECU state: Cranking, Idling, Cruising #3742 --- firmware/controllers/lua/lua_hooks.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index 7581927c8a..13858f5052 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -560,6 +560,21 @@ void configureRusefiLuaHooks(lua_State* l) { return 1; }); + lua_register(l, "getEngineState", [](lua_State* l) { + spinning_state_e state = engine->rpmCalculator.getState(); + int luaStateCode; + if (state == STOPPED) { + luaStateCode = 0; + } else if (state == RUNNING) { + luaStateCode = 2; + } else { + luaStateCode = 1; + } + lua_pushnumber(l, luaStateCode); + return 1; + }); + + lua_register(l, "setCalibration", [](lua_State* l) { auto propertyName = luaL_checklstring(l, 1, nullptr); auto value = luaL_checknumber(l, 2);