diff Discovery/Src/t3.c @ 110:cc8e24374b83 FlipDisplay

Added option to handled mirrored display to existing functions
author Ideenmodellierer
date Tue, 01 Jan 2019 21:02:17 +0100
parents 5f11787b4f42
children cc9c18075e00
line wrap: on
line diff
--- a/Discovery/Src/t3.c	Tue Jan 01 21:00:55 2019 +0100
+++ b/Discovery/Src/t3.c	Tue Jan 01 21:02:17 2019 +0100
@@ -103,6 +103,9 @@
 
 void t3_init(void)
 {
+	SSettings* pSettings;
+	pSettings = settingsGetPointer();
+
     if(getLicence() == LICENCEBONEX)
     {
         t3_customviews = t3_customviewsScooter;
@@ -119,17 +122,37 @@
     t3l1.WindowNumberOfTextLines = 2;
     t3l1.WindowLineSpacing = 19; // Abstand von Y0
     t3l1.WindowTab = 100;
-    t3l1.WindowX0 = 0;
-    t3l1.WindowX1 = BigFontSeperationLeftRight - 5;
-    t3l1.WindowY0 = BigFontSeperationTopBottom + 5;
-    t3l1.WindowY1 = 479;
+
+    if(!pSettings->FlipDisplay)
+    {
+		t3l1.WindowX0 = 0;
+		t3l1.WindowX1 = BigFontSeperationLeftRight - 5;
+		t3l1.WindowY0 = BigFontSeperationTopBottom + 5;
+		t3l1.WindowY1 = 479;
+    }
+    else
+    {
+		t3l1.WindowX0 = 800 - BigFontSeperationLeftRight + 5;
+		t3l1.WindowX1 = 799;
+		t3l1.WindowY0 = 0;
+		t3l1.WindowY1 = 479 - BigFontSeperationTopBottom + 5 ;
+    }
 
     t3r1.Image = &t3screen;
     t3r1.WindowNumberOfTextLines = t3l1.WindowNumberOfTextLines;
     t3r1.WindowLineSpacing = t3l1.WindowLineSpacing;
     t3r1.WindowTab = t3l1.WindowTab;
-    t3r1.WindowX0 = BigFontSeperationLeftRight + 5;
-    t3r1.WindowX1 = 799;
+    if(!pSettings->FlipDisplay)
+    {
+		t3r1.WindowX0 = BigFontSeperationLeftRight + 5;
+		t3r1.WindowX1 = 799;
+    }
+    else
+    {
+		t3r1.WindowX0 = 0;
+		t3r1.WindowX1 = BigFontSeperationLeftRight - 5;
+    }
+
     t3r1.WindowY0 = t3l1.WindowY0;
     t3r1.WindowY1 = t3l1.WindowY1;
 
@@ -138,16 +161,24 @@
     t3c1.WindowLineSpacing = t3l1.WindowLineSpacing;
     t3c1.WindowX0 = 0;
     t3c1.WindowX1 = 799;
-    t3c1.WindowY0 = 0;
-    t3c1.WindowY1 = BigFontSeperationTopBottom - 5;
+    if(!pSettings->FlipDisplay)
+    {
+    	t3c1.WindowY0 = 0;
+    	t3c1.WindowY1 = BigFontSeperationTopBottom - 5;
+    }
+	else
+	{
+		t3c1.WindowY0 = 480 - BigFontSeperationTopBottom + 5;
+		t3c1.WindowY1 = 479;
+	}
 
     t3c2.Image = &t3screen;
     t3c2.WindowNumberOfTextLines = 3;
     t3c2.WindowLineSpacing = 58;
     t3c2.WindowX0 = 370;
     t3c2.WindowX1 = 799;
-    t3c2.WindowY0 = 0;
-    t3c2.WindowY1 = BigFontSeperationTopBottom - 5;
+    t3c2.WindowY0 = t3c1.WindowY0;
+    t3c2.WindowY1 = t3c1.WindowY1;
     t3c2.WindowTab = 600;
 }
 
@@ -183,6 +214,9 @@
     uint8_t depthChangeAscent;
     point_t start, stop, startZeroLine;
 
+	SSettings* pSettings;
+	pSettings = settingsGetPointer();
+
     start.x = 0;
     stop.x = 799;
     stop.y = start.y = BigFontSeperationTopBottom;
@@ -190,6 +224,7 @@
 
     start.y = BigFontSeperationTopBottom;
     stop.y = 479;
+
     stop.x = start.x = BigFontSeperationLeftRight;
     GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
 
@@ -322,19 +357,50 @@
         /* ascentrate graph -standard mode */
         if(stateUsed->lifeData.ascent_rate_meter_per_min > 0)
         {
-            start.y = tXl1->WindowY0 - 1;
+        	 if(!pSettings->FlipDisplay)
+        	 {
+        		 start.y = tXl1->WindowY0 - 1;
+        	 }
+        	 else
+        	 {
+        		 start.y = tXl1->WindowY1 + 1;
+        	 }
+
             for(int i = 0; i<4;i++)
             {
                 start.y += 5*8;
                 stop.y = start.y;
-                start.x = tXl1->WindowX1 - 1;
+                if(!pSettings->FlipDisplay)
+                {
+                	start.x = tXl1->WindowX1 - 1;
+                }
+                else
+                {
+                	start.x = tXr1->WindowX1 - 1;
+                }
                 stop.x = start.x - 17;
                 GFX_draw_line(tXscreen, start, stop, 0);
             }
             // new thick bar design Sept. 2015
-            start.x = tXl1->WindowX1 - 3 - 5;
+            if(!pSettings->FlipDisplay)
+            {
+            	start.x = tXl1->WindowX1 - 3 - 5;
+            }
+            else
+            {
+            	start.x = tXr1->WindowX1 - 3 - 5;
+            }
+
             stop.x = start.x;
-            start.y = tXl1->WindowY0 - 1;
+            if(!pSettings->FlipDisplay)
+            {
+            	start.y = tXl1->WindowY0 - 1;
+            }
+            else
+            {
+            	start.y = tXl1->WindowY1 + 1;
+            }
+
             stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8);
             stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9
             if(stop.y >= 470)
@@ -600,6 +666,9 @@
     char text[512];
     uint16_t textpointer = 0;
 
+	SSettings* pSettings;
+	pSettings = settingsGetPointer();
+
     // CVIEW_T3_Decostop and CVIEW_T3_TTS
     const SDecoinfo * pDecoinfo;
     if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE)
