comparison Discovery/Src/t7.c @ 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 85bd5fea5e08
children 4a0ebade04f5
comparison
equal deleted inserted replaced
213:d539ed9aa5b8 214:51a3aeffc6b3
2170 if(pDecoinfo->output_time_to_surface_seconds) 2170 if(pDecoinfo->output_time_to_surface_seconds)
2171 { 2171 {
2172 snprintf(TextR3,TEXTSIZE,"\032\f\002%c",TXT_TTS); 2172 snprintf(TextR3,TEXTSIZE,"\032\f\002%c",TXT_TTS);
2173 GFX_write_string(&FontT42,&t7r3,TextR3,0); 2173 GFX_write_string(&FontT42,&t7r3,TextR3,0);
2174 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60) 2174 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60)
2175 snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 30)/ 60); 2175 snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
2176 else 2176 else
2177 snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_time_to_surface_seconds / 3600); 2177 snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
2178 t7_colorscheme_mod(TextR3); 2178 t7_colorscheme_mod(TextR3);
2179 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) 2179 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
2180 TextR2[0] = '\021'; 2180 TextR2[0] = '\021';
2181 GFX_write_string(&FontT105,&t7r3,TextR3,1); 2181 GFX_write_string(&FontT105,&t7r3,TextR3,1);
2182 } 2182 }
2562 break; 2562 break;
2563 2563
2564 /* Future TTS */ 2564 /* Future TTS */
2565 case 6: 2565 case 6:
2566 headerText[2] = TXT_FutureTTS; 2566 headerText[2] = TXT_FutureTTS;
2567 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, pDecoinfoFuture->output_time_to_surface_seconds / 60); 2567 if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60)
2568 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60);
2569 else
2570 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%ih TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600);
2568 tinyHeaderFont = 1; 2571 tinyHeaderFont = 1;
2569 line = 1; 2572 line = 1;
2570 break; 2573 break;
2571 2574
2572 /* CNS */ 2575 /* CNS */
3108 text[textpointer++] = '\t'; 3111 text[textpointer++] = '\t';
3109 textpointer += snprintf(&text[textpointer],10,"\020%.0f\016\016%%\017",fCNS); 3112 textpointer += snprintf(&text[textpointer],10,"\020%.0f\016\016%%\017",fCNS);
3110 text[textpointer++] = '\n'; 3113 text[textpointer++] = '\n';
3111 text[textpointer++] = '\r'; 3114 text[textpointer++] = '\r';
3112 text[textpointer++] = '\t'; 3115 text[textpointer++] = '\t';
3113 textpointer += snprintf(&text[textpointer],10,"\020%i'", pDecoinfoFuture->output_time_to_surface_seconds / 60); 3116 if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60)
3117 textpointer += snprintf(&text[textpointer],10,"\020%i'", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60);
3118 else
3119 textpointer += snprintf(&text[textpointer],10,"\020%ih", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600);
3114 text[textpointer++] = 0; 3120 text[textpointer++] = 0;
3115 t7_colorscheme_mod(text); 3121 t7_colorscheme_mod(text);
3116 GFX_write_string(&FontT42, &t7cY0free, text, 1); 3122 GFX_write_string(&FontT42, &t7cY0free, text, 1);
3117 } 3123 }
3118 3124