diff Discovery/Src/t3.c @ 602:2cb0a97a07ad

Added replay data scaling in case life data is longer than replay block Minor: variable name changes
author Ideenmodellierer
date Tue, 05 Jan 2021 20:35:01 +0100
parents 7ef2d310287d
children c56ed16dbd39
line wrap: on
line diff
--- a/Discovery/Src/t3.c	Mon Jan 04 22:49:07 2021 +0100
+++ b/Discovery/Src/t3.c	Tue Jan 05 20:35:01 2021 +0100
@@ -183,13 +183,13 @@
 void t3_miniLiveLogProfile(void)
 {
     SWindowGimpStyle wintemp;
-    uint16_t datalength = 0;
+    uint16_t replayDataLength = 0;
+    uint16_t liveDataLength = 0;
+    uint16_t drawDataLength = 0;
     uint16_t* pReplayData;
     uint16_t max_depth = 10;
     char text[TEXTSIZE];
     point_t start, stop;
-    uint8_t	doNotDrawLifeData = 0;
-
     uint16_t diveMinutes = 0;
 
     wintemp.left = t3c1.WindowX0;
@@ -206,32 +206,30 @@
 
    	if(getReplayOffset() != 0xFFFF)
    	{
-		getReplayInfo(&pReplayData, &datalength, &max_depth, &diveMinutes);
+		getReplayInfo(&pReplayData, &replayDataLength, &max_depth, &diveMinutes);
    	}
 
    	if(max_depth < (uint16_t)(stateUsed->lifeData.max_depth_meter * 100))
 	{
 		max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 100);
 	}
-	if(datalength != 0)
-	{
-		GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, datalength, CLUT_Font031, NULL);
-	}
-	else
+
+   	liveDataLength = getMiniLiveReplayLength();
+
+   	if(replayDataLength > liveDataLength)
+   	{
+   		drawDataLength = replayDataLength;
+   	}
+   	else
+   	{
+   		drawDataLength = liveDataLength;
+   	}
+
+	if(drawDataLength < CV_PROFILE_WIDTH)
 	{
-		datalength = getMiniLiveReplayLength();
-		if(datalength < CV_PROFILE_WIDTH)
-		{
-			if(datalength < 3)			/* wait for some data entries to start graph */
-			{
-				doNotDrawLifeData = 1;
-			}
-			datalength = CV_PROFILE_WIDTH;
-		}
-		diveMinutes = 0;	/* do not show divetime because it is already shown in the upper field */
+		drawDataLength = CV_PROFILE_WIDTH;
 	}
 
-
 	if(diveMinutes != 0)
 	{
 		snprintf(text,TEXTSIZE,"\002%dmin",diveMinutes);
@@ -241,9 +239,14 @@
     snprintf(text,TEXTSIZE,"\002%01.1fm", max_depth / 100.0);
     GFX_write_string(&FontT42,&t3c1,text,0);
 
-    if(!doNotDrawLifeData)
+	if(replayDataLength != 0)
+	{
+		GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, drawDataLength, CLUT_Font031, NULL);
+	}
+
+    if(liveDataLength > 3)
     {
-    	GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, getMiniLiveReplayPointerToData(), datalength, CLUT_Font030, NULL);
+    	GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, getMiniLiveReplayPointerToData(), drawDataLength, CLUT_Font030, NULL);
     }
 }