Mercurial > public > ostc4
comparison 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 |
comparison
equal
deleted
inserted
replaced
923:6fc0e3d230e4 | 924:4d98fb2a178e |
---|---|
54 static float sim_descent_rate_meter_per_min = 20; | 54 static float sim_descent_rate_meter_per_min = 20; |
55 | 55 |
56 static uint16_t* pReplayData; /* pointer to source dive data */ | 56 static uint16_t* pReplayData; /* pointer to source dive data */ |
57 static uint8_t simReplayActive = 0; | 57 static uint8_t simReplayActive = 0; |
58 | 58 |
59 static uint16_t simScrubberTimeoutCount = 0; | |
60 | |
59 | 61 |
60 //Private functions | 62 //Private functions |
61 static float sim_get_ambient_pressure(SDiveState * pDiveState); | 63 static float sim_get_ambient_pressure(SDiveState * pDiveState); |
62 static void sim_reduce_deco_time_one_second(SDiveState* pDiveState); | 64 static void sim_reduce_deco_time_one_second(SDiveState* pDiveState); |
63 static void simulation_set_aim_depth(int depth_meter); | 65 static void simulation_set_aim_depth(int depth_meter); |
106 set_stateUsedToSim(); | 108 set_stateUsedToSim(); |
107 stateSim.lifeData.boolResetAverageDepth = 1; | 109 stateSim.lifeData.boolResetAverageDepth = 1; |
108 decoLock = DECO_CALC_init_as_is_start_of_dive; | 110 decoLock = DECO_CALC_init_as_is_start_of_dive; |
109 | 111 |
110 stateSim.lifeData.apnea_total_max_depth_meter = 0; | 112 stateSim.lifeData.apnea_total_max_depth_meter = 0; |
113 | |
114 memcpy(stateSim.scrubberDataDive, settingsGetPointer()->scrubberData, sizeof(stateSim.scrubberDataDive)); | |
111 memset(simSensmVOffset,0,sizeof(simSensmVOffset)); | 115 memset(simSensmVOffset,0,sizeof(simSensmVOffset)); |
112 if(getReplayOffset() != 0xFFFF) | 116 if(getReplayOffset() != 0xFFFF) |
113 { | 117 { |
114 simReplayActive = 1; | 118 simReplayActive = 1; |
115 getReplayInfo(&pReplayData, &pReplayMarker, &replayDataLength, &max_depth, &diveMinutes); | 119 getReplayInfo(&pReplayData, &pReplayMarker, &replayDataLength, &max_depth, &diveMinutes); |
150 | 154 |
151 static int last_second = -1; | 155 static int last_second = -1; |
152 static _Bool two_second = 0; | 156 static _Bool two_second = 0; |
153 static float lastPressure_bar = 0; | 157 static float lastPressure_bar = 0; |
154 | 158 |
159 pSettings = settingsGetPointer(); | |
160 | |
155 if ((sim_aim_time_minutes && sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) | 161 if ((sim_aim_time_minutes && sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) |
156 && (!simReplayActive)) | 162 && (!simReplayActive)) |
157 { | 163 { |
158 simulation_set_aim_depth(0); | 164 simulation_set_aim_depth(0); |
159 } | 165 } |
172 two_second = 1; | 178 two_second = 1; |
173 else | 179 else |
174 { | 180 { |
175 two_second = 0; | 181 two_second = 0; |
176 } | 182 } |
177 pSettings = settingsGetPointer(); | 183 |
178 for(index = 0; index < 3; index++) | 184 for(index = 0; index < 3; index++) |
179 { | 185 { |
180 localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index]; | 186 localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index]; |
181 if(localCalibCoeff[index] < 0.01) | 187 if(localCalibCoeff[index] < 0.01) |
182 { | 188 { |
228 if(pDiveState->lifeData.pressure_ambient_bar < 1.5) | 234 if(pDiveState->lifeData.pressure_ambient_bar < 1.5) |
229 { | 235 { |
230 lastPressure_bar = 0; | 236 lastPressure_bar = 0; |
231 pDiveState->lifeData.ascent_rate_meter_per_min = 0; | 237 pDiveState->lifeData.ascent_rate_meter_per_min = 0; |
232 } | 238 } |
239 | |
240 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (pDiveState->mode == MODE_DIVE) && isLoopMode(pDiveState->diveSettings.diveMode)) | |
241 { | |
242 simScrubberTimeoutCount++; | |
243 if(simScrubberTimeoutCount >= 60) /* resolution is minutes */ | |
244 { | |
245 simScrubberTimeoutCount = 0; | |
246 if(pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) | |
247 { | |
248 pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur--; | |
249 } | |
250 translateDate(stateUsed->lifeData.dateBinaryFormat, &stateUsedWrite->scrubberDataDive[pSettings->scubberActiveId].lastDive); | |
251 } | |
252 } | |
253 | |
254 | |
233 if(lastPressure_bar > 0) | 255 if(lastPressure_bar > 0) |
234 { | 256 { |
235 //1 second * 60 == 1 minute, bar * 10 = meter | 257 //1 second * 60 == 1 minute, bar * 10 = meter |
236 pDiveState->lifeData.ascent_rate_meter_per_min = (lastPressure_bar - pDiveState->lifeData.pressure_ambient_bar) * 600.0; | 258 pDiveState->lifeData.ascent_rate_meter_per_min = (lastPressure_bar - pDiveState->lifeData.pressure_ambient_bar) * 600.0; |
237 } | 259 } |