changeset 647:15f6f0b5786c

Integrated selection of bailout in the diluent selection page: To be able to introduce a new menu page for future development, the selection of bailout cases is now combined with the selection of the diluent at one page. To enable this the concept of a "shadow page" has been introduced. With that the original functionality may be reused without need to a a standalone page. The bailout /diluen page is now switched (surface mode) using the last menu line of the gas selection page
author Ideenmodellierer
date Tue, 13 Apr 2021 19:25:41 +0200
parents 0fc1b47d2482
children ff2b393e290f
files Discovery/Inc/tMenu.h Discovery/Src/tMenu.c Discovery/Src/tMenuEditGasOC.c Discovery/Src/tMenuGas.c
diffstat 4 files changed, 174 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/tMenu.h	Tue Apr 13 19:21:14 2021 +0200
+++ b/Discovery/Inc/tMenu.h	Tue Apr 13 19:25:41 2021 +0200
@@ -83,4 +83,6 @@
 void block_diluent_page(void);
 void unblock_diluent_page(void);
 
+void selectPage(uint32_t selection);
+
 #endif /* TMENU_H */
--- a/Discovery/Src/tMenu.c	Tue Apr 13 19:21:14 2021 +0200
+++ b/Discovery/Src/tMenu.c	Tue Apr 13 19:25:41 2021 +0200
@@ -68,6 +68,8 @@
     uint8_t 	pageCountNumber[MAXPAGES+1];
     uint8_t 	pageCountTotal;
     uint8_t		modeFlipPages;
+    uint8_t		shadowPage[MAXPAGES+1];		/* the page is switch in the context of another page */
+    uint8_t	    activeShadow;				/* Base page which is used for the shadow */
 } SMenuMemory;
 
 /* Exported variables --------------------------------------------------------*/
@@ -92,7 +94,7 @@
 static void draw_tMdesignSubSelected(uint32_t *ppDestination);
 static void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination);
 static void tMenu_write(uint8_t page, char *text, char *subtext);
-
+static void nextLine(void);
 static void clean_line_actual_page(void);
 void tM_build_pages(void);
 
@@ -144,6 +146,7 @@
         menu.lineMemoryForNavigationForPage[i] = 0;
         menu.StartAddressForPage[i] = 0;
         menu.linesAvailableForPage[i] = 0;
+        menu.shadowPage[i] = 0;
     }
 
     tMscreen.FBStartAdress = 0;
@@ -342,11 +345,13 @@
 
     page = idList.page;
 
-    if(!menu.pageCountNumber[page])
-        return;
+  	if((!menu.pageCountNumber[page]) && (!menu.shadowPage[page]))		/* shadow pages are not visible on top level */
+	{
+		return;
+	}
 
-    if(menu.pagesAvailable == 0)
-        tM_create_pagenumbering();
+	if(menu.pagesAvailable == 0)
+		tM_create_pagenumbering();
 
     if(*text == 0)
         return;
@@ -433,7 +438,7 @@
     if(page == 0)
         page = first;
 
-    while((page <= MAXPAGES) && ((menu.linesAvailableForPage[page] == 0) || (menu.StartAddressForPage[page] == 0) || (menu.pageCountNumber[page] == 0)))
+    while((page <= MAXPAGES) && ((menu.linesAvailableForPage[page] == 0) || (menu.StartAddressForPage[page] == 0) || ((menu.pageCountNumber[page] == 0) && !((menu.shadowPage[page]) && (menu.pageMemoryForNavigation == page)))))
         page += 1;
 
     if(page > MAXPAGES)
@@ -467,6 +472,21 @@
     menu.pageCountNumber[page] = 1;
 }
 
+static void tM_addShadow(uint32_t id)
+{
+    SStateList idList;
+    uint8_t page;
+
+    get_idSpecificStateList(id, &idList);
+
+    page = idList.page;
+
+    if(page > MAXPAGES)
+        return;
+
+    menu.shadowPage[page] = 1;
+}
+
 
 void tM_build_pages(void)
 {
@@ -507,13 +527,26 @@
     }
 //	if((pSettings->dive_mode != DIVEMODE_Gauge) && (pSettings->dive_mode != DIVEMODE_Apnea))
 //	{
