diff Discovery/Src/tMenuXtra.c @ 850:bc2fcd002fc4 Evo_2_23

Check line enable/disable state when a new page is selected: Some lines may change the enable/disable state based on events which are triggered from outside the page scope (for example sensor setup). Updating the line states while another page is active caused problems in the framebuffer handling. To solve this usecase the conditions for the line dis/enabling is checked when a "nextPage" is selected. If condition changed then the page will be refreshed.
author Ideenmodellierer
date Fri, 01 Mar 2024 19:30:29 +0100
parents 17d9d6eddd8d
children 48b6a3b1f3f8
line wrap: on
line diff
--- a/Discovery/Src/tMenuXtra.c	Thu Feb 29 18:49:55 2024 +0100
+++ b/Discovery/Src/tMenuXtra.c	Fri Mar 01 19:30:29 2024 +0100
@@ -38,6 +38,7 @@
 #include "simulation.h"
 #include "configuration.h"
 
+
 /* Exported functions --------------------------------------------------------*/
 
 uint32_t tMXtra_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext)
@@ -168,10 +169,12 @@
            else
                text[textPointer++] = '\006';
 
-           if (!canDoFallback) {
+           if (!canDoFallback)
+           {
                text[textPointer++] = '\020';
                disableLine(StMXTRA_O2_Fallback);
-           } else {
+           } else
+           {
                enableLine(StMXTRA_O2_Fallback);
            }
            strcpy(&text[textPointer],"\n\r");
@@ -208,16 +211,48 @@
             textPointer += 2;
          }
 #endif
-        if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL))
+        if((line == 0) || (line == 5))
         {
-        	if((line == 0) || (line == 5))
+      		if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL))
         	{
-        	                 textPointer += snprintf(&text[textPointer], 60,\
-        	                             "%c"
-        	                             ,TXT_PreDive);
+        	    textPointer += snprintf(&text[textPointer], 60,"%c",TXT_PreDive);
         	}
+      		else
+      		{
+      			text[textPointer++] = '\031';		/* change text color */
+      			textPointer += snprintf(&text[textPointer], 60,"%c",TXT_PreDive);
+      			text[textPointer++] = '\020';		/* restore text color */
+      			disableLine(StMXTRA_Predive_Check);
+      		}
+      		strcpy(&text[textPointer],"\n\r");
+      		textPointer += 2;
         }
     }
     return StMXTRA;
 }
 
+void tMXtra_checkLineStatus(void)
+{
+	uint8_t localLineMask = 0;
+	uint8_t lineMask = getLineMask(StMXTRA);
+    SSettings *pSettings = settingsGetPointer();
+
+	if(pSettings->CCR_Mode != CCRMODE_Sensors)
+	{
+		localLineMask |= 1 << 2;
+	}
+	if(pSettings->dive_mode != DIVEMODE_PSCR)
+	{
+		localLineMask |= 1 << 4;
+	}
+	if((pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_ANADIG) && (pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_DIGITAL))
+	{
+		localLineMask |= 1 << 5;
+	}
+
+	if(lineMask != localLineMask)
+	{
+			updateMenu();
+	}
+}
+