diff Discovery/Src/t7.c @ 567:1c95f811967c

-Add 12HR Time Support -Add firmware image only font extensions -Show english units when required in log's graphs -Show decompression info with Font84 if 10 characters long -Remove usage of ' symbol to denote minutes and instead use min abbreviation -Show english units when required on the simulation configuration screen -Remove usage of ' symbol to denote feet in in non-metric mode and use ft abbrevation
author izzni
date Tue, 24 Nov 2020 13:22:23 -0600
parents 5e0a75e2f00b
children 9bb9a52d6ae5
line wrap: on
line diff
--- a/Discovery/Src/t7.c	Sat Nov 21 17:41:59 2020 +0100
+++ b/Discovery/Src/t7.c	Tue Nov 24 13:22:23 2020 -0600
@@ -680,6 +680,8 @@
 {
 	static float debounceAmbientPressure = 0;
     char text[256];
+    char timeSuffix;
+    uint8_t hours;
     uint8_t loop, textIdx;
     uint8_t date[3], year,month,day;
     uint32_t color;
@@ -755,13 +757,45 @@
     GFX_write_string(&FontT54,&t7surfaceR,text,3);
 */
 // debug version:
-    if(Stime.Seconds % 2)
-        snprintf(text,255,"\001%02d:%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds);
-    else if(dateNotSet)
-        snprintf(text,255,"\001\031%02d:%02d:%02d\020",Stime.Hours,Stime.Minutes,Stime.Seconds);
+
+    if (settingsGetPointer()->amPMTime)
+    {
+		if (Stime.Hours > 11)
+		{
+			timeSuffix = 'P';
+		}
+		else
+		{
+			timeSuffix = 'A';
+		}
+
+		if (Stime.Hours % 12 == 0)
+		{
+			hours = 12;
+		}
+		else
+		{
+			hours = (Stime.Hours % 12);
+		}
+
+	    if(Stime.Seconds % 2)
+	        snprintf(text,255,"\001%02d:%02d:%02d\016\016%cM\017",hours,Stime.Minutes,Stime.Seconds,timeSuffix);
+	    else if(dateNotSet)
+	        snprintf(text,255,"\001\031%02d:%02d:%02d\016\016%cM\017\020",hours,Stime.Minutes,Stime.Seconds,timeSuffix);
+	    else
+	        snprintf(text,255,"\001%02d\031:\020%02d:%02d\016\016%cM\017",hours,Stime.Minutes,Stime.Seconds,timeSuffix);
+	    GFX_write_string(&FontT48,&t7surfaceR,text,3);
+    }
     else
-        snprintf(text,255,"\001%02d\031:\020%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds);
-    GFX_write_string(&FontT54,&t7surfaceR,text,3);
+    {
+        if(Stime.Seconds % 2)
+            snprintf(text,255,"\001%02d:%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds);
+        else if(dateNotSet)
+            snprintf(text,255,"\001\031%02d:%02d:%02d\020",Stime.Hours,Stime.Minutes,Stime.Seconds);
+        else
+            snprintf(text,255,"\001%02d\031:\020%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds);
+        GFX_write_string(&FontT54,&t7surfaceR,text,3);
+    }
 
     if(settingsGetPointer()->date_format == DDMMYY)
     {
@@ -1644,6 +1678,8 @@
 	static uint8_t last_customview = CVIEW_END;
 
     char text[256];
+	char timeSuffix;
+	uint8_t hoursToDisplay;
     uint16_t textpointer = 0;
     uint16_t heading = 0;
     int16_t start;
@@ -1849,10 +1885,40 @@
 
         translateDate(stateRealGetPointer()->lifeData.dateBinaryFormat, &Sdate);
         translateTime(stateRealGetPointer()->lifeData.timeBinaryFormat, &Stime);
-        if(Stime.Seconds % 2)
-            textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d",Stime.Hours,Stime.Minutes);
+
+        if (settingsGetPointer()->amPMTime)
+        {
+			if (Stime.Hours > 11)
+			{
+				timeSuffix = 'P';
+			}
+			else
+			{
+				timeSuffix = 'A';
+			}
+
+			if (Stime.Hours % 12 == 0)
+			{
+				hoursToDisplay = 12;
+			}
+			else
+			{
+				hoursToDisplay = (Stime.Hours % 12);
+			}
+
+			if(Stime.Seconds % 2)
+				textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d %cM",hoursToDisplay,Stime.Minutes,timeSuffix);
+			else
+				textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d %cM",hoursToDisplay,Stime.Minutes,timeSuffix);
+        }
         else
-            textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d",Stime.Hours,Stime.Minutes);
+        {
+        	if(Stime.Seconds % 2)
+        		textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d",Stime.Hours,Stime.Minutes);
+        	else
+        		textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d",Stime.Hours,Stime.Minutes);
+        }
+
         GFX_write_string(&FontT42, &t7cY0free, text, 2);
 
         // EAD / END
@@ -2267,6 +2333,8 @@
             TextR2[0] = '\031';
         if(textlength <= 9)
             GFX_write_string(&FontT105,&t7r2,TextR2,1);
+        else if(textlength <= 10)
+            GFX_write_string(&FontT84Spaced,&t7r2,TextR2,1);
         else
             GFX_write_string(&FontT54,&t7r2,TextR2,1);
     }