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:
parent
f0cd4fbe8d
commit
55f0781bc9
4 changed files with 23 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue