diff Discovery/Src/logbook_miniLive.c @ 603:c56ed16dbd39

T3 profile view: Added visualization of deco data
author Ideenmodellierer
date Wed, 06 Jan 2021 19:41:43 +0100
parents 2cb0a97a07ad
children ae7f8333c900
line wrap: on
line diff
--- a/Discovery/Src/logbook_miniLive.c	Tue Jan 05 20:35:01 2021 +0100
+++ b/Discovery/Src/logbook_miniLive.c	Wed Jan 06 19:41:43 2021 +0100
@@ -24,6 +24,7 @@
 #include "logbook_miniLive.h"
 #include "data_exchange.h"
 #include "logbook.h"
+#include "tHome.h"
 
  /*
   ******************************************************************************
@@ -44,6 +45,7 @@
 #define DEPTH_DATA_LENGTH	(1800u)				/* Resolution: 1 hours dive, sampling every 2 seconds */
 uint16_t ReplayDepthData[DEPTH_DATA_LENGTH];
 uint16_t liveDepthData[DEPTH_DATA_LENGTH];
+uint16_t liveDecoData[DEPTH_DATA_LENGTH];
 static uint16_t lifeDataIndex = 0;
 
 static uint8_t	ReplayDataResolution = 2;		/* Time represented by one sample (second) */
@@ -86,6 +88,10 @@
 	static uint8_t secondsCount = 0;
 	static uint8_t lifesecondsCount = 0;
 
+	const SDecoinfo* pDecoinfo;
+	uint8_t stopDepth = 0;
+	uint16_t stopTime = 0;
+
 	if(checkOncePerSecond)
 	{
 		uint32_t now =  current_second();
@@ -110,6 +116,7 @@
 			for(lifeDataIndex = 0; lifeDataIndex < DEPTH_DATA_LENGTH; lifeDataIndex++)
 			{
 				liveDepthData[lifeDataIndex] = 0xFFFF;
+				liveDecoData[lifeDataIndex] = 0xFFFF;
 			}
 			lifesecondsCount = 0;
 			lifeDataIndex = 0;
@@ -146,7 +153,25 @@
 				compressBuffer_uint16(ReplayDepthData,DEPTH_DATA_LENGTH);		/* also compress Replay data to siplify mapping between live and replay data */
 				lifeDataIndex = DEPTH_DATA_LENGTH / 2;
 			}
-			liveDepthData[lifeDataIndex++] = (int)(stateUsed->lifeData.depth_meter * 100);
+			liveDepthData[lifeDataIndex] = (int)(stateUsed->lifeData.depth_meter * 100);
+			if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE)
+			{
+				pDecoinfo = &stateUsed->decolistVPM;
+			}
+			else
+			{
+				pDecoinfo = &stateUsed->decolistBuehlmann;
+			}
+			tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &stopDepth, &stopTime);
+			if(stopDepth)
+			{
+				liveDecoData[lifeDataIndex] = stopDepth * 100;
+			}
+			else
+			{
+				liveDecoData[lifeDataIndex] = 0xFFFF;
+			}
+			lifeDataIndex++;
 		}
 	}
 	else if(bDiveMode == 3)
@@ -221,6 +246,10 @@
 {
 	return liveDepthData;
 }
+uint16_t *getMiniLiveDecoPointerToData(void)
+{
+	return liveDecoData;
+}
 uint16_t getMiniLiveReplayLength(void)
 {
 	return lifeDataIndex;