changeset 214:51a3aeffc6b3 edit-fix

Bugfix: handle rounding of TTS and future TTS consistently There was a bug with futureTTS with an extended bottom time of 0 minutes (so same TTS and the main schedule) being not in sync with each other. This was simply caused by inconsistent rounding of seconds to minute conversions. And when fixing this, I noticed also inconsistent handling of huge 1000+ minutes TTS values. At some places, the presentation changed to hours notation, and other places not. I doubt that any OSTC4 user ever made a dive that had more than 1000 minutes of deco, but fixed this presentation as well, simply because of consistency. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Thu, 28 Mar 2019 08:26:17 +0100
parents d539ed9aa5b8
children 4a0ebade04f5
files Discovery/Src/t3.c Discovery/Src/t7.c
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/t3.c	Wed Mar 27 15:12:26 2019 +0100
+++ b/Discovery/Src/t3.c	Thu Mar 28 08:26:17 2019 +0100
@@ -855,9 +855,9 @@
         if(pDecoinfo->output_time_to_surface_seconds)
         {
             if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60)
-                snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 30)/ 60);
+                snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
             else
-                snprintf(text,TEXTSIZE,"\020\003\002%ih",pDecoinfo->output_time_to_surface_seconds / 3600);
+                snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
             t3_basics_colorscheme_mod(text);
             GFX_write_string(&FontT105,tXc1,text,1);
         }
--- a/Discovery/Src/t7.c	Wed Mar 27 15:12:26 2019 +0100
+++ b/Discovery/Src/t7.c	Thu Mar 28 08:26:17 2019 +0100
@@ -2172,9 +2172,9 @@
         snprintf(TextR3,TEXTSIZE,"\032\f\002%c",TXT_TTS);
         GFX_write_string(&FontT42,&t7r3,TextR3,0);
         if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60)
-            snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 30)/ 60);
+            snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
         else
-            snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_time_to_surface_seconds / 3600);
+            snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
         t7_colorscheme_mod(TextR3);
         if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
             TextR2[0] = '\021';
@@ -2564,7 +2564,10 @@
     /* Future TTS */
     case 6:
         headerText[2] = TXT_FutureTTS;
-        snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, pDecoinfoFuture->output_time_to_surface_seconds / 60);
+        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);
+        else
+        	snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%ih TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600);
         tinyHeaderFont = 1;
         line = 1;
         break;
@@ -3110,7 +3113,10 @@
     text[textpointer++] = '\n';
     text[textpointer++] = '\r';
     text[textpointer++] = '\t';
-    textpointer += snprintf(&text[textpointer],10,"\020%i'",		pDecoinfoFuture->output_time_to_surface_seconds / 60);
+    if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60)
+    	textpointer += snprintf(&text[textpointer],10,"\020%i'", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60);
+    else
+    	textpointer += snprintf(&text[textpointer],10,"\020%ih", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600);
     text[textpointer++] = 0;
     t7_colorscheme_mod(text);
     GFX_write_string(&FontT42, &t7cY0free, text, 1);