Mercurial > public > ostc4
comparison 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 |
comparison
equal
deleted
inserted
replaced
188:ddc21166d25b | 189:8b8074080d7b |
---|---|
50 GFX_DrawCfgWindow t3l1; | 50 GFX_DrawCfgWindow t3l1; |
51 GFX_DrawCfgWindow t3r1; | 51 GFX_DrawCfgWindow t3r1; |
52 GFX_DrawCfgWindow t3c1; | 52 GFX_DrawCfgWindow t3c1; |
53 GFX_DrawCfgWindow t3c2; | 53 GFX_DrawCfgWindow t3c2; |
54 | 54 |
55 extern float temperatureLastCall[3]; | |
56 extern uint8_t idTemperatureLastCall; | |
57 | |
58 uint8_t t3_selection_customview = 0; | 55 uint8_t t3_selection_customview = 0; |
59 | 56 |
60 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/ | 57 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/ |
61 | 58 |
62 /* Private types -------------------------------------------------------------*/ | 59 /* Private types -------------------------------------------------------------*/ |
505 { | 502 { |
506 char text[512]; | 503 char text[512]; |
507 uint16_t textpointer = 0; | 504 uint16_t textpointer = 0; |
508 | 505 |
509 // CVIEW_T3_Temperature | 506 // CVIEW_T3_Temperature |
510 float temperatureThisCall; | |
511 float temperature; | 507 float temperature; |
512 | 508 |
513 SDivetime TotalDivetime = {0,0,0,0}; | 509 SDivetime TotalDivetime = {0,0,0,0}; |
514 SDivetime LastDivetime = {0,0,0,0}; | 510 SDivetime LastDivetime = {0,0,0,0}; |
515 | 511 |
525 { | 521 { |
526 case CVIEW_T3_Temperature: | 522 case CVIEW_T3_Temperature: |
527 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); | 523 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); |
528 GFX_write_string(&FontT42,tXc1,text,0); | 524 GFX_write_string(&FontT42,tXc1,text,0); |
529 | 525 |
530 // mean value | 526 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); |
531 temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); | |
532 temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; | |
533 idTemperatureLastCall++; | |
534 if(idTemperatureLastCall >= 3) | |
535 idTemperatureLastCall = 0; | |
536 temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; | |
537 textpointer = snprintf(text,TEXTSIZE,"\020\003\016%01.0f\016\016\140",temperature); // "\016\016%01.1f `" + C or F | 527 textpointer = snprintf(text,TEXTSIZE,"\020\003\016%01.0f\016\016\140",temperature); // "\016\016%01.1f `" + C or F |
538 if(settingsGetPointer()->nonMetricalSystem == 0) | 528 if(settingsGetPointer()->nonMetricalSystem == 0) |
539 text[textpointer++] = 'C'; | 529 text[textpointer++] = 'C'; |
540 else | 530 else |
541 text[textpointer++] = 'F'; | 531 text[textpointer++] = 'F'; |
604 | 594 |
605 // CVIEW_T3_ppO2andGas | 595 // CVIEW_T3_ppO2andGas |
606 uint8_t oxygen_percentage = 0; | 596 uint8_t oxygen_percentage = 0; |
607 | 597 |
608 // CVIEW_T3_Temperature | 598 // CVIEW_T3_Temperature |
609 float temperatureThisCall; | |
610 float temperature; | 599 float temperature; |
611 | 600 |
612 // CVIEW_T3_GasList | 601 // CVIEW_T3_GasList |
613 float fPpO2limitHigh, fPpO2limitLow, fPpO2ofGasAtThisDepth; | 602 float fPpO2limitHigh, fPpO2limitLow, fPpO2ofGasAtThisDepth; |
614 const SGasLine * pGasLine; | 603 const SGasLine * pGasLine; |
616 uint8_t lineNumber; | 605 uint8_t lineNumber; |
617 | 606 |
618 // CVIEW_T3_StopWatch | 607 // CVIEW_T3_StopWatch |
619 SDivetime Stopwatch = {0,0,0,0}; | 608 SDivetime Stopwatch = {0,0,0,0}; |
620 float fAverageDepth, fAverageDepthAbsolute; | 609 float fAverageDepth, fAverageDepthAbsolute; |
621 | |
622 | 610 |
623 uint16_t tempWinX0; | 611 uint16_t tempWinX0; |
624 uint16_t tempWinX1; | 612 uint16_t tempWinX1; |
625 uint16_t tempWinY0; | 613 uint16_t tempWinY0; |
626 uint16_t tempWinY1; | 614 uint16_t tempWinY1; |
747 break; | 735 break; |
748 | 736 |
749 case CVIEW_T3_Temperature: | 737 case CVIEW_T3_Temperature: |
750 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); | 738 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); |
751 GFX_write_string(&FontT42,tXc1,text,0); | 739 GFX_write_string(&FontT42,tXc1,text,0); |
752 // mean value | 740 |
753 temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); | 741 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); |
754 temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; | |
755 idTemperatureLastCall++; | |
756 if(idTemperatureLastCall >= 3) | |
757 idTemperatureLastCall = 0; | |
758 temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; | |
759 textpointer = snprintf(text,TEXTSIZE,"\030\003\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F | 742 textpointer = snprintf(text,TEXTSIZE,"\030\003\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F |
760 if(settingsGetPointer()->nonMetricalSystem == 0) | 743 if(settingsGetPointer()->nonMetricalSystem == 0) |
761 text[textpointer++] = 'C'; | 744 text[textpointer++] = 'C'; |
762 else | 745 else |
763 text[textpointer++] = 'F'; | 746 text[textpointer++] = 'F'; |