mirror of https://github.com/FOME-Tech/fome-fw.git
script settings need names!
This commit is contained in:
parent
fde7fa93a1
commit
899a10c829
|
@ -799,6 +799,12 @@ void setHellenDefaultVrThresholds(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void proteusHarley(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
void proteusHarley(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||||
|
strcpy(engineConfiguration->scriptSettingName[0], "compReleaseRpm");
|
||||||
|
engineConfiguration->scriptSetting[0] = 300;
|
||||||
|
strcpy(engineConfiguration->scriptSettingName[1], "compReleaseDur");
|
||||||
|
engineConfiguration->scriptSetting[1] = 5000;
|
||||||
|
|
||||||
|
|
||||||
engineConfiguration->luaOutputPins[0] = PROTEUS_LS_12;
|
engineConfiguration->luaOutputPins[0] = PROTEUS_LS_12;
|
||||||
#if HW_PROTEUS
|
#if HW_PROTEUS
|
||||||
strncpy(config->luaScript, R"(
|
strncpy(config->luaScript, R"(
|
||||||
|
|
|
@ -280,6 +280,7 @@ ValueProvider3D *getscriptTable(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: template this copy-pasta
|
||||||
/**
|
/**
|
||||||
* @return zero-based index of curve with given name
|
* @return zero-based index of curve with given name
|
||||||
*/
|
*/
|
||||||
|
@ -301,6 +302,15 @@ int getTableIndexByName(const char *name DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
return EFI_ERROR_CODE;
|
return EFI_ERROR_CODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSettingIndexByName(const char *name DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
for (int i = 0;i<SCRIPT_SETTING_COUNT;i++) {
|
||||||
|
if (strEqualCaseInsensitive(name, engineConfiguration->scriptSettingName[i])) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EFI_ERROR_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
float getCurveValue(int index, float key DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
float getCurveValue(int index, float key DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
// not great code at all :(
|
// not great code at all :(
|
||||||
switch (index) {
|
switch (index) {
|
||||||
|
|
|
@ -31,5 +31,6 @@ void runHardcodedFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
float getCurveValue(int index, float key DECLARE_ENGINE_PARAMETER_SUFFIX);
|
float getCurveValue(int index, float key DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
int getCurveIndexByName(const char *name DECLARE_ENGINE_PARAMETER_SUFFIX);
|
int getCurveIndexByName(const char *name DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
int getTableIndexByName(const char *name DECLARE_ENGINE_PARAMETER_SUFFIX);
|
int getTableIndexByName(const char *name DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
int getSettingIndexByName(const char *name DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
ValueProvider3D *getscriptTable(int index);
|
ValueProvider3D *getscriptTable(int index);
|
||||||
|
|
||||||
|
|
|
@ -480,16 +480,32 @@ void configureRusefiLuaHooks(lua_State* l) {
|
||||||
EXPAND_Engine;
|
EXPAND_Engine;
|
||||||
#endif
|
#endif
|
||||||
auto name = luaL_checklstring(l, 1, nullptr);
|
auto name = luaL_checklstring(l, 1, nullptr);
|
||||||
auto result = getTableIndexByName(name PASS_ENGINE_PARAMETER_SUFFIX);
|
auto index = getTableIndexByName(name PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
if (result == EFI_ERROR_CODE) {
|
if (index == EFI_ERROR_CODE) {
|
||||||
lua_pushnil(l);
|
lua_pushnil(l);
|
||||||
} else {
|
} else {
|
||||||
// TS counts curve from 1 so convert indexing here
|
// TS counts curve from 1 so convert indexing here
|
||||||
lua_pushnumber(l, result + HUMAN_OFFSET);
|
lua_pushnumber(l, index + HUMAN_OFFSET);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
lua_register(l, "findSetting",
|
||||||
|
[](lua_State* l) {
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
Engine *engine = engineForLuaUnitTests;
|
||||||
|
EXPAND_Engine;
|
||||||
|
#endif
|
||||||
|
auto name = luaL_checklstring(l, 1, nullptr);
|
||||||
|
auto index = getSettingIndexByName(name PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
if (index == EFI_ERROR_CODE) {
|
||||||
|
lua_pushnil(l);
|
||||||
|
} else {
|
||||||
|
// TS counts curve from 1 so convert indexing here
|
||||||
|
lua_pushnumber(l, engineConfiguration->scriptSetting[index]);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
#if !EFI_UNIT_TEST
|
#if !EFI_UNIT_TEST
|
||||||
lua_register(l, "startPwm", lua_startPwm);
|
lua_register(l, "startPwm", lua_startPwm);
|
||||||
|
|
Loading…
Reference in New Issue