diff Discovery/Src/t7.c @ 442:adb18fe92737 minor_improvments

Introduced enum for lower left corner view selection: Enums allow changes in view configuration without danger of index inconsistencies
author ideenmodellierer
date Sat, 29 Feb 2020 22:25:20 +0100
parents 2b4440f75434
children f1257a32f2d4
line wrap: on
line diff
--- a/Discovery/Src/t7.c	Thu Feb 27 09:13:25 2020 +0100
+++ b/Discovery/Src/t7.c	Sat Feb 29 22:25:20 2020 +0100
@@ -91,8 +91,7 @@
 GFX_DrawCfgWindow	t7pCompass;
 GFX_DrawCfgWindow	t7surfaceL, t7surfaceR;
 
-uint8_t selection_custom_field = 1;
-uint8_t selection_customview = 1;
+uint8_t selection_customview = LLC_Temperature;
 
 uint8_t updateNecessary = 0;
 
@@ -139,6 +138,9 @@
     CVIEW_END
 };
 
+
+static uint8_t selection_custom_field = LLC_Temperature;
+
 const uint8_t *customviewsDive		= customviewsDiveStandard;
 const uint8_t *customviewsSurface	= customviewsSurfaceStandard;
 
@@ -171,7 +173,7 @@
 	SSettings* pSettings;
 	pSettings = settingsGetPointer();
 
-    selection_custom_field = 1;
+    selection_custom_field = LLC_Temperature;
     selection_customview = customviewsSurface[0];
 
     t7screen.FBStartAdress = 0;
@@ -682,7 +684,7 @@
     uint8_t dateNotSet = 0;
 
     uint8_t oxygen_percentage, gasOffset, actualGasID;
-//	uint16_t bottleFirstGas_bar;
+	uint16_t bottleFirstGas_bar;
     point_t start, stop;//, other;
 
 	SSettings* pSettings;
@@ -1005,14 +1007,14 @@
         GFX_write_string(&FontT48,&t7surfaceL,text,7);
 
         actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings;
-    /*
+
         bottleFirstGas_bar = stateUsed->lifeData.bottle_bar[actualGasID];
         if(bottleFirstGas_bar)
         {
             snprintf(text,255,"%3u\022\016\016 bar",bottleFirstGas_bar);
             GFX_write_string(&FontT48,&t7surfaceL,text,8);
         }
-    */
+
         // after gas name :-)
         if(actualGasID > gasOffset) // security
         {
@@ -2521,18 +2523,17 @@
 
 void t7_change_field(void)
 {
-    const uint8_t minVal = 0;
-    const uint8_t maxValGF 	= 8;
-    const uint8_t maxValVPM = 7;
-    uint8_t maxNow = maxValGF;
-
     selection_custom_field++;
 
-    if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE)
-        maxNow = maxValVPM;
-
-    if(selection_custom_field > maxNow)
-        selection_custom_field = minVal;
+    if((stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) && (selection_custom_field == LLC_GF)) /* no GF if in VPM mode */
+    {
+    	selection_custom_field++;
+    }
+
+    if(selection_custom_field >= LLC_END)
+    {
+        selection_custom_field = LLC_Empty;
+    }
 }
 
 
@@ -2546,6 +2547,7 @@
     uint8_t textpointer = 0;
     _Bool tinyHeaderFont = 0;
     uint8_t line = 0;
+    uint16_t agedColor = 0;
 
     SDivetime Stopwatch = {0,0,0,0};
     float fAverageDepth, fAverageDepthAbsolute;
@@ -2577,7 +2579,7 @@
     switch(selection_custom_field)
     {
     /* Temperature */
-    case 1:
+    case LLC_Temperature:
     default:
     	temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
         headerText[2] = TXT_Temperature;
@@ -2591,7 +2593,7 @@
         break;
 
     /* Average Depth */
-    case 2:
+    case LLC_AverageDepth:
         headerText[2] = TXT_AvgDepth;
         if(settingsGetPointer()->nonMetricalSystem)
             snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(fAverageDepthAbsolute));
@@ -2600,13 +2602,13 @@
         break;
 
     /* ppO2 */
-    case 3:
+    case LLC_ppO2:
         headerText[2] = TXT_ppO2;
         snprintf(text,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2);
         break;
 
     /* Stop Uhr */
-    case 4:
+    case LLC_Stopwatch:
         headerText[2] = TXT_Stopwatch;
         if(settingsGetPointer()->nonMetricalSystem)
             snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.0f",Stopwatch.Minutes, Stopwatch.Seconds,unit_depth_float(fAverageDepth));
@@ -2617,7 +2619,7 @@
         break;
 
     /* Ceiling */
-    case 5:
+    case LLC_Ceiling:
         headerText[2] = TXT_Ceiling;
         if((pDecoinfoStandard->output_ceiling_meter > 99.9f) || (settingsGetPointer()->nonMetricalSystem))
             snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(pDecoinfoStandard->output_ceiling_meter));
@@ -2626,7 +2628,7 @@
         break;
 
     /* Future TTS */
-    case 6:
+    case LLC_FutureTTS:
         headerText[2] = TXT_FutureTTS;
         if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60)
         	snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60);
@@ -2637,7 +2639,7 @@
         break;
 
     /* CNS */
-    case 7:
+    case LLC_CNS:
         headerText[2] = TXT_CNS;
         fCNS = stateUsed->lifeData .cns;
         if(fCNS > 999)
@@ -2646,10 +2648,15 @@
         break;
 
     /* actual GF */
-    case 8:
+    case LLC_GF:
         headerText[2] = TXT_ActualGradient;
         snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",100 * pDecoinfoStandard->super_saturation);
         break;
+    case LCC_BottleBar:
+        headerText[2] = TXT_AtemGasVorrat;
+        tinyHeaderFont = 1;
+        snprintf(text,TEXTSIZE,"%d\016\016\017", stateUsed->lifeData.bottle_bar[1]);
+        break;
     }
     headerText[3] = 0;
 
@@ -2659,7 +2666,29 @@
         GFX_write_string(&FontT42,&t7l3,headerText,0);
 
     t7_colorscheme_mod(text);
-    GFX_write_string(&FontT105,&t7l3,text,line);
+    if(selection_custom_field != LCC_BottleBar)
+    {
+    	GFX_write_string(&FontT105,&t7l3,text,line);
+    }
+    else
+    {
+    	agedColor = stateUsed->lifeData.bottle_bar_age_MilliSeconds[1];
+    	if(agedColor > 1200)
+    	{
+    		agedColor = 16;
+    	}
+    	else
+    	if(agedColor > 600)
+    	{
+    		agedColor = 9;
+    	}
+    	else
+    	{
+    		agedColor = 0;
+    	}
+
+    	GFX_write_string_color(&FontT105,&t7l3,text,line,agedColor);
+    }
 }
 
 /* Private functions ---------------------------------------------------------*/