mirror of https://github.com/FOME-Tech/fome-fw.git
lua curve progress
This commit is contained in:
parent
2bd0633ecb
commit
57dc9b36f4
|
@ -16,6 +16,10 @@ using namespace luaaa;
|
||||||
// Some functions lean on existing FSIO implementation
|
// Some functions lean on existing FSIO implementation
|
||||||
#include "fsio_impl.h"
|
#include "fsio_impl.h"
|
||||||
|
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
Engine *engineForLuaUnitTests;
|
||||||
|
#endif
|
||||||
|
|
||||||
static int lua_readpin(lua_State* l) {
|
static int lua_readpin(lua_State* l) {
|
||||||
auto msg = luaL_checkstring(l, 1);
|
auto msg = luaL_checkstring(l, 1);
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
@ -91,6 +95,21 @@ static int lua_table3d(lua_State* l) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lua_curve2d(lua_State* l) {
|
||||||
|
auto curveIdx = luaL_checkinteger(l, 1);
|
||||||
|
auto x = luaL_checknumber(l, 2);
|
||||||
|
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
Engine *engine = engineForLuaUnitTests;
|
||||||
|
EXPAND_Engine;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
auto result = getCurveValue(curveIdx, x PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
|
lua_pushnumber(l, result);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int lua_txCan(lua_State* l) {
|
static int lua_txCan(lua_State* l) {
|
||||||
auto channel = luaL_checkinteger(l, 1);
|
auto channel = luaL_checkinteger(l, 1);
|
||||||
// TODO: support multiple channels
|
// TODO: support multiple channels
|
||||||
|
@ -390,6 +409,7 @@ void configureRusefiLuaHooks(lua_State* l) {
|
||||||
lua_register(l, "getSensorRaw", lua_getSensorRaw);
|
lua_register(l, "getSensorRaw", lua_getSensorRaw);
|
||||||
lua_register(l, "hasSensor", lua_hasSensor);
|
lua_register(l, "hasSensor", lua_hasSensor);
|
||||||
lua_register(l, "table3d", lua_table3d);
|
lua_register(l, "table3d", lua_table3d);
|
||||||
|
lua_register(l, "curve", lua_curve2d);
|
||||||
lua_register(l, "txCan", lua_txCan);
|
lua_register(l, "txCan", lua_txCan);
|
||||||
|
|
||||||
#if !EFI_UNIT_TEST
|
#if !EFI_UNIT_TEST
|
||||||
|
|
|
@ -29,6 +29,7 @@ extern bool printTriggerDebug;
|
||||||
extern bool printTriggerTrace;
|
extern bool printTriggerTrace;
|
||||||
extern bool printFuelDebug;
|
extern bool printFuelDebug;
|
||||||
extern int minCrankingRpm;
|
extern int minCrankingRpm;
|
||||||
|
extern Engine *engineForLuaUnitTests;
|
||||||
|
|
||||||
EngineTestHelperBase::EngineTestHelperBase() {
|
EngineTestHelperBase::EngineTestHelperBase() {
|
||||||
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
||||||
|
@ -58,6 +59,8 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb
|
||||||
engine->setConfig(engine, &persistentConfig.engineConfiguration, &persistentConfig);
|
engine->setConfig(engine, &persistentConfig.engineConfiguration, &persistentConfig);
|
||||||
EXPAND_Engine;
|
EXPAND_Engine;
|
||||||
|
|
||||||
|
engineForLuaUnitTests = engine;
|
||||||
|
|
||||||
Sensor::setMockValue(SensorType::Clt, 70);
|
Sensor::setMockValue(SensorType::Clt, 70);
|
||||||
Sensor::setMockValue(SensorType::Iat, 30);
|
Sensor::setMockValue(SensorType::Iat, 30);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue