1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 00:35:18 +03:00

Show telemetry UART errors in statistics debug page (#5185)

* Show telemetry errors in Debug statistics

This introduces a second debug page on X7 and X9 platform since the original page is almost full.
Also fix the X7 menu navigation to be able to go back and forth

* Fix compile error on platforms without key_page

* avr-gcc bails on missing eolf

* Fix navigation

* Just keep pushing ....

* compile fixes of 9x and use chainMenu

* Fixes

* Align x9 behavior to x7 (for once !)

* Allow total timer reset on both long menu and long enter

* Improve 9x handling
This commit is contained in:
Arne Schwabe 2017-10-29 09:06:17 +01:00 committed by Andre Bernet
parent 1962336316
commit 318d77e863
6 changed files with 178 additions and 51 deletions

View file

@ -171,10 +171,7 @@ static const MenuHandlerFunc menuTabModel[] PROGMEM = {
void menuStatisticsView(event_t event);
void menuStatisticsDebug(event_t event);
void menuStatisticsDebug2(event_t event);
void menuAboutView(event_t event);
#if defined(DEBUG_TRACE_BUFFER)
void menuTraceBuffer(event_t event);
#endif
#endif // _MENUS_H_

View file

@ -31,12 +31,27 @@ void menuStatisticsView(event_t event)
switch (event) {
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_FIRST(KEY_MENU):
#if defined(PCBX7)
case EVT_KEY_BREAK(KEY_PAGE):
#endif
chainMenu(menuStatisticsDebug);
break;
case EVT_KEY_FIRST(KEY_DOWN):
#if defined(STM32)
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
chainMenu(menuStatisticsDebug2);
#else
chainMenu(menuStatisticsDebug);
#endif
break;
#if defined(CPUARM)
case EVT_KEY_LONG(KEY_MENU):
case EVT_KEY_LONG(KEY_MENU): // historical
#if !defined(PCBSKY9X)
case EVT_KEY_LONG(KEY_ENTER):
#endif
g_eeGeneral.globalTimer = 0;
storageDirty(EE_GENERAL);
sessionTimer = 0;
@ -101,6 +116,7 @@ void menuStatisticsView(event_t event)
#define MENU_DEBUG_COL1_OFS (11*FW-3)
#define MENU_DEBUG_COL2_OFS (17*FW)
#define MENU_DEBUG_Y_CURRENT (1*FH)
#define MENU_DEBUG_ROW1 (1*FH+1)
#define MENU_DEBUG_Y_MAH (2*FH)
#define MENU_DEBUG_Y_CPU_TEMP (3*FH)
#define MENU_DEBUG_Y_COPROC (4*FH)
@ -139,13 +155,19 @@ void menuStatisticsDebug(event_t event)
maxMixerDuration = 0;
break;
#if defined(DEBUG_TRACE_BUFFER)
case EVT_KEY_FIRST(KEY_UP):
pushMenu(menuTraceBuffer);
#if defined(STM32)
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuStatisticsDebug2);
return;
#endif
case EVT_KEY_FIRST(KEY_DOWN):
#if defined(PCBX7)
case EVT_KEY_LONG(KEY_PAGE):
#endif
killEvents(event);
chainMenu(menuStatisticsView);
break;
@ -252,3 +274,41 @@ void menuStatisticsDebug(event_t event)
lcdDrawText(4*FW, 7*FH+1, STR_MENUTORESET);
lcdInvertLastLine();
}
#if defined(STM32)
void menuStatisticsDebug2(event_t event)
{
TITLE(STR_MENUDEBUG);
switch (event) {
case EVT_KEY_FIRST(KEY_ENTER):
telemetryErrors = 0;
break;
case EVT_KEY_FIRST(KEY_UP):
#if defined(PCBX7)
case EVT_KEY_BREAK(KEY_PAGE):
#endif
chainMenu(menuStatisticsView);
return;
case EVT_KEY_FIRST(KEY_DOWN):
#if defined(PCBX7)
case EVT_KEY_LONG(KEY_PAGE):
#endif
killEvents(event);
chainMenu(menuStatisticsDebug);
break;
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuMainView);
break;
}
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW1, "Tlm RX Err");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW1, telemetryErrors, RIGHT);
lcdDrawText(4*FW, 7*FH+1, STR_MENUTORESET);
lcdInvertLastLine();
}
#endif

View file

@ -54,6 +54,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
void menuModelNotes(event_t event);
void menuStatisticsView(event_t event);
void menuStatisticsDebug(event_t event);
void menuStatisticsDebug2(event_t event);
void menuAboutView(event_t event);
#if defined(DEBUG_TRACE_BUFFER)
void menuTraceBuffer(event_t event);

View file

