diff Discovery/Src/settings.c @ 796:75ace7af8212

Expanded Sensor map structure: In the previous version the number of possible sensors were set to 5 based on the assumption that ADC slots are shared with digital O2 sensors. As result three of five slots would have been limited to O2 measurement usecase, leaving just two slots left for other sensors (e.g. CO2). In order to have as much flexibility (and less risk for data structure changes) the number of sensors has been set to 7 (3 ADC + 4 UART MUX)
author Ideenmodellierer
date Mon, 31 Jul 2023 20:00:06 +0200
parents 25103f5c7e29
children ff66b41d6fe4
line wrap: on
line diff
--- a/Discovery/Src/settings.c	Mon Jul 31 19:50:36 2023 +0200
+++ b/Discovery/Src/settings.c	Mon Jul 31 20:00:06 2023 +0200
@@ -88,7 +88,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF0026,
+    .header = 0xFFFF0027,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = SAMPLESTART,
@@ -331,6 +331,9 @@
 	.ext_sensor_map[2] = SENSOR_OPTIC,
 	.ext_sensor_map[3] = SENSOR_NONE,
 	.ext_sensor_map[4] = SENSOR_NONE,
+	.ext_sensor_map[5] = SENSOR_NONE,
+	.ext_sensor_map[6] = SENSOR_NONE,
+	.ext_sensor_map[7] = SENSOR_NONE,
 	.buttonLockActive = 0,
     .compassDeclinationDeg = 0,
     .delaySetpointLow = false,
@@ -541,8 +544,17 @@
         // Disable auto setpoint to avoid a configuration warning being triggered by the new auto setpoint validation
         // This ensures that users don't lose setpoint information if it is not in the right spot for the new configuration
         pSettings->autoSetpoint = false;
-
     	// no break;
+    case 0xFFFF0026:
+    	pSettings->ext_sensor_map[0] = pSettings->ext_sensor_map_Obsolete[0];
+    	pSettings->ext_sensor_map[1] = pSettings->ext_sensor_map_Obsolete[1];
+    	pSettings->ext_sensor_map[2] = pSettings->ext_sensor_map_Obsolete[2];
+    	pSettings->ext_sensor_map[3] = pSettings->ext_sensor_map_Obsolete[3];
+    	pSettings->ext_sensor_map[4] = pSettings->ext_sensor_map_Obsolete[4];
+    	pSettings->ext_sensor_map[5] = SENSOR_NONE;
+    	pSettings->ext_sensor_map[6] = SENSOR_NONE;
+    	pSettings->ext_sensor_map[7] = SENSOR_NONE;
+    	
     default:
         pSettings->header = pStandard->header;
         break; // no break before!!
@@ -1577,13 +1589,19 @@
     		|| (Settings.ext_sensor_map[1] >= SENSOR_END)
 			|| (Settings.ext_sensor_map[2] >= SENSOR_END)
 			|| (Settings.ext_sensor_map[3] >= SENSOR_END)
-			|| (Settings.ext_sensor_map[4] >= SENSOR_END))
+			|| (Settings.ext_sensor_map[4] >= SENSOR_END)
+			|| (Settings.ext_sensor_map[5] >= SENSOR_END)
+			|| (Settings.ext_sensor_map[6] >= SENSOR_END)
+			|| (Settings.ext_sensor_map[7] >= SENSOR_END))
     {
     	Settings.ext_sensor_map[0] = SENSOR_OPTIC;
     	Settings.ext_sensor_map[1] = SENSOR_OPTIC;
     	Settings.ext_sensor_map[2] = SENSOR_OPTIC;
     	Settings.ext_sensor_map[3] = SENSOR_NONE;
     	Settings.ext_sensor_map[4] = SENSOR_NONE;
+    	Settings.ext_sensor_map[5] = SENSOR_NONE;
+    	Settings.ext_sensor_map[6] = SENSOR_NONE;
+    	Settings.ext_sensor_map[7] = SENSOR_NONE;
        	corrections++;
     }