diff Discovery/Src/tInfoLog.c @ 452:b90ddf57f7f1 minor_improvments

Added compile variant enabling the reset of profile sample information: In case the sample ring has an overrun prior to the header ring then header will point to no longer available sample locations causing problems when the no longer existing samples are read. To avoid this also in earlier versions a variant has been added which enables the user to reset the invalid sample information by selecting the problematic dive in the infolog menu and pressing the middle button. Added function which confirms consistency of dive log settings: Meaning last dive and dive header are valid at startup. Repair and find lastDiveID are only called in case a inconsistency is detected
author ideenmodellierer
date Tue, 24 Mar 2020 21:59:11 +0100
parents f11f0bf6ef2d
children 4bd01f48c285
line wrap: on
line diff
--- a/Discovery/Src/tInfoLog.c	Tue Mar 24 21:49:52 2020 +0100
+++ b/Discovery/Src/tInfoLog.c	Tue Mar 24 21:59:11 2020 +0100
@@ -36,6 +36,8 @@
 #include "tInfo.h"
 #include "tMenu.h"
 #include "unit.h"
+#include "externLogbookFlash.h"
+#include "configuration.h"
 
 /* Exported variables --------------------------------------------------------*/
 
@@ -64,6 +66,7 @@
 void stepBackInfo(void);
 void stepForwardInfo(void);
 void showLogExit(void);
+void resetDiveProfile(void);
 
 /* Exported functions --------------------------------------------------------*/
 void tInfoLog_init(void)
@@ -176,6 +179,9 @@
     switch(sendAction)
     {
     case ACTION_BUTTON_ENTER:
+#ifdef ENABLE_PROFILE_RESET
+    	resetDiveProfile();
+#endif
         break;
     case ACTION_BUTTON_NEXT:
         showNextLogPage();
@@ -429,4 +435,21 @@
     show_logbook_test(0, stepBack);
 }
 
+#ifdef ENABLE_PROFILE_RESET
+void resetDiveProfile()
+{
+	uint8_t stepBack;
+	SLogbookHeader logbookHeader;
+	convert_Type dataStart;
+	stepBack = (6 * (infolog.page - 1)) + infolog.line - 1; /* calculate current dive ID */
+	logbook_getHeader(stepBack ,&logbookHeader);
 
+    dataStart.u8bit.byteHigh = 0;
+    dataStart.u8bit.byteLow = logbookHeader.pBeginProfileData[0];
+    dataStart.u8bit.byteMidLow = logbookHeader.pBeginProfileData[1];
+    dataStart.u8bit.byteMidHigh = logbookHeader.pBeginProfileData[2];
+
+    dataStart.u32bit &= 0xFFFF0000;		/* set to sector start */
+	ext_flash_invalidate_sample_index(dataStart.u32bit);
+}
+#endif