comparison Discovery/Src/t3.c @ 868:db92692c014f Evo_2_23

Introduce speed dependend coloring of depth: The depth value in the will now be colored based on the current ascent speed. The color code matches the one of the bar graph which was already used for visualization of the ascent speed. To keep color code consistent the existing color selection functions have been merged to one common Gfx function (T3/T7 - bar graph and color text)
author Ideenmodellierer
date Mon, 12 Aug 2024 15:14:19 +0200
parents ba1aebc6d5af
children 4d98fb2a178e
comparison
equal deleted inserted replaced
867:3311b720a072 868:db92692c014f
40 #include "timer.h" 40 #include "timer.h"
41 #include "unit.h" 41 #include "unit.h"
42 #include "motion.h" 42 #include "motion.h"
43 #include "logbook_miniLive.h" 43 #include "logbook_miniLive.h"
44 #include "tMenuEditCustom.h" 44 #include "tMenuEditCustom.h"
45 #include "gfx_engine.h"
45 46
46 47
47 #define CV_PROFILE_WIDTH (600U) 48 #define CV_PROFILE_WIDTH (600U)
48 49
49 //* Imported function prototypes ---------------------------------------------*/ 50 //* Imported function prototypes ---------------------------------------------*/
408 else 409 else
409 { 410 {
410 GFX_draw_line(tXscreen, start, stop, CLUT_Font020); 411 GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
411 } 412 }
412 413
413
414 start.y = BigFontSeperationTopBottom; 414 start.y = BigFontSeperationTopBottom;
415 stop.y = 479; 415 stop.y = 479;
416 416
417 stop.x = start.x = BigFontSeperationLeftRight; 417 stop.x = start.x = BigFontSeperationLeftRight;
418 if((viewInFocus() && (!viewDetectionSuspended()))) 418 if((viewInFocus() && (!viewDetectionSuspended())))
423 { 423 {
424 GFX_draw_line(tXscreen, start, stop, CLUT_Font020); 424 GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
425 } 425 }
426 426
427 /* depth */ 427 /* depth */
428 color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min);
428 float depth = unit_depth_float(stateUsed->lifeData.depth_meter); 429 float depth = unit_depth_float(stateUsed->lifeData.depth_meter);
429 430
430 if(depth <= 0.3f) 431 if(depth <= 0.3f)
431 depth = 0; 432 depth = 0;
432 433
451 if( depth < 100) 452 if( depth < 100)
452 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth); 453 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth);
453 else 454 else
454 snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); 455 snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth);
455 456
456 t3_basics_colorscheme_mod(text); 457 Gfx_colorsscheme_mod(text,color);
457 GFX_write_string(&FontT105,tXl1,text,1); 458 GFX_write_string(&FontT105,tXl1,text,1);
458 459
459 460
460 /* ascentrate graph */ 461 /* ascentrate graph */
461 if(mode == DIVEMODE_Apnea) 462 if(mode == DIVEMODE_Apnea)
646 if(Divetime.Minutes < 100) 647 if(Divetime.Minutes < 100)
647 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds); 648 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
648 else 649 else
649 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes); 650 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes);
650 } 651 }
651 t3_basics_colorscheme_mod(text); 652 Gfx_colorsscheme_mod(text,0);
652 GFX_write_string(&FontT105,tXr1,text,1); 653 GFX_write_string(&FontT105,tXr1,text,1);
653 } 654 }
654 else 655 else
655 { 656 {
656 switch(get_globalState()) 657 switch(get_globalState())
717 if(Divetime.Minutes < 100) 718 if(Divetime.Minutes < 100)
718 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds); 719 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
719 else 720 else
720 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes); 721 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes);
721 722
722 t3_basics_colorscheme_mod(text); 723 Gfx_colorsscheme_mod(text,0);
723 GFX_write_string(&FontT105,tXr1,text,1); 724 GFX_write_string(&FontT105,tXr1,text,1);
724 break; 725 break;
725 } 726 }
726 } 727 }
727 728
822 if(settingsGetPointer()->nonMetricalSystem == 0) 823 if(settingsGetPointer()->nonMetricalSystem == 0)
823 text[textpointer++] = 'C'; 824 text[textpointer++] = 'C';
824 else 825 else
825 text[textpointer++] = 'F'; 826 text[textpointer++] = 'F';
826 text[textpointer++] = 0; 827 text[textpointer++] = 0;
827 t3_basics_colorscheme_mod(text); 828 Gfx_colorsscheme_mod(text,0);
828 GFX_write_string(&FontT105,tXc1,text,1); 829 GFX_write_string(&FontT105,tXc1,text,1);
829 break; 830 break;
830 831
831 case CVIEW_T3_ApnoeSurfaceInfo: 832 case CVIEW_T3_ApnoeSurfaceInfo:
832 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime); 833 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime);
849 { 850 {
850 tXc1->WindowY1 -= 100; /* jump to upper of two lines */ 851 tXc1->WindowY1 -= 100; /* jump to upper of two lines */
851 } 852 }
852 853
853 snprintf(text,TEXTSIZE,"\020\016%u:%02u",LastDivetime.Minutes, LastDivetime.Seconds); 854 snprintf(text,TEXTSIZE,"\020\016%u:%02u",LastDivetime.Minutes, LastDivetime.Seconds);
854 t3_basics_colorscheme_mod(text); 855 Gfx_colorsscheme_mod(text,0);
855 GFX_write_string(&FontT105,tXc1,text,0); 856 GFX_write_string(&FontT105,tXc1,text,0);
856 857
857 if(pSettings->FlipDisplay) 858 if(pSettings->FlipDisplay)
858 { 859 {
859 tXc1->WindowX0 = 0; 860 tXc1->WindowX0 = 0;
871 tXc1->WindowX1 = tempWinX1; 872 tXc1->WindowX1 = tempWinX1;
872 tXc1->WindowY1 = tempWinY1; /* jump to upper of two lines */ 873 tXc1->WindowY1 = tempWinY1; /* jump to upper of two lines */
873 } 874 }
874 875
875 snprintf(text,TEXTSIZE,"\020\016%u:%02u",TotalDivetime.Minutes, TotalDivetime.Seconds); 876 snprintf(text,TEXTSIZE,"\020\016%u:%02u",TotalDivetime.Minutes, TotalDivetime.Seconds);
876 t3_basics_colorscheme_mod(text); 877 Gfx_colorsscheme_mod(text,0);
877 GFX_write_string(&FontT105,tXc1,text,0); 878 GFX_write_string(&FontT105,tXc1,text,0);
878 879
879 snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaTotal); 880 snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaTotal);
880 if(pSettings->FlipDisplay) 881 if(pSettings->FlipDisplay)
881 { 882 {
988 GFX_write_string(&FontT42,tXc2,text,0); 989 GFX_write_string(&FontT42,tXc2,text,0);
989 tXc2->WindowY1 -= 100; /* jump to upper of two lines */ 990 tXc2->WindowY1 -= 100; /* jump to upper of two lines */
990 } 991 }
991 992
992 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_last_max_depth_meter)); 993 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_last_max_depth_meter));
993 t3_basics_colorscheme_mod(text); 994 Gfx_colorsscheme_mod(text,0);
994 995
995 if(!pSettings->FlipDisplay) 996 if(!pSettings->FlipDisplay)
996 { 997 {
997 GFX_write_string(&FontT105,tXc1,text,0); 998 GFX_write_string(&FontT105,tXc1,text,0);
998 tXc1->WindowY0 = tempWinY0; 999 tXc1->WindowY0 = tempWinY0;
1003 tXc2->WindowY1 = tempWinC2Y1; /* jump to upper of two lines */ 1004 tXc2->WindowY1 = tempWinC2Y1; /* jump to upper of two lines */
1004 } 1005 }
1005 1006
1006 1007
1007 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_total_max_depth_meter)); 1008 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_total_max_depth_meter));
1008 t3_basics_colorscheme_mod(text); 1009 Gfx_colorsscheme_mod(text,0);
1009 if(!pSettings->FlipDisplay) 1010 if(!pSettings->FlipDisplay)
1010 { 1011 {
1011 GFX_write_string(&FontT105,tXc1,text,0); 1012 GFX_write_string(&FontT105,tXc1,text,0);
1012 } 1013 }
1013 else 1014 else
1193 snprintf(&text[textpointer],TEXTSIZE,"\020\003%u%c%c %u'" 1194 snprintf(&text[textpointer],TEXTSIZE,"\020\003%u%c%c %u'"
1194 , unit_depth_integer(nextstopDepthMeter) 1195 , unit_depth_integer(nextstopDepthMeter)
1195 , unit_depth_char1_T105() 1196 , unit_depth_char1_T105()
1196 , unit_depth_char2_T105() 1197 , unit_depth_char2_T105()
1197 , (nextstopLengthSeconds+59)/60); 1198 , (nextstopLengthSeconds+59)/60);
1198 t3_basics_colorscheme_mod(text); 1199 Gfx_colorsscheme_mod(text,0);
1199 GFX_write_string(&FontT105,tXc1,text,0); 1200 GFX_write_string(&FontT105,tXc1,text,0);
1200 } 1201 }
1201 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit())) 1202 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit()))
1202 { 1203 {
1203 textpointer = 0; 1204 textpointer = 0;
1204 snprintf(&text[textpointer],TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2); 1205 snprintf(&text[textpointer],TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2);
1205 GFX_write_string(&FontT42,tXc1,text,0); 1206 GFX_write_string(&FontT42,tXc1,text,0);
1206 1207
1207 textpointer = 0; 1208 textpointer = 0;
1208 snprintf(&text[textpointer],TEXTSIZE,"\020\003\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds); 1209 snprintf(&text[textpointer],TEXTSIZE,"\020\003\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds);
1209 t3_basics_colorscheme_mod(text); 1210 Gfx_colorsscheme_mod(text,0);
1210 GFX_write_string(&FontT105,tXc1,text,0); 1211 GFX_write_string(&FontT105,tXc1,text,0);
1211 } 1212 }
1212 else if(pDecoinfo->output_ndl_seconds) // NDL 1213 else if(pDecoinfo->output_ndl_seconds) // NDL
1213 { 1214 {
1214 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Nullzeit); 1215 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Nullzeit);
1215 GFX_write_string(&FontT42,tXc1,text,0); 1216 GFX_write_string(&FontT42,tXc1,text,0);
1216 if(pDecoinfo->output_ndl_seconds < 1000 * 60) 1217 if(pDecoinfo->output_ndl_seconds < 1000 * 60)
1217 snprintf(text,TEXTSIZE,"\020\003%i'",pDecoinfo->output_ndl_seconds/60); 1218 snprintf(text,TEXTSIZE,"\020\003%i'",pDecoinfo->output_ndl_seconds/60);
1218 else 1219 else
1219 snprintf(text,TEXTSIZE,"\020\003%ih",pDecoinfo->output_ndl_seconds/3600); 1220 snprintf(text,TEXTSIZE,"\020\003%ih",pDecoinfo->output_ndl_seconds/3600);
1220 t3_basics_colorscheme_mod(text); 1221 Gfx_colorsscheme_mod(text,0);
1221 GFX_write_string(&FontT105,tXc1,text,0); 1222 GFX_write_string(&FontT105,tXc1,text,0);
1222 } 1223 }
1223 1224
1224 if(tX_selection_customview == CVIEW_T3_DecoTTS) /* add tts data on right side of screen */ 1225 if(tX_selection_customview == CVIEW_T3_DecoTTS) /* add tts data on right side of screen */
1225 { 1226 {
1231 { 1232 {
1232 if(pDecoinfo->output_time_to_surface_seconds < 100 * 60) 1233 if(pDecoinfo->output_time_to_surface_seconds < 100 * 60)
1233 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); 1234 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
1234 else 1235 else
1235 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); 1236 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
1236 t3_basics_colorscheme_mod(text); 1237 Gfx_colorsscheme_mod(text,0);
1237 GFX_write_string(&FontT105,tXc1,text,0); 1238 GFX_write_string(&FontT105,tXc1,text,0);
1238 } 1239 }
1239 } 1240 }
1240 else if(pDecoinfo->super_saturation > 0.1) 1241 else if(pDecoinfo->super_saturation > 0.1)
1241 { 1242 {
1242 snprintf(text,TEXTSIZE,"\002\032\f%c",TXT_ActualGradient); 1243 snprintf(text,TEXTSIZE,"\002\032\f%c",TXT_ActualGradient);
1243 GFX_write_string(&FontT42,tXc1,text,0); 1244 GFX_write_string(&FontT42,tXc1,text,0);
1244 snprintf(text,TEXTSIZE,"\020\003\002%.0f\016\016%%\017",100 * pDecoinfo->super_saturation); 1245 snprintf(text,TEXTSIZE,"\020\003\002%.0f\016\016%%\017",100 * pDecoinfo->super_saturation);
1245 t3_basics_colorscheme_mod(text); 1246 Gfx_colorsscheme_mod(text,0);
1246 GFX_write_string(&FontT105,tXc1,text,0); 1247 GFX_write_string(&FontT105,tXc1,text,0);
1247 } 1248 }
1248 } 1249 }
1249 break; 1250 break;
1250 1251
1338 else 1339 else
1339 { 1340 {
1340 GFX_write_string(&FontT42,tXc1,text,0); 1341 GFX_write_string(&FontT42,tXc1,text,0);
1341 } 1342 }
1342 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); 1343 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
1343 t3_basics_colorscheme_mod(text); 1344 Gfx_colorsscheme_mod(text,0);
1344 if(pSettings->FlipDisplay) 1345 if(pSettings->FlipDisplay)
1345 { 1346 {
1346 if(mode == DIVEMODE_Apnea) 1347 if(mode == DIVEMODE_Apnea)
1347 { 1348 {
1348 GFX_write_string(&FontT105,tXc2,text,0); 1349 GFX_write_string(&FontT105,tXc2,text,0);
1365 { 1366 {
1366 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60) 1367 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60)
1367 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); 1368 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
1368 else 1369 else
1369 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); 1370 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
1370 t3_basics_colorscheme_mod(text); 1371 Gfx_colorsscheme_mod(text,0);
1371 GFX_write_string(&FontT105,tXc1,text,0); 1372 GFX_write_string(&FontT105,tXc1,text,0);
1372 } 1373 }
1373 break; 1374 break;
1374 1375
1375 case CVIEW_T3_ppO2andGas: 1376 case CVIEW_T3_ppO2andGas:
1376 snprintf(text,TEXTSIZE,"\032\f%c",TXT_ppO2); 1377 snprintf(text,TEXTSIZE,"\032\f%c",TXT_ppO2);
1377 GFX_write_string(&FontT42,tXc1,text,0); 1378 GFX_write_string(&FontT42,tXc1,text,0);
1378 snprintf(text,TEXTSIZE,"\020\003%01.2f",stateUsed->lifeData.ppO2); 1379 snprintf(text,TEXTSIZE,"\020\003%01.2f",stateUsed->lifeData.ppO2);
1379 t3_basics_colorscheme_mod(text); 1380 Gfx_colorsscheme_mod(text,0);
1380 GFX_write_string(&FontT105,tXc1,text,0); 1381 GFX_write_string(&FontT105,tXc1,text,0);
1381 1382
1382 textpointer = 0; 1383 textpointer = 0;
1383 text[textpointer++] = '\020'; 1384 text[textpointer++] = '\020';
1384 text[textpointer++] = '\003'; 1385 text[textpointer++] = '\003';
1386 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage; 1387 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage;
1387 oxygen_percentage -= stateUsed->lifeData.actualGas.helium_percentage; 1388 oxygen_percentage -= stateUsed->lifeData.actualGas.helium_percentage;
1388 text[textpointer++] = '\002'; 1389 text[textpointer++] = '\002';
1389 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[textpointer]); 1390 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[textpointer]);
1390 //textpointer = snprintf(&text[textpointer],TEXTSIZE,"\020\002%02u/%02u",oxygen_percentage, stateUsed->lifeData.actualGas.helium_percentage); 1391 //textpointer = snprintf(&text[textpointer],TEXTSIZE,"\020\002%02u/%02u",oxygen_percentage, stateUsed->lifeData.actualGas.helium_percentage);
1391 t3_basics_colorscheme_mod(text); 1392 Gfx_colorsscheme_mod(text,0);
1392 GFX_write_string(&FontT48,tXc1,text,0); 1393 GFX_write_string(&FontT48,tXc1,text,0);
1393 break; 1394 break;
1394 1395
1395 case CVIEW_T3_Navigation: 1396 case CVIEW_T3_Navigation:
1396 Stopwatch.Total = timer_Stopwatch_GetTime(); 1397 Stopwatch.Total = timer_Stopwatch_GetTime();
1452 else 1453 else
1453 { 1454 {
1454 GFX_write_string(&FontT42,tXc1,text,0); 1455 GFX_write_string(&FontT42,tXc1,text,0);
1455 } 1456 }
1456 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); 1457 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
1457 t3_basics_colorscheme_mod(text); 1458 Gfx_colorsscheme_mod(text,0);
1458 if(pSettings->FlipDisplay) 1459 if(pSettings->FlipDisplay)
1459 { 1460 {
1460 if(mode == DIVEMODE_Apnea) 1461 if(mode == DIVEMODE_Apnea)
1461 { 1462 {
1462 GFX_write_string(&FontT105,tXc2,text,0); 1463 GFX_write_string(&FontT105,tXc2,text,0);
1812 else 1813 else
1813 { 1814 {
1814 *tX_selection_customview = tX_customviews[index]; 1815 *tX_selection_customview = tX_customviews[index];
1815 } 1816 }
1816 } 1817 }
1817
1818
1819 void t3_basics_colorscheme_mod(char *text)
1820 {
1821 if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard())
1822 {
1823 text[0] = '\027';
1824 }
1825 }
1826
1827 1818
1828 point_t t3_compass_circle(uint8_t id, uint16_t degree, point_t center) 1819 point_t t3_compass_circle(uint8_t id, uint16_t degree, point_t center)
1829 { 1820 {
1830 float fCos, fSin; 1821 float fCos, fSin;
1831 const float piMult = ((2 * 3.14159) / 360); 1822 const float piMult = ((2 * 3.14159) / 360);