comparison Discovery/Src/t7.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 d32901746950
children 608d3e918146
comparison
equal deleted inserted replaced
867:3311b720a072 868:db92692c014f
31 31
32 #include "t7.h" 32 #include "t7.h"
33 #include "t3.h" 33 #include "t3.h"
34 #include "settings.h" 34 #include "settings.h"
35 #include "data_exchange_main.h" 35 #include "data_exchange_main.h"
36 #include "data_central.h"
36 #include "decom.h" 37 #include "decom.h"
37 #include "gfx_fonts.h" 38 #include "gfx_fonts.h"
38 #include "logbook_miniLive.h" 39 #include "logbook_miniLive.h"
39 #include "math.h" 40 #include "math.h"
40 #include "tComm.h" 41 #include "tComm.h"
67 void t7_debug(void); 68 void t7_debug(void);
68 69
69 void t7_miniLiveLogProfile(void); 70 void t7_miniLiveLogProfile(void);
70 void t7_logo_OSTC(void); 71 void t7_logo_OSTC(void);
71 void t7_ChargerView(void); 72 void t7_ChargerView(void);
72 static void t7_colorscheme_mod(char *text);
73 73
74 uint8_t t7_test_customview_warnings(void); 74 uint8_t t7_test_customview_warnings(void);
75 void t7_show_customview_warnings(void); 75 void t7_show_customview_warnings(void);
76 76
77 uint8_t t7_test_customview_warnings_surface_mode(void); 77 uint8_t t7_test_customview_warnings_surface_mode(void);
1977 GFX_write_string(&FontT24, &t7cY0free, heading, 1); 1977 GFX_write_string(&FontT24, &t7cY0free, heading, 1);
1978 t7cY0free.WindowY1 += 10; 1978 t7cY0free.WindowY1 += 10;
1979 t7cY0free.WindowX1 += 10; 1979 t7cY0free.WindowX1 += 10;
1980 } 1980 }
1981 1981
1982 t7_colorscheme_mod(data); 1982 Gfx_colorsscheme_mod(data, 0);
1983 1983
1984 GFX_write_string(&FontT42, &t7cY0free, data, 1); 1984 GFX_write_string(&FontT42, &t7cY0free, data, 1);
1985 } 1985 }
1986 1986
1987 1987
2131 GFX_write_string(&FontT24, &t7cY0free, heading, 1); 2131 GFX_write_string(&FontT24, &t7cY0free, heading, 1);
2132 t7cY0free.WindowY1 += 10; 2132 t7cY0free.WindowY1 += 10;
2133 t7cY0free.WindowX1 += 10; 2133 t7cY0free.WindowX1 += 10;
2134 } 2134 }
2135 2135
2136 t7_colorscheme_mod(data); 2136 Gfx_colorsscheme_mod(data, 0);
2137 2137
2138 GFX_write_string(&FontT42, &t7cY0free, data, 1); 2138 GFX_write_string(&FontT42, &t7cY0free, data, 1);
2139 2139
2140 t7_colorscheme_mod(timer); 2140 Gfx_colorsscheme_mod(timer, 0);
2141 2141
2142 GFX_write_string(&FontT105, &t7cY0free, timer, 4); 2142 GFX_write_string(&FontT105, &t7cY0free, timer, 4);
2143 } 2143 }
2144 2144
2145 2145
2760 2760
2761 if(settingsGetPointer()->nonMetricalSystem) 2761 if(settingsGetPointer()->nonMetricalSystem)
2762 snprintf(TextL1,TEXTSIZE,"\032\f[feet]"); 2762 snprintf(TextL1,TEXTSIZE,"\032\f[feet]");
2763 else 2763 else
2764 snprintf(TextL1,TEXTSIZE,"\032\f%c",TXT_Depth); 2764 snprintf(TextL1,TEXTSIZE,"\032\f%c",TXT_Depth);
2765
2766 color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min);
2767
2768
2765 GFX_write_string(&FontT24,&t7l1,TextL1,0); 2769 GFX_write_string(&FontT24,&t7l1,TextL1,0);
2766 2770
2767 if((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10)) 2771 if((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))
2768 { 2772 {
2769 snprintf(TextL1,TEXTSIZE,"\f\002%.0f %c%c/min " 2773 snprintf(TextL1,TEXTSIZE,"\f\002%.0f %c%c/min "
2777 if( depth < 100) 2781 if( depth < 100)
2778 snprintf(TextL1,TEXTSIZE,"\020%01.1f",depth); 2782 snprintf(TextL1,TEXTSIZE,"\020%01.1f",depth);
2779 else 2783 else
2780 snprintf(TextL1,TEXTSIZE,"\020%01.0f",depth); 2784 snprintf(TextL1,TEXTSIZE,"\020%01.0f",depth);
2781 2785
2782 t7_colorscheme_mod(TextL1); 2786 Gfx_colorsscheme_mod(TextL1, color);
2783 GFX_write_string(&FontT144,&t7l1,TextL1,1); 2787
2788
2789
2790 GFX_write_string(&FontT144,&t7l1,TextL1,0);
2784 2791
2785 /* max depth */ 2792 /* max depth */
2786 snprintf(TextL2,TEXTSIZE,"\032\f%c",TXT_MaxDepth); 2793 snprintf(TextL2,TEXTSIZE,"\032\f%c",TXT_MaxDepth);
2787 GFX_write_string(&FontT42,&t7l2,TextL2,0); 2794 GFX_write_string(&FontT42,&t7l2,TextL2,0);
2788 2795
2789 if(unit_depth_float(stateUsed->lifeData.max_depth_meter) < 100) 2796 if(unit_depth_float(stateUsed->lifeData.max_depth_meter) < 100)
2790 snprintf(TextL2,TEXTSIZE,"\020%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); 2797 snprintf(TextL2,TEXTSIZE,"\020%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
2791 else 2798 else
2792 snprintf(TextL2,TEXTSIZE,"\020%01.0f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); 2799 snprintf(TextL2,TEXTSIZE,"\020%01.0f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
2793 2800
2794 t7_colorscheme_mod(TextL2); 2801 Gfx_colorsscheme_mod(TextL2, 0);
2795 GFX_write_string(&FontT105,&t7l2,TextL2,1); 2802 GFX_write_string(&FontT105,&t7l2,TextL2,1);
2796 2803
2797 /* ascent rate graph */ 2804 /* ascent rate graph */
2798 if(stateUsed->lifeData.ascent_rate_meter_per_min > 1) /* a value < 1 would cause a bar in negative direction brush rectangle of 12 and step width of 6 */ 2805 if(stateUsed->lifeData.ascent_rate_meter_per_min > 1) /* a value < 1 would cause a bar in negative direction brush rectangle of 12 and step width of 6 */
2799 { 2806 {
2831 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 6); 2838 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 6);
2832 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 2839 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9
2833 if(stop.y >= 470) 2840 if(stop.y >= 470)
2834 stop.y = 470; 2841 stop.y = 470;
2835 start.y += 7; // starte etwas weiter oben 2842 start.y += 7; // starte etwas weiter oben
2836 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) 2843 if(color == 0)
2837 color = CLUT_EverythingOkayGreen; 2844 {
2838 else 2845 color = CLUT_EverythingOkayGreen; /* do not use white color for drawing graph */
2839 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) 2846 }
2840 color = CLUT_WarningYellow;
2841 else
2842 color = CLUT_WarningRed;
2843 2847
2844 GFX_draw_thick_line(12,&t7screen, start, stop, color); 2848 GFX_draw_thick_line(12,&t7screen, start, stop, color);
2845 } 2849 }
2846 //snprintf(TextL2,TEXTSIZE,"\f%.1f m/min",stateUsed->lifeData.ascent_rate_meter_per_min); 2850 //snprintf(TextL2,TEXTSIZE,"\f%.1f m/min",stateUsed->lifeData.ascent_rate_meter_per_min);
2847 2851
2859 2863
2860 if(Divetime.Minutes < 1000) 2864 if(Divetime.Minutes < 1000)
2861 snprintf(TextR1,TEXTSIZE,"\020\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds); 2865 snprintf(TextR1,TEXTSIZE,"\020\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
2862 else 2866 else
2863 snprintf(TextR1,TEXTSIZE,"\020\002\016%u'",Divetime.Minutes); 2867 snprintf(TextR1,TEXTSIZE,"\020\002\016%u'",Divetime.Minutes);
2864 t7_colorscheme_mod(TextR1); 2868 Gfx_colorsscheme_mod(TextR1, 0);
2865 GFX_write_string(&FontT105,&t7r1,TextR1,1); 2869 GFX_write_string(&FontT105,&t7r1,TextR1,1);
2866 2870
2867 /* next deco stop */ 2871 /* next deco stop */
2868 if(nextstopDepthMeter) 2872 if(nextstopDepthMeter)
2869 { 2873 {
2872 textlength = snprintf(TextR2,TEXTSIZE,"\020\002%u%c%c %u'" 2876 textlength = snprintf(TextR2,TEXTSIZE,"\020\002%u%c%c %u'"
2873 , unit_depth_integer(nextstopDepthMeter) 2877 , unit_depth_integer(nextstopDepthMeter)
2874 , unit_depth_char1_T105() 2878 , unit_depth_char1_T105()
2875 , unit_depth_char2_T105() 2879 , unit_depth_char2_T105()
2876 , (nextstopLengthSeconds+59)/60); 2880 , (nextstopLengthSeconds+59)/60);
2877 t7_colorscheme_mod(TextR2); 2881 Gfx_colorsscheme_mod(TextR2, 0);
2878 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) 2882 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
2879 TextR2[0] = '\031'; 2883 TextR2[0] = '\031';
2880 if(textlength <= 9) 2884 if(textlength <= 9)
2881 GFX_write_string(&FontT105,&t7r2,TextR2,1); 2885 GFX_write_string(&FontT105,&t7r2,TextR2,1);
2882 else if(textlength <= 10) 2886 else if(textlength <= 10)
2887 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit())) 2891 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit()))
2888 { 2892 {
2889 snprintf(TextR2,TEXTSIZE,"\032\f\002%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2); 2893 snprintf(TextR2,TEXTSIZE,"\032\f\002%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2);
2890 GFX_write_string(&FontT42,&t7r2,TextR2,0); 2894 GFX_write_string(&FontT42,&t7r2,TextR2,0);
2891 snprintf(TextR2,TEXTSIZE,"\020\002\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds); 2895 snprintf(TextR2,TEXTSIZE,"\020\002\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds);
2892 t7_colorscheme_mod(TextR2); 2896 Gfx_colorsscheme_mod(TextR2, 0);
2893 GFX_write_string(&FontT105,&t7r2,TextR2,1); 2897 GFX_write_string(&FontT105,&t7r2,TextR2,1);
2894 } 2898 }
2895 2899
2896 /* tts - option 1 2900 /* tts - option 1
2897 * ndl - option 2 2901 * ndl - option 2
2902 GFX_write_string(&FontT42,&t7r3,TextR3,0); 2906 GFX_write_string(&FontT42,&t7r3,TextR3,0);
2903 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60) 2907 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60)
2904 snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); 2908 snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
2905 else 2909 else
2906 snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); 2910 snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
2907 t7_colorscheme_mod(TextR3); 2911 Gfx_colorsscheme_mod(TextR3, 0);
2908 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) 2912 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
2909 TextR2[0] = '\031'; 2913 TextR2[0] = '\031';
2910 GFX_write_string(&FontT105,&t7r3,TextR3,1); 2914 GFX_write_string(&FontT105,&t7r3,TextR3,1);
2911 } 2915 }
2912 else if(pDecoinfo->output_ndl_seconds) 2916 else if(pDecoinfo->output_ndl_seconds)
2915 GFX_write_string(&FontT42,&t7r3,TextR3,0); 2919 GFX_write_string(&FontT42,&t7r3,TextR3,0);
2916 if(pDecoinfo->output_ndl_seconds < 1000 * 60) 2920 if(pDecoinfo->output_ndl_seconds < 1000 * 60)
2917 snprintf(TextR3,TEXTSIZE,"\020\002%i'",pDecoinfo->output_ndl_seconds/60); 2921 snprintf(TextR3,TEXTSIZE,"\020\002%i'",pDecoinfo->output_ndl_seconds/60);
2918 else 2922 else
2919 snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_ndl_seconds/3600); 2923 snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_ndl_seconds/3600);
2920 t7_colorscheme_mod(TextR3); 2924 Gfx_colorsscheme_mod(TextR3, 0);
2921 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) 2925 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
2922 TextR2[0] = '\031'; 2926 TextR2[0] = '\031';
2923 GFX_write_string(&FontT105,&t7r3,TextR3,1); 2927 GFX_write_string(&FontT105,&t7r3,TextR3,1);
2924 } 2928 }
2925 2929
3061 } 3065 }
3062 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow); 3066 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow);
3063 } 3067 }
3064 else 3068 else
3065 { 3069 {
3066 t7_colorscheme_mod(TextC2); 3070 Gfx_colorsscheme_mod(TextC2, 0);
3067 GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers 3071 GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers
3068 } 3072 }
3069 3073
3070 if(stateUsed->diveSettings.ccrOption) 3074 if(stateUsed->diveSettings.ccrOption)
3071 { 3075 {
3078 TextC2[0] = '\a'; // inverse instead of color \020 3082 TextC2[0] = '\a'; // inverse instead of color \020
3079 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow); 3083 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow);
3080 } 3084 }
3081 else 3085 else
3082 { 3086 {
3083 t7_colorscheme_mod(TextC2); 3087 Gfx_colorsscheme_mod(TextC2, 0);
3084 GFX_write_string(&FontT48,&t7c2,TextC2,0); 3088 GFX_write_string(&FontT48,&t7c2,TextC2,0);
3085 } 3089 }
3086 } 3090 }
3087 } 3091 }
3088 else if(settingsGetPointer()->alwaysShowPPO2) 3092 else if(settingsGetPointer()->alwaysShowPPO2)
3089 { 3093 {
3090 snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); 3094 snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2);
3091 t7_colorscheme_mod(TextC2); 3095 Gfx_colorsscheme_mod(TextC2, 0);
3092 GFX_write_string(&FontT48,&t7c2,TextC2,0); 3096 GFX_write_string(&FontT48,&t7c2,TextC2,0);
3093 } 3097 }
3094 } 3098 }
3095 3099
3096 /* algorithm, ccr, bailout and battery */ 3100 /* algorithm, ccr, bailout and battery */
3173 GFX_write_string(&FontT24,&t7voltage,TextC1,0); 3177 GFX_write_string(&FontT24,&t7voltage,TextC1,0);
3174 } 3178 }
3175 } 3179 }
3176 else 3180 else
3177 { 3181 {
3178 t7_colorscheme_mod(TextC1); 3182 Gfx_colorsscheme_mod(TextC1, 0);
3179 GFX_write_string(&Batt24,&t7batt,TextC1,0); 3183 GFX_write_string(&Batt24,&t7batt,TextC1,0);
3180 3184
3181 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) 3185 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140))
3182 { 3186 {
3183 snprintf(TextC1,16,"\020\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); 3187 snprintf(TextC1,16,"\020\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge);
3184 t7_colorscheme_mod(TextC1); 3188 Gfx_colorsscheme_mod(TextC1, 0);
3185 GFX_write_string(&FontT24,&t7voltage,TextC1,0); // t7batt 3189 GFX_write_string(&FontT24,&t7voltage,TextC1,0); // t7batt
3186 } 3190 }
3187 } 3191 }
3188 3192
3189 /* customizable left lower corner */ 3193 /* customizable left lower corner */
3491 if(tinyHeaderFont) 3495 if(tinyHeaderFont)
3492 GFX_write_string(&FontT24,&t7l3,headerText,0); 3496 GFX_write_string(&FontT24,&t7l3,headerText,0);
3493 else 3497 else
3494 GFX_write_string(&FontT42,&t7l3,headerText,0); 3498 GFX_write_string(&FontT42,&t7l3,headerText,0);
3495 3499
3496 t7_colorscheme_mod(text); 3500 Gfx_colorsscheme_mod(text, 0);
3497 #ifndef ENABLE_BOTTLE_SENSOR 3501 #ifndef ENABLE_BOTTLE_SENSOR
3498 #ifdef ENABLE_CO2_SUPPORT 3502 #ifdef ENABLE_CO2_SUPPORT
3499 if(selection_custom_field != LCC_CO2) 3503 if(selection_custom_field != LCC_CO2)
3500 { 3504 {
3501 GFX_write_string(&FontT105,&t7l3,text,line); 3505 GFX_write_string(&FontT105,&t7l3,text,line);
3614 3618
3615 text[textptr] = 0; 3619 text[textptr] = 0;
3616 return lineCount; 3620 return lineCount;
3617 } 3621 }
3618 3622
3619 static void t7_colorscheme_mod(char *text) {
3620 char *p = text;
3621 while (*p) {
3622 if ((*p == '\020') && !GFX_is_colorschemeDiveStandard())
3623 *p = '\027';
3624 p++;
3625 }
3626 }
3627
3628 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide) 3623 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide)
3629 { 3624 {
3630 point_t LeftLow, WidthHeight; 3625 point_t LeftLow, WidthHeight;
3631 point_t start, stop; 3626 point_t start, stop;
3632 3627
4121 text[textpointer++] = '\t'; 4116 text[textpointer++] = '\t';
4122 4117
4123 textpointer += printScrubberText(&text[textpointer], 10, pSettings); 4118 textpointer += printScrubberText(&text[textpointer], 10, pSettings);
4124 } 4119 }
4125 text[textpointer++] = 0; 4120 text[textpointer++] = 0;
4126 t7_colorscheme_mod(text); 4121 Gfx_colorsscheme_mod(text, 0);
4127 GFX_write_string(&FontT42, &t7cY0free, text, 1); 4122 GFX_write_string(&FontT42, &t7cY0free, text, 1);
4128 } 4123 }
4129 4124
4130 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading) 4125 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading)
4131 { 4126 {