Mercurial > public > ostc4
annotate Discovery/Src/simulation.c @ 977:f0622dd93fdf Evo_2_23
Bugfix ppo2 display in simulator mode:
In the previous version a wrong ppo2 value was display if a digital O2 sensor was used. Rootcause was that the calibration data of the analog sensors was used. To fix this a default calibration coefficient is used (calibration is done within the sensor => no need to store it in OSTC) if the sensor is identified as digital O2 sensor.
| author | Ideenmodellierer |
|---|---|
| date | Thu, 30 Jan 2025 21:24:46 +0100 |
| parents | 79b522fbabe6 |
| children | 7149f372b0ba |
| rev | line source |
|---|---|
| 38 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Src/simulation.c | |
| 5 /// \brief Contains dive simulation functionality | |
| 6 /// \author Heinrichs Weikamp gmbh | |
| 7 /// \date 13-Oct-2014 | |
| 8 /// | |
| 9 /// \details | |
| 10 /// The simulation uses "extern SDiveState stateSim" defined in dataCentral.h" | |
| 11 /// | |
| 12 /// simulation_start(void) sets stateUsed to stateSim and initializes simulation | |
| 13 /// simulation_UpdateLifeData should be called at least once per second | |
| 14 /// simulation_end() sets stateUsed back to stateReal | |
| 15 /// | |
| 16 /// $Id$ | |
| 17 /////////////////////////////////////////////////////////////////////////////// | |
| 18 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
| 19 /// | |
| 20 /// This program is free software: you can redistribute it and/or modify | |
| 21 /// it under the terms of the GNU General Public License as published by | |
| 22 /// the Free Software Foundation, either version 3 of the License, or | |
| 23 /// (at your option) any later version. | |
| 24 /// | |
| 25 /// This program is distributed in the hope that it will be useful, | |
| 26 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 27 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 28 /// GNU General Public License for more details. | |
| 29 /// | |
| 30 /// You should have received a copy of the GNU General Public License | |
| 31 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 32 ////////////////////////////////////////////////////////////////////////////// | |
| 33 | |
| 34 #include <string.h> | |
| 35 #include "simulation.h" | |
| 36 | |
| 37 #include "decom.h" | |
| 38 #include "calc_crush.h" | |
| 39 #include "data_exchange.h" | |
|
308
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
40 #include "data_exchange_main.h" |
| 38 | 41 #include "timer.h" |
| 42 #include "check_warning.h" | |
| 43 #include "vpm.h" | |
| 44 #include "buehlmann.h" | |
| 45 #include "logbook_miniLive.h" | |
| 46 | |
| 450 | 47 #include "configuration.h" |
| 48 | |
| 38 | 49 //Private state variables |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
50 static float sim_aim_depth_meter; |
|
760
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
748
diff
changeset
|
51 static float sim_aim_time_minutes; |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
52 static _Bool sim_heed_decostops = 1; |
| 38 | 53 |
| 897 | 54 static float sim_descent_rate_meter_per_min = 20; |
| 55 | |
| 56 static uint16_t* pReplayData; /* pointer to source dive data */ | |
| 57 static uint8_t simReplayActive = 0; | |
| 38 | 58 |
|
924
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
59 static uint16_t simScrubberTimeoutCount = 0; |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
60 |
| 38 | 61 |
| 62 //Private functions | |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
233
diff
changeset
|
63 static float sim_get_ambient_pressure(SDiveState * pDiveState); |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
64 static void sim_reduce_deco_time_one_second(SDiveState* pDiveState); |
|
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
65 static void simulation_set_aim_depth(int depth_meter); |
| 38 | 66 |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
67 #define NUM_OF_SENSORS (3u) |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
68 #define SIM_PPO2_STEP (1.1f) |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
69 static float simSensmVOffset[NUM_OF_SENSORS]; |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
70 |
| 38 | 71 /** |
| 72 ****************************************************************************** | |
| 73 * @brief sets heed_decostops_while_ascending | |
| 74 ****************************************************************************** | |
| 75 * @param heed_decostops_while_ascending : true -> deco_stops are considered while ascending | |
| 76 * @return void | |
| 77 */ | |
| 78 void simulation_set_heed_decostops(_Bool heed_decostops_while_ascending) | |
| 79 { | |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
80 sim_heed_decostops = heed_decostops_while_ascending; |
| 38 | 81 } |
| 82 | |
| 83 /** | |
| 84 ****************************************************************************** | |
| 85 * @brief start of simulation | |
| 86 ****************************************************************************** | |
| 87 * @return void | |
| 88 */ | |
|
760
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
748
diff
changeset
|
89 void simulation_start(int aim_depth, uint16_t aim_time_minutes) |
| 38 | 90 { |
| 897 | 91 uint16_t replayDataLength = 0; |
| 92 uint8_t* pReplayMarker; | |
| 93 uint16_t max_depth = 10; | |
| 94 uint16_t diveMinutes = 0; | |
| 95 | |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
96 copyDiveSettingsToSim(); |
| 38 | 97 copyVpmRepetetiveDataToSim(); |
| 901 | 98 |
| 38 | 99 //vpm_init(&stateSimGetPointerWrite()->vpm, stateSimGetPointerWrite()->diveSettings.vpm_conservatism, 0, 0); |
| 100 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = 0; | |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
101 stateSimGetPointerWrite()->mode = MODE_DIVE; |
| 38 | 102 if(aim_depth <= 0) |
| 103 aim_depth = 20; | |
| 897 | 104 sim_descent_rate_meter_per_min = 20; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
105 simulation_set_aim_depth(aim_depth); |
|
760
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
748
diff
changeset
|
106 sim_aim_time_minutes = aim_time_minutes; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
107 timer_init(); |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
108 set_stateUsedToSim(); |
| 38 | 109 stateSim.lifeData.boolResetAverageDepth = 1; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
110 decoLock = DECO_CALC_init_as_is_start_of_dive; |
| 38 | 111 |
| 112 stateSim.lifeData.apnea_total_max_depth_meter = 0; | |
|
924
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
113 |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
114 memcpy(stateSim.scrubberDataDive, settingsGetPointer()->scrubberData, sizeof(stateSim.scrubberDataDive)); |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
115 memset(simSensmVOffset,0,sizeof(simSensmVOffset)); |
| 897 | 116 if(getReplayOffset() != 0xFFFF) |
| 117 { | |
| 118 simReplayActive = 1; | |
| 119 getReplayInfo(&pReplayData, &pReplayMarker, &replayDataLength, &max_depth, &diveMinutes); | |
| 120 } | |
| 38 | 121 } |
| 122 | |
| 123 /** | |
| 124 ****************************************************************************** | |
| 125 * @brief end of simulation | |
| 126 ****************************************************************************** | |
| 127 * | |
| 128 * @return void | |
| 129 */ | |
| 130 void simulation_exit(void) | |
| 131 { | |
| 132 timer_Stopwatch_Stop(); | |
|
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
790
diff
changeset
|
133 |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
790
diff
changeset
|
134 disableTimer(); |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
790
diff
changeset
|
135 |
| 38 | 136 set_stateUsedToReal(); |
| 137 } | |
| 138 | |
| 139 /** | |
| 140 ****************************************************************************** | |
| 141 * @brief simulates change of Lifedata (saturation, depth change, etc.) within one second | |
| 142 ****************************************************************************** | |
| 143 * | |
| 144 * @param checkOncePerSecond : true -> simulation in real time (function is evaluated only once per second) | |
| 145 * and copy of parts of LifeData from SmallCPU with each call from HAL_TIM_PeriodElapsedCallback() | |
| 146 * : false -> fast simulation (many simulation cycles per second are possible) | |
| 147 * @return void | |
| 148 */ | |
| 149 void simulation_UpdateLifeData( _Bool checkOncePerSecond) | |
| 150 { | |
| 151 SDiveState * pDiveState = &stateSim; | |
| 813 | 152 const SDiveState * pRealState = stateRealGetPointer(); |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
153 SSettings *pSettings; |
| 38 | 154 |
| 155 static int last_second = -1; | |
| 156 static _Bool two_second = 0; | |
| 157 static float lastPressure_bar = 0; | |
| 158 | |
|
924
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
159 pSettings = settingsGetPointer(); |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
160 |
| 897 | 161 if ((sim_aim_time_minutes && sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) |
| 162 && (!simReplayActive)) | |
| 163 { | |
|
760
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
748
diff
changeset
|
164 simulation_set_aim_depth(0); |
|
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
748
diff
changeset
|
165 } |
|
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
748
diff
changeset
|
166 |
| 699 | 167 float localCalibCoeff[3] = { 0.0, 0.0, 0.0 }; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
168 uint8_t index, index2; |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
169 |
| 38 | 170 if(checkOncePerSecond) |
| 171 { | |
| 901 | 172 int now = current_second(); |
| 173 if( last_second == now) | |
| 174 return; | |
| 175 last_second = now; | |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
176 |
| 901 | 177 if(!two_second) |
| 178 two_second = 1; | |
| 179 else | |
| 180 { | |
| 181 two_second = 0; | |
| 182 } | |
|
924
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
183 |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
184 for(index = 0; index < 3; index++) |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
185 { |
| 977 | 186 if(pDiveState->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) |
| 187 { | |
| 188 localCalibCoeff[index] = 0.01; | |
| 189 } | |
| 190 else | |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
191 { |
| 977 | 192 localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index]; |
| 193 if(localCalibCoeff[index] < 0.01) | |
| 194 { | |
| 195 for(index2 = 0; index2 < 3; index2++) /* no valid coeff => check other entries */ | |
| 196 { | |
| 197 if(pSettings->ppo2sensors_calibCoeff[index2] > 0.01) | |
| 198 { | |
| 199 localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index2]; | |
| 200 break; | |
| 201 } | |
| 202 if(index2 == 3) /* no coeff at all => use default */ | |
| 203 { | |
| 204 localCalibCoeff[index] = 0.02; | |
| 205 } | |
| 206 } | |
| 207 } | |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
208 } |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
209 } |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
210 |
| 813 | 211 pDiveState->lifeData.temperature_celsius = pRealState->lifeData.temperature_celsius; |
| 212 pDiveState->lifeData.battery_charge = pRealState->lifeData.battery_charge; | |
| 213 pDiveState->lifeData.compass_heading = pRealState->lifeData.compass_heading; | |
| 214 pDiveState->lifeData.compass_roll = pRealState->lifeData.compass_roll; | |
| 215 pDiveState->lifeData.compass_pitch = pRealState->lifeData.compass_pitch; | |
| 216 | |
| 217 for(index = 0; index < 3; index++) | |
| 218 { | |
| 219 memcpy(&pDiveState->lifeData.extIf_sensor_data[index], &pRealState->lifeData.extIf_sensor_data[index], 32); | |
| 220 } | |
|
548
e7e44986684a
Update roll and pitch value in simulation mode:
Ideenmodellierer
parents:
450
diff
changeset
|
221 |
|
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
308
diff
changeset
|
222 #ifdef ENABLE_BOTTLE_SENSOR |
| 813 | 223 pDiveState->lifeData.bottle_bar[pDiveState->lifeData.actualGas.GasIdInSettings] = pRealState->lifeData.bottle_bar[pRealState->lifeData.actualGas.GasIdInSettings]; |
| 224 pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] = pRealState->lifeData.bottle_bar_age_MilliSeconds[pRealState->lifeData.actualGas.GasIdInSettings]; | |
|
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
308
diff
changeset
|
225 #endif |
| 38 | 226 } |
| 227 else if(pDiveState->lifeData.depth_meter <= (float)(decom_get_actual_deco_stop(pDiveState) + 0.001)) | |
| 901 | 228 { |
| 229 if(decoLock == DECO_CALC_FINSHED_vpm) | |
| 230 { | |
| 231 sim_reduce_deco_time_one_second(&stateDeco); | |
| 232 } | |
| 233 else | |
| 234 { | |
| 235 sim_reduce_deco_time_one_second(pDiveState); | |
| 236 } | |
| 237 } | |
| 897 | 238 |
| 38 | 239 pDiveState->lifeData.dive_time_seconds += 1; |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
233
diff
changeset
|
240 pDiveState->lifeData.pressure_ambient_bar = sim_get_ambient_pressure(pDiveState); |
| 953 | 241 if(pDiveState->lifeData.depth_meter < 1.5) |
| 897 | 242 { |
| 243 lastPressure_bar = 0; | |
| 244 pDiveState->lifeData.ascent_rate_meter_per_min = 0; | |
| 245 } | |
|
924
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
246 |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
247 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (pDiveState->mode == MODE_DIVE) && isLoopMode(pDiveState->diveSettings.diveMode)) |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
248 { |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
249 simScrubberTimeoutCount++; |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
250 if(simScrubberTimeoutCount >= 60) /* resolution is minutes */ |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
251 { |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
252 simScrubberTimeoutCount = 0; |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
253 if(pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
254 { |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
255 pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur--; |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
256 } |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
257 translateDate(stateUsed->lifeData.dateBinaryFormat, &stateUsedWrite->scrubberDataDive[pSettings->scubberActiveId].lastDive); |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
258 } |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
259 } |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
260 |
|
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
910
diff
changeset
|
261 |
| 897 | 262 if(lastPressure_bar > 0) |
| 263 { | |
| 264 //1 second * 60 == 1 minute, bar * 10 = meter | |
| 265 pDiveState->lifeData.ascent_rate_meter_per_min = (lastPressure_bar - pDiveState->lifeData.pressure_ambient_bar) * 600.0; | |
| 266 } | |
| 267 lastPressure_bar = pDiveState->lifeData.pressure_ambient_bar; | |
| 38 | 268 |
| 813 | 269 pDiveState->lifeData.sensorVoltage_mV[0] = pRealState->lifeData.sensorVoltage_mV[0] + simSensmVOffset[0]; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
270 if(pDiveState->lifeData.sensorVoltage_mV[0] < 0.0) { pDiveState->lifeData.sensorVoltage_mV[0] = 0.0; } |
| 813 | 271 pDiveState->lifeData.sensorVoltage_mV[1] = pRealState->lifeData.sensorVoltage_mV[1] + simSensmVOffset[1]; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
272 if(pDiveState->lifeData.sensorVoltage_mV[1] < 0.0) { pDiveState->lifeData.sensorVoltage_mV[1] = 0.0; } |
| 813 | 273 pDiveState->lifeData.sensorVoltage_mV[2] = pRealState->lifeData.sensorVoltage_mV[2] + simSensmVOffset[2]; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
274 if(pDiveState->lifeData.sensorVoltage_mV[2] < 0.0) { pDiveState->lifeData.sensorVoltage_mV[2] = 0.0; } |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
275 |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
276 pDiveState->lifeData.ppO2Sensor_bar[0] = pDiveState->lifeData.sensorVoltage_mV[0] * localCalibCoeff[0] * pDiveState->lifeData.pressure_ambient_bar; |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
277 pDiveState->lifeData.ppO2Sensor_bar[1] = pDiveState->lifeData.sensorVoltage_mV[1] * localCalibCoeff[1] * pDiveState->lifeData.pressure_ambient_bar; |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
278 pDiveState->lifeData.ppO2Sensor_bar[2] = pDiveState->lifeData.sensorVoltage_mV[2] * localCalibCoeff[2] * pDiveState->lifeData.pressure_ambient_bar; |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
279 |
| 813 | 280 pDiveState->lifeData.CO2_data.CO2_ppm = pRealState->lifeData.CO2_data.CO2_ppm; |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
281 |
| 38 | 282 if(is_ambient_pressure_close_to_surface(&pDiveState->lifeData)) // new hw 170214 |
| 283 { | |
| 284 if(!(stateSimGetPointer()->lifeData.counterSecondsShallowDepth)) | |
| 285 { | |
| 286 if(pDiveState->diveSettings.diveMode != DIVEMODE_Apnea) | |
| 287 pDiveState->lifeData.counterSecondsShallowDepth = settingsGetPointer()->timeoutDiveReachedZeroDepth - 15; | |
| 288 else | |
| 289 { | |
| 290 pDiveState->lifeData.apnea_last_dive_time_seconds = pDiveState->lifeData.dive_time_seconds; | |
| 291 if(pDiveState->lifeData.apnea_last_dive_time_seconds > pDiveState->lifeData.dive_time_seconds_without_surface_time) | |
| 292 pDiveState->lifeData.apnea_last_dive_time_seconds = pDiveState->lifeData.dive_time_seconds_without_surface_time; | |
| 293 pDiveState->lifeData.apnea_last_max_depth_meter = pDiveState->lifeData.max_depth_meter; | |
| 294 pDiveState->lifeData.counterSecondsShallowDepth = 1; | |
| 295 } | |
| 296 } | |
| 297 } | |
| 298 else | |
| 299 { | |
| 300 pDiveState->lifeData.counterSecondsShallowDepth = 0; | |
| 301 } | |
| 302 | |
|
304
43b44f8d4fb0
bugfix, simulator: fix the 1 sec difference between stopwatch and divetime
Jan Mulder <jlmulder@xs4all.nl>
parents:
300
diff
changeset
|
303 if(!is_ambient_pressure_close_to_surface(&pDiveState->lifeData) && !(stateSimGetPointer()->lifeData.counterSecondsShallowDepth) ) |
|
43b44f8d4fb0
bugfix, simulator: fix the 1 sec difference between stopwatch and divetime
Jan Mulder <jlmulder@xs4all.nl>
parents:
300
diff
changeset
|
304 { |
|
43b44f8d4fb0
bugfix, simulator: fix the 1 sec difference between stopwatch and divetime
Jan Mulder <jlmulder@xs4all.nl>
parents:
300
diff
changeset
|
305 pDiveState->lifeData.dive_time_seconds_without_surface_time += 1; |
|
43b44f8d4fb0
bugfix, simulator: fix the 1 sec difference between stopwatch and divetime
Jan Mulder <jlmulder@xs4all.nl>
parents:
300
diff
changeset
|
306 } |
|
43b44f8d4fb0
bugfix, simulator: fix the 1 sec difference between stopwatch and divetime
Jan Mulder <jlmulder@xs4all.nl>
parents:
300
diff
changeset
|
307 |
| 38 | 308 pDiveState->lifeData.depth_meter = (pDiveState->lifeData.pressure_ambient_bar - pDiveState->lifeData.pressure_surface_bar) * 10.0f; |
| 309 if(pDiveState->lifeData.max_depth_meter < pDiveState->lifeData.depth_meter) | |
| 310 pDiveState->lifeData.max_depth_meter = pDiveState->lifeData.depth_meter; | |
| 311 | |
| 312 /* apnoe specials | |
| 313 */ | |
| 314 if(pDiveState->diveSettings.diveMode == DIVEMODE_Apnea) | |
| 315 { | |
| 316 if(pDiveState->lifeData.max_depth_meter > pDiveState->lifeData.apnea_total_max_depth_meter) | |
| 317 pDiveState->lifeData.apnea_total_max_depth_meter = pDiveState->lifeData.max_depth_meter; | |
| 318 | |
| 319 if(pDiveState->lifeData.counterSecondsShallowDepth) | |
| 320 { | |
| 321 pDiveState->lifeData.dive_time_seconds = 0; | |
| 322 pDiveState->lifeData.max_depth_meter = 0; | |
| 323 pDiveState->lifeData.boolResetAverageDepth = 1; | |
| 324 } | |
| 325 } | |
| 326 | |
|
308
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
327 setAvgDepth(pDiveState); |
| 38 | 328 |
| 329 /* Exposure Tissues | |
| 330 */ | |
| 331 decom_tissues_exposure(1, &pDiveState->lifeData); | |
| 332 decom_oxygen_calculate_cns_exposure(1, &pDiveState->lifeData.actualGas, pDiveState->lifeData.pressure_ambient_bar, &pDiveState->lifeData.cns); | |
|
233
9f0efc4df01e
cleanup, bugfix: do not exit simulator on 5h dive time
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
333 |
| 38 | 334 if(stateSimGetPointer()->lifeData.counterSecondsShallowDepth) |
| 335 { | |
| 336 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth += 1; | |
| 337 if(stateSimGetPointer()->lifeData.counterSecondsShallowDepth >= settingsGetPointer()->timeoutDiveReachedZeroDepth) | |
| 338 simulation_exit(); | |
| 339 } | |
| 340 vpm_crush(pDiveState); | |
| 341 } | |
| 342 | |
| 343 /** | |
| 344 ****************************************************************************** | |
| 345 * @brief adds extra time for fast simulation | |
| 346 ****************************************************************************** | |
| 347 *@param minutes | |
| 348 * @return float : new pressure | |
| 349 */ | |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
350 static void simulation_add_time(int minutes) |
| 38 | 351 { |
| 352 for(int i = 0; i < 60 * minutes; i++) | |
| 353 { | |
| 354 simulation_UpdateLifeData(0); | |
| 355 updateMiniLiveLogbook(0); | |
| 356 timer_UpdateSecond(0); | |
| 357 } | |
| 358 } | |
| 359 | |
| 360 /** | |
| 361 ****************************************************************************** | |
| 362 * @brief get aim_depth | |
| 363 ****************************************************************************** | |
| 364 * @return sim_aim_depth_meter; | |
| 365 */ | |
| 366 | |
| 367 uint16_t simulation_get_aim_depth(void) | |
| 368 { | |
| 369 return (uint16_t)sim_aim_depth_meter; | |
| 370 } | |
| 371 | |
| 372 /** | |
| 373 ****************************************************************************** | |
| 374 * @brief get heed decostops | |
| 375 ****************************************************************************** | |
| 376 * @return true if ascend follows decostops; | |
| 377 */ | |
| 378 | |
| 379 _Bool simulation_get_heed_decostops(void) | |
| 380 { | |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
381 return sim_heed_decostops; |
| 38 | 382 } |
| 383 | |
| 384 /** | |
| 385 ****************************************************************************** | |
| 386 * @brief sets aim_depth | |
| 387 ****************************************************************************** | |
| 388 *@param depth_meter | |
| 389 * @return float : new pressure | |
| 390 */ | |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
391 static void simulation_set_aim_depth(int depth_meter) |
| 38 | 392 { |
| 393 sim_aim_depth_meter = depth_meter; | |
| 394 } | |
| 395 | |
| 396 /** | |
| 397 ****************************************************************************** | |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
233
diff
changeset
|
398 * @brief simulates ambient pressure depending on aim depth |
| 38 | 399 ****************************************************************************** |
| 400 * @note if aim_depth != actual depth, the depth change within one second | |
| 401 * (depending on descent or ascent) rate is calculated | |
| 402 * @param SDiveState* pDiveState: | |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
233
diff
changeset
|
403 * @return float : new ambient pressure |
| 38 | 404 */ |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
233
diff
changeset
|
405 static float sim_get_ambient_pressure(SDiveState * pDiveState) |
| 38 | 406 { |
| 407 //Calc next depth | |
| 408 uint8_t actual_deco_stop = decom_get_actual_deco_stop(pDiveState); | |
| 409 float depth_meter = pDiveState->lifeData.depth_meter; | |
| 410 float surface_pressure_bar = pDiveState->lifeData.pressure_surface_bar; | |
| 897 | 411 static uint8_t sampleToggle = 0; |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
412 static float sim_ascent_rate_meter_per_min_local = 0; |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
413 uint8_t sampleTime = getReplayDataResolution(); |
| 897 | 414 |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
415 if(simReplayActive) /* precondition: function is called once per second, sample rate is a multiple of second */ |
| 897 | 416 { |
| 417 if(sampleToggle == 0) | |
| 418 { | |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
419 sampleToggle = sampleTime - 1; |
| 897 | 420 sim_aim_depth_meter = (float)(*pReplayData++/100.0); |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
421 if(sim_aim_depth_meter > depth_meter) |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
422 { |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
423 sim_descent_rate_meter_per_min = (sim_aim_depth_meter - depth_meter) * (60 / sampleTime); |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
424 } |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
425 else |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
426 { |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
427 sim_ascent_rate_meter_per_min_local = (depth_meter - sim_aim_depth_meter) * (60 / sampleTime); |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
428 } |
| 897 | 429 } |
| 430 else | |
| 431 { | |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
432 sampleToggle--; |
| 897 | 433 } |
| 434 } | |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
435 else |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
436 { |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
437 sim_ascent_rate_meter_per_min_local = pDiveState->diveSettings.ascentRate_meterperminute; |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
438 } |
| 897 | 439 |
| 38 | 440 if(depth_meter < sim_aim_depth_meter) |
| 441 { | |
| 442 depth_meter = depth_meter + sim_descent_rate_meter_per_min / 60; | |
| 443 if(depth_meter > sim_aim_depth_meter) | |
| 444 depth_meter = sim_aim_depth_meter; | |
| 445 } | |
| 446 else if(depth_meter > sim_aim_depth_meter) | |
| 447 { | |
| 448 | |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
449 depth_meter -= sim_ascent_rate_meter_per_min_local / 60; |
| 38 | 450 if(depth_meter < sim_aim_depth_meter) |
| 451 depth_meter = sim_aim_depth_meter; | |
| 452 | |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
453 if(sim_heed_decostops && depth_meter < actual_deco_stop) |
| 38 | 454 { |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
455 if(actual_deco_stop < (depth_meter + sim_ascent_rate_meter_per_min_local / 60)) |
| 38 | 456 depth_meter = actual_deco_stop; |
| 457 else | |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
458 depth_meter += sim_ascent_rate_meter_per_min_local / 60; |
| 38 | 459 } |
| 460 | |
| 461 } | |
| 462 | |
| 463 return surface_pressure_bar + depth_meter / 10; | |
| 464 } | |
| 465 | |
| 466 | |
| 467 /** | |
| 468 ****************************************************************************** | |
| 469 * @brief Reduces deco time of deepest stop by one second | |
| 470 ****************************************************************************** | |
| 471 * @note called during fast simulation | |
| 472 * @param SDiveState* pDiveState: | |
| 473 * @return void | |
| 474 */ | |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
233
diff
changeset
|
475 static void sim_reduce_deco_time_one_second(SDiveState* pDiveState) |
| 38 | 476 { |
| 477 SDecoinfo* pDecoinfo; | |
| 901 | 478 int8_t index = 0; |
| 479 | |
| 480 | |
| 38 | 481 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) |
| 482 pDecoinfo = &pDiveState->decolistBuehlmann; | |
| 483 else | |
| 484 pDecoinfo = &pDiveState->decolistVPM; | |
| 485 | |
| 486 //Reduce deco time of deepest stop by one second | |
| 901 | 487 for(index = DECOINFO_STRUCT_MAX_STOPS -1 ;index >= 0; index--) |
| 38 | 488 { |
| 901 | 489 if(pDecoinfo->output_stop_length_seconds[index] > 0) |
| 38 | 490 { |
| 901 | 491 pDecoinfo->output_stop_length_seconds[index]--; |
| 38 | 492 break; |
| 493 } | |
| 494 } | |
| 901 | 495 /* update TTS */ |
| 496 if(pDecoinfo->output_time_to_surface_seconds) | |
| 497 { | |
| 498 pDecoinfo->output_time_to_surface_seconds--; | |
| 499 } | |
| 38 | 500 } |
| 501 | |
| 502 SDecoinfo* simulation_decoplaner(uint16_t depth_meter, uint16_t intervall_time_minutes, uint16_t dive_time_minutes, uint8_t *gasChangeListDepthGas20x2) | |
| 503 { | |
| 504 uint8_t ptrGasChangeList = 0; // new hw 160704 | |
| 977 | 505 #ifdef ENABLE_DECOCALC_OPTION |
|
888
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
506 uint8_t index = 0; |
| 977 | 507 #endif |
|
678
05cdd367dbd0
Bugfix: deco planner did not initialize properly
Jan Mulder <jan@jlmulder.nl>
parents:
629
diff
changeset
|
508 for (int i = 0; i < 40; i++) |
|
05cdd367dbd0
Bugfix: deco planner did not initialize properly
Jan Mulder <jan@jlmulder.nl>
parents:
629
diff
changeset
|
509 gasChangeListDepthGas20x2[i] = 0; |
|
05cdd367dbd0
Bugfix: deco planner did not initialize properly
Jan Mulder <jan@jlmulder.nl>
parents:
629
diff
changeset
|
510 |
| 38 | 511 SDiveState * pDiveState = &stateSim; |
| 512 copyDiveSettingsToSim(); | |
|
888
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
513 |
| 973 | 514 #ifdef ENABLE_DECOCALC_OPTION |
|
888
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
515 /* activate deco calculation for all deco gases */ |
|
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
516 for(index = 0; index < 1 + (2*NUM_GASES); index++) |
|
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
517 { |
|
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
518 if(pDiveState->diveSettings.gas[index].note.ub.deco) |
|
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
519 { |
|
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
520 pDiveState->diveSettings.gas[index].note.ub.decocalc = 1; |
|
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
521 } |
|
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
522 } |
| 973 | 523 #endif |
|
888
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
524 |
| 38 | 525 vpm_init(&pDiveState->vpm, pDiveState->diveSettings.vpm_conservatism, 0, 0); |
| 526 //buehlmann_init(); | |
| 527 //timer_init(); | |
| 528 memset(&pDiveState->events,0, sizeof(SEvents)); | |
| 529 pDiveState->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; | |
| 530 //Calc desaturation during intervall (with Air) | |
| 531 setActualGasAir(&pDiveState->lifeData); | |
| 532 if(intervall_time_minutes > 0) | |
| 533 { | |
| 534 decom_tissues_exposure(intervall_time_minutes * 60, &pDiveState->lifeData); | |
| 535 decom_oxygen_calculate_cns_degrade(&pDiveState->lifeData.cns, intervall_time_minutes * 60); | |
| 536 } | |
| 537 | |
| 538 //Switch to first Gas | |
| 539 setActualGasFirst(&pDiveState->lifeData); | |
| 540 | |
| 541 // new hw 160704 | |
| 542 if(gasChangeListDepthGas20x2) | |
| 543 { | |
| 544 gasChangeListDepthGas20x2[ptrGasChangeList++] = 0; | |
| 545 gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->lifeData.actualGas.GasIdInSettings; | |
| 546 gasChangeListDepthGas20x2[0] =0; // depth zero | |
| 547 } | |
| 548 | |
| 549 //Going down / descent | |
| 550 simulation_set_aim_depth(depth_meter); | |
|
790
3b5f9557c053
Fix bug introduced in 04b98a2, causing the deco planner to not show deco stops.
heinrichsweikamp
parents:
760
diff
changeset
|
551 sim_aim_time_minutes = 0; |
| 38 | 552 for(int i = 0; i < 60 * dive_time_minutes; i++) |
| 553 { | |
| 554 simulation_UpdateLifeData(0); | |
| 555 check_warning2(pDiveState); | |
| 556 if(pDiveState->warnings.betterGas) | |
| 557 { | |
| 558 setActualGas(&pDiveState->lifeData,actualBetterGasId(),pDiveState->lifeData.actualGas.setPoint_cbar); | |
| 559 if(gasChangeListDepthGas20x2 && (pDiveState->diveSettings.diveMode == DIVEMODE_OC)) | |
| 560 { | |
| 561 gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->lifeData.depth_meter; | |
| 562 gasChangeListDepthGas20x2[ptrGasChangeList++] = actualBetterGasId(); | |
| 563 } | |
| 564 } | |
| 565 } | |
| 566 | |
| 567 decom_CreateGasChangeList(&pDiveState->diveSettings, &pDiveState->lifeData); // was there before and needed for buehlmann_calc_deco and vpm_calc | |
| 568 | |
| 569 // new hw 160704 | |
| 570 if(gasChangeListDepthGas20x2 && (pDiveState->diveSettings.diveMode == DIVEMODE_OC)) | |
| 571 { | |
| 572 // change direction from better gas to deco gas | |
| 573 gasChangeListDepthGas20x2[ptrGasChangeList++] = 255; | |
| 574 gasChangeListDepthGas20x2[ptrGasChangeList++] = 255; | |
| 575 | |
| 576 // ascend (deco) gases | |
| 577 for(int i=1; i<=5;i++) | |
| 578 { | |
|
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
813
diff
changeset
|
579 if((pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) |
| 973 | 580 #ifdef ENABLE_DECOCALC_OPTION |
| 581 || (pDiveState->diveSettings.gas[pDiveState->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) | |
| 582 #endif | |
| 583 ) | |
| 38 | 584 break; |
| 585 gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
| 586 gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].GasIdInSettings; | |
| 587 } | |
| 588 gasChangeListDepthGas20x2[0] = 0; | |
| 589 } | |
| 590 | |
| 591 // deco and ascend calc | |
| 592 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) | |
| 593 { | |
| 594 /* this does modify the cns now 11.06.2015 */ | |
| 595 buehlmann_calc_deco(&pDiveState->lifeData,&pDiveState->diveSettings,&pDiveState->decolistBuehlmann); | |
| 596 pDiveState->lifeData.cns += buehlmann_get_gCNS(); | |
| 597 return &pDiveState->decolistBuehlmann; | |
| 598 } | |
| 599 else | |
| 600 { | |
| 601 /* this does modify the cns now 11.06.2015 */ | |
| 602 vpm_calc(&pDiveState->lifeData,&pDiveState->diveSettings,&pDiveState->vpm,&pDiveState->decolistVPM, DECOSTOPS); | |
| 603 pDiveState->lifeData.cns += vpm_get_CNS(); | |
|
910
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
604 |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
605 while(decoLock == DECO_CALC_FINSHED_vpm) |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
606 { |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
607 HAL_Delay(2); /* The deco data is copied during the timer ISR => wait till this has happened */ |
|
7bd347bdaa81
Devbugfix Sample time resolution for longer dives:
Ideenmodellierer
parents:
907
diff
changeset
|
608 } |
| 38 | 609 return &pDiveState->decolistVPM; |
| 610 } | |
| 611 } | |
| 612 | |
|
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
176
diff
changeset
|
613 static float sGChelper_bar(uint16_t depth_meter) |
| 38 | 614 { |
| 615 SDiveState * pDiveState = &stateSim; | |
| 616 float ambient, surface, density, meter; | |
| 617 | |
| 618 surface = pDiveState->lifeData.pressure_surface_bar; | |
| 619 | |
| 620 if(!depth_meter) | |
| 621 return surface; | |
| 622 | |
| 623 density = ((float)( 100 + settingsGetPointer()->salinity)) / 100.0f; | |
| 624 meter = depth_meter * (0.09807f * density); | |
| 625 ambient = (meter + surface); | |
| 626 | |
| 627 return ambient; | |
| 628 } | |
| 629 | |
| 630 | |
| 631 /** | |
| 632 ****************************************************************************** | |
| 633 * @brief simulation_helper_change_points | |
| 634 ****************************************************************************** | |
| 635 * @param | |
| 636 * @return void | |
| 637 */ | |
| 638 void simulation_helper_change_points(SSimDataSummary *outputSummary, uint16_t depth_meter, uint16_t dive_time_minutes, SDecoinfo *decoInfoInput, const uint8_t *gasChangeListDepthGas20x2) | |
| 639 { | |
| 640 uint8_t ptrDecoInfo = 0; | |
| 641 uint16_t actualDepthPoint = 0; | |
| 642 uint16_t nextDepthPoint = 0; | |
| 643 uint8_t actualConsumGasId = 0; | |
| 644 uint8_t nextGasChangeMeter = 0; | |
| 645 uint8_t ptrChangeList = 0; | |
| 646 | |
| 647 float timeThis = 0; | |
| 648 float timeSummary = 0; | |
| 649 float sim_descent_rate_meter_per_min_local = 10; | |
| 650 float sim_ascent_rate_meter_per_min_local = 10; | |
| 651 | |
| 652 SDiveState * pDiveState = &stateSim; | |
| 653 | |
| 654 uint8_t depthDecoNext, depthLast, depthSecond, depthInc; | |
| 655 | |
| 656 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) | |
| 657 { | |
| 658 sim_descent_rate_meter_per_min_local = sim_descent_rate_meter_per_min; // const float | |
| 659 sim_ascent_rate_meter_per_min_local = pDiveState->diveSettings.ascentRate_meterperminute; | |
| 660 } | |
| 661 else | |
| 662 { | |
| 663 sim_descent_rate_meter_per_min_local = sim_descent_rate_meter_per_min; // const float | |
| 664 sim_ascent_rate_meter_per_min_local = 10;// fix in vpm_calc_deco(); | |
| 665 } | |
| 666 | |
| 667 outputSummary->descentRateMeterPerMinute = sim_descent_rate_meter_per_min_local; | |
| 668 outputSummary->ascentRateMeterPerMinute = sim_ascent_rate_meter_per_min_local; | |
| 669 | |
| 670 // bottom gas ppO2 | |
| 671 if(gasChangeListDepthGas20x2) | |
| 672 { | |
| 673 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 674 actualConsumGasId = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 675 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 676 | |
| 677 while(actualDepthPoint < depth_meter) | |
| 678 { | |
| 679 if(nextGasChangeMeter && (nextGasChangeMeter < depth_meter) && (gasChangeListDepthGas20x2[ptrChangeList] != 255)) // list has 255,255 for turn from travel to deco | |
| 680 { | |
| 681 nextDepthPoint = nextGasChangeMeter; | |
| 682 } | |
| 683 else | |
| 684 { | |
| 685 nextDepthPoint = depth_meter; | |
| 686 } | |
| 687 | |
| 688 if(actualConsumGasId > 5) // safety first | |
| 689 actualConsumGasId = 0; | |
| 690 | |
| 691 actualDepthPoint = nextDepthPoint; | |
| 692 | |
| 693 if(actualDepthPoint != depth_meter) | |
| 694 { | |
| 695 actualConsumGasId = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 696 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 697 } | |
| 698 } | |
| 699 } | |
| 700 else | |
| 701 { | |
| 702 actualConsumGasId = pDiveState->lifeData.actualGas.GasIdInSettings; | |
| 703 nextGasChangeMeter = 0; | |
| 704 } | |
| 705 outputSummary->ppO2AtBottom = (sGChelper_bar(depth_meter) - WATER_VAPOUR_PRESSURE) * pDiveState->diveSettings.gas[actualConsumGasId].oxygen_percentage / 100.0f; | |
| 706 | |
| 707 | |
| 708 // going down | |
| 709 actualDepthPoint = 0; | |
| 710 nextDepthPoint = depth_meter; | |
| 711 | |
| 712 timeThis = ((float)(nextDepthPoint - actualDepthPoint)) / sim_descent_rate_meter_per_min_local; | |
| 713 timeSummary += timeThis; | |
| 714 outputSummary->timeToBottom = (uint16_t)timeThis; | |
| 715 | |
| 716 // bottom time | |
| 717 timeThis = ((float)dive_time_minutes) - timeSummary; | |
| 718 timeSummary += timeThis; | |
| 719 outputSummary->timeAtBottom = (uint16_t)timeSummary; | |
| 720 | |
| 721 | |
| 722 // ascend to first deco stop | |
| 723 actualDepthPoint = depth_meter; // that is where we are | |
| 724 timeThis = 0; | |
| 725 | |
| 726 if(!decoInfoInput->output_stop_length_seconds[0]) // NDL dive | |
| 727 { | |
| 728 depthLast = 0; | |
| 729 ptrDecoInfo = 0; | |
| 730 depthDecoNext = 0; | |
| 731 } | |
| 732 else | |
| 733 { | |
| 734 // prepare deco stop list | |
| 735 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); | |
| 736 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); | |
| 737 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); | |
| 738 | |
| 739 for(ptrDecoInfo=DECOINFO_STRUCT_MAX_STOPS-1; ptrDecoInfo>0; ptrDecoInfo--) | |
| 740 if(decoInfoInput->output_stop_length_seconds[ptrDecoInfo]) break; | |
| 741 | |
| 742 if(ptrDecoInfo == 0) | |
| 743 { | |
| 744 depthDecoNext = depthLast; | |
| 745 } | |
| 746 else | |
| 747 depthDecoNext = depthSecond + (( ptrDecoInfo - 1 )* depthInc); | |
| 748 } | |
| 749 | |
| 750 nextDepthPoint = depthDecoNext; | |
| 751 if(actualDepthPoint > nextDepthPoint) | |
| 752 { | |
| 753 // flip signs! It's going up | |
| 754 timeThis = ((float)(actualDepthPoint - nextDepthPoint)) / sim_ascent_rate_meter_per_min_local; | |
| 755 actualDepthPoint = nextDepthPoint; // that is where we are | |
| 756 } | |
| 757 timeSummary += timeThis; | |
| 758 outputSummary->timeToFirstStop = (uint16_t)timeSummary; | |
| 759 outputSummary->depthMeterFirstStop = actualDepthPoint; | |
| 760 | |
| 901 | 761 if(decoInfoInput->output_time_to_surface_seconds) |
| 38 | 762 { |
| 901 | 763 outputSummary->timeToSurface = outputSummary->timeAtBottom + (decoInfoInput->output_time_to_surface_seconds / 60); |
| 38 | 764 } |
| 901 | 765 else |
| 766 { | |
| 767 outputSummary->timeToSurface = outputSummary->timeToFirstStop; | |
| 768 } | |
| 38 | 769 } |
| 770 | |
| 771 | |
| 772 /** | |
| 773 ****************************************************************************** | |
| 774 * @brief simulation_gas_consumption | |
| 775 ****************************************************************************** | |
| 776 * @note called by openEdit_PlanResult() in tMenuEditPlanner.c | |
| 777 * @note the ascend and descend time is taken from pDiveState->lifeData.ascent_rate_meter_per_min and const float sim_descent_rate_meter_per_min | |
| 778 * @param outputConsumptionList list from 1 to 5 for gas 1 to 5 | |
| 779 * @param depth_meter for descend | |
| 780 * @param dive_time_minutes for descend and bottom time | |
| 781 * @param the calculated deco list | |
| 782 * @param gasConsumTravelInput: how many l/min for all but deco stops | |
| 783 * @param gasConsumDecoInput: how many l/min for deco stops only | |
| 784 * @return void | |
| 785 */ | |
| 786 | |
| 787 void simulation_gas_consumption(uint16_t *outputConsumptionList, uint16_t depth_meter, uint16_t dive_time_minutes, SDecoinfo *decoInfoInput, uint8_t gasConsumTravelInput, uint8_t gasConsumDecoInput, const uint8_t *gasChangeListDepthGas20x2) | |
| 788 { | |
| 789 uint8_t ptrDecoInfo = 0; | |
| 790 uint8_t ptrChangeList = 0; | |
| 791 uint8_t actualConsumGasId = 0; | |
| 792 uint8_t nextGasChangeMeter = 0; | |
| 793 uint16_t actualDepthPoint = 0; | |
| 794 uint16_t nextDepthPoint = 0; | |
| 795 uint16_t inBetweenDepthPoint = 0; | |
| 796 float timeThis = 0; | |
| 797 float consumThis = 0; | |
| 798 float timeSummary = 0; | |
| 799 float outputConsumptionTempFloat[6]; | |
| 800 float sim_descent_rate_meter_per_min_local = 10; | |
| 801 float sim_ascent_rate_meter_per_min_local = 10; | |
| 802 | |
| 803 SDiveState * pDiveState = &stateSim; | |
| 804 | |
|
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
805 uint8_t depthDecoNext = 0; |
|
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
806 uint8_t depthLast = 0; |
|
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
807 uint8_t depthSecond = 0; |
|
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
808 uint8_t depthInc = 0; |
| 38 | 809 |
| 810 for(int i = 1; i < 6; i++) | |
| 811 outputConsumptionTempFloat[i] = 0; | |
| 812 | |
| 813 if(gasChangeListDepthGas20x2) | |
| 814 { | |
| 815 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 816 actualConsumGasId = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 817 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 818 } | |
| 819 else | |
| 820 { | |
| 821 actualConsumGasId = pDiveState->lifeData.actualGas.GasIdInSettings; | |
| 822 nextGasChangeMeter = 0; | |
| 823 } | |
| 824 | |
| 825 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) | |
| 826 { | |
| 827 sim_descent_rate_meter_per_min_local = sim_descent_rate_meter_per_min; // const float | |
| 828 sim_ascent_rate_meter_per_min_local = pDiveState->diveSettings.ascentRate_meterperminute; | |
| 829 } | |
| 830 else | |
| 831 { | |
| 832 sim_descent_rate_meter_per_min_local = sim_descent_rate_meter_per_min; // const float | |
| 833 sim_ascent_rate_meter_per_min_local = 10;// fix in vpm_calc_deco(); | |
| 834 } | |
| 835 | |
| 836 // while((nextGasChangeMeter < depth_meter) && (actualDepthPoint < depth_meter)) | |
| 837 while(actualDepthPoint < depth_meter) | |
| 838 { | |
| 839 if(nextGasChangeMeter && (nextGasChangeMeter < depth_meter) && (gasChangeListDepthGas20x2[ptrChangeList] != 255)) // list has 255,255 for turn from travel to deco | |
| 840 { | |
| 841 nextDepthPoint = nextGasChangeMeter; | |
| 842 } | |
| 843 else | |
| 844 { | |
| 845 nextDepthPoint = depth_meter; | |
| 846 } | |
| 847 | |
| 848 if(actualConsumGasId > 5) // safety first | |
| 849 actualConsumGasId = 0; | |
| 850 | |
| 851 timeThis = ((float)(nextDepthPoint - actualDepthPoint)) / sim_descent_rate_meter_per_min_local; | |
| 852 if(actualDepthPoint) // not if on surface | |
| 853 { | |
| 854 consumThis = ((float)gasConsumTravelInput) * sGChelper_bar(actualDepthPoint) * timeThis; | |
| 855 } | |
| 856 consumThis += ((float)gasConsumTravelInput) * sGChelper_bar(nextDepthPoint -actualDepthPoint) * timeThis / 2; | |
| 857 outputConsumptionTempFloat[actualConsumGasId] += consumThis; | |
| 858 timeSummary += timeThis; | |
| 859 | |
| 860 actualDepthPoint = nextDepthPoint; | |
| 861 | |
| 862 if(actualDepthPoint != depth_meter) | |
| 863 { | |
| 864 actualConsumGasId = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 865 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 866 } | |
| 867 } | |
| 868 | |
| 869 // bottom Time | |
| 870 timeThis = ((float)dive_time_minutes) - timeSummary; | |
| 871 | |
| 872 if(timeThis > 0) | |
| 873 { | |
| 874 consumThis = ((float)gasConsumTravelInput) * sGChelper_bar(depth_meter) * timeThis; | |
| 875 outputConsumptionTempFloat[actualConsumGasId] += consumThis; | |
| 876 } | |
| 877 | |
| 878 // ascend with deco stops prepare | |
| 879 if(gasChangeListDepthGas20x2) | |
| 880 { | |
| 881 ptrChangeList++;// gasChangeListDepthGas20x2[ptrChangeList++]; // should be the 255 | |
| 882 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 883 } | |
| 884 else | |
| 885 { | |
| 886 nextGasChangeMeter = 0; | |
| 887 } | |
| 888 | |
| 889 | |
| 890 if(!decoInfoInput->output_stop_length_seconds[0]) // NDL dive | |
| 891 { | |
| 892 depthLast = 0; | |
| 893 ptrDecoInfo = 0; | |
| 894 } | |
| 895 else | |
| 896 { | |
| 897 // prepare deco stop list | |
| 898 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); | |
| 899 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); | |
| 900 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); | |
| 901 | |
| 902 for(ptrDecoInfo=DECOINFO_STRUCT_MAX_STOPS-1; ptrDecoInfo>0; ptrDecoInfo--) | |
| 903 if(decoInfoInput->output_stop_length_seconds[ptrDecoInfo]) break; | |
| 904 } | |
| 905 | |
| 906 actualDepthPoint = depth_meter; // that is where we are | |
| 907 | |
| 908 // ascend with deco stops | |
| 909 while(actualDepthPoint) | |
| 910 { | |
| 911 if(ptrDecoInfo == 0) | |
| 912 { | |
| 913 depthDecoNext = depthLast; | |
| 914 } | |
| 915 else | |
| 916 depthDecoNext = depthSecond + (( ptrDecoInfo - 1 )* depthInc); | |
| 917 | |
| 918 if(nextGasChangeMeter && (nextGasChangeMeter > depthDecoNext)) | |
| 919 { | |
| 920 nextDepthPoint = nextGasChangeMeter; | |
| 921 } | |
| 922 else | |
| 923 { | |
| 924 nextDepthPoint = depthDecoNext; | |
| 925 } | |
| 926 | |
| 927 if(actualConsumGasId > 5) // safety first | |
| 928 actualConsumGasId = 0; | |
| 929 | |
| 930 if(actualDepthPoint > nextDepthPoint) | |
| 931 { | |
| 932 // flip signs! It's going up | |
| 933 timeThis = ((float)(actualDepthPoint - nextDepthPoint)) / sim_ascent_rate_meter_per_min_local; | |
| 934 inBetweenDepthPoint = nextDepthPoint + ((actualDepthPoint - nextDepthPoint)/2); | |
| 935 consumThis = ((float)gasConsumDecoInput) * sGChelper_bar(inBetweenDepthPoint) * timeThis; | |
| 936 /* | |
| 937 if(nextDepthPoint) | |
| 938 { | |
| 939 consumThis = ((float)gasConsumDecoInput) * sGChelper_bar(nextDepthPoint) * timeThis; | |
| 940 } | |
| 941 else | |
| 942 { | |
| 943 consumThis = 0; | |
| 944 } | |
| 945 consumThis += ((float)gasConsumDecoInput) * sGChelper_bar(actualDepthPoint - nextDepthPoint) * timeThis / 2; | |
| 946 */ | |
| 947 outputConsumptionTempFloat[actualConsumGasId] += consumThis; | |
| 948 } | |
| 949 | |
| 950 if(nextGasChangeMeter && (nextDepthPoint == nextGasChangeMeter)) | |
| 951 { | |
| 952 actualConsumGasId = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 953 nextGasChangeMeter = gasChangeListDepthGas20x2[ptrChangeList++]; | |
| 954 } | |
| 955 | |
| 956 if(actualConsumGasId > 5) // safety first | |
| 957 actualConsumGasId = 0; | |
| 958 | |
| 959 if(nextDepthPoint && (nextDepthPoint == depthDecoNext)) | |
| 960 { | |
| 961 if(decoInfoInput->output_stop_length_seconds[ptrDecoInfo]) | |
| 962 { | |
| 963 timeThis = ((float)(decoInfoInput->output_stop_length_seconds[ptrDecoInfo])) / 60.0f; | |
| 964 consumThis = ((float)gasConsumDecoInput) * sGChelper_bar(nextDepthPoint) * timeThis; | |
| 965 outputConsumptionTempFloat[actualConsumGasId] += consumThis; | |
| 966 } | |
| 967 if(ptrDecoInfo != 0) | |
| 968 { | |
| 969 ptrDecoInfo--; | |
| 970 } | |
| 971 else | |
| 972 { | |
| 973 depthLast = 0; | |
| 974 } | |
| 975 } | |
| 976 actualDepthPoint = nextDepthPoint; | |
| 977 } | |
| 978 | |
| 979 // copy and return | |
| 980 for(int i = 1; i < 6; i++) | |
| 981 outputConsumptionList[i] = (uint16_t)(outputConsumptionTempFloat[i]); | |
| 982 } | |
| 983 | |
| 984 /** | |
| 985 ****************************************************************************** | |
| 986 * @brief Simulator control during simulated dive | |
| 987 ****************************************************************************** | |
| 988 * @note called by user via tHomeDiveMenuControl() | |
| 989 * @param void | |
| 990 * @return void | |
| 991 */ | |
| 992 | |
| 993 | |
| 994 void Sim_Descend (void) | |
| 995 { | |
| 996 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = 0; | |
| 997 if(simulation_get_aim_depth() < 200) | |
| 998 simulation_set_aim_depth(simulation_get_aim_depth() + 1); | |
| 999 } | |
| 1000 | |
| 1001 | |
| 1002 void Sim_Ascend (void) | |
| 1003 { | |
| 1004 if(simulation_get_aim_depth() > 0) | |
| 1005 simulation_set_aim_depth(simulation_get_aim_depth() - 1); | |
| 1006 } | |
| 1007 | |
| 1008 | |
| 1009 void Sim_Divetime (void) | |
| 1010 { | |
| 1011 simulation_add_time(5); | |
| 1012 } | |
| 1013 | |
| 1014 | |
| 1015 void Sim_Quit (void) | |
| 1016 { | |
| 1017 if(stateSimGetPointer()->lifeData.counterSecondsShallowDepth) | |
| 1018 { | |
| 1019 simulation_exit(); | |
| 1020 return; | |
| 1021 } | |
| 1022 | |
| 1023 if(simulation_get_aim_depth() > 0) | |
| 1024 { | |
| 1025 simulation_set_aim_depth(0); | |
| 1026 } | |
| 1027 else | |
| 1028 { | |
| 1029 stateSimGetPointerWrite()->lifeData.depth_meter = 0; | |
| 1030 if(stateSimGetPointer()->diveSettings.diveMode == DIVEMODE_Apnea) | |
| 1031 { | |
| 1032 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = 1; | |
| 1033 } | |
| 1034 else | |
| 1035 { | |
| 1036 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = settingsGetPointer()->timeoutDiveReachedZeroDepth - 15; | |
| 1037 } | |
| 1038 } | |
| 1039 } | |
|
760
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
748
diff
changeset
|
1040 |
|
629
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1041 void Sim_IncreasePPO(uint8_t sensorIdx) |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1042 { |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1043 if((sensorIdx < NUM_OF_SENSORS) && (simSensmVOffset[sensorIdx] + SIM_PPO2_STEP < 100.0) && ((stateUsed->diveSettings.ppo2sensors_deactivated & (1 << sensorIdx)) == 0)) |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1044 { |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1045 simSensmVOffset[sensorIdx] += SIM_PPO2_STEP; |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1046 } |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1047 } |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1048 void Sim_DecreasePPO(uint8_t sensorIdx) |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1049 { |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1050 if((sensorIdx < NUM_OF_SENSORS) && (simSensmVOffset[sensorIdx] - SIM_PPO2_STEP >= -100.0)) |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1051 { |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1052 simSensmVOffset[sensorIdx] -= SIM_PPO2_STEP; |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1053 } |
|
55a9aa740f13
Added functionality to add ppo2 mV offset:
Ideenmodellierer
parents:
548
diff
changeset
|
1054 } |
