comparison Discovery/Src/t3.c @ 981:c6c781a2e85b default

Merge into default
author heinrichsweikamp
date Tue, 11 Feb 2025 18:12:00 +0100
parents 7149f372b0ba
children 8507a87f6401
comparison
equal deleted inserted replaced
871:f7318457df4d 981:c6c781a2e85b
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 ////////////////////////////////////////////////////////////////////////////// 27 //////////////////////////////////////////////////////////////////////////////
28 28
29 /* Includes ------------------------------------------------------------------*/ 29 /* Includes ------------------------------------------------------------------*/
30 #include <stdbool.h> 30 #include <stdbool.h>
31 #include <stdlib.h>
31 32
32 #include "t3.h" 33 #include "t3.h"
33 34
34 #include "data_exchange_main.h" 35 #include "data_exchange_main.h"
35 #include "decom.h" 36 #include "decom.h"
38 #include "tHome.h" 39 #include "tHome.h"
39 #include "timer.h" 40 #include "timer.h"
40 #include "unit.h" 41 #include "unit.h"
41 #include "motion.h" 42 #include "motion.h"
42 #include "logbook_miniLive.h" 43 #include "logbook_miniLive.h"
44 #include "tMenuEditCustom.h"
45 #include "gfx_engine.h"
43 46
44 47
45 #define CV_PROFILE_WIDTH (600U) 48 #define CV_PROFILE_WIDTH (600U)
46 49
47 //* Imported function prototypes ---------------------------------------------*/ 50 //* Imported function prototypes ---------------------------------------------*/
59 GFX_DrawCfgWindow t3c1; 62 GFX_DrawCfgWindow t3c1;
60 GFX_DrawCfgWindow t3c2; 63 GFX_DrawCfgWindow t3c2;
61 64
62 uint8_t t3_selection_customview = CVIEW_noneOrDebug; 65 uint8_t t3_selection_customview = CVIEW_noneOrDebug;
63 66
67 static uint8_t AF_lastDecoDepth = 0;
68 static uint16_t AF_lastTTS = 0;
69
70
64 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/ 71 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/
65 72
66 /* Private types -------------------------------------------------------------*/ 73 /* Private types -------------------------------------------------------------*/
67 #define TEXTSIZE 16 74 #define TEXTSIZE 16
68 #define NUMBER_OF_VIEWS 7 /* number of views defined in the array below */ 75
69 76 /* defines for autofocus of compass */
70 const uint8_t t3_customviewsStandard[] = 77 #define AF_COMPASS_ACTIVATION_ANGLE (10.0f) /* angle for pitch and roll. Compass gets activated in case the value is smaller (OSTC4 hold in horitontal position */
71 { 78 #define AF_COMPASS_DEBOUNCE (10u) /* debouncing value to avoid compass activation during normal movement */
72 CVIEW_T3_Decostop, 79
73 CVIEW_sensors,
74 CVIEW_Compass,
75 CVIEW_T3_MaxDepth,
76 CVIEW_T3_StopWatch,
77 CVIEW_T3_TTS,
78 CVIEW_T3_ppO2andGas,
79 CVIEW_T3_GasList,
80 CVIEW_T3_Navigation,
81 CVIEW_T3_DepthData,
82 CVIEW_noneOrDebug,
83 CVIEW_T3_DecoTTS,
84 #ifdef ENABLE_T3_PROFILE_VIEW
85 CVIEW_T3_Profile,
86 #endif
87 CVIEW_T3_END
88 };
89 80
90 /* Private function prototypes -----------------------------------------------*/ 81 /* Private function prototypes -----------------------------------------------*/
91 void t3_refresh_divemode(void); 82 void t3_refresh_divemode(void);
92 83
93 uint8_t t3_test_customview_warnings(void); 84 uint8_t t3_test_customview_warnings(void);
94 void t3_refresh_customview(float depth); 85 void t3_refresh_customview(float depth);
95 void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, point_t center, uint16_t ActualHeading, uint16_t UserSetHeading); 86 void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, point_t center, uint16_t ActualHeading, uint16_t UserSetHeading);
87 uint8_t t3_EvaluateAFCondition(uint8_t T3CView);
88 uint8_t t3_drawSlowExitGraph(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1); /* this function is only called if diver is below last last stop depth */
96 89
97 /* Exported functions --------------------------------------------------------*/ 90 /* Exported functions --------------------------------------------------------*/
98 91
99 void t3_init(void) 92 void t3_init(void)
100 { 93 {
101 SSettings* pSettings; 94 SSettings* pSettings;
102 pSettings = settingsGetPointer(); 95 pSettings = settingsGetPointer();
103 96
104 t3_selection_customview = t3_customviewsStandard[0]; 97 t3_selection_customview = cv_changelist_BS[0];
105 98
106 t3screen.FBStartAdress = 0; 99 t3screen.FBStartAdress = 0;
107 t3screen.ImageHeight = 480; 100 t3screen.ImageHeight = 480;
108 t3screen.ImageWidth = 800; 101 t3screen.ImageWidth = 800;
109 t3screen.LayerIndex = 1; 102 t3screen.LayerIndex = 1;
170 t3c2.WindowX0 = 370; 163 t3c2.WindowX0 = 370;
171 t3c2.WindowX1 = 799; 164 t3c2.WindowX1 = 799;
172 t3c2.WindowY0 = t3c1.WindowY0; 165 t3c2.WindowY0 = t3c1.WindowY0;
173 t3c2.WindowY1 = t3c1.WindowY1; 166 t3c2.WindowY1 = t3c1.WindowY1;
174 t3c2.WindowTab = 600; 167 t3c2.WindowTab = 600;
168
169 t3_EvaluateAFCondition(CVIEW_T3_END); /* reset debounce counters */
175 } 170 }
176 171
177 void t3_select_customview(uint8_t selectedCustomview) 172 void t3_select_customview(uint8_t selectedCustomview)
178 { 173 {
179 if(selectedCustomview < CVIEW_T3_END) 174 if(selectedCustomview < CVIEW_T3_END)
394 389
395 float t3_basics_lines_depth_and_divetime(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode) 390 float t3_basics_lines_depth_and_divetime(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode)
396 { 391 {
397 char text[256]; 392 char text[256];
398 uint8_t textPointer; 393 uint8_t textPointer;
399 uint8_t color; 394 uint8_t color = 0;
400 uint8_t depthChangeRate; 395 uint8_t depthChangeRate;
401 uint8_t depthChangeAscent; 396 uint8_t depthChangeAscent;
402 point_t start, stop, startZeroLine; 397 point_t start, stop, startZeroLine;
403 SDivetime Divetime = {0,0,0,0}; 398 SDivetime Divetime = {0,0,0,0};
399 uint16_t nextstopLengthSeconds = 0;
400 uint8_t nextstopDepthMeter = 0;
404 401
405 SSettings* pSettings; 402 SSettings* pSettings;
406 pSettings = settingsGetPointer(); 403 pSettings = settingsGetPointer();
404
405 const SDecoinfo * pDecoinfo = getDecoInfo();
406 if(pDecoinfo->output_time_to_surface_seconds)
407 {
408 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds);
409 }
410 else
411 {
412 nextstopDepthMeter = 0;
413 nextstopLengthSeconds = 0;
414 }
407 415
408 start.x = 0; 416 start.x = 0;
409 stop.x = 799; 417 stop.x = 799;
410 stop.y = start.y = BigFontSeperationTopBottom; 418 stop.y = start.y = BigFontSeperationTopBottom;
411 if((viewInFocus()) && (!viewDetectionSuspended())) 419 if((viewInFocus()) && (!viewDetectionSuspended()))
415 else 423 else
416 { 424 {
417 GFX_draw_line(tXscreen, start, stop, CLUT_Font020); 425 GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
418 } 426 }
419 427
420
421 start.y = BigFontSeperationTopBottom; 428 start.y = BigFontSeperationTopBottom;
422 stop.y = 479; 429 stop.y = 479;
423 430
424 stop.x = start.x = BigFontSeperationLeftRight; 431 stop.x = start.x = BigFontSeperationLeftRight;
425 if((viewInFocus() && (!viewDetectionSuspended()))) 432 if((viewInFocus() && (!viewDetectionSuspended())))
428 } 435 }
429 else 436 else
430 { 437 {
431 GFX_draw_line(tXscreen, start, stop, CLUT_Font020); 438 GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
432 } 439 }
433
434 /* depth */
435 float depth = unit_depth_float(stateUsed->lifeData.depth_meter);
436
437 if(depth <= 0.3f)
438 depth = 0;
439
440 if(settingsGetPointer()->nonMetricalSystem)
441 snprintf(text,TEXTSIZE,"\032\f[feet]");
442 else
443 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth);
444 GFX_write_string(&FontT42,tXl1,text,0);
445
446 if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 )))
447 || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10)))
448 )
449 {
450 snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min "
451 , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min)
452 , unit_depth_char1()
453 , unit_depth_char2()
454 );
455 GFX_write_string(&FontT42,tXl1,text,0);
456 }
457
458 if( depth < 100)
459 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth);
460 else
461 snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth);
462
463 t3_basics_colorscheme_mod(text);
464 GFX_write_string(&FontT105,tXl1,text,1);
465
466 440
467 /* ascentrate graph */ 441 /* ascentrate graph */
468 if(mode == DIVEMODE_Apnea) 442 if(mode == DIVEMODE_Apnea)
469 { 443 {
470 /* ascentrate graph - apnea mode */ 444 /* ascentrate graph - apnea mode */
559 GFX_draw_thick_line(12,tXscreen, start, stop, color); 533 GFX_draw_thick_line(12,tXscreen, start, stop, color);
560 } 534 }
561 } 535 }
562 else 536 else
563 { 537 {
564 /* ascentrate graph -standard mode */ 538 color = 0xff;
565 if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) 539 if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter))
566 { 540 {
567 if(!pSettings->FlipDisplay) 541 color = t3_drawSlowExitGraph(tXscreen, tXl1, tXr1);
568 { 542 }
569 start.y = tXl1->WindowY0 - 1; 543 if(color == 0xff) /* no slow exit => continue with common ascent graph */
570 } 544 {
571 else 545 if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) /* ascentrate graph -standard mode */
572 { 546 {
573 start.y = tXl1->WindowY1 + 1; 547 if(!pSettings->FlipDisplay)
574 } 548 {
575 549 start.y = tXl1->WindowY0 - 1;
576 for(int i = 0; i<4;i++) 550 }
577 { 551 else
578 start.y += 5*8; 552 {
579 stop.y = start.y; 553 start.y = tXl1->WindowY1 + 1;
580 if(!pSettings->FlipDisplay) 554 }
581 { 555
582 start.x = tXl1->WindowX1 - 1; 556 for(int i = 0; i<4;i++)
583 } 557 {
584 else 558 start.y += 5*8;
585 { 559 stop.y = start.y;
586 start.x = tXr1->WindowX1 - 1; 560 if(!pSettings->FlipDisplay)
587 } 561 {
588 stop.x = start.x - 17; 562 start.x = tXl1->WindowX1 - 1;
589 GFX_draw_line(tXscreen, start, stop, 0); 563 }
590 } 564 else
591 // new thick bar design Sept. 2015 565 {
592 if(!pSettings->FlipDisplay) 566 start.x = tXr1->WindowX1 + 3;
593 { 567 }
594 start.x = tXl1->WindowX1 - 3 - 5; 568 stop.x = start.x - 17;
595 } 569 GFX_draw_line(tXscreen, start, stop, 0);
596 else 570 }
597 { 571 // new thick bar design Sept. 2015
598 start.x = tXr1->WindowX1 - 3 - 5; 572 if(!pSettings->FlipDisplay)
599 } 573 {
600 574 start.x = tXl1->WindowX1 - 3 - 5;
601 stop.x = start.x; 575 }
602 if(!pSettings->FlipDisplay) 576 else
603 { 577 {
604 start.y = tXl1->WindowY0 - 1; 578 start.x = tXr1->WindowX1 - 3 - 5;
605 } 579 }
606 else 580
607 { 581 stop.x = start.x;
608 start.y = tXl1->WindowY1 + 1; 582 if(!pSettings->FlipDisplay)
609 } 583 {
610 584 start.y = tXl1->WindowY0 - 1;
611 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8); 585 }
612 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 586 else
613 if(stop.y >= 470) 587 {
614 stop.y = 470; 588 start.y = tXl1->WindowY1 + 1;
615 start.y += 7; // starte etwas weiter oben 589 }
616 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) 590
617 color = CLUT_EverythingOkayGreen; 591 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8);
618 else 592 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9
619 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) 593 if(stop.y >= 470)
620 color = CLUT_WarningYellow; 594 stop.y = 470;
621 else 595 start.y += 7; // starte etwas weiter oben
622 color = CLUT_WarningRed; 596 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10)
623 597 color = CLUT_EverythingOkayGreen;
624 GFX_draw_thick_line(12,tXscreen, start, stop, color); 598 else
625 } 599 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15)
626 } 600 color = CLUT_WarningYellow;
601 else
602 color = CLUT_WarningRed;
603
604 GFX_draw_thick_line(12,tXscreen, start, stop, color);
605 }
606 color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min);
607 }
608 }
609 /* depth */
610 float depth = unit_depth_float(stateUsed->lifeData.depth_meter);
611
612 if(depth <= 0.3f)
613 depth = 0;
614
615 if(settingsGetPointer()->nonMetricalSystem)
616 snprintf(text,TEXTSIZE,"\032\f[feet]");
617 else
618 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth);
619 GFX_write_string(&FontT42,tXl1,text,0);
620
621 if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 )))
622 || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10)))
623 )
624 {
625 snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min "
626 , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min)
627 , unit_depth_char1()
628 , unit_depth_char2()
629 );
630 GFX_write_string(&FontT42,tXl1,text,0);
631 }
632
633 if( depth < 100)
634 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth);
635 else
636 snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth);
637
638 Gfx_colorsscheme_mod(text,color);
639 GFX_write_string(&FontT105,tXl1,text,1);
640
627 641
628 // divetime 642 // divetime
629 if(mode == DIVEMODE_Apnea) 643 if(mode == DIVEMODE_Apnea)
630 { 644 {
631 if(stateUsed->lifeData.counterSecondsShallowDepth) 645 if(stateUsed->lifeData.counterSecondsShallowDepth)
653 if(Divetime.Minutes < 100) 667 if(Divetime.Minutes < 100)
654 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds); 668 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
655 else 669 else
656 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes); 670 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes);
657 } 671 }
658 t3_basics_colorscheme_mod(text); 672 Gfx_colorsscheme_mod(text,0);
659 GFX_write_string(&FontT105,tXr1,text,1); 673 GFX_write_string(&FontT105,tXr1,text,1);
660 } 674 }
661 else 675 else
662 { 676 {
663 switch(get_globalState()) 677 switch(get_globalState())
724 if(Divetime.Minutes < 100) 738 if(Divetime.Minutes < 100)
725 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds); 739 snprintf(text,TEXTSIZE,"\020\003\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
726 else 740 else
727 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes); 741 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes);
728 742
729 t3_basics_colorscheme_mod(text); 743 Gfx_colorsscheme_mod(text,0);
730 GFX_write_string(&FontT105,tXr1,text,1); 744 GFX_write_string(&FontT105,tXr1,text,1);
731 break; 745 break;
732 } 746 }
733 } 747 }
734 748
747 // customview 761 // customview
748 if(stateUsed->warnings.numWarnings) 762 if(stateUsed->warnings.numWarnings)
749 customview_warnings = t3_test_customview_warnings(); 763 customview_warnings = t3_test_customview_warnings();
750 764
751 if(customview_warnings && warning_count_high_time) 765 if(customview_warnings && warning_count_high_time)
766 {
752 t3_basics_show_customview_warnings(&t3c1); 767 t3_basics_show_customview_warnings(&t3c1);
768 }
753 else 769 else
770 {
754 t3_refresh_customview(depth_meter); 771 t3_refresh_customview(depth_meter);
755 772 requestBuzzerActivation(0);
773 }
756 if(stateUsed->warnings.lowBattery) 774 if(stateUsed->warnings.lowBattery)
757 t3_basics_battery_low_customview_extra(&t3r1); //t3c1); 775 t3_basics_battery_low_customview_extra(&t3r1); //t3c1);
758 } 776 }
759 777
760 778
829 if(settingsGetPointer()->nonMetricalSystem == 0) 847 if(settingsGetPointer()->nonMetricalSystem == 0)
830 text[textpointer++] = 'C'; 848 text[textpointer++] = 'C';
831 else 849 else
832 text[textpointer++] = 'F'; 850 text[textpointer++] = 'F';
833 text[textpointer++] = 0; 851 text[textpointer++] = 0;
834 t3_basics_colorscheme_mod(text); 852 Gfx_colorsscheme_mod(text,0);
835 GFX_write_string(&FontT105,tXc1,text,1); 853 GFX_write_string(&FontT105,tXc1,text,1);
836 break; 854 break;
837 855
838 case CVIEW_T3_ApnoeSurfaceInfo: 856 case CVIEW_T3_ApnoeSurfaceInfo:
839 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime); 857 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime);
856 { 874 {
857 tXc1->WindowY1 -= 100; /* jump to upper of two lines */ 875 tXc1->WindowY1 -= 100; /* jump to upper of two lines */
858 } 876 }
859 877
860 snprintf(text,TEXTSIZE,"\020\016%u:%02u",LastDivetime.Minutes, LastDivetime.Seconds); 878 snprintf(text,TEXTSIZE,"\020\016%u:%02u",LastDivetime.Minutes, LastDivetime.Seconds);
861 t3_basics_colorscheme_mod(text); 879 Gfx_colorsscheme_mod(text,0);
862 GFX_write_string(&FontT105,tXc1,text,0); 880 GFX_write_string(&FontT105,tXc1,text,0);
863 881
864 if(pSettings->FlipDisplay) 882 if(pSettings->FlipDisplay)
865 { 883 {
866 tXc1->WindowX0 = 0; 884 tXc1->WindowX0 = 0;
878 tXc1->WindowX1 = tempWinX1; 896 tXc1->WindowX1 = tempWinX1;
879 tXc1->WindowY1 = tempWinY1; /* jump to upper of two lines */ 897 tXc1->WindowY1 = tempWinY1; /* jump to upper of two lines */
880 } 898 }
881 899
882 snprintf(text,TEXTSIZE,"\020\016%u:%02u",TotalDivetime.Minutes, TotalDivetime.Seconds); 900 snprintf(text,TEXTSIZE,"\020\016%u:%02u",TotalDivetime.Minutes, TotalDivetime.Seconds);
883 t3_basics_colorscheme_mod(text); 901 Gfx_colorsscheme_mod(text,0);
884 GFX_write_string(&FontT105,tXc1,text,0); 902 GFX_write_string(&FontT105,tXc1,text,0);
885 903
886 snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaTotal); 904 snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaTotal);
887 if(pSettings->FlipDisplay) 905 if(pSettings->FlipDisplay)
888 { 906 {
900 } 918 }
901 919
902 920
903 void t3_basics_refresh_customview(float depth, uint8_t tX_selection_customview, GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXc1, GFX_DrawCfgWindow* tXc2, uint8_t mode) 921 void t3_basics_refresh_customview(float depth, uint8_t tX_selection_customview, GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXc1, GFX_DrawCfgWindow* tXc2, uint8_t mode)
904 { 922 {
905 static uint8_t last_customview = CVIEW_END; 923 static uint8_t last_customview = CVIEW_T3_END;
906 924
907 char text[30]; 925 char text[30];
908 uint16_t textpointer = 0; 926 uint16_t textpointer = 0;
909 927
910 SSettings* pSettings; 928 SSettings* pSettings;
969 } 987 }
970 else 988 else
971 { 989 {
972 heading = (uint16_t)stateUsed->lifeData.compass_heading; 990 heading = (uint16_t)stateUsed->lifeData.compass_heading;
973 } 991 }
974 if(last_customview != tX_selection_customview) /* check if current selection is disabled and should be skipped */ 992 if((last_customview != tX_selection_customview) && (settingsGetPointer()->design == 3)) /* check if current selection is disabled and should be skipped */
975 { 993 {
976 if(t3_customview_disabled(tX_selection_customview)) 994 if(t3_customview_disabled(tX_selection_customview))
977 { 995 {
978 tX_selection_customview = t3_change_customview(ACTION_BUTTON_ENTER); 996 tX_selection_customview = t3_change_customview(ACTION_BUTTON_ENTER);
979 } 997 }
995 GFX_write_string(&FontT42,tXc2,text,0); 1013 GFX_write_string(&FontT42,tXc2,text,0);
996 tXc2->WindowY1 -= 100; /* jump to upper of two lines */ 1014 tXc2->WindowY1 -= 100; /* jump to upper of two lines */
997 } 1015 }
998 1016
999 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_last_max_depth_meter)); 1017 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_last_max_depth_meter));
1000 t3_basics_colorscheme_mod(text); 1018 Gfx_colorsscheme_mod(text,0);
1001 1019
1002 if(!pSettings->FlipDisplay) 1020 if(!pSettings->FlipDisplay)
1003 { 1021 {
1004 GFX_write_string(&FontT105,tXc1,text,0); 1022 GFX_write_string(&FontT105,tXc1,text,0);
1005 tXc1->WindowY0 = tempWinY0; 1023 tXc1->WindowY0 = tempWinY0;
1010 tXc2->WindowY1 = tempWinC2Y1; /* jump to upper of two lines */ 1028 tXc2->WindowY1 = tempWinC2Y1; /* jump to upper of two lines */
1011 } 1029 }
1012 1030
1013 1031
1014 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_total_max_depth_meter)); 1032 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_total_max_depth_meter));
1015 t3_basics_colorscheme_mod(text); 1033 Gfx_colorsscheme_mod(text,0);
1016 if(!pSettings->FlipDisplay) 1034 if(!pSettings->FlipDisplay)
1017 { 1035 {
1018 GFX_write_string(&FontT105,tXc1,text,0); 1036 GFX_write_string(&FontT105,tXc1,text,0);
1019 } 1037 }
1020 else 1038 else
1200 snprintf(&text[textpointer],TEXTSIZE,"\020\003%u%c%c %u'" 1218 snprintf(&text[textpointer],TEXTSIZE,"\020\003%u%c%c %u'"
1201 , unit_depth_integer(nextstopDepthMeter) 1219 , unit_depth_integer(nextstopDepthMeter)
1202 , unit_depth_char1_T105() 1220 , unit_depth_char1_T105()
1203 , unit_depth_char2_T105() 1221 , unit_depth_char2_T105()
1204 , (nextstopLengthSeconds+59)/60); 1222 , (nextstopLengthSeconds+59)/60);
1205 t3_basics_colorscheme_mod(text); 1223 Gfx_colorsscheme_mod(text,0);
1206 GFX_write_string(&FontT105,tXc1,text,0); 1224 GFX_write_string(&FontT105,tXc1,text,0);
1207 } 1225 }
1208 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit())) 1226 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit()))
1209 { 1227 {
1210 textpointer = 0; 1228 textpointer = 0;
1211 snprintf(&text[textpointer],TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2); 1229 snprintf(&text[textpointer],TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2);
1212 GFX_write_string(&FontT42,tXc1,text,0); 1230 GFX_write_string(&FontT42,tXc1,text,0);
1213 1231
1214 textpointer = 0; 1232 textpointer = 0;
1215 snprintf(&text[textpointer],TEXTSIZE,"\020\003\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds); 1233 snprintf(&text[textpointer],TEXTSIZE,"\020\003\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds);
1216 t3_basics_colorscheme_mod(text); 1234 Gfx_colorsscheme_mod(text,0);
1217 GFX_write_string(&FontT105,tXc1,text,0); 1235 GFX_write_string(&FontT105,tXc1,text,0);
1218 } 1236 }
1219 else if(pDecoinfo->output_ndl_seconds) // NDL 1237 else if(pDecoinfo->output_ndl_seconds) // NDL
1220 { 1238 {
1221 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Nullzeit); 1239 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Nullzeit);
1222 GFX_write_string(&FontT42,tXc1,text,0); 1240 GFX_write_string(&FontT42,tXc1,text,0);
1223 if(pDecoinfo->output_ndl_seconds < 1000 * 60) 1241 if(pDecoinfo->output_ndl_seconds < 1000 * 60)
1224 snprintf(text,TEXTSIZE,"\020\003%i'",pDecoinfo->output_ndl_seconds/60); 1242 snprintf(text,TEXTSIZE,"\020\003%i'",pDecoinfo->output_ndl_seconds/60);
1225 else 1243 else
1226 snprintf(text,TEXTSIZE,"\020\003%ih",pDecoinfo->output_ndl_seconds/3600); 1244 snprintf(text,TEXTSIZE,"\020\003%ih",pDecoinfo->output_ndl_seconds/3600);
1227 t3_basics_colorscheme_mod(text); 1245 Gfx_colorsscheme_mod(text,0);
1228 GFX_write_string(&FontT105,tXc1,text,0); 1246 GFX_write_string(&FontT105,tXc1,text,0);
1229 } 1247 }
1230 1248
1231 if(tX_selection_customview == CVIEW_T3_DecoTTS) /* add tts data on right side of screen */ 1249 if(tX_selection_customview == CVIEW_T3_DecoTTS) /* add tts data on right side of screen */
1232 { 1250 {
1238 { 1256 {
1239 if(pDecoinfo->output_time_to_surface_seconds < 100 * 60) 1257 if(pDecoinfo->output_time_to_surface_seconds < 100 * 60)
1240 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); 1258 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
1241 else 1259 else
1242 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); 1260 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
1243 t3_basics_colorscheme_mod(text); 1261 Gfx_colorsscheme_mod(text,0);
1244 GFX_write_string(&FontT105,tXc1,text,0); 1262 GFX_write_string(&FontT105,tXc1,text,0);
1245 } 1263 }
1246 } 1264 }
1247 else if(pDecoinfo->super_saturation > 0.1) 1265 else if(pDecoinfo->super_saturation > 0.1)
1248 { 1266 {
1249 snprintf(text,TEXTSIZE,"\002\032\f%c",TXT_ActualGradient); 1267 snprintf(text,TEXTSIZE,"\002\032\f%c",TXT_ActualGradient);
1250 GFX_write_string(&FontT42,tXc1,text,0); 1268 GFX_write_string(&FontT42,tXc1,text,0);
1251 snprintf(text,TEXTSIZE,"\020\003\002%.0f\016\016%%\017",100 * pDecoinfo->super_saturation); 1269 snprintf(text,TEXTSIZE,"\020\003\002%.0f\016\016%%\017",100 * pDecoinfo->super_saturation);
1252 t3_basics_colorscheme_mod(text); 1270 Gfx_colorsscheme_mod(text,0);
1253 GFX_write_string(&FontT105,tXc1,text,0); 1271 GFX_write_string(&FontT105,tXc1,text,0);
1254 } 1272 }
1255 } 1273 }
1256 break; 1274 break;
1257 1275
1258 case CVIEW_sensors: 1276 case CVIEW_T3_sensors:
1259 snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_O2monitor); 1277 snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_O2monitor);
1260 GFX_write_string(&FontT42,tXc1,text,0); 1278 GFX_write_string(&FontT42,tXc1,text,0);
1261 1279
1262 for(int i=0;i<3;i++) 1280 for(int i=0;i<3;i++)
1263 { 1281 {
1293 text[textpointer++] = '\025'; 1311 text[textpointer++] = '\025';
1294 textpointer += snprintf(&text[textpointer],TEXTSIZE,"%.2f",stateUsed->lifeData.ppO2Sensor_bar[i]); 1312 textpointer += snprintf(&text[textpointer],TEXTSIZE,"%.2f",stateUsed->lifeData.ppO2Sensor_bar[i]);
1295 } 1313 }
1296 GFX_write_string(&FontT105,tXc1,text,0); 1314 GFX_write_string(&FontT105,tXc1,text,0);
1297 1315
1316 if((pSettings->co2_sensor_active) && isLoopMode(pSettings->dive_mode))
1317 {
1318 snprintf(text,TEXTSIZE,"\032\001\f%c",TXT_CO2Sensor);
1319 GFX_write_string(&FontT42,tXc1,text,0);
1320 textpointer = 0;
1321 if(stateUsed->lifeData.CO2_data.CO2_ppm < CO2_WARNING_LEVEL_PPM)
1322 {
1323 text[textpointer++] = '\020';
1324 }
1325 else if(stateUsed->lifeData.CO2_data.CO2_ppm < CO2_ALARM_LEVEL_PPM)
1326 {
1327 text[textpointer++] = '\024'; /* yellow */
1328 }
1329 else
1330 {
1331 text[textpointer++] = '\025'; /* red */
1332 }
1333 snprintf(&text[textpointer],TEXTSIZE,"\001%5ld",stateUsed->lifeData.CO2_data.CO2_ppm);
1334 GFX_write_string(&FontT105,tXc1,text,1);
1335 }
1298 1336
1299 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && isLoopMode(pSettings->dive_mode)) 1337 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && isLoopMode(pSettings->dive_mode))
1300 { 1338 {
1301 snprintf(text,TEXTSIZE,"\032\002\f%c",TXT_ScrubTime); 1339 snprintf(text,TEXTSIZE,"\032\002\f%c",TXT_ScrubTime);
1302 GFX_write_string(&FontT42,tXc1,text,0); 1340 GFX_write_string(&FontT42,tXc1,text,0);
1303 1341
1304 textpointer = 0; 1342 textpointer = 0;
1305 text[textpointer++] = '\002'; 1343 text[textpointer++] = '\002';
1306 textpointer += printScrubberText(&text[textpointer], 10, pSettings); 1344 textpointer += printScrubberText(&text[textpointer], 10, stateUsed->scrubberDataDive, pSettings);
1307 GFX_write_string(&FontT105,tXc1,text,1); 1345 GFX_write_string(&FontT105,tXc1,text,1);
1308 } 1346 }
1309 } 1347 }
1310 break; 1348 break;
1311 1349
1325 else 1363 else
1326 { 1364 {
1327 GFX_write_string(&FontT42,tXc1,text,0); 1365 GFX_write_string(&FontT42,tXc1,text,0);
1328 } 1366 }
1329 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); 1367 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
1330 t3_basics_colorscheme_mod(text); 1368 Gfx_colorsscheme_mod(text,0);
1331 if(pSettings->FlipDisplay) 1369 if(pSettings->FlipDisplay)
1332 { 1370 {
1333 if(mode == DIVEMODE_Apnea) 1371 if(mode == DIVEMODE_Apnea)
1334 { 1372 {
1335 GFX_write_string(&FontT105,tXc2,text,0); 1373 GFX_write_string(&FontT105,tXc2,text,0);
1352 { 1390 {
1353 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60) 1391 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60)
1354 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); 1392 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
1355 else 1393 else
1356 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); 1394 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
1357 t3_basics_colorscheme_mod(text); 1395 Gfx_colorsscheme_mod(text,0);
1358 GFX_write_string(&FontT105,tXc1,text,0); 1396 GFX_write_string(&FontT105,tXc1,text,0);
1359 } 1397 }
1360 break; 1398 break;
1361 1399
1362 case CVIEW_T3_ppO2andGas: 1400 case CVIEW_T3_ppO2andGas:
1363 snprintf(text,TEXTSIZE,"\032\f%c",TXT_ppO2); 1401 snprintf(text,TEXTSIZE,"\032\f%c",TXT_ppO2);
1364 GFX_write_string(&FontT42,tXc1,text,0); 1402 GFX_write_string(&FontT42,tXc1,text,0);
1365 snprintf(text,TEXTSIZE,"\020\003%01.2f",stateUsed->lifeData.ppO2); 1403 snprintf(text,TEXTSIZE,"\020\003%01.2f",stateUsed->lifeData.ppO2);
1366 t3_basics_colorscheme_mod(text); 1404 Gfx_colorsscheme_mod(text,0);
1367 GFX_write_string(&FontT105,tXc1,text,0); 1405 GFX_write_string(&FontT105,tXc1,text,0);
1368 1406
1369 textpointer = 0; 1407 textpointer = 0;
1370 text[textpointer++] = '\020'; 1408 text[textpointer++] = '\020';
1371 text[textpointer++] = '\003'; 1409 text[textpointer++] = '\003';
1373 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage; 1411 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage;
1374 oxygen_percentage -= stateUsed->lifeData.actualGas.helium_percentage; 1412 oxygen_percentage -= stateUsed->lifeData.actualGas.helium_percentage;
1375 text[textpointer++] = '\002'; 1413 text[textpointer++] = '\002';
1376 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[textpointer]); 1414 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[textpointer]);
1377 //textpointer = snprintf(&text[textpointer],TEXTSIZE,"\020\002%02u/%02u",oxygen_percentage, stateUsed->lifeData.actualGas.helium_percentage); 1415 //textpointer = snprintf(&text[textpointer],TEXTSIZE,"\020\002%02u/%02u",oxygen_percentage, stateUsed->lifeData.actualGas.helium_percentage);
1378 t3_basics_colorscheme_mod(text); 1416 Gfx_colorsscheme_mod(text,0);
1379 GFX_write_string(&FontT48,tXc1,text,0); 1417 GFX_write_string(&FontT48,tXc1,text,0);
1380 break; 1418 break;
1381 1419
1382 case CVIEW_T3_Navigation: 1420 case CVIEW_T3_Navigation:
1383 Stopwatch.Total = timer_Stopwatch_GetTime(); 1421 Stopwatch.Total = timer_Stopwatch_GetTime();
1439 else 1477 else
1440 { 1478 {
1441 GFX_write_string(&FontT42,tXc1,text,0); 1479 GFX_write_string(&FontT42,tXc1,text,0);
1442 } 1480 }
1443 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); 1481 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
1444 t3_basics_colorscheme_mod(text); 1482 Gfx_colorsscheme_mod(text,0);
1445 if(pSettings->FlipDisplay) 1483 if(pSettings->FlipDisplay)
1446 { 1484 {
1447 if(mode == DIVEMODE_Apnea) 1485 if(mode == DIVEMODE_Apnea)
1448 { 1486 {
1449 GFX_write_string(&FontT105,tXc2,text,0); 1487 GFX_write_string(&FontT105,tXc2,text,0);
1499 //void t3_show_customview_warnings(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode) 1537 //void t3_show_customview_warnings(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode)
1500 void t3_basics_show_customview_warnings(GFX_DrawCfgWindow* tXc1) 1538 void t3_basics_show_customview_warnings(GFX_DrawCfgWindow* tXc1)
1501 { 1539 {
1502 char text[256], textMain[256]; 1540 char text[256], textMain[256];
1503 uint8_t textpointer, textpointerMain, lineFree, more; 1541 uint8_t textpointer, textpointerMain, lineFree, more;
1542 #ifdef HAVE_DEBUG_WARNINGS
1543 uint8_t index = 0;
1544 #endif
1504 1545
1505 snprintf(text,TEXTSIZE,"\025\f%c",TXT_Warning); 1546 snprintf(text,TEXTSIZE,"\025\f%c",TXT_Warning);
1506 GFX_write_string(&FontT42,&t3c1,text,0); 1547 GFX_write_string(&FontT42,&t3c1,text,0);
1507 1548
1508 lineFree = 1; 1549 lineFree = 1;
1620 text[textpointer++] = '\r'; 1661 text[textpointer++] = '\r';
1621 text[textpointer++] = '\n'; 1662 text[textpointer++] = '\n';
1622 more++; 1663 more++;
1623 } 1664 }
1624 } 1665 }
1625 1666 #ifdef HAVE_DEBUG_WARNINGS
1667 if(lineFree && stateUsed->warnings.debug)
1668 {
1669 for(index=0; index<3; index++)
1670 {
1671 if(((stateUsed->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) && (((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status & DVO2_FATAL_ERROR)))
1672 {
1673 textpointer += snprintf(&text[textpointer],32,"\001Debug: %lx\n",((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status);
1674 }
1675 }
1676 lineFree--;
1677 }
1678 #endif
1626 text[textpointer] = 0; 1679 text[textpointer] = 0;
1627 textMain[textpointerMain] = 0; 1680 textMain[textpointerMain] = 0;
1628 1681
1629 if(lineFree == 0) 1682 if(lineFree == 0)
1630 { 1683 {
1632 } 1685 }
1633 if(more) 1686 if(more)
1634 { 1687 {
1635 GFX_write_string(&FontT48,&t3c2,text,0); 1688 GFX_write_string(&FontT48,&t3c2,text,0);
1636 } 1689 }
1690 requestBuzzerActivation(1);
1637 } 1691 }
1638 1692
1639 uint8_t t3_customview_disabled(uint8_t view) 1693 uint8_t t3_customview_disabled(uint8_t view)
1640 { 1694 {
1641 uint8_t i = 0; 1695 uint8_t i = 0;
1653 break; 1707 break;
1654 } 1708 }
1655 i++; 1709 i++;
1656 } 1710 }
1657 1711
1658 if (((view == CVIEW_sensors) || (view == CVIEW_sensors_mV)) && 1712 if ((view == CVIEW_T3_sensors) &&
1659 ((stateUsed->diveSettings.ppo2sensors_deactivated == 0x07) || (stateUsed->diveSettings.ccrOption == 0) || stateUsed->warnings.fallback)) 1713 ((stateUsed->diveSettings.ppo2sensors_deactivated == 0x07) || (stateUsed->diveSettings.ccrOption == 0) || stateUsed->warnings.fallback))
1660 { 1714 {
1661 cv_disabled = 1; 1715 cv_disabled = 1;
1662 } 1716 }
1663 1717
1665 } 1719 }
1666 1720
1667 uint8_t t3_change_customview(uint8_t action) 1721 uint8_t t3_change_customview(uint8_t action)
1668 { 1722 {
1669 1723
1670 t3_basics_change_customview(&t3_selection_customview, t3_customviewsStandard, action); 1724 t3_basics_change_customview(&t3_selection_customview, cv_changelist_BS, action);
1671 return t3_selection_customview; 1725 return t3_selection_customview;
1672 } 1726 }
1673 1727
1674 1728
1675 void t3_basics_change_customview(uint8_t *tX_selection_customview,const uint8_t *tX_customviews, uint8_t action) 1729 void t3_basics_change_customview(uint8_t *tX_selection_customview,const uint8_t *tX_customviews, uint8_t action)
1686 while((tX_customviews[index] != CVIEW_T3_END)) 1740 while((tX_customviews[index] != CVIEW_T3_END))
1687 { 1741 {
1688 if (tX_customviews[index] == *tX_selection_customview) 1742 if (tX_customviews[index] == *tX_selection_customview)
1689 { 1743 {
1690 curViewIdx = index; 1744 curViewIdx = index;
1745 break;
1691 } 1746 }
1692 index++; 1747 index++;
1693 } 1748 }
1694 if(curViewIdx == 0xff) /* called with unknown view */ 1749 if(curViewIdx == 0xff) /* called with unknown view */
1695 { 1750 {
1729 break; 1784 break;
1730 default: 1785 default:
1731 break; 1786 break;
1732 } 1787 }
1733 1788
1734 if(t3_customview_disabled(tX_customviews[index])) 1789 if((tX_customviews == cv_changelist_BS) && (t3_customview_disabled(tX_customviews[index])))
1735 { 1790 {
1736 iterate = 1; 1791 iterate = 1;
1737 if(*tX_selection_customview == tX_customviews[index]) 1792 if(*tX_selection_customview == tX_customviews[index])
1738 { 1793 {
1739 useFallback = 1; /* the provided view is disabled => use fallback */ 1794 useFallback = 1; /* the provided view is disabled => use fallback */
1786 { 1841 {
1787 *tX_selection_customview = tX_customviews[index]; 1842 *tX_selection_customview = tX_customviews[index];
1788 } 1843 }
1789 } 1844 }
1790 1845
1791
1792 void t3_basics_colorscheme_mod(char *text)
1793 {
1794 if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard())
1795 {
1796 text[0] = '\027';
1797 }
1798 }
1799
1800
1801 point_t t3_compass_circle(uint8_t id, uint16_t degree, point_t center) 1846 point_t t3_compass_circle(uint8_t id, uint16_t degree, point_t center)
1802 { 1847 {
1803 float fCos, fSin; 1848 float fCos, fSin;
1804 const float piMult = ((2 * 3.14159) / 360); 1849 const float piMult = ((2 * 3.14159) / 360);
1805 // const int radius[4] = {95,105,115,60}; 1850 // const int radius[4] = {95,105,115,60};
1929 { 1974 {
1930 uint8_t *pViews; 1975 uint8_t *pViews;
1931 uint8_t increment = 1; 1976 uint8_t increment = 1;
1932 uint8_t enabledViewCnt = 0; 1977 uint8_t enabledViewCnt = 0;
1933 1978
1934 pViews = (uint8_t*)t3_customviewsStandard; 1979 pViews = (uint8_t*)cv_changelist_BS;
1935 while((*pViews != CVIEW_T3_END)) 1980 while((*pViews != CVIEW_T3_END))
1936 { 1981 {
1937 increment = 1; 1982 increment = 1;
1938 /* check if view is enabled */ 1983 /* check if view is enabled */
1939 if(t3_customview_disabled(*pViews)) 1984 if(t3_customview_disabled(*pViews))
1949 uint8_t t3_getCustomView(void) 1994 uint8_t t3_getCustomView(void)
1950 { 1995 {
1951 return t3_selection_customview; 1996 return t3_selection_customview;
1952 } 1997 }
1953 1998
1954 int printScrubberText(char *text, size_t size, SSettings *settings) 1999 int printScrubberText(char *text, size_t size, const SScrubberData *scrubberData, SSettings *settings)
1955 { 2000 {
1956 int16_t currentTimerMinutes = settings->scrubberData[settings->scubberActiveId].TimerCur; 2001 int16_t currentTimerMinutes = scrubberData[settings->scubberActiveId].TimerCur;
1957 char colour = '\020'; 2002 char colour = '\020';
1958 if (currentTimerMinutes <= 0) { 2003 if (currentTimerMinutes <= 0) {
1959 colour = '\025'; 2004 colour = '\025';
1960 } else if (currentTimerMinutes <= 30) { 2005 } else if (currentTimerMinutes <= 30) {
1961 colour = '\024'; 2006 colour = '\024';
1965 return snprintf(text, size, "%c%3i'", colour, currentTimerMinutes); 2010 return snprintf(text, size, "%c%3i'", colour, currentTimerMinutes);
1966 } else { 2011 } else {
1967 return snprintf(text, size, "%c%u\016\016%%\017", colour, currentTimerMinutes * 100 / settingsGetPointer()->scrubberData[settings->scubberActiveId].TimerMax); 2012 return snprintf(text, size, "%c%u\016\016%%\017", colour, currentTimerMinutes * 100 / settingsGetPointer()->scrubberData[settings->scubberActiveId].TimerMax);
1968 } 2013 }
1969 } 2014 }
2015
2016 void t3_AF_updateBorderConditions()
2017 {
2018 uint16_t nextstopLengthSeconds = 0;
2019 uint8_t nextstopDepthMeter = 0;
2020
2021 tHome_findNextStop(getDecoInfo()->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds);
2022 AF_lastDecoDepth = nextstopDepthMeter;
2023 AF_lastTTS = (getDecoInfo()->output_time_to_surface_seconds / 60) / 10;
2024 }
2025
2026 uint8_t t3_CheckAfCondition(uint8_t T3CView)
2027 {
2028 uint8_t retVal = 0;
2029
2030 float pitch = stateRealGetPointer()->lifeData.compass_pitch;
2031 float roll = stateRealGetPointer()->lifeData.compass_roll;
2032
2033 uint16_t nextstopLengthSeconds = 0;
2034 uint8_t nextstopDepthMeter = 0;
2035
2036 switch (T3CView)
2037 {
2038 case CVIEW_T3_GasList: retVal = (stateUsed->warnings.betterGas) /* switch if better gas is available or depending on ppo2 if in OC mode */
2039 || ((stateUsed->diveSettings.diveMode == DIVEMODE_OC) && ((stateUsed->warnings.ppO2Low) || (stateUsed->warnings.ppO2High)));
2040
2041 break;
2042 case CVIEW_T3_Navigation: retVal = (pitch > -AF_COMPASS_ACTIVATION_ANGLE) && (pitch < AF_COMPASS_ACTIVATION_ANGLE)
2043 && (roll > -AF_COMPASS_ACTIVATION_ANGLE) && (roll < AF_COMPASS_ACTIVATION_ANGLE);
2044
2045 break;
2046 case CVIEW_T3_DecoTTS: tHome_findNextStop(getDecoInfo()->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds);
2047 /* A new deco step is added to the plan */
2048 if(nextstopDepthMeter > AF_lastDecoDepth)
2049 {
2050 retVal = 1;
2051 }
2052
2053 /* Close to the next deco step or missed deco step */
2054 if((abs(stateUsed->lifeData.depth_meter - nextstopDepthMeter) < 2) || (stateUsed->warnings.decoMissed))
2055 {
2056 retVal = 1;
2057 }
2058 /* Another 10 minutes to surface */
2059 if((getDecoInfo()->output_time_to_surface_seconds) && ((uint16_t)((getDecoInfo()->output_time_to_surface_seconds / 60) / 10) > AF_lastTTS))
2060 {
2061 retVal = 1;
2062 }
2063 break;
2064 default: break;
2065 }
2066
2067 return retVal;
2068 }
2069
2070 uint8_t t3_EvaluateAFCondition(uint8_t T3CView)
2071 {
2072 static uint8_t debounce[CVIEW_T3_END];
2073 static uint8_t lastState[CVIEW_T3_END];
2074 uint8_t detectionState = AF_VIEW_NOCHANGE;
2075 uint8_t cnt = 0;
2076
2077 if(T3CView <= CVIEW_T3_END)
2078 {
2079 if(T3CView == CVIEW_T3_END)
2080 {
2081 for(cnt = 0; cnt < CVIEW_T3_END; cnt++)
2082 {
2083 debounce[cnt] = 0;
2084 lastState[cnt] = AF_VIEW_NOCHANGE;
2085 }
2086 }
2087 if(t3_CheckAfCondition(T3CView))
2088 {
2089 if(debounce[T3CView] < 10)
2090 {
2091 debounce[T3CView]++;
2092 }
2093 else
2094 {
2095 detectionState = AF_VIEW_ACTIVATED;
2096 }
2097 }
2098 else
2099 {
2100 if(debounce[T3CView] > 0)
2101 {
2102 debounce[T3CView]--;
2103 }
2104 else
2105 {
2106 detectionState = AF_VIEW_DEACTIVATED;
2107 }
2108 }
2109 if(detectionState) /* no state change => return 0 */
2110 {
2111 if((detectionState == lastState[T3CView]))
2112 {
2113 detectionState = AF_VIEW_NOCHANGE;
2114 }
2115 else
2116 {
2117 lastState[T3CView] = detectionState;
2118 }
2119 }
2120 }
2121 return detectionState;
2122 }
2123
2124 void t3_handleAutofocus(void)
2125 {
2126 static uint8_t returnView = CVIEW_T3_END;
2127
2128 uint8_t runningT3CView = 0;
2129
2130 for (runningT3CView = 0; runningT3CView < CVIEW_T3_END; runningT3CView++)
2131 {
2132 if(stateUsed->diveSettings.activeAFViews & (1 << runningT3CView))
2133 {
2134 switch(t3_EvaluateAFCondition(runningT3CView))
2135 {
2136 case AF_VIEW_ACTIVATED: returnView = t3_selection_customview;
2137 t3_select_customview(runningT3CView);
2138 t3_AF_updateBorderConditions();
2139 break;
2140 case AF_VIEW_DEACTIVATED: if((returnView != CVIEW_T3_END) && (t3_selection_customview == runningT3CView))
2141 {
2142 if(runningT3CView != CVIEW_T3_DecoTTS) /* some view does not switch back */
2143 {
2144 t3_select_customview(returnView);
2145 }
2146 returnView = CVIEW_T3_END;
2147 }
2148 break;
2149 default:
2150 break;
2151 }
2152 }
2153 }
2154 }
2155
2156 #define ASCENT_GRAPH_YPIXEL 220
2157 uint8_t t3_drawSlowExitGraph(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1) /* this function is only called if diver is below last last stop depth */
2158 {
2159 static uint16_t countDownSec = 0;
2160 uint8_t drawingMeterStep;
2161 static float exitDepthMeter = 0.0;
2162
2163
2164 uint8_t index = 0;
2165 uint8_t color = 0;
2166 point_t start, stop;
2167
2168 SSettings* pSettings;
2169 pSettings = settingsGetPointer();
2170
2171
2172 if(calculateSlowExit(&countDownSec, &exitDepthMeter, &color)) /* graph to be drawn? */
2173 {
2174 if(!pSettings->FlipDisplay)
2175 {
2176 start.y = tXl1->WindowY0 - 1;
2177 }
2178 else
2179 {
2180 start.y = tXl1->WindowY1 + 1;
2181 }
2182
2183 drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */
2184
2185 for(index = 0; index < pSettings->last_stop_depth_meter; index++) /* draw meter indicators */
2186 {
2187 start.y += drawingMeterStep;
2188 stop.y = start.y;
2189 if(!pSettings->FlipDisplay)
2190 {
2191 start.x = tXl1->WindowX1 - 1;
2192 }
2193 else
2194 {
2195 start.x = tXr1->WindowX1 + 3;
2196 }
2197 stop.x = start.x - 43;
2198 GFX_draw_line(tXscreen, start, stop, 0);
2199 }
2200
2201 /* draw cntdown bar */
2202
2203 if(!pSettings->FlipDisplay)
2204 {
2205 start.x -= 20;
2206 start.y = tXl1->WindowY0 + ASCENT_GRAPH_YPIXEL + 2;
2207 }
2208 else
2209 {
2210 start.x -= 25;
2211 start.y = tXl1->WindowY1 + ASCENT_GRAPH_YPIXEL + 5;
2212 }
2213 stop.x = start.x;
2214 stop.y = start.y - countDownSec * (ASCENT_GRAPH_YPIXEL / (float)(pSettings->slowExitTime * 60.0));
2215 if(stop.y >= 470) stop.y = 470;
2216 if(!pSettings->FlipDisplay)
2217 {
2218 stop.y += 5;
2219 }
2220 GFX_draw_thick_line(15,tXscreen, start, stop, 3);
2221 /* mark diver depth */
2222 if(!pSettings->FlipDisplay)
2223 {
2224 start.x = tXl1->WindowX1 - 32;
2225 stop.x = start.x + 24;
2226 }
2227 else
2228 {
2229 start.x = tXr1->WindowX1 - 33;
2230 stop.x = start.x + 24;
2231 }
2232
2233
2234 start.y = start.y - (stateUsed->lifeData.depth_meter * (ASCENT_GRAPH_YPIXEL) / pSettings->last_stop_depth_meter);
2235 stop.y = start.y;
2236 GFX_draw_thick_line(10,tXscreen, start, stop, 9);
2237 }
2238 else
2239 {
2240 color = 0xff;
2241 }
2242 return color;
2243 }