Mercurial > public > ostc4
comparison Discovery/Src/simulation.c @ 225:2bb1db22b5f5 div-fixes-3
cleanup: random set of cleanups
A random set of cleanups, as found during code reading, and looking
around fixing issues. Contains all kinds of things: typo's in comment,
typo in variable name, removal of unused code, making things static
where possible. Does not contain any functional changes.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Mon, 01 Apr 2019 15:50:41 +0200 |
parents | 1719b9d1094b |
children | 9f0efc4df01e |
comparison
equal
deleted
inserted
replaced
224:ceecabfddb57 | 225:2bb1db22b5f5 |
---|---|
42 #include "vpm.h" | 42 #include "vpm.h" |
43 #include "buehlmann.h" | 43 #include "buehlmann.h" |
44 #include "logbook_miniLive.h" | 44 #include "logbook_miniLive.h" |
45 | 45 |
46 //Private state variables | 46 //Private state variables |
47 float sim_aim_depth_meter; | 47 static float sim_aim_depth_meter; |
48 _Bool sim_head_decostops = 1; | 48 static _Bool sim_heed_decostops = 1; |
49 | 49 |
50 const float sim_descent_rate_meter_per_min = 20; | 50 static const float sim_descent_rate_meter_per_min = 20; |
51 | 51 |
52 | 52 |
53 //Private functions | 53 //Private functions |
54 float sim_get_ambiant_pressure(SDiveState * pDiveState); | 54 static float sim_get_ambiant_pressure(SDiveState * pDiveState); |
55 void sim_reduce_deco_time_one_second(SDiveState* pDiveState); | 55 static void sim_reduce_deco_time_one_second(SDiveState* pDiveState); |
56 static void simulation_set_aim_depth(int depth_meter); | |
56 | 57 |
57 /** | 58 /** |
58 ****************************************************************************** | 59 ****************************************************************************** |
59 * @brief sets heed_decostops_while_ascending | 60 * @brief sets heed_decostops_while_ascending |
60 ****************************************************************************** | 61 ****************************************************************************** |
61 * @param heed_decostops_while_ascending : true -> deco_stops are considered while ascending | 62 * @param heed_decostops_while_ascending : true -> deco_stops are considered while ascending |
62 * @return void | 63 * @return void |
63 */ | 64 */ |
64 void simulation_set_heed_decostops(_Bool heed_decostops_while_ascending) | 65 void simulation_set_heed_decostops(_Bool heed_decostops_while_ascending) |
65 { | 66 { |
66 sim_head_decostops = heed_decostops_while_ascending; | 67 sim_heed_decostops = heed_decostops_while_ascending; |
67 } | 68 } |
68 | 69 |
69 /** | 70 /** |
70 ****************************************************************************** | 71 ****************************************************************************** |
71 * @brief start of simulation | 72 * @brief start of simulation |
81 stateSimGetPointerWrite()->mode = MODE_DIVE; | 82 stateSimGetPointerWrite()->mode = MODE_DIVE; |
82 if(aim_depth <= 0) | 83 if(aim_depth <= 0) |
83 aim_depth = 20; | 84 aim_depth = 20; |
84 simulation_set_aim_depth(aim_depth); | 85 simulation_set_aim_depth(aim_depth); |
85 timer_init(); | 86 timer_init(); |
86 stateUsed = &stateSim; | 87 set_stateUsedToSim(); |
87 stateSim.lifeData.boolResetAverageDepth = 1; | 88 stateSim.lifeData.boolResetAverageDepth = 1; |
88 decoLock = DECO_CALC_init_as_is_start_of_dive; | 89 decoLock = DECO_CALC_init_as_is_start_of_dive; |
89 | 90 |
90 stateSim.lifeData.apnea_total_max_depth_meter = 0; | 91 stateSim.lifeData.apnea_total_max_depth_meter = 0; |
91 } | 92 } |
260 * @brief adds extra time for fast simulation | 261 * @brief adds extra time for fast simulation |
261 ****************************************************************************** | 262 ****************************************************************************** |
262 *@param minutes | 263 *@param minutes |
263 * @return float : new pressure | 264 * @return float : new pressure |
264 */ | 265 */ |
265 void simulation_add_time(int minutes) | 266 static void simulation_add_time(int minutes) |
266 { | 267 { |
267 for(int i = 0; i < 60 * minutes; i++) | 268 for(int i = 0; i < 60 * minutes; i++) |
268 { | 269 { |
269 simulation_UpdateLifeData(0); | 270 simulation_UpdateLifeData(0); |
270 updateMiniLiveLogbook(0); | 271 updateMiniLiveLogbook(0); |
291 * @return true if ascend follows decostops; | 292 * @return true if ascend follows decostops; |
292 */ | 293 */ |
293 | 294 |
294 _Bool simulation_get_heed_decostops(void) | 295 _Bool simulation_get_heed_decostops(void) |
295 { | 296 { |
296 return sim_head_decostops; | 297 return sim_heed_decostops; |
297 } | 298 } |
298 | 299 |
299 /** | 300 /** |
300 ****************************************************************************** | 301 ****************************************************************************** |
301 * @brief sets aim_depth | 302 * @brief sets aim_depth |
302 ****************************************************************************** | 303 ****************************************************************************** |
303 *@param depth_meter | 304 *@param depth_meter |
304 * @return float : new pressure | 305 * @return float : new pressure |
305 */ | 306 */ |
306 void simulation_set_aim_depth(int depth_meter) | 307 static void simulation_set_aim_depth(int depth_meter) |
307 { | 308 { |
308 sim_aim_depth_meter = depth_meter; | 309 sim_aim_depth_meter = depth_meter; |
309 } | 310 } |
310 | 311 |
311 /** | 312 /** |
315 * @note if aim_depth != actual depth, the depth change within one second | 316 * @note if aim_depth != actual depth, the depth change within one second |
316 * (depending on descent or ascent) rate is calculated | 317 * (depending on descent or ascent) rate is calculated |
317 * @param SDiveState* pDiveState: | 318 * @param SDiveState* pDiveState: |
318 * @return float : new ambiant pressure | 319 * @return float : new ambiant pressure |
319 */ | 320 */ |
320 float sim_get_ambiant_pressure(SDiveState * pDiveState) | 321 static float sim_get_ambiant_pressure(SDiveState * pDiveState) |
321 { | 322 { |
322 //Calc next depth | 323 //Calc next depth |
323 uint8_t actual_deco_stop = decom_get_actual_deco_stop(pDiveState); | 324 uint8_t actual_deco_stop = decom_get_actual_deco_stop(pDiveState); |
324 float depth_meter = pDiveState->lifeData.depth_meter; | 325 float depth_meter = pDiveState->lifeData.depth_meter; |
325 float surface_pressure_bar = pDiveState->lifeData.pressure_surface_bar; | 326 float surface_pressure_bar = pDiveState->lifeData.pressure_surface_bar; |
334 | 335 |
335 depth_meter -= pDiveState->diveSettings.ascentRate_meterperminute / 60; | 336 depth_meter -= pDiveState->diveSettings.ascentRate_meterperminute / 60; |
336 if(depth_meter < sim_aim_depth_meter) | 337 if(depth_meter < sim_aim_depth_meter) |
337 depth_meter = sim_aim_depth_meter; | 338 depth_meter = sim_aim_depth_meter; |
338 | 339 |
339 if(sim_head_decostops && depth_meter < actual_deco_stop) | 340 if(sim_heed_decostops && depth_meter < actual_deco_stop) |
340 { | 341 { |
341 if(actual_deco_stop < (depth_meter + pDiveState->diveSettings.ascentRate_meterperminute / 60)) | 342 if(actual_deco_stop < (depth_meter + pDiveState->diveSettings.ascentRate_meterperminute / 60)) |
342 depth_meter = actual_deco_stop; | 343 depth_meter = actual_deco_stop; |
343 else | 344 else |
344 depth_meter += pDiveState->diveSettings.ascentRate_meterperminute / 60; | 345 depth_meter += pDiveState->diveSettings.ascentRate_meterperminute / 60; |
459 pDiveState->lifeData.cns += vpm_get_CNS(); | 460 pDiveState->lifeData.cns += vpm_get_CNS(); |
460 return &pDiveState->decolistVPM; | 461 return &pDiveState->decolistVPM; |
461 } | 462 } |
462 } | 463 } |
463 | 464 |
464 float sGChelper_bar(uint16_t depth_meter) | 465 static float sGChelper_bar(uint16_t depth_meter) |
465 { | 466 { |
466 SDiveState * pDiveState = &stateSim; | 467 SDiveState * pDiveState = &stateSim; |
467 float ambient, surface, density, meter; | 468 float ambient, surface, density, meter; |
468 | 469 |
469 surface = pDiveState->lifeData.pressure_surface_bar; | 470 surface = pDiveState->lifeData.pressure_surface_bar; |