mirror of https://github.com/rusefi/rusefi-1.git
deinit lua pins when not used (#2876)
Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
2dd476dfc7
commit
3f63a108aa
|
@ -247,6 +247,9 @@ static bool runOneLua() {
|
||||||
chThdSleepMilliseconds(luaTickPeriodMs);
|
chThdSleepMilliseconds(luaTickPeriodMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// De-init pins, they will reinit next start of the script.
|
||||||
|
luaDeInitPins();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,13 @@ static int lua_startPwm(lua_State* l) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void luaDeInitPins() {
|
||||||
|
// Simply de-init all pins - when the script runs again, they will be re-init'd
|
||||||
|
for (size_t i = 0; i < efi::size(pins); i++) {
|
||||||
|
pins[i].deInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int lua_setPwmDuty(lua_State* l) {
|
static int lua_setPwmDuty(lua_State* l) {
|
||||||
auto p = luaL_checkPwmIndex(l, 1);
|
auto p = luaL_checkPwmIndex(l, 1);
|
||||||
auto duty = luaL_checknumber(l, 2);
|
auto duty = luaL_checknumber(l, 2);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void configureRusefiLuaHooks(lua_State*);
|
void configureRusefiLuaHooks(lua_State*);
|
||||||
|
void luaDeInitPins();
|
||||||
|
|
Loading…
Reference in New Issue