Lua to read tsOutputs #3376
This commit is contained in:
parent
efdad35984
commit
dafeaeaa31
|
@ -517,25 +517,7 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
return 1;
|
||||
});
|
||||
|
||||
#if !EFI_UNIT_TEST
|
||||
lua_register(l, "startPwm", lua_startPwm);
|
||||
lua_register(l, "setPwmDuty", lua_setPwmDuty);
|
||||
lua_register(l, "setPwmFreq", lua_setPwmFreq);
|
||||
|
||||
lua_register(l, "getFan", lua_fan);
|
||||
lua_register(l, "getDigital", lua_getDigital);
|
||||
lua_register(l, "setDebug", lua_setDebug);
|
||||
lua_register(l, "getAirmass", lua_getAirmass);
|
||||
lua_register(l, "setAirmass", lua_setAirmass);
|
||||
|
||||
lua_register(l, "stopEngine", [](lua_State* l) {
|
||||
doScheduleStopEngine();
|
||||
return 0;
|
||||
});
|
||||
lua_register(l, "setTimingAdd", [](lua_State* l) {
|
||||
engine->engineState.luaAdjustments.ignitionTimingAdd = luaL_checknumber(l, 1);
|
||||
return 0;
|
||||
});
|
||||
lua_register(l, "setTimingMult", [](lua_State* l) {
|
||||
engine->engineState.luaAdjustments.ignitionTimingMult = luaL_checknumber(l, 1);
|
||||
return 0;
|
||||
|
@ -553,12 +535,6 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
return 0;
|
||||
});
|
||||
|
||||
lua_register(l, "getTimeSinceTriggerEventMs", [](lua_State* l) {
|
||||
int result = engine->triggerCentral.m_lastEventTimer.getElapsedUs() / 1000;
|
||||
lua_pushnumber(l, result);
|
||||
return 1;
|
||||
});
|
||||
|
||||
lua_register(l, "getCalibration", [](lua_State* l) {
|
||||
auto propertyName = luaL_checklstring(l, 1, nullptr);
|
||||
auto result = getConfigValueByName(propertyName);
|
||||
|
@ -566,6 +542,45 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
return 1;
|
||||
});
|
||||
|
||||
lua_register(l, "setCalibration", [](lua_State* l) {
|
||||
auto propertyName = luaL_checklstring(l, 1, nullptr);
|
||||
auto value = luaL_checknumber(l, 2);
|
||||
auto incrementVersion = lua_toboolean(l, 3);
|
||||
setConfigValueByName(propertyName, value);
|
||||
if (incrementVersion) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
lua_register(l, "setTimingAdd", [](lua_State* l) {
|
||||
engine->engineState.luaAdjustments.ignitionTimingAdd = luaL_checknumber(l, 1);
|
||||
return 0;
|
||||
});
|
||||
|
||||
#if !EFI_UNIT_TEST
|
||||
lua_register(l, "startPwm", lua_startPwm);
|
||||
lua_register(l, "setPwmDuty", lua_setPwmDuty);
|
||||
lua_register(l, "setPwmFreq", lua_setPwmFreq);
|
||||
|
||||
lua_register(l, "getFan", lua_fan);
|
||||
lua_register(l, "getDigital", lua_getDigital);
|
||||
lua_register(l, "setDebug", lua_setDebug);
|
||||
lua_register(l, "getAirmass", lua_getAirmass);
|
||||
lua_register(l, "setAirmass", lua_setAirmass);
|
||||
|
||||
lua_register(l, "stopEngine", [](lua_State* l) {
|
||||
doScheduleStopEngine();
|
||||
return 0;
|
||||
});
|
||||
|
||||
lua_register(l, "getTimeSinceTriggerEventMs", [](lua_State* l) {
|
||||
int result = engine->triggerCentral.m_lastEventTimer.getElapsedUs() / 1000;
|
||||
lua_pushnumber(l, result);
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
#if EFI_CAN_SUPPORT
|
||||
lua_register(l, "canRxAdd", [](lua_State* l) {
|
||||
auto eid = luaL_checkinteger(l, 1);
|
||||
|
|
|
@ -23,6 +23,29 @@ TEST(LuaHooks, TestCrc8) {
|
|||
EXPECT_EQ(testLuaReturnsNumberOrNil(crc8scripts).value_or(0), 0x43);
|
||||
}
|
||||
|
||||
TEST(LuaHooks, TestGetCalibration) {
|
||||
// const char* sourceCode = R"(
|
||||
//
|
||||
// function testFunc()
|
||||
// return getCalibration("cranking.rpm")
|
||||
// end
|
||||
//
|
||||
// )";
|
||||
// EXPECT_EQ(testLuaReturnsNumber(sourceCode), 0x86);
|
||||
}
|
||||
|
||||
TEST(LuaHooks, TestSetCalibration) {
|
||||
// const char* sourceCode = R"(
|
||||
//
|
||||
// function testFunc()
|
||||
// setCalibration("cranking.rpm", 900, false)
|
||||
// end
|
||||
//
|
||||
// )";
|
||||
// EXPECT_EQ(testLuaReturnsNumber(sourceCode), 0x43);
|
||||
|
||||
}
|
||||
|
||||
static const char* getSensorTestByIndex = R"(
|
||||
|
||||
function testFunc()
|
||||
|
|
Loading…
Reference in New Issue