1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 08:15:17 +03:00

Refactoring continued: Try to run lua scripts before the first LCD function

This commit is contained in:
Damjan Adamic 2014-12-06 15:12:18 +01:00
parent fac8571c29
commit 8aeb35c912
10 changed files with 371 additions and 190 deletions

View file

@ -36,11 +36,10 @@
#include "opentx.h"
static uint8_t currentSpeakerVolume = 255;
uint8_t requiredSpeakerVolume;
extern void batteryCheck();
extern void checkBattery();
void handleUsbConnection()
{
@ -109,6 +108,7 @@ void perMainArm()
writeLogs();
handleUsbConnection();
checkTrainerSettings();
checkBattery();
uint8_t evt = getEvent(false);
if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on
@ -118,49 +118,47 @@ void perMainArm()
if (sticks_evt) evt = sticks_evt;
#endif
#if defined(USB_MASS_STORAGE)
if (usbPlugged()) {
// disable access to menus
lcd_clear();
menuMainView(0);
lcdRefresh();
return;
}
else
#endif
{
// run Lua scripts that don't use LCD (to use CPU time while LCD DMA is running)
luaRunNonGuiScripts();
// draw LCD from menus or from Lua script
if (luaRunGuiScripts(evt)) { // either stand-alone or telemetry scripts
// let Lua manage LCD fully
}
else {
// normal GUI from menus
const char *warn = s_warning;
uint8_t menu = s_menu_count;
if (!LUA_STANDALONE_SCRIPT_RUNNING()) {
lcd_clear();
if (menuEvent) {
m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0;
m_posHorz = 0;
evt = menuEvent;
menuEvent = 0;
AUDIO_MENUS();
}
g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt);
lcd_clear();
if (menuEvent) {
m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0;
m_posHorz = 0;
evt = menuEvent;
menuEvent = 0;
AUDIO_MENUS();
}
#if defined(LUA)
luaTask(evt);
#endif
if (!LUA_STANDALONE_SCRIPT_RUNNING()) {
if (warn) DISPLAY_WARNING(evt);
if (menu) {
const char * result = displayMenu(evt);
if (result) {
menuHandler(result);
putEvent(EVT_MENU_UP);
}
g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt);
if (warn) DISPLAY_WARNING(evt);
if (menu) {
const char * result = displayMenu(evt);
if (result) {
menuHandler(result);
putEvent(EVT_MENU_UP);
}
}
drawStatusLine();
}
drawStatusLine();
lcdRefresh();
batteryCheck();
}
#define MENUS_STACK_SIZE 2000