# HG changeset patch # User Ideenmodellierer # Date 1723468459 -7200 # Node ID db92692c014f75d9c43704bc7ae17c5cdf0dda19 # Parent 3311b720a072c5303b8e8d29c631480a62682369 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) diff -r 3311b720a072 -r db92692c014f Common/Inc/data_central.h --- a/Common/Inc/data_central.h Mon Aug 12 14:30:22 2024 +0200 +++ b/Common/Inc/data_central.h Mon Aug 12 15:14:19 2024 +0200 @@ -531,4 +531,7 @@ const SDecoinfo *getDecoInfo(void); void disableTimer(void); + +uint8_t drawingColor_from_ascentspeed(float speed); + #endif // DATA_CENTRAL_H diff -r 3311b720a072 -r db92692c014f Discovery/Src/data_central.c --- a/Discovery/Src/data_central.c Mon Aug 12 14:30:22 2024 +0200 +++ b/Discovery/Src/data_central.c Mon Aug 12 15:14:19 2024 +0200 @@ -911,3 +911,28 @@ { stateUsedWrite->timerState = TIMER_STATE_OFF; } + +#define SPEED_SLOW (5.0f) +#define SPEED_MEDIUM (10.0f) +#define SPEED_HIGH (15.0f) + +uint8_t drawingColor_from_ascentspeed(float speed) +{ + uint8_t color = CLUT_Font020; + + if(speed >= SPEED_HIGH) + { + color = CLUT_WarningRed; + } + else if(speed >= SPEED_MEDIUM) + { + color = CLUT_WarningYellow; + } + else if(speed >= SPEED_SLOW) + { + color = CLUT_NiceGreen; + } + return color; +} + + diff -r 3311b720a072 -r db92692c014f Discovery/Src/t3.c --- a/Discovery/Src/t3.c Mon Aug 12 14:30:22 2024 +0200 +++ b/Discovery/Src/t3.c Mon Aug 12 15:14:19 2024 +0200 @@ -42,6 +42,7 @@ #include "motion.h" #include "logbook_miniLive.h" #include "tMenuEditCustom.h" +#include "gfx_engine.h" #define CV_PROFILE_WIDTH (600U) @@ -410,7 +411,6 @@ GFX_draw_line(tXscreen, start, stop, CLUT_Font020); } - start.y = BigFontSeperationTopBottom; stop.y = 479; @@ -425,6 +425,7 @@ } /* depth */ + color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); float depth = unit_depth_float(stateUsed->lifeData.depth_meter); if(depth <= 0.3f) @@ -453,7 +454,7 @@ else snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,color); GFX_write_string(&FontT105,tXl1,text,1); @@ -648,7 +649,7 @@ else snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes); } - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXr1,text,1); } else @@ -719,7 +720,7 @@ else snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXr1,text,1); break; } @@ -824,7 +825,7 @@ else text[textpointer++] = 'F'; text[textpointer++] = 0; - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,1); break; @@ -851,7 +852,7 @@ } snprintf(text,TEXTSIZE,"\020\016%u:%02u",LastDivetime.Minutes, LastDivetime.Seconds); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); if(pSettings->FlipDisplay) @@ -873,7 +874,7 @@ } snprintf(text,TEXTSIZE,"\020\016%u:%02u",TotalDivetime.Minutes, TotalDivetime.Seconds); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaTotal); @@ -990,7 +991,7 @@ } snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_last_max_depth_meter)); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); if(!pSettings->FlipDisplay) { @@ -1005,7 +1006,7 @@ snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_total_max_depth_meter)); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); if(!pSettings->FlipDisplay) { GFX_write_string(&FontT105,tXc1,text,0); @@ -1195,7 +1196,7 @@ , unit_depth_char1_T105() , unit_depth_char2_T105() , (nextstopLengthSeconds+59)/60); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); } else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit())) @@ -1206,7 +1207,7 @@ textpointer = 0; snprintf(&text[textpointer],TEXTSIZE,"\020\003\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); } else if(pDecoinfo->output_ndl_seconds) // NDL @@ -1217,7 +1218,7 @@ snprintf(text,TEXTSIZE,"\020\003%i'",pDecoinfo->output_ndl_seconds/60); else snprintf(text,TEXTSIZE,"\020\003%ih",pDecoinfo->output_ndl_seconds/3600); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); } @@ -1233,7 +1234,7 @@ snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); else snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); } } @@ -1242,7 +1243,7 @@ snprintf(text,TEXTSIZE,"\002\032\f%c",TXT_ActualGradient); GFX_write_string(&FontT42,tXc1,text,0); snprintf(text,TEXTSIZE,"\020\003\002%.0f\016\016%%\017",100 * pDecoinfo->super_saturation); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); } } @@ -1340,7 +1341,7 @@ GFX_write_string(&FontT42,tXc1,text,0); } snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); if(pSettings->FlipDisplay) { if(mode == DIVEMODE_Apnea) @@ -1367,7 +1368,7 @@ snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); else snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); } break; @@ -1376,7 +1377,7 @@ snprintf(text,TEXTSIZE,"\032\f%c",TXT_ppO2); GFX_write_string(&FontT42,tXc1,text,0); snprintf(text,TEXTSIZE,"\020\003%01.2f",stateUsed->lifeData.ppO2); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,tXc1,text,0); textpointer = 0; @@ -1388,7 +1389,7 @@ text[textpointer++] = '\002'; tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[textpointer]); //textpointer = snprintf(&text[textpointer],TEXTSIZE,"\020\002%02u/%02u",oxygen_percentage, stateUsed->lifeData.actualGas.helium_percentage); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT48,tXc1,text,0); break; @@ -1454,7 +1455,7 @@ GFX_write_string(&FontT42,tXc1,text,0); } snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); if(pSettings->FlipDisplay) { if(mode == DIVEMODE_Apnea) @@ -1815,16 +1816,6 @@ } } - -void t3_basics_colorscheme_mod(char *text) -{ - if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard()) - { - text[0] = '\027'; - } -} - - point_t t3_compass_circle(uint8_t id, uint16_t degree, point_t center) { float fCos, fSin; diff -r 3311b720a072 -r db92692c014f Discovery/Src/t4_tetris.c --- a/Discovery/Src/t4_tetris.c Mon Aug 12 14:30:22 2024 +0200 +++ b/Discovery/Src/t4_tetris.c Mon Aug 12 15:14:19 2024 +0200 @@ -36,6 +36,7 @@ #include "tHome.h" #include "timer.h" #include "unit.h" +#include "gfx_engine.h" /* Exported variables --------------------------------------------------------*/ @@ -152,7 +153,7 @@ else snprintf(text,TEXTSIZE,"\020%01.0f",depth); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT144,&t4l1,text,1); // divetime @@ -186,7 +187,7 @@ snprintf(text,TEXTSIZE,"\020\016%u:%02u",Divetime.Minutes, Divetime.Seconds); else snprintf(text,TEXTSIZE,"\020\016%u'",Divetime.Minutes); - t3_basics_colorscheme_mod(text); + Gfx_colorsscheme_mod(text,0); GFX_write_string(&FontT105,&t4l2,text,1); } diff -r 3311b720a072 -r db92692c014f Discovery/Src/t7.c --- a/Discovery/Src/t7.c Mon Aug 12 14:30:22 2024 +0200 +++ b/Discovery/Src/t7.c Mon Aug 12 15:14:19 2024 +0200 @@ -33,6 +33,7 @@ #include "t3.h" #include "settings.h" #include "data_exchange_main.h" +#include "data_central.h" #include "decom.h" #include "gfx_fonts.h" #include "logbook_miniLive.h" @@ -69,7 +70,6 @@ void t7_miniLiveLogProfile(void); void t7_logo_OSTC(void); void t7_ChargerView(void); -static void t7_colorscheme_mod(char *text); uint8_t t7_test_customview_warnings(void); void t7_show_customview_warnings(void); @@ -1979,7 +1979,7 @@ t7cY0free.WindowX1 += 10; } - t7_colorscheme_mod(data); + Gfx_colorsscheme_mod(data, 0); GFX_write_string(&FontT42, &t7cY0free, data, 1); } @@ -2133,11 +2133,11 @@ t7cY0free.WindowX1 += 10; } - t7_colorscheme_mod(data); + Gfx_colorsscheme_mod(data, 0); GFX_write_string(&FontT42, &t7cY0free, data, 1); - t7_colorscheme_mod(timer); + Gfx_colorsscheme_mod(timer, 0); GFX_write_string(&FontT105, &t7cY0free, timer, 4); } @@ -2762,6 +2762,10 @@ snprintf(TextL1,TEXTSIZE,"\032\f[feet]"); else snprintf(TextL1,TEXTSIZE,"\032\f%c",TXT_Depth); + + color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); + + GFX_write_string(&FontT24,&t7l1,TextL1,0); if((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10)) @@ -2779,8 +2783,11 @@ else snprintf(TextL1,TEXTSIZE,"\020%01.0f",depth); - t7_colorscheme_mod(TextL1); - GFX_write_string(&FontT144,&t7l1,TextL1,1); + Gfx_colorsscheme_mod(TextL1, color); + + + + GFX_write_string(&FontT144,&t7l1,TextL1,0); /* max depth */ snprintf(TextL2,TEXTSIZE,"\032\f%c",TXT_MaxDepth); @@ -2791,7 +2798,7 @@ else snprintf(TextL2,TEXTSIZE,"\020%01.0f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); - t7_colorscheme_mod(TextL2); + Gfx_colorsscheme_mod(TextL2, 0); GFX_write_string(&FontT105,&t7l2,TextL2,1); /* ascent rate graph */ @@ -2833,13 +2840,10 @@ if(stop.y >= 470) stop.y = 470; start.y += 7; // starte etwas weiter oben - if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) - color = CLUT_EverythingOkayGreen; - else - if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) - color = CLUT_WarningYellow; - else - color = CLUT_WarningRed; + if(color == 0) + { + color = CLUT_EverythingOkayGreen; /* do not use white color for drawing graph */ + } GFX_draw_thick_line(12,&t7screen, start, stop, color); } @@ -2861,7 +2865,7 @@ snprintf(TextR1,TEXTSIZE,"\020\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds); else snprintf(TextR1,TEXTSIZE,"\020\002\016%u'",Divetime.Minutes); - t7_colorscheme_mod(TextR1); + Gfx_colorsscheme_mod(TextR1, 0); GFX_write_string(&FontT105,&t7r1,TextR1,1); /* next deco stop */ @@ -2874,7 +2878,7 @@ , unit_depth_char1_T105() , unit_depth_char2_T105() , (nextstopLengthSeconds+59)/60); - t7_colorscheme_mod(TextR2); + Gfx_colorsscheme_mod(TextR2, 0); if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) TextR2[0] = '\031'; if(textlength <= 9) @@ -2889,7 +2893,7 @@ snprintf(TextR2,TEXTSIZE,"\032\f\002%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2); GFX_write_string(&FontT42,&t7r2,TextR2,0); snprintf(TextR2,TEXTSIZE,"\020\002\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds); - t7_colorscheme_mod(TextR2); + Gfx_colorsscheme_mod(TextR2, 0); GFX_write_string(&FontT105,&t7r2,TextR2,1); } @@ -2904,7 +2908,7 @@ snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); else snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); - t7_colorscheme_mod(TextR3); + Gfx_colorsscheme_mod(TextR3, 0); if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) TextR2[0] = '\031'; GFX_write_string(&FontT105,&t7r3,TextR3,1); @@ -2917,7 +2921,7 @@ snprintf(TextR3,TEXTSIZE,"\020\002%i'",pDecoinfo->output_ndl_seconds/60); else snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_ndl_seconds/3600); - t7_colorscheme_mod(TextR3); + Gfx_colorsscheme_mod(TextR3, 0); if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) TextR2[0] = '\031'; GFX_write_string(&FontT105,&t7r3,TextR3,1); @@ -3063,7 +3067,7 @@ } else { - t7_colorscheme_mod(TextC2); + Gfx_colorsscheme_mod(TextC2, 0); GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers } @@ -3080,7 +3084,7 @@ } else { - t7_colorscheme_mod(TextC2); + Gfx_colorsscheme_mod(TextC2, 0); GFX_write_string(&FontT48,&t7c2,TextC2,0); } } @@ -3088,7 +3092,7 @@ else if(settingsGetPointer()->alwaysShowPPO2) { snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); - t7_colorscheme_mod(TextC2); + Gfx_colorsscheme_mod(TextC2, 0); GFX_write_string(&FontT48,&t7c2,TextC2,0); } } @@ -3175,13 +3179,13 @@ } else { - t7_colorscheme_mod(TextC1); + Gfx_colorsscheme_mod(TextC1, 0); GFX_write_string(&Batt24,&t7batt,TextC1,0); if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) { snprintf(TextC1,16,"\020\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); - t7_colorscheme_mod(TextC1); + Gfx_colorsscheme_mod(TextC1, 0); GFX_write_string(&FontT24,&t7voltage,TextC1,0); // t7batt } } @@ -3493,7 +3497,7 @@ else GFX_write_string(&FontT42,&t7l3,headerText,0); - t7_colorscheme_mod(text); + Gfx_colorsscheme_mod(text, 0); #ifndef ENABLE_BOTTLE_SENSOR #ifdef ENABLE_CO2_SUPPORT if(selection_custom_field != LCC_CO2) @@ -3616,15 +3620,6 @@ return lineCount; } -static void t7_colorscheme_mod(char *text) { - char *p = text; - while (*p) { - if ((*p == '\020') && !GFX_is_colorschemeDiveStandard()) - *p = '\027'; - p++; - } -} - void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide) { point_t LeftLow, WidthHeight; @@ -4123,7 +4118,7 @@ textpointer += printScrubberText(&text[textpointer], 10, pSettings); } text[textpointer++] = 0; - t7_colorscheme_mod(text); + Gfx_colorsscheme_mod(text, 0); GFX_write_string(&FontT42, &t7cY0free, text, 1); }