diff --git a/radio/src/gui/9x/view_statistics.cpp b/radio/src/gui/9x/view_statistics.cpp index 983bc474b..3ab84fa95 100644 --- a/radio/src/gui/9x/view_statistics.cpp +++ b/radio/src/gui/9x/view_statistics.cpp @@ -1,23 +1,23 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + #include "../../opentx.h" #include "../../timers.h" @@ -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) traceRd = 0; - if (traceRd==s_traceWr) break; + + uint16_t traceRd = s_traceWr > MAXTRACE ? s_traceWr - MAXTRACE : 0; + for (coord_t i=1; i<=MAXTRACE && traceRd0 && i0 && i=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=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= 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 diff --git a/radio/src/opentx.h b/radio/src/opentx.h index c75e8cca9..6bb84001c 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -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