Mercurial > public > ostc4
changeset 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 | 6fc0e3d230e4 |
children | 79c888f5d8d2 |
files | Discovery/Src/data_exchange_main.c Discovery/Src/simulation.c Discovery/Src/t3.c Discovery/Src/tCCR.c |
diffstat | 4 files changed, 33 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c Mon Nov 04 20:21:02 2024 +0100 +++ b/Discovery/Src/data_exchange_main.c Wed Nov 13 17:55:05 2024 +0100 @@ -1039,6 +1039,8 @@ //Init dive Mode decoLock = DECO_CALC_init_as_is_start_of_dive; pStateReal->lifeData.boolResetAverageDepth = 1; + + memcpy(pStateReal->scrubberDataDive, pSettings->scrubberData, sizeof(pStateReal->scrubberDataDive)); } pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns; @@ -1066,6 +1068,8 @@ } if(pStateReal->warnings.decoMissed) dataOut.setAccidentFlag += ACCIDENT_DECOSTOP; + + memcpy(pSettings->scrubberData, pStateReal->scrubberDataDive, sizeof(pStateReal->scrubberDataDive)); /* Store value of current usage */ } pStateReal->mode = dataIn.mode; pStateReal->chargeStatus = dataIn.chargeStatus;
--- 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
--- a/Discovery/Src/t3.c Mon Nov 04 20:21:02 2024 +0100 +++ b/Discovery/Src/t3.c Wed Nov 13 17:55:05 2024 +0100 @@ -1971,7 +1971,7 @@ int printScrubberText(char *text, size_t size, SSettings *settings) { - int16_t currentTimerMinutes = settings->scrubberData[settings->scubberActiveId].TimerCur; + int16_t currentTimerMinutes = stateUsed->scrubberDataDive[settings->scubberActiveId].TimerCur; char colour = '\020'; if (currentTimerMinutes <= 0) { colour = '\025';
--- a/Discovery/Src/tCCR.c Mon Nov 04 20:21:02 2024 +0100 +++ b/Discovery/Src/tCCR.c Wed Nov 13 17:55:05 2024 +0100 @@ -337,18 +337,18 @@ } } - /* decrease scrubber timer only in real dive mode, and if we are not bailed out */ - if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (stateUsed->mode == MODE_DIVE) && isLoopMode(stateUsed->diveSettings.diveMode)) // && (stateUsed == stateRealGetPointer())) + /* decrease scrubber timer only if we are not bailed out */ + if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (stateUsed->mode == MODE_DIVE) && isLoopMode(stateUsed->diveSettings.diveMode)) { ScrubberTimeoutCount++; if(ScrubberTimeoutCount >= 600) /* resolution is minutes */ { ScrubberTimeoutCount = 0; - if(pSettings->scrubberData[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) + if(stateUsed->scrubberDataDive[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) { - pSettings->scrubberData[pSettings->scubberActiveId].TimerCur--; + stateUsedWrite->scrubberDataDive[pSettings->scubberActiveId].TimerCur--; } - translateDate(stateUsed->lifeData.dateBinaryFormat, &pSettings->scrubberData[pSettings->scubberActiveId].lastDive); + translateDate(stateUsed->lifeData.dateBinaryFormat, &stateUsedWrite->scrubberDataDive[pSettings->scubberActiveId].lastDive); } } }