Mercurial > public > ostc4
diff Discovery/Src/simulation.c @ 924:4d98fb2a178e Evo_2_23
Bugfix real scrubber time decreased in sim mode:
In the previous version the condition check for dive / simulation had been commented out causing the scrubber timer to be decreased during simulator usage. The problem has been fixed. In addition the scrubbertimer will now be maintained in simulator mode. In case the +5 minutes option is used the scrubber time is decreased by 5 minutes as well.
author | Ideenmodellierer |
---|---|
date | Wed, 13 Nov 2024 17:55:05 +0100 |
parents | 7bd347bdaa81 |
children |
line wrap: on
line diff
--- a/Discovery/Src/simulation.c Mon Nov 04 20:21:02 2024 +0100 +++ b/Discovery/Src/simulation.c Wed Nov 13 17:55:05 2024 +0100 @@ -56,6 +56,8 @@ static uint16_t* pReplayData; /* pointer to source dive data */ static uint8_t simReplayActive = 0; +static uint16_t simScrubberTimeoutCount = 0; + //Private functions static float sim_get_ambient_pressure(SDiveState * pDiveState); @@ -108,6 +110,8 @@ decoLock = DECO_CALC_init_as_is_start_of_dive; stateSim.lifeData.apnea_total_max_depth_meter = 0; + + memcpy(stateSim.scrubberDataDive, settingsGetPointer()->scrubberData, sizeof(stateSim.scrubberDataDive)); memset(simSensmVOffset,0,sizeof(simSensmVOffset)); if(getReplayOffset() != 0xFFFF) { @@ -152,6 +156,8 @@ static _Bool two_second = 0; static float lastPressure_bar = 0; + pSettings = settingsGetPointer(); + if ((sim_aim_time_minutes && sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) && (!simReplayActive)) { @@ -174,7 +180,7 @@ { two_second = 0; } - pSettings = settingsGetPointer(); + for(index = 0; index < 3; index++) { localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index]; @@ -230,6 +236,22 @@ lastPressure_bar = 0; pDiveState->lifeData.ascent_rate_meter_per_min = 0; } + + if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (pDiveState->mode == MODE_DIVE) && isLoopMode(pDiveState->diveSettings.diveMode)) + { + simScrubberTimeoutCount++; + if(simScrubberTimeoutCount >= 60) /* resolution is minutes */ + { + simScrubberTimeoutCount = 0; + if(pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) + { + pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur--; + } + translateDate(stateUsed->lifeData.dateBinaryFormat, &stateUsedWrite->scrubberDataDive[pSettings->scubberActiveId].lastDive); + } + } + + if(lastPressure_bar > 0) { //1 second * 60 == 1 minute, bar * 10 = meter