minor move of code around

This commit is contained in:
rusefillc 2022-10-28 19:31:17 -04:00
parent ceab00d53d
commit c0ab0c7de3
3 changed files with 46 additions and 46 deletions

View File

@ -641,50 +641,6 @@ void configureRusefiLuaHooks(lua_State* l) {
return 1; 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 #if EFI_SENT_SUPPORT
lua_register(l, "getSentValue", lua_register(l, "getSentValue",
[](lua_State* l) { [](lua_State* l) {
@ -889,4 +845,8 @@ void configureRusefiLuaHooks(lua_State* l) {
lua_register(l, "canRxAddMask", lua_canRxAddMask); lua_register(l, "canRxAddMask", lua_canRxAddMask);
#endif // EFI_CAN_SUPPORT #endif // EFI_CAN_SUPPORT
#endif // not EFI_UNIT_TEST #endif // not EFI_UNIT_TEST
#if EFI_CAN_SUPPORT || EFI_UNIT_TEST
lua_register(l, "txCan", lua_txCan);
#endif
} }

View File

@ -7,6 +7,7 @@
#include "pch.h" #include "pch.h"
#include "lua_hooks_util.h" #include "lua_hooks_util.h"
#include "script_impl.h"
static int lua_efi_print(lua_State* l) { static int lua_efi_print(lua_State* l) {
auto msg = luaL_checkstring(l, 1); 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, "print", lua_efi_print);
lua_register(l, "interpolate", lua_interpolate); 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) #if defined(STM32F4) || defined(STM32F7)
lua_register(l, "mcu_standby", [](lua_State*) { lua_register(l, "mcu_standby", [](lua_State*) {
stm32_standby(); stm32_standby();

View File

@ -1,6 +1,5 @@
/** /**
* @file fsio_impl.h * @file script_impl.h
* @brief FSIO as it's used for GPIO
* *
* @date Oct 5, 2014 * @date Oct 5, 2014
* @author Andrey Belomutskiy, (c) 2012-2020 * @author Andrey Belomutskiy, (c) 2012-2020