mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 06:15:10 +03:00
Lua metrics (duration and interval) added to the Debug screen
This commit is contained in:
parent
fc54178c8e
commit
b10709f68b
4 changed files with 54 additions and 9 deletions
|
@ -120,6 +120,10 @@ void menuStatisticsDebug(uint8_t event)
|
||||||
#if !defined(CPUARM)
|
#if !defined(CPUARM)
|
||||||
g_tmr1Latency_min = 0xff;
|
g_tmr1Latency_min = 0xff;
|
||||||
g_tmr1Latency_max = 0;
|
g_tmr1Latency_max = 0;
|
||||||
|
#endif
|
||||||
|
#if defined(LUA)
|
||||||
|
maxLuaInterval = 0;
|
||||||
|
maxLuaDuration = 0;
|
||||||
#endif
|
#endif
|
||||||
maxMixerDuration = 0;
|
maxMixerDuration = 0;
|
||||||
AUDIO_KEYPAD_UP();
|
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_COL1_OFS, 4*FH, Coproc_temp, UNIT_TEMPERATURE, LEFT);
|
||||||
putsTelemetryValue(MENU_DEBUG_COL2_OFS, 4*FH, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT);
|
putsTelemetryValue(MENU_DEBUG_COL2_OFS, 4*FH, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT);
|
||||||
}
|
}
|
||||||
#elif defined(PCBTARANIS) && !defined(SIMU)
|
#endif
|
||||||
lcd_putsLeft(4*FH, "Free Mem");
|
|
||||||
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 4*FH, 0x20020000 - (unsigned int)heap, LEFT);
|
#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
|
#endif
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
lcd_putsLeft(5*FH, STR_TMIXMAXMS);
|
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_puts(lcdLastPos, 5*FH, "ms");
|
||||||
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
|
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
|
||||||
|
|
||||||
|
@ -211,7 +225,7 @@ void menuStatisticsDebug(uint8_t event)
|
||||||
lcd_putsLeft(3*FH, STR_TMR1JITTERUS);
|
lcd_putsLeft(3*FH, STR_TMR1JITTERUS);
|
||||||
lcd_outdez8(MENU_DEBUG_COL1_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 );
|
lcd_outdez8(MENU_DEBUG_COL1_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 );
|
||||||
lcd_putsLeft(4*FH, STR_TMIXMAXMS);
|
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_putsLeft(5*FH, STR_FREESTACKMINB);
|
||||||
lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ;
|
lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -60,10 +60,12 @@ lua_State *L = NULL;
|
||||||
uint8_t luaState = 0;
|
uint8_t luaState = 0;
|
||||||
ScriptInternalData scriptInternalData[MAX_SCRIPTS] = { { SCRIPT_NOFILE, 0 } };
|
ScriptInternalData scriptInternalData[MAX_SCRIPTS] = { { SCRIPT_NOFILE, 0 } };
|
||||||
ScriptInternalData standaloneScript = { SCRIPT_NOFILE, 0 };
|
ScriptInternalData standaloneScript = { SCRIPT_NOFILE, 0 };
|
||||||
|
uint16_t maxLuaInterval = 0;
|
||||||
|
uint16_t maxLuaDuration = 0;
|
||||||
|
|
||||||
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (1000/100)
|
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (1000/100)
|
||||||
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (10000/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))
|
#define SET_LUA_INSTRUCTIONS_COUNT(x) (instructionsPercent=0, lua_sethook(L, hook, LUA_MASKCOUNT, x))
|
||||||
|
|
||||||
static int instructionsPercent = 0;
|
static int instructionsPercent = 0;
|
||||||
|
@ -1242,6 +1244,14 @@ void luaTask(uint8_t evt)
|
||||||
lcd_locked = false;
|
lcd_locked = false;
|
||||||
static uint8_t luaDisplayStatistics = 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) {
|
if (luaState & LUASTATE_STANDALONE_SCRIPT_RUNNING) {
|
||||||
// standalone script
|
// standalone script
|
||||||
if (standaloneScript.state == SCRIPT_OK && standaloneScript.run) {
|
if (standaloneScript.state == SCRIPT_OK && standaloneScript.run) {
|
||||||
|
@ -1391,4 +1401,9 @@ void luaTask(uint8_t evt)
|
||||||
TRACE("GC Use: %dbytes", gc);
|
TRACE("GC Use: %dbytes", gc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
t0 = get_tmr10ms() - t0;
|
||||||
|
if (t0 > maxLuaDuration) {
|
||||||
|
maxLuaDuration = t0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,13 +115,14 @@ void loadModelBitmap(char *name, uint8_t *bitmap)
|
||||||
#if !defined(CPUARM)
|
#if !defined(CPUARM)
|
||||||
uint8_t g_tmr1Latency_max;
|
uint8_t g_tmr1Latency_max;
|
||||||
uint8_t g_tmr1Latency_min;
|
uint8_t g_tmr1Latency_min;
|
||||||
|
uint16_t lastMixerDuration;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t unexpectedShutdown = 0;
|
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 maxMixerDuration;
|
||||||
uint16_t lastMixerDuration;
|
|
||||||
|
|
||||||
#if defined(AUDIO) && !defined(CPUARM)
|
#if defined(AUDIO) && !defined(CPUARM)
|
||||||
audioQueue audio;
|
audioQueue audio;
|
||||||
|
|
|
@ -838,10 +838,25 @@ void timerReset(uint8_t idx);
|
||||||
void flightReset();
|
void flightReset();
|
||||||
|
|
||||||
extern uint8_t unexpectedShutdown;
|
extern uint8_t unexpectedShutdown;
|
||||||
|
|
||||||
|
extern uint16_t maxMixerDuration;
|
||||||
|
|
||||||
|
#if !defined(CPUARM)
|
||||||
extern uint8_t g_tmr1Latency_max;
|
extern uint8_t g_tmr1Latency_max;
|
||||||
extern uint8_t g_tmr1Latency_min;
|
extern uint8_t g_tmr1Latency_min;
|
||||||
extern uint16_t maxMixerDuration;
|
|
||||||
extern uint16_t lastMixerDuration;
|
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)
|
#if defined(THRTRACE)
|
||||||
#define MAXTRACE (LCD_W - 8)
|
#define MAXTRACE (LCD_W - 8)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue