Mercurial > public > ostc4
comparison Discovery/Src/t7.c @ 190:cca59de24fe0
Merged in janlmulder/ostc4/avg-temp (pull request #6)
Bugfix: average temperature on arrival from RTE instead of display time
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Fri, 15 Mar 2019 15:48:53 +0000 |
parents | 8b8074080d7b |
children | 255326edf00b |
comparison
equal
deleted
inserted
replaced
188:ddc21166d25b | 190:cca59de24fe0 |
---|---|
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 |