comparison Discovery/Src/tMenuEditCustom.c @ 552:531e7818b737

Added menu structure to acces viewport calibration: A menu item in surface and dive mode has been added to calibrate the view point between diver and OSTC display. For a proper calibration the diver needs to face north (0? ) => Detailed instruction / guidance to be added.
author Ideenmodellierer
date Sun, 08 Nov 2020 18:46:46 +0100
parents 6960df7ddb09
children e581425c7e3e
comparison
equal deleted inserted replaced
551:e3237f580ae9 552:531e7818b737
38 #include "t7.h" 38 #include "t7.h"
39 #include "data_exchange_main.h" 39 #include "data_exchange_main.h"
40 #include "motion.h" 40 #include "motion.h"
41 #include "tMenu.h" 41 #include "tMenu.h"
42 #include "tMenuSystem.h" 42 #include "tMenuSystem.h"
43 #include <math.h>
43 44
44 45
45 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */ 46 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */
46 #define CV_SUBPAGE_MAX (2u) /* max number of customer view selection pages */ 47 #define CV_SUBPAGE_MAX (2u) /* max number of customer view selection pages */
47 48
50 static const uint8_t* pcv_curchangelist; 51 static const uint8_t* pcv_curchangelist;
51 /* Private function prototypes -----------------------------------------------*/ 52 /* Private function prototypes -----------------------------------------------*/
52 void openEdit_Customview(void); 53 void openEdit_Customview(void);
53 void openEdit_BigScreen(void); 54 void openEdit_BigScreen(void);
54 void openEdit_MotionCtrl(void); 55 void openEdit_MotionCtrl(void);
56 void openEdit_ViewPort(void);
55 void refresh_Customviews(void); 57 void refresh_Customviews(void);
56 char customview_TXT2BYTE_helper(uint8_t customViewId); 58 char customview_TXT2BYTE_helper(uint8_t customViewId);
57 /* Announced function prototypes -----------------------------------------------*/ 59 /* Announced function prototypes -----------------------------------------------*/
58 uint8_t OnAction_CViewTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 60 uint8_t OnAction_CViewTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
59 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 61 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
60 uint8_t OnAction_CViewStandardBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 62 uint8_t OnAction_CViewStandardBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
61 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 63 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
62 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 64 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
65 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
66 uint8_t OnAction_CViewPortLayout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
67 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
63 /* Exported functions --------------------------------------------------------*/ 68 /* Exported functions --------------------------------------------------------*/
64 69
65 70
66 71
67 72
88 text[0] = TXT_2BYTE; 93 text[0] = TXT_2BYTE;
89 text[1] = TXT2BYTE_CViewStandard; 94 text[1] = TXT2BYTE_CViewStandard;
90 text[2] = ' '; 95 text[2] = ' ';
91 text[3] = ' '; 96 text[3] = ' ';
92 97
93 #if 0
94 switch(settingsGetPointer()->tX_customViewPrimary)
95 {
96 case CVIEW_sensors:
97 text[4] = TXT_2BYTE;
98 text[5] = TXT2BYTE_O2monitor;
99 break;
100 case CVIEW_sensors_mV:
101 text[4] = TXT_2BYTE;
102 text[5] = TXT2BYTE_O2voltage;
103 break;
104 case CVIEW_Compass:
105 text[4] = TXT_2BYTE;
106 text[5] = TXT2BYTE_Compass;
107 break;
108 case CVIEW_Decolist:
109 text[4] = TXT_2BYTE;
110 text[5] = TXT2BYTE_Decolist;
111 break;
112 case CVIEW_Tissues:
113 text[4] = TXT_2BYTE;
114 text[5] = TXT2BYTE_Tissues;
115 break;
116 case CVIEW_Profile:
117 text[4] = TXT_2BYTE;
118 text[5] = TXT2BYTE_Profile;
119 break;
120 case CVIEW_Gaslist:
121 text[4] = TXT_2BYTE;
122 text[5] = TXT2BYTE_Gaslist;
123 break;
124 case CVIEW_EADTime:
125 text[4] = TXT_2BYTE;
126 text[5] = TXT2BYTE_Info;
127 break;
128 case CVIEW_SummaryOfLeftCorner:
129 text[4] = TXT_2BYTE;
130 text[5] = TXT2BYTE_Summary;
131 break;
132 case CVIEW_noneOrDebug:
133 text[4] = ' ';
134 text[5] = '-';
135 break;
136 default:
137 snprintf(&text[4],3,"%02u",settingsGetPointer()->tX_customViewPrimary);
138 break;
139 }
140 #endif
141 text[4] = TXT_2BYTE; 98 text[4] = TXT_2BYTE;
142 text[5] = customview_TXT2BYTE_helper(settingsGetPointer()->tX_customViewPrimary); 99 text[5] = customview_TXT2BYTE_helper(settingsGetPointer()->tX_customViewPrimary);
143 text[6] = 0; 100 text[6] = 0;
144 write_label_var( 30, 700, ME_Y_LINE2, &FontT48, text); 101 write_label_var( 30, 700, ME_Y_LINE2, &FontT48, text);
145 102
215 write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text); 172 write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text);
216 173
217 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 174 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
218 } 175 }
219 176
177 void refresh_ViewPort(void)
178 {
179 uint16_t heading;
180 char text[32];
181 uint8_t textIndex = 0;
182 float distance = 0.0;
183 SSettings* pSettings = settingsGetPointer();
184 GFX_DrawCfgScreen* pdrawScreen;
185 point_t lowerleft = {0,0};
186 point_t upperright = {799,479};
187
188 text[0] = '\001';
189 text[1] = TXT_2BYTE;
190 text[2] = TXT2BYTE_CalibView;
191 text[3] = 0;
192 write_topline(text);
193
194 text[0] = TXT_2BYTE;
195 text[1] = TXT2BYTE_CalibView;
196 text[2] = 0;
197 write_label_var( 30, 700, ME_Y_LINE3, &FontT48, text);
198
199 if(pSettings->compassInertia)
200 {
201 heading = (uint16_t)compass_getCompensated();
202 }
203 else
204 {
205 heading = (uint16_t)stateUsed->lifeData.compass_heading;
206 }
207 snprintf(text,32,"\001%03i`",heading);
208 write_label_var( 30, 700, ME_Y_LINE1, &FontT48, text);
209
210 textIndex = 0;
211 text[textIndex++] = TXT_2BYTE;
212 text[textIndex++] = TXT2BYTE_IndicateFrame;
213 text[textIndex++] = ' ';
214 text[textIndex++] = '\006' - (settingsGetPointer()->viewPortMode >> 4);
215 text[textIndex++] = 0;
216 write_label_var( 30, 700, ME_Y_LINE5, &FontT48, text);
217 textIndex = 0;
218 text[textIndex++] = TXT_2BYTE;
219 text[textIndex++] = TXT2BYTE_BoostBacklight;
220 text[textIndex++] = ' ';
221 snprintf(&text[textIndex],32," %d",(settingsGetPointer()->viewPortMode & 0x3));
222 write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text);
223
224 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
225
226 /* test if we are in focus */
227 if((pSettings->viewPitch != 0.0) || (pSettings->viewRoll != 0.0) || (pSettings->viewYaw != 0.0))
228 {
229 distance = checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading);
230
231 if(distance < 0.5)
232 {
233 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03);
234 if(pSettings->viewPortMode >> 4)
235 {
236 pdrawScreen = getMenuEditScreen();
237 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_NiceGreen);
238 }
239 }
240 else
241 {
242 set_Backlight_Boost(0);
243 if(pSettings->viewPortMode >> 4)
244 {
245 pdrawScreen = getMenuEditScreen();
246 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_MenuTopBackground);
247 }
248 }
249 resetFocusState(); /* no other instance shall be impacted by the local detection */
250 }
251
252 }
253
220 void openEdit_Custom(uint8_t line) 254 void openEdit_Custom(uint8_t line)
221 { 255 {
222 set_globalState_Menu_Line(line); 256 set_globalState_Menu_Line(line);
223 resetMenuEdit(CLUT_MenuPageCustomView); 257 resetMenuEdit(CLUT_MenuPageCustomView);
224 258
233 break; 267 break;
234 case 4: openEdit_CustomviewDivemode(cv_changelist_BS); 268 case 4: openEdit_CustomviewDivemode(cv_changelist_BS);
235 break; 269 break;
236 case 5: openEdit_MotionCtrl(); 270 case 5: openEdit_MotionCtrl();
237 break; 271 break;
272 case 6: openEdit_ViewPort();
273 break;
238 } 274 }
239 } 275 }
240 276
241 /* Private functions ---------------------------------------------------------*/ 277 /* Private functions ---------------------------------------------------------*/
242 void openEdit_Customview(void) 278 void openEdit_Customview(void)
303 pSettings->MotionDetection = newValue; 339 pSettings->MotionDetection = newValue;
304 InitMotionDetection(); 340 InitMotionDetection();
305 341
306 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(); 342 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only();
307 } 343 }
344
345
346
347 void openEdit_ViewPort(void)
348 {
349 refresh_ViewPort();
350
351 write_field_button(StMCustom6_CViewPortCalib, 400, 700, ME_Y_LINE3, &FontT48, "");
352 write_field_button(StMCustom6_CViewPortLayout, 400, 700, ME_Y_LINE5, &FontT48, "");
353 write_field_button(StMCustom6_CViewPortAmbient, 400, 700, ME_Y_LINE6, &FontT48, "");
354
355 setEvent(StMCustom6_CViewPortCalib, (uint32_t)OnAction_CViewPortCalib);
356 setEvent(StMCustom6_CViewPortLayout, (uint32_t)OnAction_CViewPortLayout);
357 setEvent(StMCustom6_CViewPortAmbient, (uint32_t)OnAction_CViewPortAmbient);
358 }
359
308 360
309 char customview_TXT2BYTE_helper(uint8_t customViewId) 361 char customview_TXT2BYTE_helper(uint8_t customViewId)
310 { 362 {
311 char text = 0; 363 char text = 0;
312 364
559 openEdit_CustomviewDivemode(pcv_curchangelist); 611 openEdit_CustomviewDivemode(pcv_curchangelist);
560 612
561 tMenuEdit_select(StMCustom3_CViewSelection6); 613 tMenuEdit_select(StMCustom3_CViewSelection6);
562 return UPDATE_DIVESETTINGS; 614 return UPDATE_DIVESETTINGS;
563 } 615 }
616
617 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
618 {
619 float heading;
620 if(settingsGetPointer()->compassInertia)
621 {
622 heading = (uint16_t)compass_getCompensated();
623 }
624 else
625 {
626 heading = (uint16_t)stateUsed->lifeData.compass_heading;
627 }
628 calibrateViewport(stateUsed->lifeData.compass_roll,stateUsed->lifeData.compass_pitch,heading);
629
630 return UPDATE_DIVESETTINGS;
631 }
632 uint8_t OnAction_CViewPortLayout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
633 {
634 SSettings* pSettings = settingsGetPointer();
635 if(pSettings->viewPortMode >> 4 != 0)
636 {
637 pSettings->viewPortMode &= 0x0F;
638 }
639 else
640 {
641 pSettings->viewPortMode |= 0x10;
642 }
643
644 return UPDATE_DIVESETTINGS;
645 }
646 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
647 {
648 SSettings* pSettings = settingsGetPointer();
649 pSettings->viewPortMode = (pSettings->viewPortMode + 1) & 0xF3;
650
651 return UPDATE_DIVESETTINGS;
652 }
653
654
564 655
565 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist) 656 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist)
566 { 657 {
567 658
568 SSettings *pSettings = settingsGetPointer(); 659 SSettings *pSettings = settingsGetPointer();
799 text[textPointer] = 0; 890 text[textPointer] = 0;
800 write_label_var( 30, 800, ME_Y_LINE6, &FontT48, text); 891 write_label_var( 30, 800, ME_Y_LINE6, &FontT48, text);
801 } 892 }
802 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 893 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
803 } 894 }
895
896 void tViewControl(uint8_t sendAction)
897 {
898 switch(sendAction)
899 {
900 case ACTION_BUTTON_ENTER:
901 break;
902 case ACTION_BUTTON_NEXT:
903 break;
904 case ACTION_TIMEOUT:
905 case ACTION_MODE_CHANGE:
906 case ACTION_BUTTON_BACK:
907 exitInfo();
908 break;
909 default:
910 break;
911 case ACTION_IDLE_TICK:
912 case ACTION_IDLE_SECOND:
913 break;
914 }
915 }