diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index ce98b272cd..b1c086d632 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -641,50 +641,6 @@ void configureRusefiLuaHooks(lua_State* l) { return 1; }); - lua_register(l, "findCurveIndex", [](lua_State* l) { - auto name = luaL_checklstring(l, 1, nullptr); - auto result = getCurveIndexByName(name); - if (!result) { - lua_pushnil(l); - } else { - // TS counts curve from 1 so convert indexing here - lua_pushnumber(l, result.Value + HUMAN_OFFSET); - } - return 1; - }); - -#if EFI_CAN_SUPPORT || EFI_UNIT_TEST - lua_register(l, "txCan", lua_txCan); -#endif - - lua_register(l, "findTableIndex", - [](lua_State* l) { - auto name = luaL_checklstring(l, 1, nullptr); - auto index = getTableIndexByName(name); - if (!index) { - lua_pushnil(l); - } else { - // TS counts curve from 1 so convert indexing here - lua_pushnumber(l, index.Value + HUMAN_OFFSET); - } - return 1; - }); - - lua_register(l, "findSetting", - [](lua_State* l) { - auto name = luaL_checklstring(l, 1, nullptr); - auto defaultValue = luaL_checknumber(l, 2); - - auto index = getSettingIndexByName(name); - if (!index) { - lua_pushnumber(l, defaultValue); - } else { - // TS counts curve from 1 so convert indexing here - lua_pushnumber(l, engineConfiguration->scriptSetting[index.Value]); - } - return 1; - }); - #if EFI_SENT_SUPPORT lua_register(l, "getSentValue", [](lua_State* l) { @@ -889,4 +845,8 @@ void configureRusefiLuaHooks(lua_State* l) { lua_register(l, "canRxAddMask", lua_canRxAddMask); #endif // EFI_CAN_SUPPORT #endif // not EFI_UNIT_TEST + +#if EFI_CAN_SUPPORT || EFI_UNIT_TEST + lua_register(l, "txCan", lua_txCan); +#endif } diff --git a/firmware/controllers/lua/lua_hooks_util.cpp b/firmware/controllers/lua/lua_hooks_util.cpp index c984d23149..e930fdd86c 100644 --- a/firmware/controllers/lua/lua_hooks_util.cpp +++ b/firmware/controllers/lua/lua_hooks_util.cpp @@ -7,6 +7,7 @@ #include "pch.h" #include "lua_hooks_util.h" +#include "script_impl.h" static int lua_efi_print(lua_State* l) { auto msg = luaL_checkstring(l, 1); @@ -39,6 +40,46 @@ void configureRusefiLuaUtilHooks(lua_State* l) { lua_register(l, "print", lua_efi_print); lua_register(l, "interpolate", lua_interpolate); + lua_register(l, "findCurveIndex", [](lua_State* l) { + auto name = luaL_checklstring(l, 1, nullptr); + auto result = getCurveIndexByName(name); + if (!result) { + lua_pushnil(l); + } else { + // TS counts curve from 1 so convert indexing here + lua_pushnumber(l, result.Value + HUMAN_OFFSET); + } + return 1; + }); + + lua_register(l, "findTableIndex", + [](lua_State* l) { + auto name = luaL_checklstring(l, 1, nullptr); + auto index = getTableIndexByName(name); + if (!index) { + lua_pushnil(l); + } else { + // TS counts curve from 1 so convert indexing here + lua_pushnumber(l, index.Value + HUMAN_OFFSET); + } + return 1; + }); + + lua_register(l, "findSetting", + [](lua_State* l) { + auto name = luaL_checklstring(l, 1, nullptr); + auto defaultValue = luaL_checknumber(l, 2); + + auto index = getSettingIndexByName(name); + if (!index) { + lua_pushnumber(l, defaultValue); + } else { + // TS counts curve from 1 so convert indexing here + lua_pushnumber(l, engineConfiguration->scriptSetting[index.Value]); + } + return 1; + }); + #if defined(STM32F4) || defined(STM32F7) lua_register(l, "mcu_standby", [](lua_State*) { stm32_standby(); diff --git a/firmware/controllers/lua/script_impl.h b/firmware/controllers/lua/script_impl.h index 5b79c006f8..6e15eb9b12 100644 --- a/firmware/controllers/lua/script_impl.h +++ b/firmware/controllers/lua/script_impl.h @@ -1,6 +1,5 @@ /** - * @file fsio_impl.h - * @brief FSIO as it's used for GPIO + * @file script_impl.h * * @date Oct 5, 2014 * @author Andrey Belomutskiy, (c) 2012-2020