 
 	switch (currentScreen) {
 		case GAUGE_SCREEN: {
+
+			view.drawDiveDuration(now()-diveStartTimestamp);
+
 			//Instead of dive information we will display the current time
 			view.drawCurrentTime(settings.getCurrentTimeText());
-
-			diveDurationInSeconds++;
-			view.drawDiveDuration(diveDurationInSeconds);
 		}
 		break;
 		case DIVE_SCREEN: {
-			//Progress with the dive, if we are deeper than 1.2 meter
 			if (pressureInMillibar > (seaLevelPressureSetting + 120) || diveDurationInSeconds > 60) {
-				diveDurationInSeconds++;
+
+				//Progress with the dive, if we are deeper than 1.2 meter
+				unsigned int intervalDuration = now()-diveStartTimestamp-diveDurationInSeconds;
+				calculateSafetyStop(maxDepthInMeter, depthInMeter, intervalDuration);
+
+				diveDurationInSeconds = diveDurationInSeconds + intervalDuration;
 				view.drawDiveDuration(diveDurationInSeconds);
 
-				//The timer fires in every second
-				calculateSafetyStop(maxDepthInMeter, depthInMeter, 1);
-
-				//Progress with the algorithm in every second
+				//Progress with the algorithm
 				diveProgress(temperatureInCelsius, pressureInMillibar, depthInMeter, diveDurationInSeconds);
+			} else {
+				//No dive progress - reset the dive timestamp
+				diveStartTimestamp = now();
 			}
 		}
 		break;


	tft.InitLCD();

    // Set the function, which will be called in every second, if the timer is enabled
	diveDurationTimer.setTimer(1000, diveUnderWater, diveDurationTimer.RUN_FOREVER);
	diveDurationTimer.disable(diveDurationTimer.RUN_FOREVER);

	displayScreen(MENU_SCREEN);


byte safetyStopState = SAFETY_STOP_NOT_STARTED;

unsigned long diveStartTimestamp;
unsigned long diveDurationInSeconds;
unsigned long safetyStopDurationInSeconds;
unsigned long testPreviousDiveDurationInSeconds;

SimpleTimer diveDurationTimer;
float previousDepthInMeter;

MAX17043 batteryMonitor;
float batterySoc = 255;
