comparison Discovery/Src/t7.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 485c5135cf7f
children 255326edf00b
comparison
equal deleted inserted replaced
188:ddc21166d25b 189:8b8074080d7b
72 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); 72 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium);
73 73
74 /* Exported variables --------------------------------------------------------*/ 74 /* Exported variables --------------------------------------------------------*/
75 75
76 /* Private variables ---------------------------------------------------------*/ 76 /* Private variables ---------------------------------------------------------*/
77 float temperatureLastCall[3] = { 0,0,0};
78 uint8_t idTemperatureLastCall = 0;
79 77
80 GFX_DrawCfgScreen t7screen; 78 GFX_DrawCfgScreen t7screen;
81 GFX_DrawCfgScreen t7screenCompass; 79 GFX_DrawCfgScreen t7screenCompass;
82 80
83 /* left 3 fields 81 /* left 3 fields
2470 SDivetime Stopwatch = {0,0,0,0}; 2468 SDivetime Stopwatch = {0,0,0,0};
2471 float fAverageDepth, fAverageDepthAbsolute; 2469 float fAverageDepth, fAverageDepthAbsolute;
2472 const SDecoinfo * pDecoinfoStandard; 2470 const SDecoinfo * pDecoinfoStandard;
2473 const SDecoinfo * pDecoinfoFuture; 2471 const SDecoinfo * pDecoinfoFuture;
2474 float fCNS; 2472 float fCNS;
2475
2476 float temperatureThisCall;
2477 float temperature; 2473 float temperature;
2478 2474
2479 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) 2475 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE)
2480 { 2476 {
2481 pDecoinfoStandard = &stateUsed->decolistBuehlmann; 2477 pDecoinfoStandard = &stateUsed->decolistBuehlmann;
2499 switch(selection_custom_field) 2495 switch(selection_custom_field)
2500 { 2496 {
2501 /* Temperature */ 2497 /* Temperature */
2502 case 1: 2498 case 1:
2503 default: 2499 default:
2504 // mean value 2500 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
2505 temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
2506 temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f;
2507 idTemperatureLastCall++;
2508 if(idTemperatureLastCall >= 3)
2509 idTemperatureLastCall = 0;
2510 temperatureLastCall[idTemperatureLastCall] = temperatureThisCall;
2511 // output
2512 headerText[2] = TXT_Temperature; 2501 headerText[2] = TXT_Temperature;
2513 textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F 2502 textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F
2514 if(settingsGetPointer()->nonMetricalSystem == 0) 2503 if(settingsGetPointer()->nonMetricalSystem == 0)
2515 text[textpointer++] = 'C'; 2504 text[textpointer++] = 'C';
2516 else 2505 else