changeset 560:5d80bb8d22cb

Added O2 sensor source and calibration parameters to setting structure
author Ideenmodellierer
date Sun, 15 Nov 2020 19:53:09 +0100
parents 84a4e1200726
children e581425c7e3e
files Common/Inc/settings.h Discovery/Src/settings.c
diffstat 2 files changed, 33 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/settings.h	Sun Nov 15 19:52:03 2020 +0100
+++ b/Common/Inc/settings.h	Sun Nov 15 19:53:09 2020 +0100
@@ -68,8 +68,16 @@
 
 #define PRESSURE_OFFSET_LIMIT_MBAR	50
 
-#define MAX_COMPASS_COMP (2u)
-#define MAX_VIEWPORT_MODE (0x1F)
+#define MAX_COMPASS_COMP 		(2u)
+#define MAX_VIEWPORT_MODE 		(0x1F)
+
+typedef enum
+{
+	O2_SENSOR_SOURCE_OPTIC = 0,
+	O2_SENSOR_SOURCE_ANALOG,
+	O2_SENSOR_SOURCE_MAX
+} SensorSource;
+#define MAX_O2_SENSOR_SOURCE 	(2u)
 
 /*	2015 Jan 30, hw, deco and travel added for MenuEditGas
 	* can be used for buehlmann, vpm, etc. later but be carefull
@@ -173,7 +181,7 @@
 	uint32_t backup_localtime_rtc_tr;
 	uint32_t backup_localtime_rtc_dr;
 	uint16_t totalDiveCounter;
-	uint16_t	personalDiveCount;
+	uint16_t personalDiveCount;
 	uint8_t showDebugInfo;
 	uint8_t ButtonResponsiveness[4];// changed content in 0xFFFF0016
 	uint8_t nonMetricalSystem;
@@ -234,6 +242,9 @@
 	uint16_t viewRoll;
 	uint16_t viewPitch;
 	uint16_t viewYaw;
+	/* new in 0xFFFF001E */
+	uint8_t ppo2sensors_source;
+	float   ppo2sensors_calibCoeff[3];
 } SSettings;
 
 typedef struct
--- a/Discovery/Src/settings.c	Sun Nov 15 19:52:03 2020 +0100
+++ b/Discovery/Src/settings.c	Sun Nov 15 19:53:09 2020 +0100
@@ -85,7 +85,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF001D,
+    .header = 0xFFFF001E,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = 0,
@@ -318,6 +318,10 @@
 	.viewRoll = 0,
 	.viewPitch = 0,
 	.viewYaw = 0,
+	.ppo2sensors_source = 0,
+	.ppo2sensors_calibCoeff[0] = 0.0,
+	.ppo2sensors_calibCoeff[1] = 0.0,
+	.ppo2sensors_calibCoeff[2] = 0.0,
 };
 
 /* Private function prototypes -----------------------------------------------*/
@@ -482,6 +486,12 @@
     	pSettings->viewPitch = 0;
     	pSettings->viewYaw = 0;
     	// no break
+    case 0xFFFF001D:
+    	pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC;
+    	pSettings->ppo2sensors_calibCoeff[0] = 0.0;
+    	pSettings->ppo2sensors_calibCoeff[1] = 0.0;
+    	pSettings->ppo2sensors_calibCoeff[2] = 0.0;
+    	// no break
     default:
         pSettings->header = pStandard->header;
         break; // no break before!!
@@ -1414,6 +1424,14 @@
     	Settings.viewPortMode = 0;
     	corrections++;
     }
+    if(Settings.ppo2sensors_source >= O2_SENSOR_SOURCE_MAX)
+    {
+    	Settings.ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC;
+    	Settings.ppo2sensors_calibCoeff[0] = 0.0;
+    	Settings.ppo2sensors_calibCoeff[1] = 0.0;
+    	Settings.ppo2sensors_calibCoeff[2] = 0.0;
+        corrections++;
+    }
 
     if(corrections > 255)
         return 255;