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

[Horus] Stats menu refactoring

This commit is contained in:
Bertrand Songis 2016-03-14 21:56:53 +01:00
parent 13657587b1
commit 7adccc23dc
8 changed files with 116 additions and 170 deletions

View file

@ -53,20 +53,18 @@ void menuStatisticsView(uint8_t event)
putsTimer( 12*FW+5*FWNUM+1, FH*0, sessionTimer, 0, 0);
#if defined(THRTRACE)
coord_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0);
const coord_t x = 5;
const coord_t y = 60;
lcdDrawSolidHorizontalLine(x-3, y, MAXTRACE+3+3);
lcdDrawSolidVerticalLine(x, y-32, 32+3);
for (coord_t i=0; i<MAXTRACE; i+=6) {
lcdDrawSolidVerticalLine(x+i+6, y-1, 3);
}
for (coord_t i=1; i<=MAXTRACE; i++) {
lcdDrawSolidVerticalLine(x+i, y-s_traceBuf[traceRd], s_traceBuf[traceRd]);
traceRd++;
if (traceRd>=MAXTRACE) traceRd = 0;
if (traceRd==s_traceWr) break;
uint16_t traceRd = s_traceWr > MAXTRACE ? s_traceWr - MAXTRACE : 0;
for (coord_t i=1; i<=MAXTRACE && traceRd<s_traceWr; i++, traceRd++) {
uint8_t h = s_traceBuf[traceRd % MAXTRACE];
lcdDrawSolidVerticalLine(x+i, y-h, h);
}
#endif
}

View file

