diff Discovery/Src/logbook.c @ 662:1b995079c045 Betatest

PSCR Mode
author heinrichs weikamp
date Tue, 14 Dec 2021 15:36:10 +0100
parents 4eba86129d35
children b456be1e152d
line wrap: on
line diff
--- a/Discovery/Src/logbook.c	Mon Nov 01 12:39:34 2021 +0100
+++ b/Discovery/Src/logbook.c	Tue Dec 14 15:36:10 2021 +0100
@@ -1002,7 +1002,7 @@
             break;
     }
     firstgasid = i + 1;
-    if(header.diveMode == DIVEMODE_CCR)
+    if(isLoopMode(header.diveMode))
       setPointLast = header.setpoint[0].setpoint_cbar;
     else
       setPointLast = 0;
@@ -1166,6 +1166,10 @@
 						gas.setPoint_cbar = setPointVal;
 						if(gasidVal > 0)
 						{
+							if((gasidVal >= NUM_GASES) && (header.diveMode == DIVEMODE_PSCR))		/* in case gas switches the absolute gas ID is used => map to the 0..NUM_GASES index used in header */
+							{
+								gasidVal -= NUM_GASES;
+							}
 							gas.helium_percentage = header.gasordil[gasidVal - 1].helium_percentage;
 							gas.nitrogen_percentage = 100 -  gas.helium_percentage - header.gasordil[gasidVal - 1].oxygen_percentage;
 						}
@@ -1175,7 +1179,15 @@
 							gas.nitrogen_percentage = 100 -  gas.helium_percentage - manualGasVal.percentageO2;
 						}
 						ambiant_pressure_bar =((float)(depthVal + header.surfacePressure_mbar))/1000;
-						ppO2 = decom_calc_ppO2(ambiant_pressure_bar, &gas );
+
+						if(header.diveMode == DIVEMODE_PSCR)
+						{
+							ppO2 = decom_calc_SimppO2(ambiant_pressure_bar, &gas);
+						}
+						else	/* open circuit calculation */
+						{
+							ppO2 = decom_calc_ppO2(ambiant_pressure_bar, &gas);
+						}
 						ppo2[iNum] = (uint16_t) ( ppO2 * 100);
 					}