@@ -632,7 +701,9 @@
 
 
     uint16_t tempWinX0;
+    uint16_t tempWinX1;
     uint16_t tempWinY0;
+    uint16_t tempWinY1;
     uint16_t tempWinC2X0;
     uint16_t tempWinC2Tab;
 
@@ -676,6 +747,12 @@
         break;
 
     case CVIEW_T3_StopWatch:
+
+        tempWinX0 = tXc1->WindowX0;
+        tempWinY0 = tXc1->WindowY0;
+        tempWinX1 = tXc1->WindowX1;
+        tempWinY1 = tXc1->WindowY1;
+
         Stopwatch.Total = timer_Stopwatch_GetTime();
         Stopwatch.Minutes = Stopwatch.Total / 60;
         Stopwatch.Seconds = Stopwatch.Total - ( Stopwatch.Minutes * 60 );
@@ -687,19 +764,39 @@
         snprintf(text,TEXTSIZE,"\030\003\016%01.1f",unit_depth_float(fAverageDepthAbsolute));
         GFX_write_string(&FontT105,tXc1,text,0);
 
-        tempWinX0 = tXc1->WindowX0;
-        tempWinY0 = tXc1->WindowY0;
-        tXc1->WindowX0 = 480;
+
+
+        if(!pSettings->FlipDisplay)
+        {
+        	tXc1->WindowX0 = 480;
+        }
+        else
+        {
+        	tXc1->WindowX1 = 320;
+        	tXc1->WindowY0 = t3c1.WindowY0; /* select customer window */
+        }
 //			snprintf(text,TEXTSIZE,"\032\f%c%c - %c",TXT_2BYTE, TXT2BYTE_Clock, TXT_AvgDepth);
+
         snprintf(text,TEXTSIZE,"\032\f%c", TXT_Stopwatch);
         GFX_write_string(&FontT42,tXc1,text,0);
         snprintf(text,TEXTSIZE,"\030\016%01.1f",unit_depth_float(fAverageDepth));
         GFX_write_string(&FontT105,tXc1,text,0);
-        tXc1->WindowY0 = 100;
+        if(!pSettings->FlipDisplay)
+        {
+        	tXc1->WindowY0 = 100;
+        }
+        else
+        {
+        	tXc1->WindowY1 -= 100; /* jump to upper of two lines */
+        }
+
         snprintf(text,TEXTSIZE,"\030%u:\016\016%02u",Stopwatch.Minutes, Stopwatch.Seconds);
         GFX_write_string(&FontT105,tXc1,text,0);
+
         tXc1->WindowX0 = tempWinX0;
         tXc1->WindowY0 = tempWinY0;
+        tXc1->WindowX1 = tempWinX1;
+        tXc1->WindowY1 = tempWinY1;
         break;
 
     case CVIEW_T3_GasList: