diff Discovery/Src/tCCR.c @ 655:980b4aa60a0e

Added count down timer for scrubber time: The countdown is performed in case CCR mode and scrubber timer are active
author Ideenmodellierer
date Sun, 25 Apr 2021 20:42:56 +0200
parents 66c8a4ff9fc4
children 1b995079c045
line wrap: on
line diff
--- a/Discovery/Src/tCCR.c	Sun Apr 25 20:41:19 2021 +0200
+++ b/Discovery/Src/tCCR.c	Sun Apr 25 20:42:56 2021 +0200
@@ -75,6 +75,7 @@
 
 static uint8_t StartListeningToUART_HUD = 0;
 static uint16_t HUDTimeoutCount = 0;
+static uint16_t ScrubberTimeoutCount = 0;
 
 static __IO ITStatus UartReadyHUD = RESET;
 static uint32_t LastReceivedTick_HUD = 0;
@@ -312,7 +313,9 @@
     */
 void tCCR_tick(void)
 {
-	if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
+	SSettings* pSettings = settingsGetPointer();
+
+	if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
 	{
 		if(HUDTimeoutCount < 3 * 10)
 			HUDTimeoutCount++;
@@ -325,6 +328,20 @@
 				tCCR_fallbackToFixedSetpoint();
 		}
 	}
+
+	/* decrease scrubber timer only in real dive mode */
+    if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (pSettings->dive_mode == DIVEMODE_CCR) && (stateUsed->mode == MODE_DIVE) && (stateUsed == stateRealGetPointer()))
+    {
+    	ScrubberTimeoutCount++;
+    	if(ScrubberTimeoutCount >= 600)		/* resolution is minutes */
+    	{
+    		ScrubberTimeoutCount = 0;
+    		if(pSettings->scrubTimerCur > 0)
+    		{
+    			pSettings->scrubTimerCur--;
+    		}
+    	}
+    }
 }
 
 void tCCR_SetRXIndication(void)