diff Discovery/Src/tMenuEditCustom.c @ 820:7322adb00305

Split definition of custom views: In the previous version the T7 and T3 custom views were defined using the same enum. As result an ID shift may happen causing errors in the selection of the big font views. The second reason to split the definition is that shift operations are used in uint32_t variable (limit 32). The total number of current views is 27 => splitting will avoid ID problems in case new views are added.
author Ideenmodellierer
date Sun, 24 Sep 2023 18:43:12 +0200
parents ce8f71217f45
children 2a8af51ab04d
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditCustom.c	Sun Sep 24 18:39:26 2023 +0200
+++ b/Discovery/Src/tMenuEditCustom.c	Sun Sep 24 18:43:12 2023 +0200
@@ -58,6 +58,7 @@
 void openEdit_ViewPort(void);
 void refresh_Customviews(void);
 char customview_TXT2BYTE_helper(uint8_t customViewId);
+char customviewBF_TXT2BYTE_helper(uint8_t customViewId);
 /* Announced function prototypes -----------------------------------------------*/
 uint8_t OnAction_CViewTimeout  (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
@@ -110,7 +111,7 @@
     text[2] = ' ';
     text[3] = ' ';
     text[4] = TXT_2BYTE;
-    text[5] = customview_TXT2BYTE_helper(settingsGetPointer()->tX_customViewPrimaryBF);
+    text[5] = customviewBF_TXT2BYTE_helper(settingsGetPointer()->tX_customViewPrimaryBF);
     text[6] = 0;
     write_label_var(  30, 700, ME_Y_LINE3, &FontT48, text);
 
@@ -470,20 +471,15 @@
         text = TXT2BYTE_Compass;
         break;
     case CVIEW_Decolist:
-    case CVIEW_T3_Decostop:
         text = TXT2BYTE_Decolist;
         break;
     case CVIEW_Tissues:
         text = TXT2BYTE_Tissues;
         break;
     case CVIEW_Profile:
-#ifdef ENABLE_T3_PROFILE_VIEW
-    case CVIEW_T3_Profile:
-#endif
         text = TXT2BYTE_Profile;
         break;
     case CVIEW_Gaslist:
-    case CVIEW_T3_GasList:
         text = TXT2BYTE_Gaslist;
         break;
     case CVIEW_EADTime:
@@ -497,6 +493,37 @@
         break;
     case CVIEW_noneOrDebug:
     	text = TXT2BYTE_DispNoneDbg;
+    	break;
+    default:
+        break;
+    }
+    return text;
+}
+char customviewBF_TXT2BYTE_helper(uint8_t customViewId)
+{
+    char text = 0;
+
+    switch(customViewId)
+    {
+    case CVIEW_T3_noneOrDebug:
+    	text = TXT2BYTE_DispNoneDbg;
+        break;
+    case CVIEW_T3_sensors:
+        text = TXT2BYTE_O2monitor;
+        break;
+    case CVIEW_T3_Compass:
+        text = TXT2BYTE_Compass;
+        break;
+    case CVIEW_T3_Decostop:
+        text = TXT2BYTE_Decolist;
+        break;
+#ifdef ENABLE_T3_PROFILE_VIEW
+    case CVIEW_T3_Profile:
+        text = TXT2BYTE_Profile;
+        break;
+#endif
+    case CVIEW_T3_GasList:
+        text = TXT2BYTE_Gaslist;
         break;
     case CVIEW_T3_MaxDepth:
     	text = TXT2BYTE_MaxDepth;
@@ -525,7 +552,6 @@
     return text;
 }
 
-
 uint8_t OnAction_CViewTimeout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     uint8_t value;
@@ -603,7 +629,7 @@
     uint8_t newValue;
 
 	/* list contains all views which may be selected => get index of current setting */
-	while((settingsGetPointer()->tX_customViewPrimaryBF != cv_changelist_BS[index])	 || (cv_changelist_BS[index] == CVIEW_T3_END))
+	while((settingsGetPointer()->tX_customViewPrimaryBF != cv_changelist_BS[index])	 && (cv_changelist_BS[index] != CVIEW_T3_END))
 	{
 		index++;
 	}
@@ -1001,29 +1027,31 @@
  			if(pcv_curchangelist == cv_changelist)
  			{
  				text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_configuration,id);
+ 				text[textPointer++] = ' ';
+ 				textPointer += snprintf(&text[textPointer], 60,	"%c%c\n\r",	TXT_2BYTE, customview_TXT2BYTE_helper(id));
  			}
  			else
  			{
  				text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id);
+ 				text[textPointer++] = ' ';
+ 				textPointer += snprintf(&text[textPointer], 60,	"%c%c\n\r",	TXT_2BYTE, customviewBF_TXT2BYTE_helper(id));
  			}
-			text[textPointer++] = ' ';
-			textPointer += snprintf(&text[textPointer], 60,	"%c%c\n\r",	TXT_2BYTE, customview_TXT2BYTE_helper(id));
 
-				switch(i)
-				{
-					case 0: 	write_label_var( 30, 800, ME_Y_LINE1, &FontT48, text);
-						break;
-					case 1:		write_label_var( 30, 800, ME_Y_LINE2, &FontT48, text);
-						break;
-					case 2: 	write_label_var( 30, 800, ME_Y_LINE3, &FontT48, text);
-						break;
-					case 3: 	write_label_var( 30, 800, ME_Y_LINE4, &FontT48, text);
-						break;
-					case 4: 	write_label_var( 30, 800, ME_Y_LINE5, &FontT48, text);
-						break;
-					default:
-						break;
-				}
+			switch(i)
+			{
+				case 0: 	write_label_var( 30, 800, ME_Y_LINE1, &FontT48, text);
+					break;
+				case 1:		write_label_var( 30, 800, ME_Y_LINE2, &FontT48, text);
+					break;
+				case 2: 	write_label_var( 30, 800, ME_Y_LINE3, &FontT48, text);
+					break;
+				case 3: 	write_label_var( 30, 800, ME_Y_LINE4, &FontT48, text);
+					break;
+				case 4: 	write_label_var( 30, 800, ME_Y_LINE5, &FontT48, text);
+					break;
+				default:
+					break;
+			}
      	}
      }
      if(customviewsSubpageMax != 1)