@ -88,18 +88,10 @@ const uint8_t LBM_STATS_GRAPH_ICON[] = {
#include "mask_stats_graph.lbm"
};
const uint8_t LBM_STATS_VALUE_ICON[] = {
#include "mask_stats_value.lbm"
};
const uint8_t LBM_STATS_TIME_ICON[] = {
#include "mask_stats_time.lbm"
};
const uint8_t LBM_STATS_LUA_ICON[] = {
#include "mask_stats_lua.lbm"
};
const uint8_t LBM_STATS_DEBUG_ICON[] = {
#include "mask_stats_debug.lbm"
};
@ -107,11 +99,7 @@ const uint8_t LBM_STATS_DEBUG_ICON[] = {
const uint8_t * const LBM_STATS_ICONS[] = {
LBM_STATS_ICON,
LBM_STATS_GRAPH_ICON,
LBM_STATS_VALUE_ICON,
LBM_STATS_TIME_ICON,
#if defined(LUA)
LBM_STATS_LUA_ICON,
#endif
#if defined(DEBUG_TRACE_BUFFER)
LBM_STATS_DEBUG_ICON
#endif

View file

@ -36,15 +36,16 @@ struct point_t {
point_t getPoint(uint8_t i)
{
point_t result = {0, 0};
CurveInfo &crv = g_model.curves[s_curveChan];
int8_t *points = curveAddress(s_curveChan);
CurveInfo & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
bool custom = (crv.type == CURVE_TYPE_CUSTOM);
uint8_t count = 5+crv.points;
if (i < count) {
result.x = CURVE_CENTER_X-1-CURVE_SIDE_WIDTH+i*CURVE_SIDE_WIDTH*2/(count-1);
result.y = CURVE_CENTER_Y - (points[i]) * (CURVE_SIDE_WIDTH-1) / 100;
if (custom && i>0 && i<count-1)
result.x = CURVE_CENTER_X-1-CURVE_SIDE_WIDTH + (100 + (100 + points[count+i-1]) * (2*CURVE_SIDE_WIDTH)) / 200;
if (custom && i>0 && i<count-1) {
result.x = CURVE_CENTER_X - 1 - CURVE_SIDE_WIDTH + (100 + (100 + points[count + i - 1]) * (2 * CURVE_SIDE_WIDTH)) / 200;
}
}
return result;
}

View file

@ -147,31 +147,21 @@ static const MenuHandlerFunc menuTabGeneral[] PROGMEM = {
enum EnumTabDiag
{
e_StatsGraph,
e_StatsValue,
e_StatsTime,
#if defined(LUA)
e_StatsLua,
#endif
e_StatsDebug,
#if defined(DEBUG_TRACE_BUFFER)
s_StatsDebug,
e_StatsTraces,
#endif
};
bool menuStatsGraph(evt_t event);
bool menuStatsValue(evt_t event);
bool menuStatsTime(evt_t event);
bool menuStatsLua(evt_t event);
bool menuStatsDebug(evt_t event);
bool menuStatsTraces(evt_t event);
static const MenuHandlerFunc menuTabStats[] PROGMEM = {
menuStatsGraph,
menuStatsValue,
menuStatsTime,
#if defined(LUA)
menuStatsLua,
#endif
#if defined(DEBUG_TRACE_BUFFER)
menuStatsDebug,
#if defined(DEBUG_TRACE_BUFFER)
menuStatsTraces,
#endif
};

View file

@ -22,31 +22,68 @@
#include "stamp.h"
#define MENU_STATS_COLUMN1 (MENUS_MARGIN_LEFT + 120)
#define MENU_STATS_COLUMN2 (LCD_W/2)
#define MENU_STATS_COLUMN3 (LCD_W/2 + 120)
bool menuStatsGraph(evt_t event)
{
MENU("Throttle graph", LBM_STATS_ICONS, menuTabStats, e_StatsGraph, 0, { 0 });
MENU("Statistics", LBM_STATS_ICONS, menuTabStats, e_StatsGraph, 0, { 0 });
coord_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0);
const coord_t x = 4;
const coord_t y = 200;
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, "Session");
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP, sessionTimer, TIMEHOUR);
lcdDrawText(MENU_STATS_COLUMN2, MENU_CONTENT_TOP, "Battery");
putsTimer(MENU_STATS_COLUMN3, MENU_CONTENT_TOP, g_eeGeneral.globalTimer+sessionTimer, TIMEHOUR);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+FH, "Throttle");
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+FH, s_timeCumThr);
lcdDrawText(MENU_STATS_COLUMN2, MENU_CONTENT_TOP+FH, "Throttle %");
putsTimer(MENU_STATS_COLUMN3, MENU_CONTENT_TOP+FH, s_timeCum16ThrP/16);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+2*FH, "Timers");
lcdDrawText(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+2*FH, "[1]", HEADER_COLOR);
putsTimer(lcdNextPos+5, MENU_CONTENT_TOP+2*FH, timersStates[0].val);
lcdDrawText(MENU_STATS_COLUMN2, MENU_CONTENT_TOP+2*FH, "[2]", HEADER_COLOR);
putsTimer(lcdNextPos+10, MENU_CONTENT_TOP+2*FH, timersStates[2].val);
lcdDrawText(MENU_STATS_COLUMN3, MENU_CONTENT_TOP+2*FH, "[3]", HEADER_COLOR);
putsTimer(lcdNextPos+10, MENU_CONTENT_TOP+2*FH, timersStates[3].val);
const coord_t x = 10;
const coord_t y = 240;
lcdDrawHorizontalLine(x-3, y, MAXTRACE+3+3, SOLID, TEXT_COLOR);
lcdDrawVerticalLine(x, y-96, 96+3, SOLID, TEXT_COLOR);
for (coord_t i=0; i<MAXTRACE; i+=6) {
lcdDrawVerticalLine(x+i+6, y-1, 3, SOLID, TEXT_COLOR);
lcdDrawVerticalLine(x+i, y-1, 3, SOLID, TEXT_COLOR);
}
for (coord_t i=1; i<=MAXTRACE; i++) {
lcdDrawVerticalLine(x+i, y-3*s_traceBuf[traceRd], 3*s_traceBuf[traceRd], SOLID, TEXT_COLOR);
traceRd++;
if (traceRd>=MAXTRACE) traceRd = 0;
if (traceRd==s_traceWr) break;
uint16_t traceRd = s_traceWr > MAXTRACE ? s_traceWr - MAXTRACE : 0;
coord_t prev_yv = (coord_t)-1;
for (coord_t i=1; i<=MAXTRACE && traceRd<s_traceWr; i++, traceRd++) {
uint8_t h = s_traceBuf[traceRd % MAXTRACE];
coord_t yv = y - 2 - 3*h;
if (prev_yv != (coord_t)-1) {
if (prev_yv < yv) {
for (int y=prev_yv; y<=yv; y++) {
lcdDrawBitmapPattern(x + i - 3, y, LBM_POINT, TEXT_COLOR);
}
}
else {
for (int y=yv; y<=prev_yv; y++) {
lcdDrawBitmapPattern(x + i - 3, y, LBM_POINT, TEXT_COLOR);
}
}
}
else {
lcdDrawBitmapPattern(x + i - 3, yv, LBM_POINT, TEXT_COLOR);
}
prev_yv = yv;
}
return true;
}
bool menuStatsValue(evt_t event)
bool menuStatsDebug(evt_t event)
{
switch(event)
{
@ -60,11 +97,15 @@ bool menuStatsValue(evt_t event)
case EVT_KEY_FIRST(KEY_ENTER):
maxMixerDuration = 0;
#if defined(LUA)
maxLuaInterval = 0;
maxLuaDuration = 0;
#endif
AUDIO_KEYPAD_UP();
break;
}
MENU("Values", LBM_STATS_ICONS, menuTabStats, e_StatsValue, 0, { 0 });
MENU("Debug", LBM_STATS_ICONS, menuTabStats, e_StatsDebug, 0, { 0 });
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, "Free Mem");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP, availableMemory(), LEFT, 0, NULL, "b");
@ -80,89 +121,29 @@ bool menuStatsValue(evt_t event)
lcdDrawText(lcdNextPos+20, MENU_CONTENT_TOP+2*FH+1, "[Audio]", HEADER_COLOR|SMLSIZE);
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+2*FH, audioStack.available(), LEFT);
#if defined(LUA)
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+3*FH, "Free Mem");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+3*FH, availableMemory(), LEFT, 0, NULL, "b");
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+4*FH, "Lua duration");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+4*FH, 10*maxLuaDuration, LEFT, 0, NULL, "ms");
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+5*FH, "Lua interval");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+5*FH, 10*maxLuaInterval, LEFT, 0, NULL, "ms");
#endif
lcdDrawText(LCD_W/2, MENU_FOOTER_TOP+2, STR_MENUTORESET, CENTERED);
return true;
}
bool menuStatsTime(evt_t event)
{
switch(event) {
case EVT_KEY_LONG(KEY_MENU):
g_eeGeneral.globalTimer = 0;
storageDirty(EE_GENERAL);
sessionTimer = 0;
break;
}
MENU("Time Stats", LBM_STATS_ICONS, menuTabStats, e_StatsTime, 0, { 0 });
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, "Session", HEADER_COLOR);
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP, sessionTimer, TIMEHOUR);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+FH, "Battery", HEADER_COLOR);
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+FH, g_eeGeneral.globalTimer+sessionTimer, TIMEHOUR);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+2*FH, "Timer1", HEADER_COLOR);
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+2*FH, timersStates[0].val);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+3*FH, "Timer2", HEADER_COLOR);
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+3*FH, timersStates[2].val);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+4*FH, "Timer3", HEADER_COLOR);
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+4*FH, timersStates[3].val);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+5*FH, "Throttle", HEADER_COLOR);
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+5*FH, s_timeCumThr);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+6*FH, "Throttle %", HEADER_COLOR);
putsTimer(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+6*FH, s_timeCum16ThrP/16);
return true;
}
#if defined(LUA)
bool menuStatsLua(evt_t event)
{
switch(event)
{
case EVT_KEY_LONG(KEY_ENTER):
g_eeGeneral.globalTimer = 0;
storageDirty(EE_GENERAL);
sessionTimer = 0;
killEvents(event);
AUDIO_KEYPAD_UP();
break;
case EVT_KEY_FIRST(KEY_ENTER):
maxLuaInterval = 0;
maxLuaDuration = 0;
AUDIO_KEYPAD_UP();
break;
}
MENU("LUA", LBM_STATS_ICONS, menuTabStats, e_StatsLua, 0, { 0 });
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, "Free Mem");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP, availableMemory(), LEFT, 0, NULL, "b");
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+FH, "Duration");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+FH, 10*maxLuaDuration, LEFT, 0, NULL, "ms");
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+2*FH, "Interval");
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+2*FH, 10*maxLuaInterval, LEFT, 0, NULL, "ms");
return true;
}
#endif
#if defined(DEBUG_TRACE_BUFFER)
#define STATS_TRACES_INDEX_POS MENUS_MARGIN_LEFT
#define STATS_TRACES_TIME_POS MENUS_MARGIN_LEFT + 4*10
#define STATS_TRACES_EVENT_POS MENUS_MARGIN_LEFT + 14*10
#define STATS_TRACES_DATA_POS MENUS_MARGIN_LEFT + 20*10
bool menuStatsDebug(evt_t event)
bool menuStatsTraces(evt_t event)
{
switch(event)
{
@ -172,7 +153,7 @@ bool menuStatsDebug(evt_t event)
break;
}
SIMPLE_MENU("", LBM_STATS_ICONS, menuTabStats, s_StatsDebug, TRACE_BUFFER_LEN);
SIMPLE_MENU("", LBM_STATS_ICONS, menuTabStats, e_StatsTraces, TRACE_BUFFER_LEN);
uint8_t k = 0;
int8_t sub = menuVerticalPosition;

View file

@ -69,20 +69,18 @@ void menuStatisticsView(uint8_t event)
}
#if defined(THRTRACE)
coord_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0);
const coord_t x = 5;
const coord_t y = 60;
lcdDrawSolidHorizontalLine(x-3, y, MAXTRACE+3+3);
lcdDrawSolidVerticalLine(x, y-32, 32+3);
for (coord_t i=0; i<MAXTRACE; i+=6) {
lcdDrawSolidVerticalLine(x+i+6, y-1, 3);
}
for (coord_t i=1; i<=MAXTRACE; i++) {
lcdDrawSolidVerticalLine(x+i, y-s_traceBuf[traceRd], s_traceBuf[traceRd]);
traceRd++;
if (traceRd>=MAXTRACE) traceRd = 0;
if (traceRd==s_traceWr) break;
uint16_t traceRd = s_traceWr > MAXTRACE ? s_traceWr - MAXTRACE : 0;
for (coord_t i=1; i<=MAXTRACE && traceRd<s_traceWr; i++, traceRd++) {
uint8_t h = s_traceBuf[traceRd % MAXTRACE];
lcdDrawSolidVerticalLine(x+i, y-h, h);
}
#endif
}

