comparison Discovery/Src/t7.c @ 984:41136649b90d GasConsumption

Improvment temperature measurent: In the previous verion no plausibility check for over temperature values was done. In addition the temperature display switches fast between e.g. 24 and 25 in case the value is 24.9 because of measurement tolerances. To avoid this a hysterese was added to the display function.
author Ideenmodellierer
date Sat, 29 Mar 2025 14:56:08 +0100 (4 weeks ago)
parents 7149f372b0ba
children d9290c76b840
comparison
equal deleted inserted replaced
983:7891160acde3 984:41136649b90d
169 #define CUSTOMBOX_SPACE_INSIDE (CUSTOMBOX_LINE_RIGHT + 1 - (CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_INSIDE_OFFSET)) 169 #define CUSTOMBOX_SPACE_INSIDE (CUSTOMBOX_LINE_RIGHT + 1 - (CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_INSIDE_OFFSET))
170 #define TOP_LINE_HIGHT (25) 170 #define TOP_LINE_HIGHT (25)
171 171
172 #define SHOW_AMBIENTE_SURFACE_DELTA (0.02f) 172 #define SHOW_AMBIENTE_SURFACE_DELTA (0.02f)
173 #define SHOW_AMBIENTE_DEBOUNCE (0.003f) 173 #define SHOW_AMBIENTE_DEBOUNCE (0.003f)
174 #define SHOW_TEMPERATURE_DEBOUNCE (0.5f)
174 175
175 #define MAX_NUM_SUMMARY_LINES 6 176 #define MAX_NUM_SUMMARY_LINES 6
176 177
177 /* Exported functions --------------------------------------------------------*/ 178 /* Exported functions --------------------------------------------------------*/
178 179
701 702
702 void t7_refresh_surface(void) 703 void t7_refresh_surface(void)
703 { 704 {
704 static float debounceAmbientPressure = 0; 705 static float debounceAmbientPressure = 0;
705 static uint8_t lastChargeStatus = 0; 706 static uint8_t lastChargeStatus = 0;
707 static float lastTemperature = 100.0;
706 char text[256]; 708 char text[256];
707 char timeSuffix; 709 char timeSuffix;
708 uint8_t hours; 710 uint8_t hours;
709 uint8_t loop, textIdx; 711 uint8_t loop, textIdx;
710 uint8_t date[3], year,month,day; 712 uint8_t date[3], year,month,day;
1024 snprintf(text,30,"%01.0f\022\016\016 %s", debounceAmbientPressure * 1000.0f,TEXT_PRESSURE_UNIT); 1026 snprintf(text,30,"%01.0f\022\016\016 %s", debounceAmbientPressure * 1000.0f,TEXT_PRESSURE_UNIT);
1025 } 1027 }
1026 1028
1027 GFX_write_string(&FontT48,&t7surfaceL,text,3); 1029 GFX_write_string(&FontT48,&t7surfaceL,text,3);
1028 1030
1031 if(fabsf(stateUsed->lifeData.temperature_celsius - lastTemperature) > SHOW_TEMPERATURE_DEBOUNCE)
1032 {
1033 lastTemperature = stateUsed->lifeData.temperature_celsius;
1034 }
1029 if(settingsGetPointer()->nonMetricalSystem) 1035 if(settingsGetPointer()->nonMetricalSystem)
1030 snprintf(text,40,"%01.0f\140\022\016\016 fahrenheit",unit_temperature_float(stateUsed->lifeData.temperature_celsius)); 1036 snprintf(text,40,"%01.0f\140\022\016\016 fahrenheit",unit_temperature_float(lastTemperature));
1031 else 1037 else
1032 snprintf(text,30,"%01.0f\140\022\016\016 celsius",stateUsed->lifeData.temperature_celsius); 1038 snprintf(text,30,"%01.0f\140\022\016\016 celsius",lastTemperature);
1033 GFX_write_string(&FontT48,&t7surfaceL,text,4); 1039 GFX_write_string(&FontT48,&t7surfaceL,text,4);
1034 } 1040 }
1035 else 1041 else
1036 { 1042 {
1037 snprintf(text,30,"ERR\022\016\016 %s",TEXT_PRESSURE_UNIT); 1043 snprintf(text,30,"ERR\022\016\016 %s",TEXT_PRESSURE_UNIT);