comparison Discovery/Src/tMenuEditGasOC.c @ 528:a9c195be907e

Added new option to gas configuration: "Off": Added functionality needed to handle the new state
author Ideenmodellierer
date Sun, 13 Sep 2020 20:59:38 +0200
parents 3f09b283d993
children 15f6f0b5786c
comparison
equal deleted inserted replaced
527:962d7b2c18c6 528:a9c195be907e
31 31
32 #include "check_warning.h" 32 #include "check_warning.h"
33 #include "gfx_fonts.h" 33 #include "gfx_fonts.h"
34 #include "tMenuEdit.h" 34 #include "tMenuEdit.h"
35 #include "unit.h" 35 #include "unit.h"
36 #include "configuration.h"
36 37
37 /* Private types -------------------------------------------------------------*/ 38 /* Private types -------------------------------------------------------------*/
38 typedef struct 39 typedef struct
39 { 40 {
40 uint8_t gasID; 41 uint8_t gasID;
69 70
70 uint8_t OnAction_First (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 71 uint8_t OnAction_First (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
71 uint8_t OnAction_Deco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 72 uint8_t OnAction_Deco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
72 uint8_t OnAction_Travel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 73 uint8_t OnAction_Travel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
73 uint8_t OnAction_Inactive (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 74 uint8_t OnAction_Inactive (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
75 uint8_t OnAction_Off (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
74 76
75 uint8_t OnAction_DM_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 77 uint8_t OnAction_DM_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
76 uint8_t OnAction_DM_Mix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 78 uint8_t OnAction_DM_Mix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
77 79
78 /* 80 /*
153 { 155 {
154 editGasPage.gasID = line; 156 editGasPage.gasID = line;
155 setpoint = 0; 157 setpoint = 0;
156 } 158 }
157 159
160 #ifdef ENABLE_UNUSED_GAS_HIDING
161 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.off) /* disable selection of switched off gases */
162 {
163 return;
164 }
165 #endif
158 for(int i=0;i<(1+ (2*NUM_GASES));i++) 166 for(int i=0;i<(1+ (2*NUM_GASES));i++)
159 editGasPage.pGasLine[i].note.ub.first = 0; 167 editGasPage.pGasLine[i].note.ub.first = 0;
160 168
161 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; 169 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
162 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1; 170 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
334 342
335 343
336 /* surface mode */ 344 /* surface mode */
337 void openEdit_Gas(uint8_t line, uint8_t ccr) 345 void openEdit_Gas(uint8_t line, uint8_t ccr)
338 { 346 {
339 uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive;//, bottleSizeLiter; 347 uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive, off;//, bottleSizeLiter;
340 348
341 char text[32]; 349 char text[32];
342 char textMOD[32]; 350 char textMOD[32];
343 uint8_t txtptr; 351 uint8_t txtptr;
344 352
372 //depthTravel = editGasPage.pGasLine[gasID].depth_meter_travel; 380 //depthTravel = editGasPage.pGasLine[gasID].depth_meter_travel;
373 active = editGasPage.pGasLine[gasID].note.ub.active; 381 active = editGasPage.pGasLine[gasID].note.ub.active;
374 first = editGasPage.pGasLine[gasID].note.ub.first; 382 first = editGasPage.pGasLine[gasID].note.ub.first;
375 deco = editGasPage.pGasLine[gasID].note.ub.deco; 383 deco = editGasPage.pGasLine[gasID].note.ub.deco;
376 travel = editGasPage.pGasLine[gasID].note.ub.travel; 384 travel = editGasPage.pGasLine[gasID].note.ub.travel;
377 385 off = editGasPage.pGasLine[gasID].note.ub.off;
378 //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter; 386 //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter;
379 387
380 if(active) 388 if(active)
381 inactive = 0; 389 inactive = 0;
382 else 390 else
409 write_label_fix( 20, 800, ME_Y_LINE1, &FontT48, TXT_Mix); 417 write_label_fix( 20, 800, ME_Y_LINE1, &FontT48, TXT_Mix);
410 write_field_udigit(StMOG_Mix, 210, 400, ME_Y_LINE1, &FontT48, "##/##", (uint32_t)oxygen, (uint32_t)helium, 0, 0); 418 write_field_udigit(StMOG_Mix, 210, 400, ME_Y_LINE1, &FontT48, "##/##", (uint32_t)oxygen, (uint32_t)helium, 0, 0);
411 419
412 420
413 text[1] = 0; 421 text[1] = 0;
422 if(off)
423 text[0] = TXT_Off;
424 else
414 if(inactive) 425 if(inactive)
415 text[0] = TXT_Inactive; 426 text[0] = TXT_Inactive;
416 else 427 else
417 if(first) 428 if(first)
418 text[0] = TXT_First; 429 text[0] = TXT_First;
421 text[0] = TXT_Deco; 432 text[0] = TXT_Deco;
422 else 433 else
423 if(travel) 434 if(travel)
424 text[0] = TXT_Travel; 435 text[0] = TXT_Travel;
425 else 436 else
426 text[0] = TXT_Inactive; 437 text[0] = TXT_Inactive;
427 438
428 write_field_button(StMOG_GasType, 20, 710, ME_Y_LINE2, &FontT48, text); 439 write_field_button(StMOG_GasType, 20, 710, ME_Y_LINE2, &FontT48, text);
429 440
430 441
431 if(deco) 442 if(deco)
451 write_field_button(StMOG_SetToMOD, 20, 710, ME_Y_LINE4, &FontT48,text); 462 write_field_button(StMOG_SetToMOD, 20, 710, ME_Y_LINE4, &FontT48,text);
452 } 463 }
453 else 464 else
454 { 465 {
455 txtptr = 0; 466 txtptr = 0;
456 text[txtptr++] = '\021'; 467 text[txtptr++] = '\031';
457 text[txtptr++] = TXT_ChangeDepth; 468 text[txtptr++] = TXT_ChangeDepth;
458 text[txtptr++] = ' '; 469 text[txtptr++] = ' ';
459 text[txtptr++] = TXT_Deco; 470 text[txtptr++] = TXT_Deco;
460 text[txtptr++] = 0; 471 text[txtptr++] = 0;
461 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text); 472 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text);
462 473
463 txtptr = 0; 474 txtptr = 0;
464 text[txtptr++] = '\021'; 475 text[txtptr++] = '\031';
465 text[txtptr++] = TXT_2BYTE; 476 text[txtptr++] = TXT_2BYTE;
466 text[txtptr++] = TXT2BYTE_SetToMOD; 477 text[txtptr++] = TXT2BYTE_SetToMOD;
467 text[txtptr++] = 0; 478 text[txtptr++] = 0;
468 write_label_var( 20 ,800, ME_Y_LINE4, &FontT48, text); 479 write_label_var( 20 ,800, ME_Y_LINE4, &FontT48, text);
469 } 480 }
508 } 519 }
509 520
510 /* surface mode */ 521 /* surface mode */
511 void openEdit_GasType(void) 522 void openEdit_GasType(void)
512 { 523 {
513 uint8_t gasID, active, first, deco, travel, inactive; 524 uint8_t gasID, active, first, deco, travel, inactive, off;
514 char text[32]; 525 char text[32];
515 526
516 527
517 if(editGasPage.ccr) 528 if(editGasPage.ccr)
518 { 529 {
528 gasID = editGasPage.gasID; 539 gasID = editGasPage.gasID;
529 active = editGasPage.pGasLine[gasID].note.ub.active; 540 active = editGasPage.pGasLine[gasID].note.ub.active;
530 first = editGasPage.pGasLine[gasID].note.ub.first; 541 first = editGasPage.pGasLine[gasID].note.ub.first;
531 deco = editGasPage.pGasLine[gasID].note.ub.deco; 542 deco = editGasPage.pGasLine[gasID].note.ub.deco;
532 travel = editGasPage.pGasLine[gasID].note.ub.travel; 543 travel = editGasPage.pGasLine[gasID].note.ub.travel;
533 544 off = editGasPage.pGasLine[gasID].note.ub.off;
534 if(active) 545
546 if((active) || (off))
535 inactive = 0; 547 inactive = 0;
536 else 548 else
537 inactive = 1; 549 inactive = 1;
538 550
539 551
568 text[0] = TXT_Travel; 580 text[0] = TXT_Travel;
569 write_field_on_off(StMOG_Travel, 30, 400, ME_Y_LINE3, &FontT48, text, travel); 581 write_field_on_off(StMOG_Travel, 30, 400, ME_Y_LINE3, &FontT48, text, travel);
570 582
571 text[0] = TXT_Inactive; 583 text[0] = TXT_Inactive;
572 write_field_on_off(StMOG_Inactive, 30, 400, ME_Y_LINE4, &FontT48, text, inactive); 584 write_field_on_off(StMOG_Inactive, 30, 400, ME_Y_LINE4, &FontT48, text, inactive);
585
586 #ifdef ENABLE_UNUSED_GAS_HIDING
587 text[0] = TXT_Off;
588 write_field_on_off(StMOG_Off, 30, 400, ME_Y_LINE5, &FontT48, text, off);
589 #endif
573 590
574 setEvent(StMOG_First, (uint32_t)OnAction_First); 591 setEvent(StMOG_First, (uint32_t)OnAction_First);
575 setEvent(StMOG_Deco, (uint32_t)OnAction_Deco); 592 setEvent(StMOG_Deco, (uint32_t)OnAction_Deco);
576 setEvent(StMOG_Travel, (uint32_t)OnAction_Travel); 593 setEvent(StMOG_Travel, (uint32_t)OnAction_Travel);
577 setEvent(StMOG_Inactive, (uint32_t)OnAction_Inactive); 594 setEvent(StMOG_Inactive, (uint32_t)OnAction_Inactive);
595 #ifdef ENABLE_UNUSED_GAS_HIDING
596 setEvent(StMOG_Off, (uint32_t)OnAction_Off);
597 #endif
578 598
579 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 599 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
580 } 600 }
581 601
582 uint8_t OnAction_GasType(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 602 uint8_t OnAction_GasType(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
800 820
801 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1; 821 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
802 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; 822 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
803 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; 823 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0;
804 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; 824 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0;
825 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0;
805 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0; 826 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0;
806 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; 827 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0;
807 828
808 tMenuEdit_set_on_off(StMOG_First, 1); 829 tMenuEdit_set_on_off(StMOG_First, 1);
809 tMenuEdit_set_on_off(StMOG_Deco, 0); 830 tMenuEdit_set_on_off(StMOG_Deco, 0);
810 tMenuEdit_set_on_off(StMOG_Travel, 0); 831 tMenuEdit_set_on_off(StMOG_Travel, 0);
811 tMenuEdit_set_on_off(StMOG_Inactive, 0); 832 tMenuEdit_set_on_off(StMOG_Inactive, 0);
833 #ifdef ENABLE_UNUSED_GAS_HIDING
834 tMenuEdit_set_on_off(StMOG_Off, 0);
835 #endif
812 836
813 if(!first) 837 if(!first)
814 return UPDATE_DIVESETTINGS; 838 return UPDATE_DIVESETTINGS;
815 else 839 else
816 return UPDATE_AND_EXIT_TO_MENU; 840 return UPDATE_AND_EXIT_TO_MENU;
846 870
847 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; 871 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0;
848 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; 872 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
849 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 1; 873 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 1;
850 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; 874 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0;
875 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0;
851 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; 876 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0;
852 editGasPage.mod = calc_MOD(editGasPage.gasID); 877 editGasPage.mod = calc_MOD(editGasPage.gasID);
853 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod; 878 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod;
854 879
855 /* 880 /*
862 887
863 tMenuEdit_set_on_off(StMOG_First, 0); 888 tMenuEdit_set_on_off(StMOG_First, 0);
864 tMenuEdit_set_on_off(StMOG_Deco, 1); 889 tMenuEdit_set_on_off(StMOG_Deco, 1);
865 tMenuEdit_set_on_off(StMOG_Travel, 0); 890 tMenuEdit_set_on_off(StMOG_Travel, 0);
866 tMenuEdit_set_on_off(StMOG_Inactive, 0); 891 tMenuEdit_set_on_off(StMOG_Inactive, 0);
892 #ifdef ENABLE_UNUSED_GAS_HIDING
893 tMenuEdit_set_on_off(StMOG_Off, 0);
894 #endif
867 895
868 if(!deco) 896 if(!deco)
869 return UPDATE_DIVESETTINGS; 897 return UPDATE_DIVESETTINGS;
870 else 898 else
871 return UPDATE_AND_EXIT_TO_MENU; 899 return UPDATE_AND_EXIT_TO_MENU;
901 929
902 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; 930 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0;
903 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; 931 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
904 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; 932 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0;
905 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 1; 933 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 1;
934 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0;
906 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0; 935 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0;
907 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; 936 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0;
908 937
909 tMenuEdit_set_on_off(StMOG_First, 0); 938 tMenuEdit_set_on_off(StMOG_First, 0);
910 tMenuEdit_set_on_off(StMOG_Deco, 0); 939 tMenuEdit_set_on_off(StMOG_Deco, 0);
911 tMenuEdit_set_on_off(StMOG_Travel, 1); 940 tMenuEdit_set_on_off(StMOG_Travel, 1);
912 tMenuEdit_set_on_off(StMOG_Inactive, 0); 941 tMenuEdit_set_on_off(StMOG_Inactive, 0);
942 #ifdef ENABLE_UNUSED_GAS_HIDING
943 tMenuEdit_set_on_off(StMOG_Off, 0);
944 #endif
913 945
914 if(!travel) 946 if(!travel)
915 return UPDATE_DIVESETTINGS; 947 return UPDATE_DIVESETTINGS;
916 else 948 else
917 return UPDATE_AND_EXIT_TO_MENU; 949 return UPDATE_AND_EXIT_TO_MENU;
951 983
952 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; 984 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0;
953 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0; 985 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0;
954 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; 986 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0;
955 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; 987 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0;
988 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0;
956 989
957 tMenuEdit_set_on_off(StMOG_First, 0); 990 tMenuEdit_set_on_off(StMOG_First, 0);
958 tMenuEdit_set_on_off(StMOG_Deco, 0); 991 tMenuEdit_set_on_off(StMOG_Deco, 0);
959 tMenuEdit_set_on_off(StMOG_Travel, 0); 992 tMenuEdit_set_on_off(StMOG_Travel, 0);
960 tMenuEdit_set_on_off(StMOG_Inactive, 1); 993 tMenuEdit_set_on_off(StMOG_Inactive, 1);
961 994 #ifdef ENABLE_UNUSED_GAS_HIDING
995 tMenuEdit_set_on_off(StMOG_Off, 0);
996 #endif
962 if(!inactive) 997 if(!inactive)
963 return UPDATE_DIVESETTINGS; 998 return UPDATE_DIVESETTINGS;
964 else 999 else
965 return UPDATE_AND_EXIT_TO_MENU; 1000 return UPDATE_AND_EXIT_TO_MENU;
966 } 1001 }
967 1002
1003 uint8_t OnAction_Off (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
1004 {
1005 uint8_t first, off, gasOne;
1006
1007 if(editGasPage.ccr)
1008 gasOne = 1 + NUM_OFFSET_DILUENT;
1009 else
1010 gasOne = 1;
1011
1012 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first;
1013 off =editGasPage.pGasLine[editGasPage.gasID].note.ub.off;
1014
1015 if(first)
1016 {
1017 if(editGasPage.gasID == gasOne)
1018 return UNSPECIFIC_RETURN;
1019 else
1020 {
1021 editGasPage.pGasLine[gasOne].note.ub.first = 1;
1022 editGasPage.pGasLine[gasOne].note.ub.active = 1;
1023 editGasPage.pGasLine[gasOne].note.ub.deco = 0;
1024 editGasPage.pGasLine[gasOne].note.ub.travel = 0;
1025 editGasPage.pGasLine[gasOne].depth_meter = 0;
1026 editGasPage.pGasLine[gasOne].depth_meter_travel = 0;
1027 }
1028 }
1029
1030 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0;
1031 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0;
1032 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0;
1033 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0;
1034 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 1;
1035
1036 tMenuEdit_set_on_off(StMOG_First, 0);
1037 tMenuEdit_set_on_off(StMOG_Deco, 0);
1038 tMenuEdit_set_on_off(StMOG_Travel, 0);
1039 tMenuEdit_set_on_off(StMOG_Inactive, 0);
1040 #ifdef ENABLE_UNUSED_GAS_HIDING
1041 tMenuEdit_set_on_off(StMOG_Off, 1);
1042 #endif
1043 if(!off)
1044 return UPDATE_DIVESETTINGS;
1045 else
1046 return UPDATE_AND_EXIT_TO_MENU;
1047 }
968 1048
969 uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 1049 uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
970 { 1050 {
971 uint8_t newChangeDepth = editGasPage.mod; 1051 uint8_t newChangeDepth = editGasPage.mod;
972 1052