diff Discovery/Src/settings.c @ 387:0dbb74be972f

Merged in Ideenmodellierer/ostc4/MotionDetection (pull request #34) MotionDetection
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Sun, 24 Nov 2019 15:46:58 +0000
parents 14fd5f35cb50
children ebc2b571a0b9
line wrap: on
line diff
--- a/Discovery/Src/settings.c	Sun Nov 24 16:08:29 2019 +0100
+++ b/Discovery/Src/settings.c	Sun Nov 24 15:46:58 2019 +0000
@@ -32,6 +32,7 @@
 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP
 #include "text_multilanguage.h" // for LANGUAGE_END
 #include "tHome.h" // for CVIEW_END
+#include "Motion.h"
 
 SSettings Settings;
 
@@ -82,7 +83,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF0019,
+    .header = 0xFFFF001A,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = 0,
@@ -307,6 +308,7 @@
     .FactoryButtonBalance[2] = 3,
 	.FlipDisplay = 0,
 	.cv_configuration = 0xFFFFFFFF,
+	.MotionDetection = MOTION_DETECT_OFF,
 };
 
 /* Private function prototypes -----------------------------------------------*/
@@ -353,6 +355,7 @@
 
     pSettings->scooterControl = 0;
 
+    /* Pointing to the old header data => set new data depending on what had been added since last version */
     switch(pSettings->header)
     {
     case 0xFFFF0000:
@@ -450,6 +453,9 @@
     case 0xFFFF0018:
     	pSettings->cv_configuration = 0xFFFFFFFF;
     	// no break
+    case 0xFFFF0019:
+    	pSettings->MotionDetection = MOTION_DETECT_OFF;
+    	// no break
     default:
         pSettings->header = pStandard->header;
         break; // no break before!!
@@ -1347,6 +1353,11 @@
     	Settings.FlipDisplay = 0;
 	    corrections++;
    	}
+    if(Settings.MotionDetection >= MOTION_DETECT_END)
+   	{
+    	Settings.MotionDetection = MOTION_DETECT_OFF;
+	    corrections++;
+   	}
 
     if(corrections > 255)
         return 255;
@@ -1399,7 +1410,7 @@
     return ((firmware_FirmwareData.versionSecond & 0x03)  << 6)	+ ((firmware_FirmwareData.versionThird & 0x1F) << 1) + (firmware_FirmwareData.versionBeta & 0x01);
 }
 
-SSettings* settingsGetPointer(void)
+inline SSettings* settingsGetPointer(void)
 {
     return &Settings;
 }