changeset 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 d4083ac09b5d
children acf6614dc396
files Common/Inc/data_central.h Common/Inc/settings.h Discovery/Src/data_exchange_main.c Discovery/Src/settings.c
diffstat 4 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/data_central.h	Mon Jul 31 19:50:36 2023 +0200
+++ b/Common/Inc/data_central.h	Mon Jul 31 20:00:06 2023 +0200
@@ -41,8 +41,8 @@
 #define false  0
 #define true 1
 
-#define EXT_INTERFACE_SENSOR_CNT	(5u)		/* 5 sensors may be connected to the external interface */
-
+#define EXT_INTERFACE_SENSOR_CNT	(8u)		/* 1 MUX + 7 sensors may be connected to the external interface (1 MUX + 3 ADC + 4 UART) */
+#define EXT_INTERFACE_MUX_OFFSET	(3u)		/* the sensor struct starts with 3 ADC sensors */
 
 /* Helper structs ------------------------------------------------------------*/
 
@@ -433,6 +433,7 @@
 	 SENSOR_OPTIC,
 	 SENSOR_ANALOG,
 	 SENSOR_DIGO2,
+	 SENSOR_DIGO2M,
 	 SENSOR_SENTINEL,
 	 SENSOR_TYPE_O2_END,
 	 SENSOR_CO2,
--- a/Common/Inc/settings.h	Mon Jul 31 19:50:36 2023 +0200
+++ b/Common/Inc/settings.h	Mon Jul 31 20:00:06 2023 +0200
@@ -243,8 +243,8 @@
 
 	uint8_t scubberActiveId;									/* redefined in 0xFFFF0023 */
 	SScrubberData scrubberData[2];
-	uint8_t ext_sensor_map[5];
-	uint8_t buttonLockActive;										/* redefined in 0xFFFF0025 */
+	uint8_t ext_sensor_map_Obsolete[5];
+	uint8_t buttonLockActive;									/* redefined in 0xFFFF0025 */
 	int8_t compassDeclinationDeg;
     uint8_t delaySetpointLow;                                         /* redefined in 0xFFFF0026 */
 	uint8_t Future_SPARE[FUTURE_SPARE_SIZE];					/* redefined in 0xFFFF0020 (old scooter Block was 32 byte)*/
@@ -303,6 +303,7 @@
 	uint16_t scrubTimerMax_Obsolete;	/* have been replaced with new scrubber data format */
 	uint16_t scrubTimerCur_Obsolete;	/* have been replaced with new scrubber data format */
 	uint8_t scrubTimerMode;
+	uint8_t ext_sensor_map[8];		/* redefined in 0xFFFF0027 */
 } SSettings;
 
 typedef struct
--- a/Discovery/Src/data_exchange_main.c	Mon Jul 31 19:50:36 2023 +0200
+++ b/Discovery/Src/data_exchange_main.c	Mon Jul 31 20:00:06 2023 +0200
@@ -397,7 +397,7 @@
 	dataOut.data.offsetTemperatureSensor_centiDegree = settings->offsetTemperature_centigrad;
 
 
-	memcpy(dataOut.data.externalInterface_SensorMap, settings->ext_sensor_map, 5);
+	memcpy(dataOut.data.externalInterface_SensorMap, settings->ext_sensor_map, EXT_INTERFACE_SENSOR_CNT);
 
 	memset(SensorActive, 0, sizeof(SensorActive));
 	for (index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++)
@@ -406,7 +406,7 @@
 		{
 			case SENSOR_ANALOG:	SensorActive[SENSOR_ANALOG] = 1;
 				break;
-			case SENSOR_DIGO2:	SensorActive[SENSOR_DIGO2] = 1;
+			case SENSOR_DIGO2M:	SensorActive[SENSOR_DIGO2] = 1;
 				break;
 			case SENSOR_CO2:	SensorActive[SENSOR_CO2] = 1;
 				break;
@@ -977,7 +977,7 @@
 				}
 				else
 				{
-					if(dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map[idx] == SENSOR_DIGO2)
+					if(dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map[idx] == SENSOR_DIGO2M)
 					{
 						pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] / 100.0;
 					}
--- 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++;
     }