diff Discovery/Src/tMenuEditSetpoint.c @ 773:2c243233c999

Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
author heinrichsweikamp
date Wed, 10 May 2023 16:24:57 +0200
parents 1b995079c045
children 46c6d2380d4e
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditSetpoint.c	Sat Apr 22 21:11:50 2023 -0500
+++ b/Discovery/Src/tMenuEditSetpoint.c	Wed May 10 16:24:57 2023 +0200
@@ -27,6 +27,8 @@
 //////////////////////////////////////////////////////////////////////////////
 
 /* Includes ------------------------------------------------------------------*/
+#include <stdbool.h>
+
 #include "tMenuEditSetpoint.h"
 
 #include "check_warning.h"
@@ -55,6 +57,16 @@
 
 /* Exported functions --------------------------------------------------------*/
 
+void checkSwitchToLoop(void)
+{
+    if(!isLoopMode(stateUsedWrite->diveSettings.diveMode)) {
+        stateUsedWrite->diveSettings.diveMode = settingsGetPointer()->dive_mode;
+
+        unblock_diluent_page();
+    }
+}
+
+
 void openEdit_Setpoint(uint8_t line)
 {
     uint8_t useSensorSubMenu = 0;
@@ -121,11 +133,7 @@
 
         setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar);
 
-        if(!isLoopMode(stateUsedWrite->diveSettings.diveMode))
-        {
-        	stateUsedWrite->diveSettings.diveMode = settingsGetPointer()->dive_mode;
-            unblock_diluent_page();
-        }
+        checkSwitchToLoop();
 
         clear_warning_fallback();
 
@@ -329,7 +337,7 @@
     return EXIT_TO_MENU;
 }
 
-void openEdit_DiveSelectBetterSetpoint(void)
+void openEdit_DiveSelectBetterSetpoint(bool useLastDiluent)
 {
     uint8_t spId;
     uint8_t depth;
@@ -351,11 +359,19 @@
 		// new setpoint
 		stateUsedWrite->diveSettings.setpoint[spId].note.ub.first = 1;
 
+        uint8_t gasId;
+        if (useLastDiluent) {
+            gasId = stateUsed->lifeData.lastDiluent_GasIdInSettings;
+        } else {
+            gasId = stateUsed->lifeData.actualGas.GasIdInSettings;
+        }
+
 		// change in lifeData
-		setActualGas_DM(&stateUsedWrite->lifeData, stateUsedWrite->lifeData.actualGas.GasIdInSettings, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar);
+		setActualGas_DM(&stateUsedWrite->lifeData, gasId, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar);
     }
 }
 
+
 static uint8_t OnAction_SP_DM_Sensor1	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1)