diff Discovery/Src/t3.c @ 189:8b8074080d7b avg-temp

Bugfix: average temperature on arrival from RTE instead of display time This commit is heavily inspired by commits 05c770dc2911 and ecb71521d004. Reading the code, it was clear that a display time averaging process for measured temperature was implemented as was fixed for current depth display in the two mentioned commits. The bug for the late averaging of the temperature is, obviously, not as prominent as the current depth fault. The bug fixed here was nothing more than a visual glitch when first selecting the temperature display in the lower left corner (by default at the start of the dive, or by manually selecting it during the dive using the left button). So, to summarize. A small visual glitch fix, but more important, more consistent data handling and code. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Fri, 15 Mar 2019 15:04:57 +0100
parents ecb71521d004
children 51a3aeffc6b3
line wrap: on
line diff
--- a/Discovery/Src/t3.c	Fri Mar 15 12:55:58 2019 +0000
+++ b/Discovery/Src/t3.c	Fri Mar 15 15:04:57 2019 +0100
@@ -52,9 +52,6 @@
 GFX_DrawCfgWindow	t3c1;
 GFX_DrawCfgWindow	t3c2;
 
-extern float temperatureLastCall[3];
-extern uint8_t idTemperatureLastCall;
-
 uint8_t t3_selection_customview = 0;
 
 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/
@@ -507,7 +504,6 @@
     uint16_t textpointer = 0;
 
     // CVIEW_T3_Temperature
-    float temperatureThisCall;
     float temperature;
 
     SDivetime TotalDivetime = {0,0,0,0};
@@ -527,13 +523,7 @@
         snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature);
         GFX_write_string(&FontT42,tXc1,text,0);
 
-        // mean value
-        temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
-        temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f;
-        idTemperatureLastCall++;
-        if(idTemperatureLastCall >= 3)
-            idTemperatureLastCall = 0;
-        temperatureLastCall[idTemperatureLastCall] = temperatureThisCall;
+        temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
         textpointer = snprintf(text,TEXTSIZE,"\020\003\016%01.0f\016\016\140",temperature); // "\016\016%01.1f `" + C or F
         if(settingsGetPointer()->nonMetricalSystem == 0)
             text[textpointer++] = 'C';
@@ -606,7 +596,6 @@
     uint8_t oxygen_percentage = 0;
 
     // CVIEW_T3_Temperature
-    float temperatureThisCall;
     float temperature;
 
     // CVIEW_T3_GasList
@@ -619,7 +608,6 @@
     SDivetime Stopwatch = {0,0,0,0};
     float fAverageDepth, fAverageDepthAbsolute;
 
-
     uint16_t tempWinX0;
     uint16_t tempWinX1;
     uint16_t tempWinY0;
@@ -749,13 +737,8 @@
     case CVIEW_T3_Temperature:
         snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature);
         GFX_write_string(&FontT42,tXc1,text,0);
-        // mean value
-        temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
-        temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f;
-        idTemperatureLastCall++;
-        if(idTemperatureLastCall >= 3)
-            idTemperatureLastCall = 0;
-        temperatureLastCall[idTemperatureLastCall] = temperatureThisCall;
+
+        temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
         textpointer = snprintf(text,TEXTSIZE,"\030\003\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F
         if(settingsGetPointer()->nonMetricalSystem == 0)
             text[textpointer++] = 'C';