diff Discovery/Src/t7.c @ 196:2885628ab3ba div-fixes-cleaup-2

Bugfix, minor: color the overview customview correctly When using a custom color (from the SYS2 menu, layout), the overview customview was the only one presented in the wrong color. While the fix for this is rather simple (in hindsight), it was a non trivial search trough rather obfuscated code. There is a specific function to set the text color index on this page, but this only worked for a single line text string, that has the color index byte as the very first character. The original author already recognized that this function "could be extended", but left this extension as an exercise to the reader. So, the coloring is fixed by extending the function, and actually using it for the overview customview. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Wed, 20 Mar 2019 16:24:10 +0100
parents 255326edf00b
children 878dc9e0dbc5
line wrap: on
line diff
--- a/Discovery/Src/t7.c	Tue Mar 19 15:43:38 2019 +0000
+++ b/Discovery/Src/t7.c	Wed Mar 20 16:24:10 2019 +0100
@@ -58,7 +58,7 @@
 void t7_miniLiveLogProfile(void);
 //void t7_clock(void);
 void t7_logo_OSTC(void);
-void t7_colorscheme_mod(char *text);
+static void t7_colorscheme_mod(char *text);
 
 uint8_t t7_test_customview_warnings(void);
 void t7_show_customview_warnings(void);
@@ -2639,14 +2639,13 @@
     return lineCount;
 }
 
-/* could be extended to search for \020 inside
- */
-void t7_colorscheme_mod(char *text)
-{
-    if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard())
-    {
-        text[0] = '\027';
-    }
+static void t7_colorscheme_mod(char *text) {
+	char *p = text;
+	while (*p) {
+		if ((*p == '\020') && !GFX_is_colorschemeDiveStandard())
+			*p = '\027';
+		p++;
+	}
 }
 
 
@@ -3106,6 +3105,7 @@
     text[textpointer++] = '\t';
     textpointer += snprintf(&text[textpointer],10,"\020%i'",		pDecoinfoFuture->output_time_to_surface_seconds / 60);
     text[textpointer++] = 0;
+    t7_colorscheme_mod(text);
     GFX_write_string(&FontT42, &t7cY0free, text, 1);
 }