Merged LuaScriptPreemption
This commit is contained in:
@@ -157,9 +157,6 @@ void menuModelCustomScripts(event_t event)
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
lcdDrawText(30*FW+2, y, "(error)");
|
||||
break;
|
||||
case SCRIPT_KILLED:
|
||||
lcdDrawText(29*FW+2, y, "(killed)");
|
||||
break;
|
||||
default:
|
||||
lcdDrawNumber(34*FW, y, luaGetCpuUsed(scriptIndex), RIGHT);
|
||||
lcdDrawChar(34*FW, y, '%');
|
||||
|
||||
@@ -177,7 +177,6 @@ bool displayTelemetryScreen()
|
||||
return false; // requested lua telemetry screen not available
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
case SCRIPT_PANIC:
|
||||
case SCRIPT_KILLED:
|
||||
luaError(lsScripts, state, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -150,9 +150,6 @@ void menuModelCustomScripts(event_t event)
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
lcdDrawText(30*FW+2, y, "(error)");
|
||||
break;
|
||||
case SCRIPT_KILLED:
|
||||
lcdDrawText(29*FW+2, y, "(killed)");
|
||||
break;
|
||||
default:
|
||||
lcdDrawNumber(34*FW, y, luaGetCpuUsed(scriptIndex), RIGHT);
|
||||
lcdDrawChar(34*FW, y, '%');
|
||||
|
||||
@@ -179,7 +179,6 @@ bool displayTelemetryScreen()
|
||||
return false; // requested lua telemetry screen not available
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
case SCRIPT_PANIC:
|
||||
case SCRIPT_KILLED:
|
||||
luaError(lsScripts, state, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user