fix(lua): Do not pass key event that triggered telemetry view to lua (#4168)

This commit is contained in:
bug400
2023-11-07 09:08:31 +10:00
committed by GitHub
parent 3051f70625
commit 926dc36d51
4 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ void StandaloneLuaWindow::checkEvents()
if (luaState != INTERPRETER_RELOAD_PERMANENT_SCRIPTS) { if (luaState != INTERPRETER_RELOAD_PERMANENT_SCRIPTS) {
// if LUA finished a full cycle, // if LUA finished a full cycle,
// invalidate to display the screen buffer // invalidate to display the screen buffer
if (luaTask(0, true)) { invalidate(); } if (luaTask(true)) { invalidate(); }
} }
if (luaState == INTERPRETER_RELOAD_PERMANENT_SCRIPTS) { if (luaState == INTERPRETER_RELOAD_PERMANENT_SCRIPTS) {
+1 -4
View File
@@ -1255,14 +1255,11 @@ static bool resumeLua(bool init, bool allowLcdUsage)
} //resumeLua(...) } //resumeLua(...)
bool luaTask(event_t evt, bool allowLcdUsage) bool luaTask(bool allowLcdUsage)
{ {
bool init = false; bool init = false;
bool scriptWasRun = false; bool scriptWasRun = false;
// Add event to buffer
if (evt != 0) { luaPushEvent(evt); }
// For preemption // For preemption
luaCycleStart = get_tmr10ms(); luaCycleStart = get_tmr10ms();
+1 -1
View File
@@ -189,7 +189,7 @@ extern ScriptInternalData scriptInternalData[MAX_SCRIPTS];
extern ScriptInputsOutputs scriptInputsOutputs[MAX_SCRIPTS]; extern ScriptInputsOutputs scriptInputsOutputs[MAX_SCRIPTS];
void luaClose(lua_State ** L); void luaClose(lua_State ** L);
bool luaTask(event_t evt, bool allowLcdUsage); bool luaTask(bool allowLcdUsage);
void checkLuaMemoryUsage(); void checkLuaMemoryUsage();
void luaExec(const char * filename); void luaExec(const char * filename);
void luaDoGc(lua_State * L, bool full); void luaDoGc(lua_State * L, bool full);
+15 -8
View File
@@ -34,6 +34,10 @@
#include "cli.h" #include "cli.h"
#endif #endif
#if defined(LUA)
#include "lua/lua_event.h"
#endif
uint8_t currentSpeakerVolume = 255; uint8_t currentSpeakerVolume = 255;
uint8_t requiredSpeakerVolume = 255; uint8_t requiredSpeakerVolume = 255;
uint8_t currentBacklightBright = 0; uint8_t currentBacklightBright = 0;
@@ -394,7 +398,7 @@ void guiMain(event_t evt)
} }
DEBUG_TIMER_START(debugTimerLua); DEBUG_TIMER_START(debugTimerLua);
luaTask(0, false); luaTask(false);
DEBUG_TIMER_STOP(debugTimerLua); DEBUG_TIMER_STOP(debugTimerLua);
t0 = get_tmr10ms() - t0; t0 = get_tmr10ms() - t0;
@@ -429,14 +433,17 @@ void guiMain(event_t evt)
bool handleGui(event_t event) { bool handleGui(event_t event) {
bool refreshNeeded; bool refreshNeeded;
#if defined(LUA) #if defined(LUA)
refreshNeeded = luaTask(event, true); bool isTelemView =
if (menuHandlers[menuLevel] == menuViewTelemetry && menuHandlers[menuLevel] == menuViewTelemetry &&
TELEMETRY_SCREEN_TYPE(s_frsky_view) == TELEMETRY_SCREEN_TYPE_SCRIPT) { TELEMETRY_SCREEN_TYPE(s_frsky_view) == TELEMETRY_SCREEN_TYPE_SCRIPT;
menuHandlers[menuLevel](event); bool isStandalone = scriptInternalData[0].reference == SCRIPT_STANDALONE;
} if (isTelemView || isStandalone) luaPushEvent(event);
refreshNeeded = luaTask(true);
if (isTelemView)
menuHandlers[menuLevel](event);
else if (scriptInternalData[0].reference != SCRIPT_STANDALONE) else if (scriptInternalData[0].reference != SCRIPT_STANDALONE)
#endif #endif
// No foreground Lua script is running - clear the screen show normal menu // No foreground Lua script is running - clear the screen show normal menu
{ {
lcdClear(); lcdClear();
menuHandlers[menuLevel](event); menuHandlers[menuLevel](event);
@@ -460,7 +467,7 @@ void guiMain(event_t evt)
} }
// run Lua scripts that don't use LCD (to use CPU time while LCD DMA is running) // run Lua scripts that don't use LCD (to use CPU time while LCD DMA is running)
luaTask(0, false); luaTask(false);
t0 = get_tmr10ms() - t0; t0 = get_tmr10ms() - t0;
if (t0 > maxLuaDuration) { if (t0 > maxLuaDuration) {