View file

@ -1717,13 +1717,7 @@ void flightReset()
#if defined(THRTRACE)
uint8_t s_traceBuf[MAXTRACE];
#if LCD_W >= 255
int16_t s_traceWr;
int16_t s_traceCnt;
#else
uint8_t s_traceWr;
int16_t s_traceCnt;
#endif
uint16_t s_traceWr;
uint8_t s_cnt_10s;
uint16_t s_cnt_samples_thr_10s;
uint16_t s_sum_samples_thr_10s;
@ -1918,10 +1912,8 @@ void doMixerCalculations()
val = s_sum_samples_thr_10s / s_cnt_samples_thr_10s;
s_sum_samples_thr_10s = 0;
s_cnt_samples_thr_10s = 0;
s_traceBuf[s_traceWr++] = val;
if (s_traceWr >= MAXTRACE) s_traceWr = 0;
if (s_traceCnt >= 0) s_traceCnt++;
s_traceBuf[s_traceWr % MAXTRACE] = val;
s_traceWr++;
}
#endif

View file

@ -929,19 +929,17 @@ extern uint16_t lastMixerDuration;
#endif
#if defined(THRTRACE)
#define MAXTRACE (LCD_W - 8)
extern uint8_t s_traceBuf[MAXTRACE];
#if LCD_W >= 255
extern int16_t s_traceWr;
extern int16_t s_traceCnt;
#if defined(COLORLCD)
#define MAXTRACE (LCD_W-2*10)
#else
extern uint8_t s_traceWr;
extern int16_t s_traceCnt;
#define MAXTRACE (LCD_W - 8)
#endif
extern uint8_t s_traceBuf[MAXTRACE];
extern uint16_t s_traceWr;
extern uint8_t s_cnt_10s;
extern uint16_t s_cnt_samples_thr_10s;
extern uint16_t s_sum_samples_thr_10s;
#define RESET_THR_TRACE() s_traceCnt = s_traceWr = s_cnt_10s = s_cnt_samples_thr_10s = s_sum_samples_thr_10s = s_timeCum16ThrP = s_timeCumThr = 0
#define RESET_THR_TRACE() s_traceWr = s_cnt_10s = s_cnt_samples_thr_10s = s_sum_samples_thr_10s = s_timeCum16ThrP = s_timeCumThr = 0
#else
#define RESET_THR_TRACE() s_timeCum16ThrP = s_timeCumThr = 0
#endif