diff Discovery/Src/data_exchange_main.c @ 1014:8c0134a287da GasConsumption

Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes) is decremented. The event contains a 12 bit signed integer for the remaining scrubber duration, and two flags for scrubber warning (0x2000, <= 30 minutes remaining) and scrubber error (0x4000, <= 0 minutes remaining). (mikeller)
author heinrichsweikamp
date Sun, 11 May 2025 16:18:20 +0200
parents d9290c76b840
children
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Sat May 10 21:27:06 2025 +0200
+++ b/Discovery/Src/data_exchange_main.c	Sun May 11 16:18:20 2025 +0200
@@ -849,8 +849,7 @@
 	SDiveState *pStateReal = stateRealGetPointerWrite();
 	uint8_t idx;
 	float meter = 0;
-	SSettings *pSettings;
-	
+
 #ifdef ENABLE_EXTERNAL_PRESSURE
     float CO2Corr = 0.0;
 #endif
@@ -914,6 +913,7 @@
 		}
 	}
 
+	SSettings *pSettings = settingsGetPointer();
 	if((requestNecessary.uw != 0) && (dataIn.confirmRequest.uw != 0))
 	{
 		if(((dataIn.confirmRequest.uw) & CRBUTTON) != 0)
@@ -951,14 +951,12 @@
 
 		if(requestNecessary.ub.button == 1)	/* send button values to RTE */
 		{
-			setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness);
+			setButtonResponsiveness(pSettings->ButtonResponsiveness);
 		}
 	}
 
 	/*	uint8_t IAmStolenPleaseKillMe;
 	 */
-	pSettings = settingsGetPointer();
-
 	if(pSettings->IAmStolenPleaseKillMe > 3)
 	{
 		pSettings->salinity = 0;
@@ -1046,7 +1044,7 @@
             disableTimer();
 
 				// new 170508
-			settingsGetPointer()->bluetoothActive = 0;
+			pSettings->bluetoothActive = 0;
 			MX_Bluetooth_PowerOff();
 			//Init dive Mode
 			decoLock = DECO_CALC_init_as_is_start_of_dive;
@@ -1376,3 +1374,12 @@
 	return;
 }
 
+bool isScrubberTimerEnabled(const SSettings *settings)
+{
+	return settings->scrubberActiveId != 0x00 && isLoopMode(settings->dive_mode);
+}
+
+bool isScrubberTimerRunning(const SDiveState *diveState, const SSettings *settings)
+{
+	return isScrubberTimerEnabled(settings) && diveState->mode == MODE_DIVE && isLoopMode(diveState->diveSettings.diveMode);
+}