minor move of code around
This commit is contained in:
parent
0f851f17d3
commit
9efd9aaa15
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue