diff --git a/radio/src/lcd.h b/radio/src/lcd.h index 7cff29233..666651f86 100644 --- a/radio/src/lcd.h +++ b/radio/src/lcd.h @@ -170,9 +170,9 @@ #endif #if defined(PCBTARANIS) && defined(REVPLUS) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU) - void lcdWaitDmaEnd(); + void lcdRefreshWait(); #else - #define lcdWaitDmaEnd() + #define lcdRefreshWait() #endif extern coord_t lcdLastPos; diff --git a/radio/src/lua_api.h b/radio/src/lua_api.h index f461329fb..0dd0bc8ad 100644 --- a/radio/src/lua_api.h +++ b/radio/src/lua_api.h @@ -121,7 +121,6 @@ #define LUA_LOAD_MODEL_SCRIPTS() #define LUA_LOAD_MODEL_SCRIPT(idx) #define LUA_STANDALONE_SCRIPT_RUNNING() (0) - #define luaTask(evt, scriptType, allowLcdUsage) (false) #endif #endif // #ifndef luaapi_h diff --git a/radio/src/main_arm.cpp b/radio/src/main_arm.cpp index 862af5d33..9a9f4e741 100644 --- a/radio/src/main_arm.cpp +++ b/radio/src/main_arm.cpp @@ -128,23 +128,40 @@ void perMain() } #endif +#if defined(LUA) + + uint32_t t0 = get_tmr10ms(); + static uint32_t lastLuaTime = 0; + uint16_t interval = (lastLuaTime == 0 ? 0 : (t0 - lastLuaTime)); + lastLuaTime = t0; + if (interval > maxLuaInterval) { + maxLuaInterval = interval; + } + // run Lua scripts that don't use LCD (to use CPU time while LCD DMA is running) - (void)luaTask(0, RUN_MIX_SCRIPT | RUN_FUNC_SCRIPT | RUN_TELEM_BG_SCRIPT, false); + luaTask(0, RUN_MIX_SCRIPT | RUN_FUNC_SCRIPT | RUN_TELEM_BG_SCRIPT, false); // wait for LCD DMA to finish before continuing, because code from this point // is allowed to change the contents of LCD buffer // // WARNING: make sure no code above this line does any change to the LCD display buffer! // - lcdWaitDmaEnd(); + lcdRefreshWait(); // draw LCD from menus or from Lua script // run Lua scripts that use LCD bool scriptWasRun = luaTask(evt, RUN_TELEM_FG_SCRIPT | RUN_STNDAL_SCRIPT, true); - // TODO luaTask timing must be done here + t0 = get_tmr10ms() - t0; + if (t0 > maxLuaDuration) { + maxLuaDuration = t0; + } if (!scriptWasRun) { +#else + lcdRefreshWait(); // WARNING: make sure no code above this line does any change to the LCD display buffer! + { +#endif // normal GUI from menus const char *warn = s_warning; uint8_t menu = s_menu_count; diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 148b84096..533c83fb0 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -180,7 +180,7 @@ void Set_Address(u8 x, u8 y) volatile bool lcd_busy; #if !defined(LCD_DUAL_BUFFER) -void lcdWaitDmaEnd() +void lcdRefreshWait() { WAIT_FOR_DMA_END(); }