Merge pull request #1442 from opentx/projectkk2glider/total_timer_fixes

Bug fix and refactoring of globalTimer
This commit is contained in:
Bertrand Songis
2014-07-04 11:23:00 +02:00
3 changed files with 13 additions and 19 deletions
+5 -4
View File
@@ -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);
sessionTimer = 0;
break;
#endif
case EVT_KEY_FIRST(KEY_EXIT):
@@ -63,9 +65,9 @@ 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(PCBTARANIS)
#if defined(CPUARM)
putsTimer(21*FW+5*FWNUM+1, 0*FH, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0);
#endif
@@ -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)
+7 -14
View File
@@ -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
@@ -1601,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
@@ -2369,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) ;
@@ -2378,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)
@@ -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;
@@ -3249,6 +3240,8 @@ void saveTimers()
#if defined(CPUARM) && !defined(REVA)
if (sessionTimer > 0) {
g_eeGeneral.globalTimer += sessionTimer;
eeDirty(EE_GENERAL);
sessionTimer = 0;
}
#endif
}
+1 -1
View File
@@ -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;