comparison Discovery/Src/t7.c @ 336:449e9e9632e4 PressureMeasure_Improvment

Show actual instead of surface (30minute old) pressure if the actual differs significant (e.g. in plane or during pressure testing)
author ideenmodellierer
date Sat, 17 Aug 2019 18:44:43 +0200
parents 7420ed6c3508
children 84f5c18b74ea 75eedde05ff6
comparison
equal deleted inserted replaced
335:c11ce8c885d3 336:449e9e9632e4
156 #define CUSTOMBOX_INSIDE_OFFSET (2) 156 #define CUSTOMBOX_INSIDE_OFFSET (2)
157 #define CUSTOMBOX_OUTSIDE_OFFSET (2) 157 #define CUSTOMBOX_OUTSIDE_OFFSET (2)
158 #define CUSTOMBOX_SPACE_INSIDE (CUSTOMBOX_LINE_RIGHT + 1 - (CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_INSIDE_OFFSET)) 158 #define CUSTOMBOX_SPACE_INSIDE (CUSTOMBOX_LINE_RIGHT + 1 - (CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_INSIDE_OFFSET))
159 #define TOP_LINE_HIGHT (25) 159 #define TOP_LINE_HIGHT (25)
160 160
161 #define SHOW_AMBIENTE_SURFACE_DELTA (0.02f)
162 #define SHOW_AMBIENTE_DEBOUNCE (0.003f)
163
161 /* Exported functions --------------------------------------------------------*/ 164 /* Exported functions --------------------------------------------------------*/
162 165
163 void t7_init(void) 166 void t7_init(void)
164 { 167 {
165 168
659 Gfx_write_label_var(&t7screen, 300,800, ytop,&FontT48,CLUT_Font020,"Shutting down..."); 662 Gfx_write_label_var(&t7screen, 300,800, ytop,&FontT48,CLUT_Font020,"Shutting down...");
660 } 663 }
661 664
662 void t7_refresh_surface(void) 665 void t7_refresh_surface(void)
663 { 666 {
667 static float debounceAmbientPressure = 0;
664 char text[256]; 668 char text[256];
665 uint8_t date[3], year,month,day; 669 uint8_t date[3], year,month,day;
666 uint32_t color; 670 uint32_t color;
667 uint8_t customview_warnings = 0; 671 uint8_t customview_warnings = 0;
668 672
903 } 907 }
904 908
905 /* surface pressure and temperature */ 909 /* surface pressure and temperature */
906 if(stateUsed->sensorErrorsRTE == 0) 910 if(stateUsed->sensorErrorsRTE == 0)
907 { 911 {
908 snprintf(text,30,"%01.0f\022\016\016 %s", stateUsed->lifeData.pressure_surface_bar * 1000.0f,TEXT_PRESSURE_UNIT); 912 if(fabs(stateUsed->lifeData.pressure_surface_bar - stateUsed->lifeData.pressure_ambient_bar) < SHOW_AMBIENTE_SURFACE_DELTA) /* show ambient pressure if difference to surface is significant*/
913 {
914 snprintf(text,30,"%01.0f\022\016\016 %s", stateUsed->lifeData.pressure_surface_bar * 1000.0f,TEXT_PRESSURE_UNIT);
915 }
916 else
917 {
918 if(fabsf(debounceAmbientPressure - stateUsed->lifeData.pressure_ambient_bar) > SHOW_AMBIENTE_DEBOUNCE) /* there might be a jitter ~+-1 HPa on the pressure signal => update only if delta is bigger */
919 {
920 debounceAmbientPressure = stateUsed->lifeData.pressure_ambient_bar;
921 }
922 snprintf(text,30,"%01.0f\022\016\016 %s", debounceAmbientPressure * 1000.0f,TEXT_PRESSURE_UNIT);
923 }
924
909 GFX_write_string(&FontT48,&t7surfaceL,text,3); 925 GFX_write_string(&FontT48,&t7surfaceL,text,3);
910 926
911 if(settingsGetPointer()->nonMetricalSystem) 927 if(settingsGetPointer()->nonMetricalSystem)
912 snprintf(text,40,"%01.0f\140\022\016\016 fahrenheit",unit_temperature_float(stateUsed->lifeData.temperature_celsius)); 928 snprintf(text,40,"%01.0f\140\022\016\016 fahrenheit",unit_temperature_float(stateUsed->lifeData.temperature_celsius));
913 else 929 else
1221 Gfx_write_label_var(&t7screen, 500,800, 45,&FontT48,CLUT_Font020,TextL1); 1237 Gfx_write_label_var(&t7screen, 500,800, 45,&FontT48,CLUT_Font020,TextL1);
1222 } 1238 }
1223 else 1239 else
1224 if(DataEX_lost_connection_count()) 1240 if(DataEX_lost_connection_count())
1225 { 1241 {
1226 snprintf(TextL1,TEXTSIZE,"\002%i",DataEX_lost_connection_count()); 1242 snprintf(TextL1,TEXTSIZE,"\002%ld",DataEX_lost_connection_count());
1227 Gfx_write_label_var(&t7screen, 600,800, 45,&FontT48,CLUT_Font020,TextL1); 1243 Gfx_write_label_var(&t7screen, 600,800, 45,&FontT48,CLUT_Font020,TextL1);
1228 } 1244 }
1229 1245
1230 snprintf(TextL1,TEXTSIZE,"\002%i",blockedFramesCount()); 1246 snprintf(TextL1,TEXTSIZE,"\002%i",blockedFramesCount());
1231 Gfx_write_label_var(&t7screen, 600,800, 0,&FontT48,CLUT_Font020,TextL1); 1247 Gfx_write_label_var(&t7screen, 600,800, 0,&FontT48,CLUT_Font020,TextL1);
1286 Gfx_write_label_var(&t7screen, 660,800,200,&Batt24,color,TextL1); 1302 Gfx_write_label_var(&t7screen, 660,800,200,&Batt24,color,TextL1);
1287 } 1303 }
1288 1304
1289 extern uint32_t base_tempLightLevel; 1305 extern uint32_t base_tempLightLevel;
1290 1306
1291 snprintf(TextL1,TEXTSIZE,"# %u (%u)",stateUsed->lifeData.ambient_light_level, base_tempLightLevel); 1307 snprintf(TextL1,TEXTSIZE,"# %u (%ld)",stateUsed->lifeData.ambient_light_level, base_tempLightLevel);
1292 Gfx_write_label_var(&t7screen, 401,600,310,&FontT42,CLUT_DiveMainLabel,"Light"); 1308 Gfx_write_label_var(&t7screen, 401,600,310,&FontT42,CLUT_DiveMainLabel,"Light");
1293 Gfx_write_label_var(&t7screen, 401,800,355,&FontT48,CLUT_Font020,TextL1); 1309 Gfx_write_label_var(&t7screen, 401,800,355,&FontT48,CLUT_Font020,TextL1);
1294 1310
1295 // snprintf(TextL1,TEXTSIZE,"# %u",stateUsed->lifeData.ambient_light_level); 1311 // snprintf(TextL1,TEXTSIZE,"# %u",stateUsed->lifeData.ambient_light_level);
1296 // Gfx_write_label_var(&t7screen, 601,800,310,&FontT42,CLUT_DiveMainLabel,"Light"); 1312 // Gfx_write_label_var(&t7screen, 601,800,310,&FontT42,CLUT_DiveMainLabel,"Light");