diff Discovery/Src/tInfoSensor.c @ 783:c31237d20491

Update digital O2 sensor information: In the previous version only one digital O2 sensor was supported and the additional data could be accessed via a separate menu item. Because of the intraduction of the multiplexer there are three datasets available not. Because of the existing menu structure it was not possible to add additional menu items. To solve the problem the sensor information has been moved beghind the sensor On/Off functionality. When selecting a sensor the sensor data will be shown and the de-/activation of a sensor may be done in scope of the sensor information dialog.
author Ideenmodellierer
date Mon, 29 May 2023 20:26:38 +0200
parents e33d661d1743
children 19ab6f3ed52a
line wrap: on
line diff
--- a/Discovery/Src/tInfoSensor.c	Mon May 29 20:22:15 2023 +0200
+++ b/Discovery/Src/tInfoSensor.c	Mon May 29 20:26:38 2023 +0200
@@ -39,14 +39,49 @@
 #include <inttypes.h>
 
 extern void openEdit_O2Sensors(void);
+uint8_t OnAction_Sensor	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 
 /* Private variables ---------------------------------------------------------*/
-
+static uint8_t	activeSensorId = 0;
+static uint8_t sensorActive = 0;
 /* Exported functions --------------------------------------------------------*/
-void openInfo_Sensor(void)
+void openInfo_Sensor(uint8_t sensorId)
 {
+	SSettings *pSettings = settingsGetPointer();
+	activeSensorId = sensorId;
     set_globalState(StISENINFO);
-    setBackMenu((uint32_t)openEdit_O2Sensors,0,6);
+    switch (activeSensorId)
+    {
+    	case 3: setBackMenu((uint32_t)openEdit_O2Sensors,0,3);
+    		break;
+    	case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,2);
+    	    		break;
+    	default:
+    	case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,1);
+    	    		break;
+    }
+
+    sensorActive = 1;
+    if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
+    {
+    	sensorActive = 0;
+    }
+}
+
+
+uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+	if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
+	{
+		settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId - 1));
+		tMenuEdit_set_on_off(editId, 1);
+	}
+	else
+	{
+		settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId - 1));
+		tMenuEdit_set_on_off(editId, 0);
+	}
+    return UPDATE_DIVESETTINGS;
 }
 
 
@@ -73,16 +108,45 @@
 	strcpy(pbuf,&tmpBuf[index+1]);
 }
 
-//  ===============================================================================
-//	refreshInfo_Compass
-/// @brief	there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode
-///					the accel is not called during this process
+void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode)
+{
+    char localtext[32];
+
+    if(left2ByteCode)
+    {
+        localtext[0] = TXT_2BYTE;
+        localtext[1] = left2ByteCode;
+        localtext[2] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+
+    if(middle2ByteCode)
+    {
+        localtext[0] = '\001';
+        localtext[1] = TXT_2BYTE;
+        localtext[2] = middle2ByteCode;
+        localtext[3] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+
+    if(right2ByteCode)
+    {
+        localtext[0] = '\002';
+        localtext[1] = TXT_2BYTE;
+        localtext[2] = right2ByteCode;
+        localtext[3] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+}
+
 //  ===============================================================================
 void refreshInfo_Sensor(GFX_DrawCfgScreen s)
 {
+	const SDiveState *pStateReal = stateRealGetPointer();
     SSensorDataDiveO2* pDiveO2Data;
     char text[31];
     uint8_t strIndex = 0;
+    char *textPointer = text;
 
     float pressure = 0.0;
 
@@ -90,11 +154,12 @@
 	text[1] = TXT_Sensor;
 	text[2] = ' ';
 	text[3] = TXT_Information;
-	text[4] = 0;
+	text[4] = ' ';
+	text[5] = '0' + activeSensorId;
+	text[6] = 0;
 	tInfo_write_content_simple(  30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
 
-
-    pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data;
+    pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId-1];
 
     strIndex = snprintf(text,32,"ID: ");
     if(pDiveO2Data->sensorId != 0)
@@ -121,19 +186,49 @@
     snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
     tInfo_write_content_simple(  30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
 #endif
+
+    if(sensorActive)
+    {
+    	*textPointer++ = '\005';
+    }
+    else
+    {
+    	*textPointer++ = '\006';
+    }
+    *textPointer++ = ' ';
+    *textPointer++ = TXT_2BYTE;
+    *textPointer++ = TXT2BYTE_Sensor;
+    *textPointer++ = ' ';
+    *textPointer++ = TXT_2BYTE;
+    *textPointer++ = TXT2BYTE_O2IFDigital;
+    *textPointer++ = '0' + activeSensorId;
+
+    snprintf(textPointer, 20,": %01.2f, %01.1f mV",  pStateReal->lifeData.ppO2Sensor_bar[activeSensorId - 1], pStateReal->lifeData.sensorVoltage_mV[activeSensorId - 1]);
+
+    tInfo_write_content_simple(  30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
+
+    tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
 }
 
 void sendActionToInfoSensor(uint8_t sendAction)
 {
-
     switch(sendAction)
     {
-
     	case ACTION_BUTTON_BACK:
     		exitMenuEdit_to_BackMenu();
     			break;
 
-    	case ACTION_BUTTON_ENTER:
+    	case ACTION_BUTTON_ENTER:    	if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
+										{
+    										settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId - 1));
+											sensorActive = 1;
+										}
+										else
+										{
+											settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId - 1));
+											sensorActive = 0;
+										}
+    		break;
 		case ACTION_BUTTON_NEXT:
 		case ACTION_TIMEOUT:
 		case ACTION_MODE_CHANGE: