# HG changeset patch # User heinrichsweikamp # Date 1679399814 -3600 # Node ID 21949c88da9026cc059672c68357b45deb5dad31 # Parent 9825dcf5067552097fc73ccccb754acd048d6c31 Quit simualted dives after the dive time set in the SIM tab. diff -r 9825dcf50675 -r 21949c88da90 Discovery/Inc/simulation.h --- a/Discovery/Inc/simulation.h Fri Mar 17 09:35:25 2023 +0100 +++ b/Discovery/Inc/simulation.h Tue Mar 21 12:56:54 2023 +0100 @@ -42,7 +42,7 @@ float ppO2AtBottom; } SSimDataSummary; -void simulation_start(int aim_depth); +void simulation_start(int aim_depth, uint16_t aim_time_minutes); void simulation_exit(void); void simulation_set_heed_decostops(_Bool heed_decostops_while_ascending); diff -r 9825dcf50675 -r 21949c88da90 Discovery/Src/simulation.c --- a/Discovery/Src/simulation.c Fri Mar 17 09:35:25 2023 +0100 +++ b/Discovery/Src/simulation.c Tue Mar 21 12:56:54 2023 +0100 @@ -48,6 +48,7 @@ //Private state variables static float sim_aim_depth_meter; +static float sim_aim_time_minutes; static _Bool sim_heed_decostops = 1; static const float sim_descent_rate_meter_per_min = 20; @@ -80,7 +81,7 @@ ****************************************************************************** * @return void */ -void simulation_start(int aim_depth) +void simulation_start(int aim_depth, uint16_t aim_time_minutes) { copyDiveSettingsToSim(); copyVpmRepetetiveDataToSim(); @@ -90,6 +91,7 @@ if(aim_depth <= 0) aim_depth = 20; simulation_set_aim_depth(aim_depth); + sim_aim_time_minutes = aim_time_minutes; timer_init(); set_stateUsedToSim(); stateSim.lifeData.boolResetAverageDepth = 1; @@ -131,6 +133,10 @@ static _Bool two_second = 0; static float lastPressure_bar = 0; + if (sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) { + simulation_set_aim_depth(0); + } + float localCalibCoeff[3] = { 0.0, 0.0, 0.0 }; uint8_t index, index2; @@ -912,6 +918,7 @@ } } } + void Sim_IncreasePPO(uint8_t sensorIdx) { if((sensorIdx < NUM_OF_SENSORS) && (simSensmVOffset[sensorIdx] + SIM_PPO2_STEP < 100.0) && ((stateUsed->diveSettings.ppo2sensors_deactivated & (1 << sensorIdx)) == 0)) diff -r 9825dcf50675 -r 21949c88da90 Discovery/Src/tMenuEditPlanner.c --- a/Discovery/Src/tMenuEditPlanner.c Fri Mar 17 09:35:25 2023 +0100 +++ b/Discovery/Src/tMenuEditPlanner.c Tue Mar 21 12:56:54 2023 +0100 @@ -86,7 +86,7 @@ settingsGetPointer()->bluetoothActive = 0; MX_Bluetooth_PowerOff(); } - simulation_start(tMplan_depth_meter); + simulation_start(tMplan_depth_meter, tMplan_dive_time_minutes); exitMenuEdit_to_Home(); break; case 2: