Mercurial > public > ostc4
comparison Discovery/Src/t7.c @ 461:b3f684cea9c0
Merged in Ideenmodellierer/ostc4/minor_improvments (pull request #41)
Minor improvments
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Mon, 30 Mar 2020 13:16:11 +0000 |
parents | 4bd01f48c285 |
children | 5e6a612d03b5 |
comparison
equal
deleted
inserted
replaced
441:9a9e4908ce2e | 461:b3f684cea9c0 |
---|---|
89 GFX_DrawCfgWindow t7c1, t7batt, t7c2, t7charge, t7voltage; | 89 GFX_DrawCfgWindow t7c1, t7batt, t7c2, t7charge, t7voltage; |
90 GFX_DrawCfgWindow t7cH, t7cC, t7cW, t7cY0free; | 90 GFX_DrawCfgWindow t7cH, t7cC, t7cW, t7cY0free; |
91 GFX_DrawCfgWindow t7pCompass; | 91 GFX_DrawCfgWindow t7pCompass; |
92 GFX_DrawCfgWindow t7surfaceL, t7surfaceR; | 92 GFX_DrawCfgWindow t7surfaceL, t7surfaceR; |
93 | 93 |
94 uint8_t selection_custom_field = 1; | 94 uint8_t selection_customview = LLC_Temperature; |
95 uint8_t selection_customview = 1; | |
96 | 95 |
97 uint8_t updateNecessary = 0; | 96 uint8_t updateNecessary = 0; |
98 | 97 |
99 typedef struct{ | 98 typedef struct{ |
100 uint32_t pointer; | 99 uint32_t pointer; |
137 CVIEW_sensors_mV, | 136 CVIEW_sensors_mV, |
138 CVIEW_END, | 137 CVIEW_END, |
139 CVIEW_END | 138 CVIEW_END |
140 }; | 139 }; |
141 | 140 |
141 | |
142 static uint8_t selection_custom_field = LLC_Temperature; | |
143 | |
142 const uint8_t *customviewsDive = customviewsDiveStandard; | 144 const uint8_t *customviewsDive = customviewsDiveStandard; |
143 const uint8_t *customviewsSurface = customviewsSurfaceStandard; | 145 const uint8_t *customviewsSurface = customviewsSurfaceStandard; |
144 | 146 |
145 #define TEXTSIZE 16 | 147 #define TEXTSIZE 16 |
146 /* offset includes line: 2 = line +1 | 148 /* offset includes line: 2 = line +1 |
169 { | 171 { |
170 | 172 |
171 SSettings* pSettings; | 173 SSettings* pSettings; |
172 pSettings = settingsGetPointer(); | 174 pSettings = settingsGetPointer(); |
173 | 175 |
174 selection_custom_field = 1; | 176 selection_custom_field = LLC_Temperature; |
175 selection_customview = customviewsSurface[0]; | 177 selection_customview = customviewsSurface[0]; |
176 | 178 |
177 t7screen.FBStartAdress = 0; | 179 t7screen.FBStartAdress = 0; |
178 t7screen.ImageHeight = 480; | 180 t7screen.ImageHeight = 480; |
179 t7screen.ImageWidth = 800; | 181 t7screen.ImageWidth = 800; |
680 RTC_DateTypeDef SdateFirmware; | 682 RTC_DateTypeDef SdateFirmware; |
681 | 683 |
682 uint8_t dateNotSet = 0; | 684 uint8_t dateNotSet = 0; |
683 | 685 |
684 uint8_t oxygen_percentage, gasOffset, actualGasID; | 686 uint8_t oxygen_percentage, gasOffset, actualGasID; |
685 // uint16_t bottleFirstGas_bar; | 687 #ifdef ENABLE_BOTTLE_SENSOR |
688 uint16_t bottleFirstGas_bar; | |
689 #endif | |
686 point_t start, stop;//, other; | 690 point_t start, stop;//, other; |
687 | 691 |
688 SSettings* pSettings; | 692 SSettings* pSettings; |
689 pSettings = settingsGetPointer(); | 693 pSettings = settingsGetPointer(); |
690 | 694 |
1003 | 1007 |
1004 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[0]); | 1008 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[0]); |
1005 GFX_write_string(&FontT48,&t7surfaceL,text,7); | 1009 GFX_write_string(&FontT48,&t7surfaceL,text,7); |
1006 | 1010 |
1007 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; | 1011 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; |
1008 /* | 1012 |
1013 #ifdef ENABLE_BOTTLE_SENSOR | |
1009 bottleFirstGas_bar = stateUsed->lifeData.bottle_bar[actualGasID]; | 1014 bottleFirstGas_bar = stateUsed->lifeData.bottle_bar[actualGasID]; |
1010 if(bottleFirstGas_bar) | 1015 if(bottleFirstGas_bar) |
1011 { | 1016 { |
1012 snprintf(text,255,"%3u\022\016\016 bar",bottleFirstGas_bar); | 1017 snprintf(text,255,"%3u\022\016\016 bar",bottleFirstGas_bar); |
1013 GFX_write_string(&FontT48,&t7surfaceL,text,8); | 1018 GFX_write_string(&FontT48,&t7surfaceL,text,8); |
1014 } | 1019 } |
1015 */ | 1020 #endif |
1016 // after gas name :-) | 1021 // after gas name :-) |
1017 if(actualGasID > gasOffset) // security | 1022 if(actualGasID > gasOffset) // security |
1018 { | 1023 { |
1019 if(!pSettings->FlipDisplay) | 1024 if(!pSettings->FlipDisplay) |
1020 { | 1025 { |
1087 text[1] = '2'; | 1092 text[1] = '2'; |
1088 } | 1093 } |
1089 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_WarningRed); | 1094 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_WarningRed); |
1090 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) | 1095 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) |
1091 { | 1096 { |
1097 #ifdef ALWAYS_SHOW_VOLTAGE | |
1092 // show battery percent and voltage | 1098 // show battery percent and voltage |
1093 snprintf(text,16,"\f\002%u%% \f%.1fV",(uint8_t)stateUsed->lifeData.battery_charge,stateUsed->lifeData.battery_voltage); | 1099 snprintf(text,16,"\f\002%u%% \f%.1fV",(uint8_t)stateUsed->lifeData.battery_charge,stateUsed->lifeData.battery_voltage); |
1100 #else | |
1101 snprintf(text,16,"\004\025\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); | |
1102 #endif | |
1094 if(warning_count_high_time) | 1103 if(warning_count_high_time) |
1095 text[0] = '\a'; | 1104 text[0] = '\a'; |
1096 GFX_write_string(&FontT24,&t7voltage,text,0); | 1105 GFX_write_string(&FontT24,&t7voltage,text,0); |
1097 } | 1106 } |
1098 else | 1107 else |
1105 { | 1114 { |
1106 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryStandard); | 1115 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryStandard); |
1107 | 1116 |
1108 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) | 1117 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) |
1109 { | 1118 { |
1119 #ifdef ALWAYS_SHOW_VOLTAGE | |
1110 // show battery percent and voltage | 1120 // show battery percent and voltage |
1111 snprintf(text,16,"\f\002%u%% \f%.1fV",(uint8_t)stateUsed->lifeData.battery_charge,stateUsed->lifeData.battery_voltage); | 1121 snprintf(text,16,"\f\002%u%% \f%.1fV",(uint8_t)stateUsed->lifeData.battery_charge,stateUsed->lifeData.battery_voltage); |
1112 // GFX_write_string(&FontT24,&t7batt,text,0); | 1122 #else |
1123 snprintf(text,16,"\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); | |
1124 #endif | |
1113 GFX_write_string(&FontT24,&t7voltage,text,0); | 1125 GFX_write_string(&FontT24,&t7voltage,text,0); |
1114 } | 1126 } |
1115 else | 1127 else |
1116 { | 1128 { |
1117 snprintf(text,6,"\f%.1fV",stateUsed->lifeData.battery_voltage); | 1129 snprintf(text,6,"\f%.1fV",stateUsed->lifeData.battery_voltage); |
2519 selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary; | 2531 selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary; |
2520 } | 2532 } |
2521 | 2533 |
2522 void t7_change_field(void) | 2534 void t7_change_field(void) |
2523 { | 2535 { |
2524 const uint8_t minVal = 0; | |
2525 const uint8_t maxValGF = 8; | |
2526 const uint8_t maxValVPM = 7; | |
2527 uint8_t maxNow = maxValGF; | |
2528 | |
2529 selection_custom_field++; | 2536 selection_custom_field++; |
2530 | 2537 |
2531 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | 2538 if((stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) && (selection_custom_field == LLC_GF)) /* no GF if in VPM mode */ |
2532 maxNow = maxValVPM; | 2539 { |
2533 | 2540 selection_custom_field++; |
2534 if(selection_custom_field > maxNow) | 2541 } |
2535 selection_custom_field = minVal; | 2542 |
2543 if(selection_custom_field >= LLC_END) | |
2544 { | |
2545 selection_custom_field = LLC_Empty; | |
2546 } | |
2536 } | 2547 } |
2537 | 2548 |
2538 | 2549 |
2539 void t7_refresh_divemode_userselected_left_lower_corner(void) | 2550 void t7_refresh_divemode_userselected_left_lower_corner(void) |
2540 { | 2551 { |
2544 char headerText[10]; | 2555 char headerText[10]; |
2545 char text[TEXTSIZE]; | 2556 char text[TEXTSIZE]; |
2546 uint8_t textpointer = 0; | 2557 uint8_t textpointer = 0; |
2547 _Bool tinyHeaderFont = 0; | 2558 _Bool tinyHeaderFont = 0; |
2548 uint8_t line = 0; | 2559 uint8_t line = 0; |
2560 #ifdef ENABLE_BOTTLE_SENSOR | |
2561 uint16_t agedColor = 0; | |
2562 #endif | |
2549 | 2563 |
2550 SDivetime Stopwatch = {0,0,0,0}; | 2564 SDivetime Stopwatch = {0,0,0,0}; |
2551 float fAverageDepth, fAverageDepthAbsolute; | 2565 float fAverageDepth, fAverageDepthAbsolute; |
2552 const SDecoinfo * pDecoinfoStandard; | 2566 const SDecoinfo * pDecoinfoStandard; |
2553 const SDecoinfo * pDecoinfoFuture; | 2567 const SDecoinfo * pDecoinfoFuture; |
2575 headerText[1] = '\f'; | 2589 headerText[1] = '\f'; |
2576 | 2590 |
2577 switch(selection_custom_field) | 2591 switch(selection_custom_field) |
2578 { | 2592 { |
2579 /* Temperature */ | 2593 /* Temperature */ |
2580 case 1: | 2594 case LLC_Temperature: |
2581 default: | 2595 default: |
2582 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); | 2596 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); |
2583 headerText[2] = TXT_Temperature; | 2597 headerText[2] = TXT_Temperature; |
2584 textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F | 2598 textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F |
2585 if(settingsGetPointer()->nonMetricalSystem == 0) | 2599 if(settingsGetPointer()->nonMetricalSystem == 0) |
2589 text[textpointer++] = 0; | 2603 text[textpointer++] = 0; |
2590 tinyHeaderFont = 0; | 2604 tinyHeaderFont = 0; |
2591 break; | 2605 break; |
2592 | 2606 |
2593 /* Average Depth */ | 2607 /* Average Depth */ |
2594 case 2: | 2608 case LLC_AverageDepth: |
2595 headerText[2] = TXT_AvgDepth; | 2609 headerText[2] = TXT_AvgDepth; |
2596 if(settingsGetPointer()->nonMetricalSystem) | 2610 if(settingsGetPointer()->nonMetricalSystem) |
2597 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(fAverageDepthAbsolute)); | 2611 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(fAverageDepthAbsolute)); |
2598 else | 2612 else |
2599 snprintf(text,TEXTSIZE,"\020%01.1f",fAverageDepthAbsolute); | 2613 snprintf(text,TEXTSIZE,"\020%01.1f",fAverageDepthAbsolute); |
2600 break; | 2614 break; |
2601 | 2615 |
2602 /* ppO2 */ | 2616 /* ppO2 */ |
2603 case 3: | 2617 case LLC_ppO2: |
2604 headerText[2] = TXT_ppO2; | 2618 headerText[2] = TXT_ppO2; |
2605 snprintf(text,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); | 2619 snprintf(text,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); |
2606 break; | 2620 break; |
2607 | 2621 |
2608 /* Stop Uhr */ | 2622 /* Stop Uhr */ |
2609 case 4: | 2623 case LLC_Stopwatch: |
2610 headerText[2] = TXT_Stopwatch; | 2624 headerText[2] = TXT_Stopwatch; |
2611 if(settingsGetPointer()->nonMetricalSystem) | 2625 if(settingsGetPointer()->nonMetricalSystem) |
2612 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.0f",Stopwatch.Minutes, Stopwatch.Seconds,unit_depth_float(fAverageDepth)); | 2626 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.0f",Stopwatch.Minutes, Stopwatch.Seconds,unit_depth_float(fAverageDepth)); |
2613 else | 2627 else |
2614 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.1f",Stopwatch.Minutes, Stopwatch.Seconds,fAverageDepth); | 2628 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.1f",Stopwatch.Minutes, Stopwatch.Seconds,fAverageDepth); |
2615 tinyHeaderFont = 1; | 2629 tinyHeaderFont = 1; |
2616 line = 1; | 2630 line = 1; |
2617 break; | 2631 break; |
2618 | 2632 |
2619 /* Ceiling */ | 2633 /* Ceiling */ |
2620 case 5: | 2634 case LLC_Ceiling: |
2621 headerText[2] = TXT_Ceiling; | 2635 headerText[2] = TXT_Ceiling; |
2622 if((pDecoinfoStandard->output_ceiling_meter > 99.9f) || (settingsGetPointer()->nonMetricalSystem)) | 2636 if((pDecoinfoStandard->output_ceiling_meter > 99.9f) || (settingsGetPointer()->nonMetricalSystem)) |
2623 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(pDecoinfoStandard->output_ceiling_meter)); | 2637 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(pDecoinfoStandard->output_ceiling_meter)); |
2624 else | 2638 else |
2625 snprintf(text,TEXTSIZE,"\020%01.1f",pDecoinfoStandard->output_ceiling_meter); | 2639 snprintf(text,TEXTSIZE,"\020%01.1f",pDecoinfoStandard->output_ceiling_meter); |
2626 break; | 2640 break; |
2627 | 2641 |
2628 /* Future TTS */ | 2642 /* Future TTS */ |
2629 case 6: | 2643 case LLC_FutureTTS: |
2630 headerText[2] = TXT_FutureTTS; | 2644 headerText[2] = TXT_FutureTTS; |
2631 if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60) | 2645 if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60) |
2632 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60); | 2646 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60); |
2633 else | 2647 else |
2634 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%ih TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600); | 2648 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%ih TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600); |
2635 tinyHeaderFont = 1; | 2649 tinyHeaderFont = 1; |
2636 line = 1; | 2650 line = 1; |
2637 break; | 2651 break; |
2638 | 2652 |
2639 /* CNS */ | 2653 /* CNS */ |
2640 case 7: | 2654 case LLC_CNS: |
2641 headerText[2] = TXT_CNS; | 2655 headerText[2] = TXT_CNS; |
2642 fCNS = stateUsed->lifeData .cns; | 2656 fCNS = stateUsed->lifeData .cns; |
2643 if(fCNS > 999) | 2657 if(fCNS > 999) |
2644 fCNS = 999; | 2658 fCNS = 999; |
2645 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",fCNS); | 2659 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",fCNS); |
2646 break; | 2660 break; |
2647 | 2661 |
2648 /* actual GF */ | 2662 /* actual GF */ |
2649 case 8: | 2663 case LLC_GF: |
2650 headerText[2] = TXT_ActualGradient; | 2664 headerText[2] = TXT_ActualGradient; |
2651 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",100 * pDecoinfoStandard->super_saturation); | 2665 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",100 * pDecoinfoStandard->super_saturation); |
2652 break; | 2666 break; |
2667 #ifdef ENABLE_BOTTLE_SENSOR | |
2668 case LCC_BottleBar: | |
2669 headerText[2] = TXT_AtemGasVorrat; | |
2670 tinyHeaderFont = 1; | |
2671 snprintf(text,TEXTSIZE,"%d\016\016\017", stateUsed->lifeData.bottle_bar[stateUsed->lifeData.actualGas.GasIdInSettings]); | |
2672 break; | |
2673 #endif | |
2653 } | 2674 } |
2654 headerText[3] = 0; | 2675 headerText[3] = 0; |
2655 | 2676 |
2656 if(tinyHeaderFont) | 2677 if(tinyHeaderFont) |
2657 GFX_write_string(&FontT24,&t7l3,headerText,0); | 2678 GFX_write_string(&FontT24,&t7l3,headerText,0); |
2658 else | 2679 else |
2659 GFX_write_string(&FontT42,&t7l3,headerText,0); | 2680 GFX_write_string(&FontT42,&t7l3,headerText,0); |
2660 | 2681 |
2661 t7_colorscheme_mod(text); | 2682 t7_colorscheme_mod(text); |
2662 GFX_write_string(&FontT105,&t7l3,text,line); | 2683 #ifndef ENABLE_BOTTLE_SENSOR |
2684 GFX_write_string(&FontT105,&t7l3,text,line); | |
2685 #else | |
2686 if(selection_custom_field != LCC_BottleBar) /* a changing color set is used for bar display */ | |
2687 { | |
2688 GFX_write_string(&FontT105,&t7l3,text,line); | |
2689 } | |
2690 else | |
2691 { | |
2692 agedColor = stateUsed->lifeData.bottle_bar_age_MilliSeconds[stateUsed->lifeData.actualGas.GasIdInSettings]; | |
2693 if(agedColor > 1200) | |
2694 { | |
2695 agedColor = CLUT_WarningRed; | |
2696 } | |
2697 else | |
2698 if(agedColor > 600) | |
2699 { | |
2700 agedColor = CLUT_MenuLineUnselected; | |
2701 } | |
2702 else | |
2703 if(agedColor > 20) | |
2704 { | |
2705 agedColor = CLUT_Font031; | |
2706 } | |
2707 else | |
2708 { | |
2709 agedColor = CLUT_Font020; | |
2710 } | |
2711 | |
2712 GFX_write_string_color(&FontT105,&t7l3,text,line,agedColor); | |
2713 } | |
2714 #endif | |
2663 } | 2715 } |
2664 | 2716 |
2665 /* Private functions ---------------------------------------------------------*/ | 2717 /* Private functions ---------------------------------------------------------*/ |
2666 | 2718 |
2667 uint8_t t7_customtextPrepare(char * text) | 2719 uint8_t t7_customtextPrepare(char * text) |