1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-14 11:59:50 +03:00

Lua task timing done in perMain()

This commit is contained in:
Damjan Adamic 2014-12-07 17:23:44 +01:00
parent f0cd4fbe8d
commit 55f0781bc9
4 changed files with 23 additions and 7 deletions

View file

@ -170,9 +170,9 @@
#endif #endif
#if defined(PCBTARANIS) && defined(REVPLUS) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU) #if defined(PCBTARANIS) && defined(REVPLUS) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU)
void lcdWaitDmaEnd(); void lcdRefreshWait();
#else #else
#define lcdWaitDmaEnd() #define lcdRefreshWait()
#endif #endif
extern coord_t lcdLastPos; extern coord_t lcdLastPos;

View file

@ -121,7 +121,6 @@
#define LUA_LOAD_MODEL_SCRIPTS() #define LUA_LOAD_MODEL_SCRIPTS()
#define LUA_LOAD_MODEL_SCRIPT(idx) #define LUA_LOAD_MODEL_SCRIPT(idx)
#define LUA_STANDALONE_SCRIPT_RUNNING() (0) #define LUA_STANDALONE_SCRIPT_RUNNING() (0)
#define luaTask(evt, scriptType, allowLcdUsage) (false)
#endif #endif
#endif // #ifndef luaapi_h #endif // #ifndef luaapi_h

View file

@ -128,23 +128,40 @@ void perMain()
} }
#endif #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) // 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 // wait for LCD DMA to finish before continuing, because code from this point
// is allowed to change the contents of LCD buffer // 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! // 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 // draw LCD from menus or from Lua script
// run Lua scripts that use LCD // run Lua scripts that use LCD
bool scriptWasRun = luaTask(evt, RUN_TELEM_FG_SCRIPT | RUN_STNDAL_SCRIPT, true); 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) { 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 // normal GUI from menus
const char *warn = s_warning; const char *warn = s_warning;
uint8_t menu = s_menu_count; uint8_t menu = s_menu_count;

View file

@ -180,7 +180,7 @@ void Set_Address(u8 x, u8 y)
volatile bool lcd_busy; volatile bool lcd_busy;
#if !defined(LCD_DUAL_BUFFER) #if !defined(LCD_DUAL_BUFFER)
void lcdWaitDmaEnd() void lcdRefreshWait()
{ {
WAIT_FOR_DMA_END(); WAIT_FOR_DMA_END();
} }