From b6cbde48be7ee0d0294768658f33085219d93b50 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Thu, 3 Jul 2014 19:14:15 +0200 Subject: [PATCH 1/2] Removed sessionTimer and replaced with existing s_timeCumTot. Corrected bug when saving g_eeGeneral.globalTimer (missing reset of session timer and eeprom dirty) --- radio/src/gui/view_statistics.cpp | 11 ++++++----- radio/src/opentx.cpp | 15 ++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/radio/src/gui/view_statistics.cpp b/radio/src/gui/view_statistics.cpp index a18c55041..aa3f81b44 100644 --- a/radio/src/gui/view_statistics.cpp +++ b/radio/src/gui/view_statistics.cpp @@ -46,9 +46,11 @@ void menuStatisticsView(uint8_t event) chainMenu(menuStatisticsDebug); return; -#if defined(PCBTARANIS) +#if defined(CPUARM) case EVT_KEY_LONG(KEY_MENU): g_eeGeneral.globalTimer = 0; + eeDirty(EE_GENERAL); + s_timeCumTot = 0; break; #endif case EVT_KEY_FIRST(KEY_EXIT): @@ -65,8 +67,8 @@ void menuStatisticsView(uint8_t event) putsTimer( 12*FW+5*FWNUM+1, FH*0, s_timeCumTot, 0, 0); -#if defined(PCBTARANIS) - putsTimer(21*FW+5*FWNUM+1, 0*FH, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0); +#if defined(CPUARM) + putsTimer(21*FW+5*FWNUM+1, 0*FH, g_eeGeneral.globalTimer + s_timeCumTot, TIMEHOUR, 0); #endif #if defined(THRTRACE) @@ -111,7 +113,7 @@ void menuStatisticsDebug(uint8_t event) #if defined(PCBSKY9X) Current_used = 0; #endif - sessionTimer = 0; + s_timeCumTot = 0; killEvents(event); AUDIO_KEYPAD_UP(); break; @@ -155,7 +157,6 @@ void menuStatisticsDebug(uint8_t event) // consumption lcd_putsLeft(2*FH, STR_CPU_MAH); putsTelemetryValue(MENU_DEBUG_COL1_OFS, 2*FH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1); - putsTimer(MENU_DEBUG_COL2_OFS, 2*FH, g_eeGeneral.globalTimer + sessionTimer, LEFT, 0); #endif #if defined(PCBSKY9X) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 6735cd0c0..4d4b34c12 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1385,10 +1385,6 @@ uint32_t Current_accumulator; uint32_t Current_used; #endif -#if defined(CPUARM) && !defined(REVA) -uint16_t sessionTimer; -#endif - #if !defined(SIMU) static uint16_t s_anaFilt[NUMBER_ANALOG]; #endif @@ -2653,16 +2649,11 @@ void perMain() static uint32_t OneSecTimer; if (++OneSecTimer >= 100) { OneSecTimer -= 100 ; - sessionTimer += 1; Current_used += Current_accumulator / 100 ; // milliAmpSeconds (but scaled) Current_accumulator = 0 ; } #endif -#if defined(PCBTARANIS) - sessionTimer = s_timeCumTot; -#endif - #if defined(CPUARM) if (currentSpeakerVolume != requiredSpeakerVolume) { currentSpeakerVolume = requiredSpeakerVolume; @@ -3247,8 +3238,10 @@ void saveTimers() } #if defined(CPUARM) && !defined(REVA) - if (sessionTimer > 0) { - g_eeGeneral.globalTimer += sessionTimer; + if (s_timeCumTot > 0) { + g_eeGeneral.globalTimer += s_timeCumTot; + eeDirty(EE_GENERAL); + s_timeCumTot = 0; } #endif } From 8c010277c9f80d828206ca74f707f0309567bb87 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Fri, 4 Jul 2014 11:09:30 +0200 Subject: [PATCH 2/2] Renamed s_timeCumTot to sessionTimer --- radio/src/gui/view_statistics.cpp | 8 ++++---- radio/src/opentx.cpp | 16 ++++++++-------- radio/src/opentx.h | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/radio/src/gui/view_statistics.cpp b/radio/src/gui/view_statistics.cpp index aa3f81b44..3240202e4 100644 --- a/radio/src/gui/view_statistics.cpp +++ b/radio/src/gui/view_statistics.cpp @@ -50,7 +50,7 @@ void menuStatisticsView(uint8_t event) case EVT_KEY_LONG(KEY_MENU): g_eeGeneral.globalTimer = 0; eeDirty(EE_GENERAL); - s_timeCumTot = 0; + sessionTimer = 0; break; #endif case EVT_KEY_FIRST(KEY_EXIT): @@ -65,10 +65,10 @@ void menuStatisticsView(uint8_t event) putsTimer( 5*FW+5*FWNUM+1, FH*2, s_timeCumThr, 0, 0); putsTimer( 12*FW+5*FWNUM+1, FH*2, s_timeCum16ThrP/16, 0, 0); - putsTimer( 12*FW+5*FWNUM+1, FH*0, s_timeCumTot, 0, 0); + putsTimer( 12*FW+5*FWNUM+1, FH*0, sessionTimer, 0, 0); #if defined(CPUARM) - putsTimer(21*FW+5*FWNUM+1, 0*FH, g_eeGeneral.globalTimer + s_timeCumTot, TIMEHOUR, 0); + putsTimer(21*FW+5*FWNUM+1, 0*FH, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0); #endif #if defined(THRTRACE) @@ -113,7 +113,7 @@ void menuStatisticsDebug(uint8_t event) #if defined(PCBSKY9X) Current_used = 0; #endif - s_timeCumTot = 0; + sessionTimer = 0; killEvents(event); AUDIO_KEYPAD_UP(); break; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 4d4b34c12..cb53ebb18 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1597,7 +1597,7 @@ uint8_t g_vbat100mV = 0; uint16_t lightOffCounter; uint8_t flashCounter = 0; -uint16_t s_timeCumTot; +uint16_t sessionTimer; uint16_t s_timeCumThr; // THR in 1/16 sec uint16_t s_timeCum16ThrP; // THR% in 1/16 sec @@ -2365,7 +2365,7 @@ void doMixerCalculations() if (s_cnt_1s >= 10) { // 1sec s_cnt_1s -= 10; - s_timeCumTot += 1; + sessionTimer += 1; struct t_inactivity *ptrInactivity = &inactivity; FORCE_INDIRECT(ptrInactivity) ; @@ -2374,9 +2374,9 @@ void doMixerCalculations() AUDIO_INACTIVITY(); #if defined(AUDIO) - if (mixWarning & 1) if ((s_timeCumTot&0x03)==0) AUDIO_MIX_WARNING(1); - if (mixWarning & 2) if ((s_timeCumTot&0x03)==1) AUDIO_MIX_WARNING(2); - if (mixWarning & 4) if ((s_timeCumTot&0x03)==2) AUDIO_MIX_WARNING(3); + if (mixWarning & 1) if ((sessionTimer&0x03)==0) AUDIO_MIX_WARNING(1); + if (mixWarning & 2) if ((sessionTimer&0x03)==1) AUDIO_MIX_WARNING(2); + if (mixWarning & 4) if ((sessionTimer&0x03)==2) AUDIO_MIX_WARNING(3); #endif #if defined(ACCURAT_THROTTLE_TIMER) @@ -3238,10 +3238,10 @@ void saveTimers() } #if defined(CPUARM) && !defined(REVA) - if (s_timeCumTot > 0) { - g_eeGeneral.globalTimer += s_timeCumTot; + if (sessionTimer > 0) { + g_eeGeneral.globalTimer += sessionTimer; eeDirty(EE_GENERAL); - s_timeCumTot = 0; + sessionTimer = 0; } #endif } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 0a576ff26..1e057f3d2 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -828,7 +828,7 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim); #define GV_RANGELARGE_OFFSET_NEG GV_RANGELARGE_NEG #endif -extern uint16_t s_timeCumTot; +extern uint16_t sessionTimer; extern uint16_t s_timeCumThr; extern uint16_t s_timeCum16ThrP;