comparison Discovery/Src/tMenuEditCustom.c @ 834:2a8af51ab04d Evo_2_23

Added event based display changes for big font view: It is now possible to activate "Autofocus" option in custom view dialog. This enables automatic switching of the current view depending on current dive situation. Because T7 view already displays a lot of information this feature targets the T3 view.
author Ideenmodellierer
date Sun, 17 Dec 2023 21:14:17 +0100
parents 7322adb00305
children 717b460294cd
comparison
equal deleted inserted replaced
833:e963d32f746e 834:2a8af51ab04d
61 char customviewBF_TXT2BYTE_helper(uint8_t customViewId); 61 char customviewBF_TXT2BYTE_helper(uint8_t customViewId);
62 /* Announced function prototypes -----------------------------------------------*/ 62 /* Announced function prototypes -----------------------------------------------*/
63 uint8_t OnAction_CViewTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 63 uint8_t OnAction_CViewTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
64 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 64 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
65 uint8_t OnAction_CViewStandardBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 65 uint8_t OnAction_CViewStandardBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
66 uint8_t OnAction_CViewAutofocusBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
66 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 67 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
67 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 68 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
68 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 69 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
69 uint8_t OnAction_CViewPortLayout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 70 uint8_t OnAction_CViewPortLayout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
70 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 71 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
112 text[3] = ' '; 113 text[3] = ' ';
113 text[4] = TXT_2BYTE; 114 text[4] = TXT_2BYTE;
114 text[5] = customviewBF_TXT2BYTE_helper(settingsGetPointer()->tX_customViewPrimaryBF); 115 text[5] = customviewBF_TXT2BYTE_helper(settingsGetPointer()->tX_customViewPrimaryBF);
115 text[6] = 0; 116 text[6] = 0;
116 write_label_var( 30, 700, ME_Y_LINE3, &FontT48, text); 117 write_label_var( 30, 700, ME_Y_LINE3, &FontT48, text);
118
119 /* Bigfont autofocus selector */
120 textpointer = 0;
121 text[textpointer++] = TXT_2BYTE;
122 text[textpointer++] = TXT2BYTE_ExtraDisplay;
123 textpointer += snprintf(&text[textpointer],20," %c%c",TXT_2BYTE, TXT2BYTE_Autofocus);
124 write_label_var( 30, 700, ME_Y_LINE4, &FontT48, text);
125
126 tMenuEdit_refresh_field(StMCustom1_CViewAutoFocusBF);
127
117 128
118 // field corner return 129 // field corner return
119 textpointer = 0; 130 textpointer = 0;
120 text[textpointer++] = TXT_2BYTE; 131 text[textpointer++] = TXT_2BYTE;
121 text[textpointer++] = TXT2BYTE_CornerTimeout; 132 text[textpointer++] = TXT2BYTE_CornerTimeout;
375 refresh_Customviews(); 386 refresh_Customviews();
376 387
377 write_field_button(StMCustom1_CViewTimeout, 400, 700, ME_Y_LINE1, &FontT48, ""); 388 write_field_button(StMCustom1_CViewTimeout, 400, 700, ME_Y_LINE1, &FontT48, "");
378 write_field_button(StMCustom1_CViewStandard, 400, 700, ME_Y_LINE2, &FontT48, ""); 389 write_field_button(StMCustom1_CViewStandard, 400, 700, ME_Y_LINE2, &FontT48, "");
379 write_field_button(StMCustom1_CViewStandardBF, 400, 700, ME_Y_LINE3, &FontT48, ""); 390 write_field_button(StMCustom1_CViewStandardBF, 400, 700, ME_Y_LINE3, &FontT48, "");
380 391 write_field_on_off(StMCustom1_CViewAutoFocusBF, 650, 700, ME_Y_LINE4, &FontT48, "", settingsGetPointer()->cvAutofocus);
381 write_field_button(StMCustom1_CornerTimeout, 400, 700, ME_Y_LINE5, &FontT48, ""); 392 write_field_button(StMCustom1_CornerTimeout, 400, 700, ME_Y_LINE5, &FontT48, "");
382 write_field_button(StMCustom1_CornerStandard, 400, 700, ME_Y_LINE6, &FontT48, ""); 393 write_field_button(StMCustom1_CornerStandard, 400, 700, ME_Y_LINE6, &FontT48, "");
383 394
384 setEvent(StMCustom1_CViewTimeout, (uint32_t)OnAction_CViewTimeout); 395 setEvent(StMCustom1_CViewTimeout, (uint32_t)OnAction_CViewTimeout);
385 setEvent(StMCustom1_CViewStandard, (uint32_t)OnAction_CViewStandard); 396 setEvent(StMCustom1_CViewStandard, (uint32_t)OnAction_CViewStandard);
386 setEvent(StMCustom1_CViewStandardBF, (uint32_t)OnAction_CViewStandardBF); 397 setEvent(StMCustom1_CViewStandardBF, (uint32_t)OnAction_CViewStandardBF);
387 398 setEvent(StMCustom1_CViewAutoFocusBF, (uint32_t)OnAction_CViewAutofocusBF);
388 setEvent(StMCustom1_CornerTimeout, (uint32_t)OnAction_CornerTimeout); 399 setEvent(StMCustom1_CornerTimeout, (uint32_t)OnAction_CornerTimeout);
389 setEvent(StMCustom1_CornerStandard, (uint32_t)OnAction_CornerStandard); 400 setEvent(StMCustom1_CornerStandard, (uint32_t)OnAction_CornerStandard);
390 } 401 }
391 402
392 void openEdit_BigScreen(void) 403 void openEdit_BigScreen(void)
644 655
645 settingsGetPointer()->tX_customViewPrimaryBF = newValue; 656 settingsGetPointer()->tX_customViewPrimaryBF = newValue;
646 return UPDATE_DIVESETTINGS; 657 return UPDATE_DIVESETTINGS;
647 } 658 }
648 659
660 uint8_t OnAction_CViewAutofocusBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
661 {
662 SSettings *pSettings = settingsGetPointer();
663 if(pSettings->cvAutofocus)
664 {
665 pSettings->cvAutofocus = 0;
666 }
667 else
668 {
669 pSettings->cvAutofocus = 1;
670 }
671 tMenuEdit_set_on_off(editId, pSettings->cvAutofocus);
672 return UPDATE_DIVESETTINGS;
673 }
649 674
650 uint8_t OnAction_CornerTimeout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 675 uint8_t OnAction_CornerTimeout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
651 { 676 {
652 uint8_t value; 677 uint8_t value;
653 value = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout; 678 value = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout;
1062 text[textPointer] = 0; 1087 text[textPointer] = 0;
1063 write_label_var( 30, 800, ME_Y_LINE6, &FontT48, text); 1088 write_label_var( 30, 800, ME_Y_LINE6, &FontT48, text);
1064 } 1089 }
1065 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 1090 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
1066 } 1091 }
1092
1093 uint8_t HandleAFCompass()
1094 {
1095 static uint8_t debounce = 0;
1096 static uint8_t lastState = 0;
1097 uint8_t detectionState = 0;
1098
1099 float pitch = stateRealGetPointer()->lifeData.compass_pitch;
1100 float roll = stateRealGetPointer()->lifeData.compass_roll;
1101
1102 if((pitch > -5.0) && (pitch < 5.0) && (roll > -5.0) && (roll < 5.0)) /* OSTC in horizontal position */
1103 {
1104 if(debounce < 10) debounce++;
1105 if(debounce == 10)
1106 {
1107 detectionState = 1;
1108 // debounce = 0;
1109 // t3_select_customview(CVIEW_T3_Navigation);
1110 }
1111 }
1112 else
1113 {
1114 if(debounce > 0) debounce--;
1115 if(debounce == 0)
1116 {
1117 detectionState = 2;
1118 }
1119 }
1120 if(detectionState) /* no state change => return 0 */
1121 {
1122 if((detectionState == lastState))
1123 {
1124 detectionState = 0;
1125 }
1126 else
1127 {
1128 lastState = detectionState;
1129 }
1130 }
1131 return detectionState;
1132 }