Merged LuaScriptPreemption

This commit is contained in:
jfrickmann
2021-07-24 17:32:41 -04:00
11 changed files with 682 additions and 508 deletions
@@ -167,7 +167,6 @@ class ScriptEditWindow : public Page {
};
constexpr char SCRIPT_STATUS_ERROR[] = "(error)";
constexpr char SCRIPT_STATUS_KILLED[] = "(killed)";
class ScriptLineButton : public Button
{
@@ -204,10 +203,6 @@ class ScriptLineButton : public Button
dc->drawSizedText(x, y, SCRIPT_STATUS_ERROR,
sizeof(SCRIPT_STATUS_ERROR), textColor);
break;
case SCRIPT_KILLED:
dc->drawSizedText(x, y, SCRIPT_STATUS_KILLED,
sizeof(SCRIPT_STATUS_KILLED), textColor);
break;
default:
dc->drawNumber(x, y, runtimeData->instructions, textColor, 0, nullptr, "%");
break;
+11 -8
View File
@@ -155,20 +155,23 @@ void StandaloneLuaWindow::runLua(event_t evt)
// Set global LUA LCD buffer
luaLcdBuffer = &lcdBuffer;
TRACE("evt = 0x%x", evt);
bool hasRun = luaTask(evt, RUN_STNDAL_SCRIPT, true);
if (hasRun) {
if (luaState != INTERPRETER_RELOAD_PERMANENT_SCRIPTS) {
if (luaTask(evt, true)) {
#if defined(DEBUG_WINDOWS)
TRACE("# StandaloneLuaWindow::invalidate()");
TRACE("# StandaloneLuaWindow::invalidate()");
#endif
invalidate();
} else {
invalidate();
} else {
// The script was preempted, and the LCD should not be updated yet
}
}
if (luaState == INTERPRETER_RELOAD_PERMANENT_SCRIPTS) {
// Script does not run anymore...
TRACE("LUA standalone script exited: deleting window!");
deleteLater();
}
// Kill global LUA LCD buffer
luaLcdBuffer = nullptr;
}