deinit lua pins when not used (#2876)

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-06-28 05:39:03 -07:00 committed by GitHub
parent 2dd476dfc7
commit 3f63a108aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -247,6 +247,9 @@ static bool runOneLua() {
chThdSleepMilliseconds(luaTickPeriodMs);
}
// De-init pins, they will reinit next start of the script.
luaDeInitPins();
return true;
}

View File

@ -101,6 +101,13 @@ static int lua_startPwm(lua_State* l) {
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) {
auto p = luaL_checkPwmIndex(l, 1);
auto duty = luaL_checknumber(l, 2);

View File

@ -1,3 +1,4 @@
#pragma once
void configureRusefiLuaHooks(lua_State*);
void luaDeInitPins();