changeset 748:be25ab2d902c

Added display of co2 ppm values: Updated output functions for CO2 visualization and added the CO2 measurement to the lower left corner selection field. The sensor provides the value as factor 10 of ppm that's why the data type had to be changed to 32bit if ppm should be available without scaling every time. Cleanup sensor dialog: The HUD battery was displayed by default and some sensor combinations were not displayed correctly. The refresh function was updated to fix these issues.
author Ideenmodellierer
date Sun, 05 Mar 2023 22:14:53 +0100
parents df0d43da1614
children 9334bdc30d60
files Common/Inc/data_central.h Discovery/Src/simulation.c Discovery/Src/t7.c Discovery/Src/tMenuEditHardware.c Discovery/Src/tMenuEditXtra.c
diffstat 5 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/data_central.h	Sun Mar 05 22:06:47 2023 +0100
+++ b/Common/Inc/data_central.h	Sun Mar 05 22:14:53 2023 +0100
@@ -83,7 +83,7 @@
 
 typedef struct
 {
-		uint16_t CO2_ppm;
+		uint32_t CO2_ppm;
 		uint16_t signalStrength;
 } 	SCO2Sensor;
 
--- a/Discovery/Src/simulation.c	Sun Mar 05 22:06:47 2023 +0100
+++ b/Discovery/Src/simulation.c	Sun Mar 05 22:14:53 2023 +0100
@@ -203,6 +203,7 @@
     pDiveState->lifeData.ppO2Sensor_bar[1]  = pDiveState->lifeData.sensorVoltage_mV[1] * localCalibCoeff[1] * pDiveState->lifeData.pressure_ambient_bar;
     pDiveState->lifeData.ppO2Sensor_bar[2]  = pDiveState->lifeData.sensorVoltage_mV[2] * localCalibCoeff[2] * pDiveState->lifeData.pressure_ambient_bar;
 
+    pDiveState->lifeData.CO2_data.CO2_ppm  = stateRealGetPointer()->lifeData.CO2_data.CO2_ppm;
 
     if(is_ambient_pressure_close_to_surface(&pDiveState->lifeData)) // new hw 170214
     {
--- a/Discovery/Src/t7.c	Sun Mar 05 22:06:47 2023 +0100
+++ b/Discovery/Src/t7.c	Sun Mar 05 22:14:53 2023 +0100
@@ -3022,7 +3022,18 @@
 
     t7_colorscheme_mod(text);
 #ifndef ENABLE_BOTTLE_SENSOR
-   	GFX_write_string(&FontT105,&t7l3,text,line);
+#ifdef ENABLE_CO2_SUPPORT
+    if(selection_custom_field != LCC_CO2)
+    {
+    	GFX_write_string(&FontT105,&t7l3,text,line);
+    }
+    else
+    {
+        	GFX_write_string(&FontT48,&t7l3,text,line);
+    }
+#else
+    GFX_write_string(&FontT105,&t7l3,text,line);
+#endif
 #else
     if(selection_custom_field != LCC_BottleBar)			/* a changing color set is used for bar display */
     {
--- a/Discovery/Src/tMenuEditHardware.c	Sun Mar 05 22:06:47 2023 +0100
+++ b/Discovery/Src/tMenuEditHardware.c	Sun Mar 05 22:14:53 2023 +0100
@@ -41,6 +41,7 @@
 #include "tComm.h"
 #include "data_exchange_main.h"
 
+
 extern void tM_build_pages(void);
 
 /* Private function prototypes -----------------------------------------------*/
@@ -371,7 +372,9 @@
 
 			switch(pSettings->ext_sensor_map[index])
 			{
-				case SENSOR_SEARCH: strSensorId[4] = TXT2BYTE_SensorDetect;
+				case SENSOR_SEARCH: strSensorId[1] = TXT2BYTE_SensorDetect;
+									strSensorId[2] = 0;
+									strSensorId[4] = 0;
 								break;
 				case SENSOR_OPTIC:	strSensorId[4] = TXT2BYTE_O2IFOptic;
 								break;
@@ -386,6 +389,7 @@
 				 	 	 	 	 	  strSensorId[4] = 'e';
 				 	 	 	 	break;
 				default:
+									  strSensorId[5] = 0;
 					break;
 			}
 			if(strSensorId[4] != 'X')
@@ -399,7 +403,7 @@
 			}
 			else if(pSettings->ext_sensor_map[index] == SENSOR_CO2)
 			{
-				snprintf(strSensorValue, 10,"%d ppm",  pStateReal->lifeData.CO2_data.CO2_ppm);
+				snprintf(strSensorValue, 20,"%ld ppm",  pStateReal->lifeData.CO2_data.CO2_ppm);
 			}
 			y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP);
 			if(strSensorValue[0] != 0)
@@ -408,7 +412,7 @@
 			}
 		}
 
-		if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
+		if(pSettings->ext_sensor_map[0] == SENSOR_OPTIC)
 		{
 			strSensorId[0] = TXT_2BYTE;
 			strSensorId[1] = TXT2BYTE_HUDbattery;
--- a/Discovery/Src/tMenuEditXtra.c	Sun Mar 05 22:06:47 2023 +0100
+++ b/Discovery/Src/tMenuEditXtra.c	Sun Mar 05 22:14:53 2023 +0100
@@ -376,7 +376,7 @@
     snprintf(text,32,"\001%c",TXT_CO2Sensor);
     write_topline(text);
 
-    snprintf(text,32,"CO2: %d ppm",stateUsed->lifeData.CO2_data.CO2_ppm);
+    snprintf(text,32,"CO2: %ld ppm",stateUsed->lifeData.CO2_data.CO2_ppm);
     write_label_var(   30, 800, ME_Y_LINE1, &FontT48, text);
 
     snprintf(text,32,"Signal: %d",stateUsed->lifeData.CO2_data.signalStrength);