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

Lua metrics (duration and interval) added to the Debug screen

This commit is contained in:
bsongis 2014-05-30 22:37:12 +02:00
parent fc54178c8e
commit b10709f68b
4 changed files with 54 additions and 9 deletions

View file

@ -120,6 +120,10 @@ void menuStatisticsDebug(uint8_t event)
#if !defined(CPUARM)
g_tmr1Latency_min = 0xff;
g_tmr1Latency_max = 0;
#endif
#if defined(LUA)
maxLuaInterval = 0;
maxLuaDuration = 0;
#endif
maxMixerDuration = 0;
AUDIO_KEYPAD_UP();
@ -177,14 +181,24 @@ void menuStatisticsDebug(uint8_t event)
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 4*FH, Coproc_temp, UNIT_TEMPERATURE, LEFT);
putsTelemetryValue(MENU_DEBUG_COL2_OFS, 4*FH, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT);
}
#elif defined(PCBTARANIS) && !defined(SIMU)
lcd_putsLeft(4*FH, "Free Mem");
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 4*FH, 0x20020000 - (unsigned int)heap, LEFT);
#endif
#if defined(PCBTARANIS) && !defined(SIMU)
lcd_putsLeft(3*FH, "Free Mem");
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 3*FH, 0x20020000 - (unsigned int)heap, LEFT);
#endif
#if defined(LUA)
lcd_putsLeft(4*FH, "Lua scripts");
lcd_putsAtt(MENU_DEBUG_COL1_OFS-1, 4*FH+1, "[Duration]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaDuration, LEFT);
lcd_putsAtt(lcdLastPos+2, 4*FH+1, "[Interval]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaInterval, LEFT);
#endif
#if defined(CPUARM)
lcd_putsLeft(5*FH, STR_TMIXMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 5*FH, (maxMixerDuration)/20, PREC2|LEFT);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 5*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
lcd_puts(lcdLastPos, 5*FH, "ms");
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
@ -211,7 +225,7 @@ void menuStatisticsDebug(uint8_t event)
lcd_putsLeft(3*FH, STR_TMR1JITTERUS);
lcd_outdez8(MENU_DEBUG_COL1_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 );
lcd_putsLeft(4*FH, STR_TMIXMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 4*FH, (maxMixerDuration*100)/16, PREC2);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 4*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2);
lcd_putsLeft(5*FH, STR_FREESTACKMINB);
lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ;
#endif

View file

@ -60,10 +60,12 @@ lua_State *L = NULL;
uint8_t luaState = 0;
ScriptInternalData scriptInternalData[MAX_SCRIPTS] = { { SCRIPT_NOFILE, 0 } };
ScriptInternalData standaloneScript = { SCRIPT_NOFILE, 0 };
uint16_t maxLuaInterval = 0;
uint16_t maxLuaDuration = 0;
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (1000/100)
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (10000/100)
#define SCRIPTS_MAX_HEAP 100
#define SCRIPTS_MAX_HEAP 50
#define SET_LUA_INSTRUCTIONS_COUNT(x) (instructionsPercent=0, lua_sethook(L, hook, LUA_MASKCOUNT, x))
static int instructionsPercent = 0;
@ -1242,6 +1244,14 @@ void luaTask(uint8_t evt)
lcd_locked = false;
static uint8_t luaDisplayStatistics = false;
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;
}
if (luaState & LUASTATE_STANDALONE_SCRIPT_RUNNING) {
// standalone script
if (standaloneScript.state == SCRIPT_OK && standaloneScript.run) {
@ -1391,4 +1401,9 @@ void luaTask(uint8_t evt)
TRACE("GC Use: %dbytes", gc);
}
#endif
t0 = get_tmr10ms() - t0;
if (t0 > maxLuaDuration) {
maxLuaDuration = t0;
}
}

View file

@ -115,13 +115,14 @@ void loadModelBitmap(char *name, uint8_t *bitmap)
#if !defined(CPUARM)
uint8_t g_tmr1Latency_max;
uint8_t g_tmr1Latency_min;
uint16_t lastMixerDuration;
#endif
uint8_t unexpectedShutdown = 0;
/* mixer duration in 1/16ms */
/* AVR: mixer duration in 1/16ms */
/* ARM: mixer duration in 0.5us */
uint16_t maxMixerDuration;
uint16_t lastMixerDuration;
#if defined(AUDIO) && !defined(CPUARM)
audioQueue audio;

View file

@ -838,10 +838,25 @@ void timerReset(uint8_t idx);
void flightReset();
extern uint8_t unexpectedShutdown;
extern uint16_t maxMixerDuration;
#if !defined(CPUARM)
extern uint8_t g_tmr1Latency_max;
extern uint8_t g_tmr1Latency_min;
extern uint16_t maxMixerDuration;
extern uint16_t lastMixerDuration;
#endif
#if defined(LUA)
extern uint16_t maxLuaInterval;
extern uint16_t maxLuaDuration;
#endif
#if defined(CPUARM)
#define DURATION_MS_PREC2(x) ((x)/20)
#else
#define DURATION_MS_PREC2(x) ((x)*100)/16
#endif
#if defined(THRTRACE)
#define MAXTRACE (LCD_W - 8)