Mercurial > public > ostc4
comparison Discovery/Src/simulation.c @ 760:21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
author | heinrichsweikamp |
---|---|
date | Tue, 21 Mar 2023 12:56:54 +0100 |
parents | be25ab2d902c |
children | 3b5f9557c053 |
comparison
equal
deleted
inserted
replaced
759:9825dcf50675 | 760:21949c88da90 |
---|---|
46 | 46 |
47 #include "configuration.h" | 47 #include "configuration.h" |
48 | 48 |
49 //Private state variables | 49 //Private state variables |
50 static float sim_aim_depth_meter; | 50 static float sim_aim_depth_meter; |
51 static float sim_aim_time_minutes; | |
51 static _Bool sim_heed_decostops = 1; | 52 static _Bool sim_heed_decostops = 1; |
52 | 53 |
53 static const float sim_descent_rate_meter_per_min = 20; | 54 static const float sim_descent_rate_meter_per_min = 20; |
54 | 55 |
55 | 56 |
78 ****************************************************************************** | 79 ****************************************************************************** |
79 * @brief start of simulation | 80 * @brief start of simulation |
80 ****************************************************************************** | 81 ****************************************************************************** |
81 * @return void | 82 * @return void |
82 */ | 83 */ |
83 void simulation_start(int aim_depth) | 84 void simulation_start(int aim_depth, uint16_t aim_time_minutes) |
84 { | 85 { |
85 copyDiveSettingsToSim(); | 86 copyDiveSettingsToSim(); |
86 copyVpmRepetetiveDataToSim(); | 87 copyVpmRepetetiveDataToSim(); |
87 //vpm_init(&stateSimGetPointerWrite()->vpm, stateSimGetPointerWrite()->diveSettings.vpm_conservatism, 0, 0); | 88 //vpm_init(&stateSimGetPointerWrite()->vpm, stateSimGetPointerWrite()->diveSettings.vpm_conservatism, 0, 0); |
88 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = 0; | 89 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = 0; |
89 stateSimGetPointerWrite()->mode = MODE_DIVE; | 90 stateSimGetPointerWrite()->mode = MODE_DIVE; |
90 if(aim_depth <= 0) | 91 if(aim_depth <= 0) |
91 aim_depth = 20; | 92 aim_depth = 20; |
92 simulation_set_aim_depth(aim_depth); | 93 simulation_set_aim_depth(aim_depth); |
94 sim_aim_time_minutes = aim_time_minutes; | |
93 timer_init(); | 95 timer_init(); |
94 set_stateUsedToSim(); | 96 set_stateUsedToSim(); |
95 stateSim.lifeData.boolResetAverageDepth = 1; | 97 stateSim.lifeData.boolResetAverageDepth = 1; |
96 decoLock = DECO_CALC_init_as_is_start_of_dive; | 98 decoLock = DECO_CALC_init_as_is_start_of_dive; |
97 | 99 |
128 SSettings *pSettings; | 130 SSettings *pSettings; |
129 | 131 |
130 static int last_second = -1; | 132 static int last_second = -1; |
131 static _Bool two_second = 0; | 133 static _Bool two_second = 0; |
132 static float lastPressure_bar = 0; | 134 static float lastPressure_bar = 0; |
135 | |
136 if (sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) { | |
137 simulation_set_aim_depth(0); | |
138 } | |
133 | 139 |
134 float localCalibCoeff[3] = { 0.0, 0.0, 0.0 }; | 140 float localCalibCoeff[3] = { 0.0, 0.0, 0.0 }; |
135 uint8_t index, index2; | 141 uint8_t index, index2; |
136 | 142 |
137 if(checkOncePerSecond) | 143 if(checkOncePerSecond) |
910 { | 916 { |
911 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = settingsGetPointer()->timeoutDiveReachedZeroDepth - 15; | 917 stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = settingsGetPointer()->timeoutDiveReachedZeroDepth - 15; |
912 } | 918 } |
913 } | 919 } |
914 } | 920 } |
921 | |
915 void Sim_IncreasePPO(uint8_t sensorIdx) | 922 void Sim_IncreasePPO(uint8_t sensorIdx) |
916 { | 923 { |
917 if((sensorIdx < NUM_OF_SENSORS) && (simSensmVOffset[sensorIdx] + SIM_PPO2_STEP < 100.0) && ((stateUsed->diveSettings.ppo2sensors_deactivated & (1 << sensorIdx)) == 0)) | 924 if((sensorIdx < NUM_OF_SENSORS) && (simSensmVOffset[sensorIdx] + SIM_PPO2_STEP < 100.0) && ((stateUsed->diveSettings.ppo2sensors_deactivated & (1 << sensorIdx)) == 0)) |
918 { | 925 { |
919 simSensmVOffset[sensorIdx] += SIM_PPO2_STEP; | 926 simSensmVOffset[sensorIdx] += SIM_PPO2_STEP; |