@ -32,11 +32,22 @@ void menuStatisticsView(event_t event)
switch(event)
{
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_FIRST(KEY_MENU):
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuStatisticsDebug);
break;
case EVT_KEY_LONG(KEY_MENU):
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
#if defined(DEBUG_TRACE_BUFFER)
chainMenu(menuTraceBuffer);
#else
chainMenu(menuStatisticsDebug2);
#endif
break;
case EVT_KEY_LONG(KEY_MENU): // historical
case EVT_KEY_LONG(KEY_ENTER):
g_eeGeneral.globalTimer = 0;
storageDirty(EE_GENERAL);
sessionTimer = 0;
@ -86,11 +97,11 @@ void menuStatisticsView(event_t event)
}
#define MENU_DEBUG_COL1_OFS (11*FW-2)
#define MENU_DEBUG_Y_MIXMAX (2*FH-3)
#define MENU_DEBUG_Y_LUA (3*FH-2)
#define MENU_DEBUG_Y_FREE_RAM (4*FH-1)
#define MENU_DEBUG_Y_USB (5*FH)
#define MENU_DEBUG_Y_RTOS (6*FH)
#define MENU_DEBUG_ROW1 (2*FH-3)
#define MENU_DEBUG_ROW2 (3*FH-2)
#define MENU_DEBUG_ROW3 (4*FH-1)
#define MENU_DEBUG_ROW4 (5*FH)
#define MENU_DEBUG_ROW5 (6*FH)
void menuStatisticsDebug(event_t event)
{
@ -121,15 +132,17 @@ void menuStatisticsDebug(event_t event)
maxMixerDuration = 0;
break;
#if defined(DEBUG_TRACE_BUFFER)
case EVT_KEY_FIRST(KEY_UP):
pushMenu(menuTraceBuffer);
return;
#endif
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
chainMenu(menuStatisticsView);
break;
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuStatisticsDebug2);
break;
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuMainView);
break;
@ -144,47 +157,89 @@ void menuStatisticsDebug(event_t event)
#endif
}
lcdDrawTextAlignedLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, availableMemory(), LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_Y_FREE_RAM, "b");
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW3, "Free Mem");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW3, availableMemory(), LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW3, "b");
#if defined(LUA)
lcdDrawTextAlignedLeft(MENU_DEBUG_Y_LUA, "Lua scripts");
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT);
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW2, "Lua scripts");
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW2+1, "[Duration]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW2, 10*maxLuaDuration, LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW2+1, "[Interval]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW2, 10*maxLuaInterval, LEFT);
#endif
lcdDrawTextAlignedLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS);
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_Y_MIXMAX, "ms");
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW1, STR_TMIXMAXMS);
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW1, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW1, "ms");
#if !defined(SIMU) && defined(USB_SERIAL)
lcdDrawTextAlignedLeft(MENU_DEBUG_Y_USB, "Usb");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_USB, charsWritten, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_Y_USB, " ");
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_USB, APP_Rx_ptr_in, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_Y_USB, " ");
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_USB, APP_Rx_ptr_out, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_Y_USB, " ");
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_USB, usbWraps, LEFT);
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW4, "Usb");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW4, charsWritten, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, " ");
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW4, APP_Rx_ptr_in, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, " ");
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW4, APP_Rx_ptr_out, LEFT);
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, " ");
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW4, usbWraps, LEFT);
#endif
lcdDrawTextAlignedLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB);
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[M]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_RTOS, menusStack.available(), LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_Y_RTOS+1, "[X]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_RTOS, mixerStack.available(), LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_Y_RTOS+1, "[A]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_RTOS, audioStack.available(), LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_Y_RTOS+1, "[I]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_Y_RTOS, stackAvailable(), LEFT);
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW5, STR_FREESTACKMINB);
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW5+1, "[M]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, menusStack.available(), LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW5+1, "[X]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, mixerStack.available(), LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW5+1, "[A]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, audioStack.available(), LEFT);
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW5+1, "[I]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, stackAvailable(), LEFT);
lcdDrawText(3*FW, 7*FH+1, STR_MENUTORESET);
lcdInvertLastLine();
}
void menuStatisticsDebug2(event_t event)
{
TITLE(STR_MENUDEBUG);
switch(event)
{
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_BREAK(KEY_PAGE):
#if defined(DEBUG_TRACE_BUFFER)
chainMenu(menuTraceBuffer);
#else
chainMenu(menuStatisticsView);
#endif
return;
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
chainMenu(menuStatisticsDebug);
break;
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuMainView);
break;
case EVT_KEY_LONG(KEY_ENTER):
telemetryErrors = 0;
break;
}
// UART statistics
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW1, "Tlm RX Err");
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW1, telemetryErrors, RIGHT);
lcdDrawText(3*FW, 7*FH+1, STR_MENUTORESET);
lcdInvertLastLine();
}
#if defined(DEBUG_TRACE_BUFFER)
void menuTraceBuffer(event_t event)
@ -195,6 +250,17 @@ void menuTraceBuffer(event_t event)
dumpTraceBuffer();
killEvents(event);
break;
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_LONG(KEY_PAGE):
killEvents(event);
chainMenu(menuStatisticsDebug2);
break;
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuStatisticsView);
return;
}
SIMPLE_SUBMENU("Trace Buffer", TRACE_BUFFER_LEN);

View file

@ -148,11 +148,13 @@ bool menuStatsDebug(event_t event)
lcdDrawText(lcdNextPos+20, MENU_CONTENT_TOP+line*FH+1, "[B]", HEADER_COLOR|SMLSIZE);
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+line*FH, luaExtraMemoryUsage, LEFT);
++line;
#endif
lcdDrawText(LCD_W/2, MENU_FOOTER_TOP+2, STR_MENUTORESET, CENTERED);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "Tlm RX Errs");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+line*FH, telemetryErrors, LEFT);
++line;
lcdDrawText(LCD_W/2, MENU_FOOTER_TOP+2, STR_MENUTORESET, CENTERED);
return true;
}

View file

@ -501,6 +501,7 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode);
void telemetryPortSetDirectionOutput(void);
void sportSendBuffer(uint8_t * buffer, uint32_t count);
uint8_t telemetryGetByte(uint8_t * byte);
extern uint32_t telemetryErrors;
// Sport update driver
#define SPORT_UPDATE_POWER_ON() EXTERNAL_MODULE_ON()