changeset 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 fce639612464
children 9f487ad38170
files Discovery/Inc/tMenu.h Discovery/Inc/tMenuXtra.h Discovery/Src/tMenu.c Discovery/Src/tMenuEditHardware.c Discovery/Src/tMenuXtra.c
diffstat 5 files changed, 63 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/tMenu.h	Thu Feb 29 18:49:55 2024 +0100
+++ b/Discovery/Inc/tMenu.h	Fri Mar 01 19:30:29 2024 +0100
@@ -87,6 +87,7 @@
 
 void selectPage(uint32_t selection);
 
+uint8_t getLineMask(uint32_t lineId);
 void resetLineMask(uint32_t lineId);
 void disableLine(uint32_t lineId);
 void enableLine(uint32_t lineId);
--- a/Discovery/Inc/tMenuXtra.h	Thu Feb 29 18:49:55 2024 +0100
+++ b/Discovery/Inc/tMenuXtra.h	Fri Mar 01 19:30:29 2024 +0100
@@ -45,7 +45,7 @@
 /* Exported functions --------------------------------------------------------*/
 
 uint32_t tMXtra_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext);
-
+void tMXtra_checkLineStatus(void);
 	 #ifdef __cplusplus
 }
 #endif
--- a/Discovery/Src/tMenu.c	Thu Feb 29 18:49:55 2024 +0100
+++ b/Discovery/Src/tMenu.c	Fri Mar 01 19:30:29 2024 +0100
@@ -261,6 +261,13 @@
 	}
 }
 
+uint8_t getLineMask(uint32_t lineId)
+{
+	SStateList idList;
+	get_idSpecificStateList(lineId, &idList);
+	return(menu.disableLineMask[idList.page]);
+}
+
 void resetLineMask(uint32_t lineId)
 {
 	SStateList idList;
@@ -931,6 +938,16 @@
     block_diluent_handler(1);
 }
 
+static void checkLineStatus()
+{
+	switch(get_globalState())
+	{
+		case StMXTRA: tMXtra_checkLineStatus();
+			break;
+		default:
+			break;
+	}
+}
 
 static void nextPage(void)
 {
@@ -950,6 +967,8 @@
 
     set_globalState_Menu_Page(page);
 
+    checkLineStatus();		/* some lines may be enabled / disabled depending on condition occuring outside the page scope => check if update is necessary */
+
     change_CLUT_entry(CLUT_MenuLineSelectedSides, 		(CLUT_MenuPageGasOC + page - 1));
     change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1));
 
--- a/Discovery/Src/tMenuEditHardware.c	Thu Feb 29 18:49:55 2024 +0100
+++ b/Discovery/Src/tMenuEditHardware.c	Fri Mar 01 19:30:29 2024 +0100
@@ -427,9 +427,6 @@
 									break;
 				}
 		}
-
-		set_globalState(StMXTRA); /* new map may have impact to top level menu => update */
-		updateMenu();
 		openEdit_O2Sensors();
 	}
 
--- 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();
+	}
+}
+