diff Discovery/Src/tInfoLog.c @ 461:b3f684cea9c0

Merged in Ideenmodellierer/ostc4/minor_improvments (pull request #41) Minor improvments
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Mon, 30 Mar 2020 13:16:11 +0000
parents 4bd01f48c285
children 04d94851cd1b
line wrap: on
line diff
--- a/Discovery/Src/tInfoLog.c	Sun Mar 01 10:06:45 2020 +0100
+++ b/Discovery/Src/tInfoLog.c	Mon Mar 30 13:16:11 2020 +0000
@@ -36,6 +36,8 @@
 #include "tInfo.h"
 #include "tMenu.h"
 #include "unit.h"
+#include "externLogbookFlash.h"
+#include "configuration.h"
 
 /* Exported variables --------------------------------------------------------*/
 
@@ -64,6 +66,9 @@
 void stepBackInfo(void);
 void stepForwardInfo(void);
 void showLogExit(void);
+#ifdef ENABLE_PROFILE_RESET
+void resetDiveProfile(void);
+#endif
 
 /* Exported functions --------------------------------------------------------*/
 void tInfoLog_init(void)
@@ -176,6 +181,9 @@
     switch(sendAction)
     {
     case ACTION_BUTTON_ENTER:
+#ifdef ENABLE_PROFILE_RESET
+    	resetDiveProfile();
+#endif
         break;
     case ACTION_BUTTON_NEXT:
         showNextLogPage();
@@ -429,4 +437,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