lua interpolate
This commit is contained in:
parent
b188c70823
commit
44fa9b028b
|
@ -16,8 +16,23 @@ static int lua_efi_print(lua_State* l) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void configureRusefiLuaUtilHooks(lua_State* l) {
|
||||
lua_register(l, "print", lua_efi_print);
|
||||
static int lua_interpolate(lua_State* l) {
|
||||
auto x1 = luaL_checknumber(l, 1);
|
||||
auto y1 = luaL_checknumber(l, 2);
|
||||
auto x2 = luaL_checknumber(l, 3);
|
||||
auto y2 = luaL_checknumber(l, 4);
|
||||
auto x = luaL_checknumber(l, 5);
|
||||
|
||||
auto result = interpolateMsg("lua", x1, y1, x2, y2, x);
|
||||
|
||||
lua_pushnumber(l, result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void configureRusefiLuaUtilHooks(lua_State* l) {
|
||||
lua_register(l, "print", lua_efi_print);
|
||||
lua_register(l, "interpolate", lua_interpolate);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,16 @@ TEST(LuaHooks, CanTxDataLength) {
|
|||
EXPECT_ANY_THROW(testLuaExecString("txCan(1, 0, 0, 26)"));
|
||||
}
|
||||
|
||||
static const char* interpolationTest = R"(
|
||||
function testFunc()
|
||||
return interpolate(1, 10, 5, 50, 3)
|
||||
end
|
||||
)";
|
||||
|
||||
TEST(LuaHooks, LuaInterpolate) {
|
||||
EXPECT_EQ(testLuaReturnsNumber(interpolationTest), 30);
|
||||
}
|
||||
|
||||
static const char* timerTest = R"(
|
||||
function testFunc()
|
||||
local a = Timer.new()
|
||||
|
|
Loading…
Reference in New Issue