# HG changeset patch # User Ideenmodellierer # Date 1650914101 -7200 # Node ID 8775d3dc6325e3a18a4ea6bbb602aa4d02e10ea6 # Parent 7fa5ef6ae419a6527cae785d49696a44474fa9f3 Bugfix low ppO2 warning in bailout mode: the code has different sources for divesettings (real and simulated). The ppo2 calculation code used the pointer to the real structure. As result in simulation mode an error occured caused by the ppo2 calculation which was not aware that a bailout happened (because the real structure was references instead of the simulator ones). The problem has been fixed by using the "stateUsed" pointer which is refering to the structure currenty in use. diff -r 7fa5ef6ae419 -r 8775d3dc6325 Discovery/Src/data_central.c --- a/Discovery/Src/data_central.c Mon Apr 25 21:10:10 2022 +0200 +++ b/Discovery/Src/data_central.c Mon Apr 25 21:15:01 2022 +0200 @@ -412,7 +412,7 @@ void updateSetpointStateUsed(void) { - if(!isLoopMode(stateReal.diveSettings.diveMode)) + if(!isLoopMode(stateUsed->diveSettings.diveMode)) { stateUsedWrite->lifeData.actualGas.setPoint_cbar = 0; stateUsedWrite->lifeData.ppO2 = decom_calc_ppO2(stateUsed->lifeData.pressure_ambient_bar, &stateUsed->lifeData.actualGas); @@ -498,7 +498,7 @@ lifeData->actualGas.helium_percentage = pSettings->gas[gasId].helium_percentage; lifeData->actualGas.setPoint_cbar = setpoint_cbar; lifeData->actualGas.change_during_ascent_depth_meter_otherwise_zero = 0; - lifeData->actualGas.AppliedDiveMode = pSettings->dive_mode; + lifeData->actualGas.AppliedDiveMode = stateUsed->diveSettings.diveMode; lifeData->actualGas.pscr_factor = 1.0 / pSettings->pscr_lung_ratio * pSettings->pscr_o2_drop; if(isLoopMode(pSettings->dive_mode) && (gasId > NUM_OFFSET_DILUENT)) lifeData->lastDiluent_GasIdInSettings = gasId; diff -r 7fa5ef6ae419 -r 8775d3dc6325 Discovery/Src/tMenuEditGasOC.c --- a/Discovery/Src/tMenuEditGasOC.c Mon Apr 25 21:10:10 2022 +0200 +++ b/Discovery/Src/tMenuEditGasOC.c Mon Apr 25 21:15:01 2022 +0200 @@ -167,9 +167,12 @@ /* select gas in divemode */ void openEdit_DiveGasSelect(uint8_t line, uint8_t ccr) { - openEdit_DiveGasSelect_Subroutine(line, ccr); - if(!ccr) - tMEGas_check_switch_to_bailout(); + if(!ccr) + { + tMEGas_check_switch_to_bailout(); + } + openEdit_DiveGasSelect_Subroutine(line, ccr); + exitMenuEdit_to_Home_with_Menu_Update(); }