comparison Discovery/Src/t7.c @ 442:adb18fe92737 minor_improvments

Introduced enum for lower left corner view selection: Enums allow changes in view configuration without danger of index inconsistencies
author ideenmodellierer
date Sat, 29 Feb 2020 22:25:20 +0100
parents 2b4440f75434
children f1257a32f2d4
comparison
equal deleted inserted replaced
440:4787cd767a9d 442:adb18fe92737
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 uint16_t bottleFirstGas_bar;
686 point_t start, stop;//, other; 688 point_t start, stop;//, other;
687 689
688 SSettings* pSettings; 690 SSettings* pSettings;
689 pSettings = settingsGetPointer(); 691 pSettings = settingsGetPointer();
690 692
1003 1005
1004 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[0]); 1006 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[0]);
1005 GFX_write_string(&FontT48,&t7surfaceL,text,7); 1007 GFX_write_string(&FontT48,&t7surfaceL,text,7);
1006 1008
1007 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; 1009 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings;
1008 /* 1010
1009 bottleFirstGas_bar = stateUsed->lifeData.bottle_bar[actualGasID]; 1011 bottleFirstGas_bar = stateUsed->lifeData.bottle_bar[actualGasID];
1010 if(bottleFirstGas_bar) 1012 if(bottleFirstGas_bar)
1011 { 1013 {
1012 snprintf(text,255,"%3u\022\016\016 bar",bottleFirstGas_bar); 1014 snprintf(text,255,"%3u\022\016\016 bar",bottleFirstGas_bar);
1013 GFX_write_string(&FontT48,&t7surfaceL,text,8); 1015 GFX_write_string(&FontT48,&t7surfaceL,text,8);
1014 } 1016 }
1015 */ 1017
1016 // after gas name :-) 1018 // after gas name :-)
1017 if(actualGasID > gasOffset) // security 1019 if(actualGasID > gasOffset) // security
1018 { 1020 {
1019 if(!pSettings->FlipDisplay) 1021 if(!pSettings->FlipDisplay)
1020 { 1022 {
2519 selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary; 2521 selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary;
2520 } 2522 }
2521 2523
2522 void t7_change_field(void) 2524 void t7_change_field(void)
2523 { 2525 {
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++; 2526 selection_custom_field++;
2530 2527
2531 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) 2528 if((stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) && (selection_custom_field == LLC_GF)) /* no GF if in VPM mode */
2532 maxNow = maxValVPM; 2529 {
2533 2530 selection_custom_field++;
2534 if(selection_custom_field > maxNow) 2531 }
2535 selection_custom_field = minVal; 2532
2533 if(selection_custom_field >= LLC_END)
2534 {
2535 selection_custom_field = LLC_Empty;
2536 }
2536 } 2537 }
2537 2538
2538 2539
2539 void t7_refresh_divemode_userselected_left_lower_corner(void) 2540 void t7_refresh_divemode_userselected_left_lower_corner(void)
2540 { 2541 {
2544 char headerText[10]; 2545 char headerText[10];
2545 char text[TEXTSIZE]; 2546 char text[TEXTSIZE];
2546 uint8_t textpointer = 0; 2547 uint8_t textpointer = 0;
2547 _Bool tinyHeaderFont = 0; 2548 _Bool tinyHeaderFont = 0;
2548 uint8_t line = 0; 2549 uint8_t line = 0;
2550 uint16_t agedColor = 0;
2549 2551
2550 SDivetime Stopwatch = {0,0,0,0}; 2552 SDivetime Stopwatch = {0,0,0,0};
2551 float fAverageDepth, fAverageDepthAbsolute; 2553 float fAverageDepth, fAverageDepthAbsolute;
2552 const SDecoinfo * pDecoinfoStandard; 2554 const SDecoinfo * pDecoinfoStandard;
2553 const SDecoinfo * pDecoinfoFuture; 2555 const SDecoinfo * pDecoinfoFuture;
2575 headerText[1] = '\f'; 2577 headerText[1] = '\f';
2576 2578
2577 switch(selection_custom_field) 2579 switch(selection_custom_field)
2578 { 2580 {
2579 /* Temperature */ 2581 /* Temperature */
2580 case 1: 2582 case LLC_Temperature:
2581 default: 2583 default:
2582 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius); 2584 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
2583 headerText[2] = TXT_Temperature; 2585 headerText[2] = TXT_Temperature;
2584 textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F 2586 textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F
2585 if(settingsGetPointer()->nonMetricalSystem == 0) 2587 if(settingsGetPointer()->nonMetricalSystem == 0)
2589 text[textpointer++] = 0; 2591 text[textpointer++] = 0;
2590 tinyHeaderFont = 0; 2592 tinyHeaderFont = 0;
2591 break; 2593 break;
2592 2594
2593 /* Average Depth */ 2595 /* Average Depth */
2594 case 2: 2596 case LLC_AverageDepth:
2595 headerText[2] = TXT_AvgDepth; 2597 headerText[2] = TXT_AvgDepth;
2596 if(settingsGetPointer()->nonMetricalSystem) 2598 if(settingsGetPointer()->nonMetricalSystem)
2597 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(fAverageDepthAbsolute)); 2599 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(fAverageDepthAbsolute));
2598 else 2600 else
2599 snprintf(text,TEXTSIZE,"\020%01.1f",fAverageDepthAbsolute); 2601 snprintf(text,TEXTSIZE,"\020%01.1f",fAverageDepthAbsolute);
2600 break; 2602 break;
2601 2603
2602 /* ppO2 */ 2604 /* ppO2 */
2603 case 3: 2605 case LLC_ppO2:
2604 headerText[2] = TXT_ppO2; 2606 headerText[2] = TXT_ppO2;
2605 snprintf(text,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); 2607 snprintf(text,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2);
2606 break; 2608 break;
2607 2609
2608 /* Stop Uhr */ 2610 /* Stop Uhr */
2609 case 4: 2611 case LLC_Stopwatch:
2610 headerText[2] = TXT_Stopwatch; 2612 headerText[2] = TXT_Stopwatch;
2611 if(settingsGetPointer()->nonMetricalSystem) 2613 if(settingsGetPointer()->nonMetricalSystem)
2612 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.0f",Stopwatch.Minutes, Stopwatch.Seconds,unit_depth_float(fAverageDepth)); 2614 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.0f",Stopwatch.Minutes, Stopwatch.Seconds,unit_depth_float(fAverageDepth));
2613 else 2615 else
2614 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.1f",Stopwatch.Minutes, Stopwatch.Seconds,fAverageDepth); 2616 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.1f",Stopwatch.Minutes, Stopwatch.Seconds,fAverageDepth);
2615 tinyHeaderFont = 1; 2617 tinyHeaderFont = 1;
2616 line = 1; 2618 line = 1;
2617 break; 2619 break;
2618 2620
2619 /* Ceiling */ 2621 /* Ceiling */
2620 case 5: 2622 case LLC_Ceiling:
2621 headerText[2] = TXT_Ceiling; 2623 headerText[2] = TXT_Ceiling;
2622 if((pDecoinfoStandard->output_ceiling_meter > 99.9f) || (settingsGetPointer()->nonMetricalSystem)) 2624 if((pDecoinfoStandard->output_ceiling_meter > 99.9f) || (settingsGetPointer()->nonMetricalSystem))
2623 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(pDecoinfoStandard->output_ceiling_meter)); 2625 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(pDecoinfoStandard->output_ceiling_meter));
2624 else 2626 else
2625 snprintf(text,TEXTSIZE,"\020%01.1f",pDecoinfoStandard->output_ceiling_meter); 2627 snprintf(text,TEXTSIZE,"\020%01.1f",pDecoinfoStandard->output_ceiling_meter);
2626 break; 2628 break;
2627 2629
2628 /* Future TTS */ 2630 /* Future TTS */
2629 case 6: 2631 case LLC_FutureTTS:
2630 headerText[2] = TXT_FutureTTS; 2632 headerText[2] = TXT_FutureTTS;
2631 if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60) 2633 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); 2634 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60);
2633 else 2635 else
2634 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%ih TTS",settingsGetPointer()->future_TTS, (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600); 2636 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; 2637 tinyHeaderFont = 1;
2636 line = 1; 2638 line = 1;
2637 break; 2639 break;
2638 2640
2639 /* CNS */ 2641 /* CNS */
2640 case 7: 2642 case LLC_CNS:
2641 headerText[2] = TXT_CNS; 2643 headerText[2] = TXT_CNS;
2642 fCNS = stateUsed->lifeData .cns; 2644 fCNS = stateUsed->lifeData .cns;
2643 if(fCNS > 999) 2645 if(fCNS > 999)
2644 fCNS = 999; 2646 fCNS = 999;
2645 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",fCNS); 2647 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",fCNS);
2646 break; 2648 break;
2647 2649
2648 /* actual GF */ 2650 /* actual GF */
2649 case 8: 2651 case LLC_GF:
2650 headerText[2] = TXT_ActualGradient; 2652 headerText[2] = TXT_ActualGradient;
2651 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",100 * pDecoinfoStandard->super_saturation); 2653 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",100 * pDecoinfoStandard->super_saturation);
2652 break; 2654 break;
2655 case LCC_BottleBar:
2656 headerText[2] = TXT_AtemGasVorrat;
2657 tinyHeaderFont = 1;
2658 snprintf(text,TEXTSIZE,"%d\016\016\017", stateUsed->lifeData.bottle_bar[1]);
2659 break;
2653 } 2660 }
2654 headerText[3] = 0; 2661 headerText[3] = 0;
2655 2662
2656 if(tinyHeaderFont) 2663 if(tinyHeaderFont)
2657 GFX_write_string(&FontT24,&t7l3,headerText,0); 2664 GFX_write_string(&FontT24,&t7l3,headerText,0);
2658 else 2665 else
2659 GFX_write_string(&FontT42,&t7l3,headerText,0); 2666 GFX_write_string(&FontT42,&t7l3,headerText,0);
2660 2667
2661 t7_colorscheme_mod(text); 2668 t7_colorscheme_mod(text);
2662 GFX_write_string(&FontT105,&t7l3,text,line); 2669 if(selection_custom_field != LCC_BottleBar)
2670 {
2671 GFX_write_string(&FontT105,&t7l3,text,line);
2672 }
2673 else
2674 {
2675 agedColor = stateUsed->lifeData.bottle_bar_age_MilliSeconds[1];
2676 if(agedColor > 1200)
2677 {
2678 agedColor = 16;
2679 }
2680 else
2681 if(agedColor > 600)
2682 {
2683 agedColor = 9;
2684 }
2685 else
2686 {
2687 agedColor = 0;
2688 }
2689
2690 GFX_write_string_color(&FontT105,&t7l3,text,line,agedColor);
2691 }
2663 } 2692 }
2664 2693
2665 /* Private functions ---------------------------------------------------------*/ 2694 /* Private functions ---------------------------------------------------------*/
2666 2695
2667 uint8_t t7_customtextPrepare(char * text) 2696 uint8_t t7_customtextPrepare(char * text)