-        tM_add(StMOG);
         tM_add(StMDECOP);
 //	}
+
     if((pSettings->dive_mode == DIVEMODE_CCR) || (stateUsed->diveSettings.ccrOption == 1))
     {
         tM_add(StMCG);
         tM_add(StMSP);
+        if (actual_menu_content == MENU_SURFACE)  /* StMOG is now accessed using StMCG in CCR mode*/
+        {
+        	tM_add(StMXTRA);
+        	tM_addShadow(StMOG);
+        }
+        else
+        {
+        	tM_add(StMOG);
+        }
+    }
+    else
+    {
+        tM_add(StMOG);
     }
 
     id = tMOG_refresh(0, text, &tabPosition, subtext);
@@ -848,6 +881,57 @@
     }
 }
 
+void selectPage(uint32_t selection)
+{
+    uint8_t page, line;
+    SStateList idList;
+
+	SSettings* pSettings;
+	pSettings = settingsGetPointer();
+
+ //   menu.pageMemoryForNavigation = selection;
+
+ //   findValidPosition(&page, &line);
+    if(selection > MAXPAGES)		/* selection via structure */
+    {
+    	get_idSpecificStateList(selection, &idList);
+    	page = idList.page;
+    }
+    else
+    {
+    	page = selection;
+    }
+
+    if(menu.shadowPage[page])		/* backup base page in case a shadow was selected */
+    {
+    	menu.activeShadow = menu.pageMemoryForNavigation;
+    }
+
+    menu.pageMemoryForNavigation = page;
+    /* new test for 3button design */
+    //menu.lineMemoryForNavigationForPage[page] = line;
+    menu.lineMemoryForNavigationForPage[page] = 0;
+    menu.modeFlipPages = 1;
+
+    set_globalState_Menu_Page(page);
+
+    change_CLUT_entry(CLUT_MenuLineSelectedSides, 		(CLUT_MenuPageGasOC + page - 1));
+    change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1));
+
+    GFX_SetFrameTop(menu.StartAddressForPage[page]);
+    /* new test for 3button design */
+    //GFX_SetFrameBottom((.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
+    if(!pSettings->FlipDisplay)
+    {
+    	GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
+    }
+    else
+    {
+    	GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 65, 800, 390);
+    }
+    nextLine();
+}
+
 
 static void nextLine(void)
 {
@@ -876,6 +960,11 @@
 
 static void stepBackMenu(void)
 {
+	if(menu.activeShadow)	/* restore base page */
+	{
+		selectPage(menu.activeShadow);
+		menu.activeShadow = 0;
+	}
     if(menu.modeFlipPages == 0)
     {
         menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation] = 0;
@@ -1143,7 +1232,7 @@
     uint16_t positionText;
     uint8_t pageText;
 
-    const char text8max[MAXPAGES+1][8] =
+    char text8max[MAXPAGES+1][8] =
     {   "",
         "OC",
         "CC",
@@ -1157,7 +1246,7 @@
         "SIM"
     };
 
-    const _Bool spacing[MAXPAGES+1] =
+    _Bool spacing[MAXPAGES+1] =
     {   0,
         0, // behind OC
         0, // behind CC
@@ -1172,6 +1261,12 @@
         0
     };
 
+    if(actual_menu_content == MENU_SURFACE)
+    {
+    	spacing[3] = 0;		/* Display extra menu directly after setpoint */
+    	sprintf(text8max[4],"OP");
+    }
+
     pBackup = tMscreen.FBStartAdress;
     tMscreen.FBStartAdress = menu.StartAddressForPage[page];
     pDestination = (uint16_t*) menu.StartAddressForPage[page];
@@ -1237,7 +1332,7 @@
 					pDestination += 5 * 480;
 					positionText += 70;
 
-					if((k == 4) || ((k == 6) && (menu.pageCountNumber[5] == 0)))
+					if(((k == 4) && (actual_menu_content != MENU_SURFACE)) || ((k == 6) && (menu.pageCountNumber[5] == 0)))
 					{
 						pDestination += 70 * 480;
 						positionText += 70;
--- a/Discovery/Src/tMenuEditGasOC.c	Tue Apr 13 19:21:14 2021 +0200
+++ b/Discovery/Src/tMenuEditGasOC.c	Tue Apr 13 19:25:41 2021 +0200
@@ -89,24 +89,58 @@
 void openEdit_GasCC(uint8_t line)
 {
     if(actual_menu_content == MENU_SURFACE)
-        openEdit_Gas(line , 1);
+    {
+		if(line == 6)
+		{
+			if((settingsGetPointer()->dive_mode == DIVEMODE_CCR) || (stateUsed->diveSettings.ccrOption == 1))
+			{
+				selectPage(StMOG);
+			}
+		}
+		else
+		{
+			openEdit_Gas(line , 1);
+		}
+    }
     else
-    if(line == 6)
-        openEdit_SpecialDiveGasMenu(1);
-    else
-        openEdit_DiveGasSelect(line, 1);
+    {
+		if(line == 6)
+		{
+			openEdit_SpecialDiveGasMenu(1);
+		}
+		else
+		{
+			openEdit_DiveGasSelect(line, 1);
+		}
+    }
 }
 
 
 void openEdit_GasOC(uint8_t line)
 {
     if(actual_menu_content == MENU_SURFACE)
-        openEdit_Gas(line, 0);
+    {
+		if(line == 6)
+		{
+			if((settingsGetPointer()->dive_mode == DIVEMODE_CCR) || (stateUsed->diveSettings.ccrOption == 1))
+			{
+				selectPage(StMCG);
+			}
+		}
+		else
+		{
+			openEdit_Gas(line, 0);
+		}
+    }
     else
     if(line == 6)
+    {
         openEdit_SpecialDiveGasMenu(0);
+    }
     else
+    {
         openEdit_DiveGasSelect(line, 0);
+    }
 }
 
 
--- a/Discovery/Src/tMenuGas.c	Tue Apr 13 19:21:14 2021 +0200
+++ b/Discovery/Src/tMenuGas.c	Tue Apr 13 19:25:41 2021 +0200
@@ -37,7 +37,7 @@
 #define OCGAS_STANDARD (0)
 #define OCGAS_BAILOUT_INACTIVE (1)
 #define OCGAS_BAILOUT_ACTIVE (2)
-#define CCGAS_STANDARD (0)
+#define CCGAS_STANDARD (3)
 
 /* Private function prototypes -----------------------------------------------*/
 uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium);
@@ -313,17 +313,33 @@
     }
 
     /* special gas number #6 in dive mode*/
-    if(((line == 0) || (line == 6)) && (actual_menu_content != MENU_SURFACE))
+    if(((line == 0) || (line == 6)))
     {
-        text[textPointer++] = '\020';
-        text[textPointer++] = TXT_2BYTE;
-        if(start == NUM_OFFSET_DILUENT)
-            text[textPointer++] = TXT2BYTE_SpecialDiveGasMenuCCR;
-        else
-            text[textPointer++] = TXT2BYTE_SpecialDiveGasMenu;
-        text[textPointer++] = '\n';
-        text[textPointer++] = '\r';
-        text[textPointer++] = 0;
+    	if(actual_menu_content != MENU_SURFACE)
+    	{
+			text[textPointer++] = '\020';
+			text[textPointer++] = TXT_2BYTE;
+			if(start == NUM_OFFSET_DILUENT)
+				text[textPointer++] = TXT2BYTE_SpecialDiveGasMenuCCR;
+			else
+				text[textPointer++] = TXT2BYTE_SpecialDiveGasMenu;
+			text[textPointer++] = '\n';
+			text[textPointer++] = '\r';
+			text[textPointer++] = 0;
+    	}
+    	else	/* switch to bailout selection in surface mode */
+    	if((settingsGetPointer()->dive_mode == DIVEMODE_CCR) || (stateUsed->diveSettings.ccrOption == 1))
+    	{
+			text[textPointer++] = '\024';
+			if(gasMode == CCGAS_STANDARD)
+			{
+				textPointer += snprintf(&text[textPointer], 14,"Bailout\n");
+			}
+			else
+			{
+				textPointer += snprintf(&text[textPointer], 14,"Diluent\n");
+			}
+    	}
     }
 }