diff Discovery/Src/logbook_miniLive.c @ 610:ae7f8333c900

Added access to logbook marker data: In previous version event data could only be stored in memory but read back and usage in the OSTC itself was not supported. After the events like a marker set by the diver may be retrieved from the log. Added visualization of markers to T3_Profile view
author Ideenmodellierer
date Thu, 14 Jan 2021 20:38:28 +0100
parents c56ed16dbd39
children bf574fb3efa0
line wrap: on
line diff
--- a/Discovery/Src/logbook_miniLive.c	Thu Jan 14 19:17:28 2021 +0100
+++ b/Discovery/Src/logbook_miniLive.c	Thu Jan 14 20:38:28 2021 +0100
@@ -44,6 +44,7 @@
 /* Replay Block data storage */
 #define DEPTH_DATA_LENGTH	(1800u)				/* Resolution: 1 hours dive, sampling every 2 seconds */
 uint16_t ReplayDepthData[DEPTH_DATA_LENGTH];
+uint8_t ReplayMarkerData[DEPTH_DATA_LENGTH];
 uint16_t liveDepthData[DEPTH_DATA_LENGTH];
 uint16_t liveDecoData[DEPTH_DATA_LENGTH];
 static uint16_t lifeDataIndex = 0;
@@ -69,6 +70,7 @@
 {
 	uint16_t* pTarget = pdata;
 	uint16_t* pSource = pdata;
+	uint16_t  result = 0;
 	
 	uint16_t index = 0;
 	
@@ -76,7 +78,15 @@
 	{
 		*pTarget = *pSource++;
 		*pTarget += *pSource++;
-		*pTarget++ /= 2;
+		result = *pTarget /= 2;
+		if((*pTarget != 0) && (result == 0))	/* avoid termination of information by round up to 1 */
+		{
+			*pTarget++ = 1;
+		}
+		else
+		{
+			*pTarget++ = result;
+		}
 	}
 	memset(pTarget,0,size/2);
 }
@@ -186,7 +196,9 @@
 uint8_t prepareReplayLog(uint8_t StepBackwards)
 {
 	uint8_t retVal = 0;
+	uint16_t index = 0;
 	uint16_t dataLength = 0;
+	uint8_t markerDetected = 0;
 
     SLogbookHeader logbookHeader;
 
@@ -205,7 +217,21 @@
     	ReplayDataOffset = StepBackwards;
 		logbook_getHeader(StepBackwards ,&logbookHeader);
 
-		dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+		dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ReplayMarkerData);
+
+	/* check if a marker is provided. If not disable marker functionality for the replay block */
+		for(index = 0; index < dataLength; index++)
+		{
+			if(ReplayMarkerData[index] != 0)
+			{
+				markerDetected = 1;
+				break;
+			}
+		}
+		if(markerDetected == 0)
+		{
+			ReplayMarkerData[0] = 0xFF;
+		}
 
 		if( dataLength == DEPTH_DATA_LENGTH)		/* log data has been compressed to fit into buffer */
 		{
@@ -226,13 +252,14 @@
 	return retVal;
 }
 
-uint8_t getReplayInfo(uint16_t** pReplayData, uint16_t* DataLength, uint16_t* MaxDepth, uint16_t* diveMinutes)
+uint8_t getReplayInfo(uint16_t** pReplayData, uint8_t** pReplayMarker, uint16_t* DataLength, uint16_t* MaxDepth, uint16_t* diveMinutes)
 {
 	uint8_t retVal = 0;
 
-	if((ReplayDataOffset != 0xFFFF) && (pReplayData != NULL) && (DataLength != NULL) && (MaxDepth != NULL))
+	if((ReplayDataOffset != 0xFFFF) && (pReplayData != NULL) && (DataLength != NULL) && (MaxDepth != NULL) && (pReplayMarker != 0))
 	{
 		*pReplayData = ReplayDepthData;
+		*pReplayMarker = ReplayMarkerData;
 		*DataLength = ReplayDataLength;
 		*MaxDepth = ReplayDataMaxDepth;
 		*diveMinutes = ReplayDataMinutes;