diff Discovery/Src/show_logbook.c @ 653:269e57ac4e56

Bugfix temperature display Logpage2: Temperature was shown in Centidegrees (Fahrenheit as well as Celsius). Root cause was that conversion was done via character cutting (string: removal of last digit). This has been replaced by a factor 10 devision.
author Ideenmodellierer
date Sun, 25 Apr 2021 20:36:18 +0200
parents 2586f7b734f4
children 1b995079c045
line wrap: on
line diff
--- a/Discovery/Src/show_logbook.c	Mon Apr 19 20:34:53 2021 +0200
+++ b/Discovery/Src/show_logbook.c	Sun Apr 25 20:36:18 2021 +0200
@@ -774,6 +774,7 @@
     int newBottom = 0;
     uint16_t step = 0;
     int16_t maxValTop = 0;
+    int16_t tmp = 0;
 
     scaleHelper(dataLength, tempdata, wintemp.top, wintemp.bottom,
                             &minVal, &maxVal, &newTop, &newBottom,
@@ -786,25 +787,18 @@
     // temperature in 1/10 �C
     int deltaline = (1 + wintemp.bottom - wintemp.top)/5;
     char msg[15];
-    int tmp = maxValTop;
-    int converted;
+
+    /* temperature is provided in centi scaling => convert */
+    maxValTop /= 10;
+    step /= 10;
+
+    tmp = maxValTop;
     for(int i = 1; i<=5; i++)
     {
         tmp -= 	step;
-        if(settingsGetPointer()->nonMetricalSystem) {
-        	converted = unit_temperature_integer(tmp);
-        }
-        else{
-        	converted = tmp;
-        }
-        //if(tmp < 0)
-            //break;
         winsmal.top	= wintemp.top + deltaline * i - 14;
         winsmal.bottom = winsmal.top + 16;
-        if((converted >= 0) && (converted < 100))
-            snprintf(msg,15,"%1i",converted);
-        else
-            snprintf(msg,15,"%2i",converted);
+        snprintf(msg,15,"%2i",unit_temperature_integer(tmp));
         Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_LogbookTemperature,msg);
     }