comparison Discovery/Src/tMenuEditCustom.c @ 604:fb5bb04ad914

Merged menu items of viewport and motion control: viewport and motion control are depending on each other and were listed at the to level of custom view tab. Because motion control is just a one line item it has been moved into the viewport page. As result there is one free line for future custom view options available again.
author Ideenmodellierer
date Wed, 06 Jan 2021 21:01:00 +0100
parents a48a1cd983af
children 028d8f3a9410
comparison
equal deleted inserted replaced
603:c56ed16dbd39 604:fb5bb04ad914
41 #include "tMenu.h" 41 #include "tMenu.h"
42 #include "tMenuSystem.h" 42 #include "tMenuSystem.h"
43 #include <math.h> 43 #include <math.h>
44 44
45 45
46 #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 */
47 #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 */
48 #define MAX_BACKLIGHT_BOOST (2u) /* max number of backlight levels which may be increased during focus state */
48 49
49 static uint8_t customviewsSubpage = 0; 50 static uint8_t customviewsSubpage = 0;
50 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */ 51 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */
51 static const uint8_t* pcv_curchangelist; 52 static const uint8_t* pcv_curchangelist;
52 /* Private function prototypes -----------------------------------------------*/ 53 /* Private function prototypes -----------------------------------------------*/
63 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 64 uint8_t OnAction_CornerTimeout (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_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_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_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); 68 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
69 uint8_t OnAction_CViewPortControl(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
68 /* Exported functions --------------------------------------------------------*/ 70 /* Exported functions --------------------------------------------------------*/
69 71
70 72
71 73
72 74
185 point_t upperright = {799,479}; 187 point_t upperright = {799,479};
186 float localLimit = 0.1; 188 float localLimit = 0.1;
187 189
188 text[0] = '\001'; 190 text[0] = '\001';
189 text[1] = TXT_2BYTE; 191 text[1] = TXT_2BYTE;
190 text[2] = TXT2BYTE_CalibView; 192 text[2] = TXT2BYTE_MotionCtrl;
191 text[3] = 0; 193 text[3] = 0;
192 write_topline(text); 194 write_topline(text);
193 195
194 text[0] = TXT_2BYTE; 196 text[0] = TXT_2BYTE;
195 text[1] = TXT2BYTE_CalibView; 197 text[1] = TXT2BYTE_CalibView;
196 text[2] = 0; 198 text[2] = 0;
197 write_label_var( 30, 700, ME_Y_LINE3, &FontT48, text); 199 write_label_var( 30, 700, ME_Y_LINE2, &FontT48, text);
198 200
199 textIndex = 0; 201 textIndex = 0;
200 text[textIndex++] = TXT_2BYTE; 202 text[textIndex++] = TXT_2BYTE;
201 text[textIndex++] = TXT2BYTE_IndicateFrame; 203 text[textIndex++] = TXT2BYTE_IndicateFrame;
202 text[textIndex++] = ' '; 204 text[textIndex++] = ' ';
203 text[textIndex++] = '\006' - (settingsGetPointer()->viewPortMode >> 4); 205 text[textIndex++] = '\006' - (settingsGetPointer()->viewPortMode >> 4);
204 text[textIndex++] = 0; 206 text[textIndex++] = 0;
205 write_label_var( 30, 700, ME_Y_LINE5, &FontT48, text); 207 write_label_var( 30, 700, ME_Y_LINE3, &FontT48, text);
206 textIndex = 0; 208 textIndex = 0;
207 text[textIndex++] = TXT_2BYTE; 209 text[textIndex++] = TXT_2BYTE;
208 text[textIndex++] = TXT2BYTE_BoostBacklight; 210 text[textIndex++] = TXT2BYTE_BoostBacklight;
209 text[textIndex++] = ' '; 211 text[textIndex++] = ' ';
210 snprintf(&text[textIndex],32," %d",(settingsGetPointer()->viewPortMode & 0x3)); 212 snprintf(&text[textIndex],32," %d",(settingsGetPointer()->viewPortMode & 0x3));
211 write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text); 213 write_label_var( 30, 700, ME_Y_LINE4, &FontT48, text);
212 214
213 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 215 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
214 216
215 /* test if we are in focus */ 217 /* test if we are in focus */
216 if((pSettings->viewPitch != 0.0) || (pSettings->viewRoll != 0.0) || (pSettings->viewYaw != 0.0)) 218 if((pSettings->viewPitch != 0.0) || (pSettings->viewRoll != 0.0) || (pSettings->viewYaw != 0.0))
217 { 219 {
218 distance = checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading); 220 distance = checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading);
219
220 if(pSettings->showDebugInfo)
221 {
222 snprintf(text,32,"\001%03.3f",distance);
223 write_label_var( 30, 700, ME_Y_LINE2, &FontT48, text);
224 }
225
226 221
227 /* show "bar graph" indicating the distance to the center point */ 222 /* show "bar graph" indicating the distance to the center point */
228 textIndex = 0; 223 textIndex = 0;
229 text[textIndex++] = '\001'; 224 text[textIndex++] = '\001';
230 225
247 } 242 }
248 } 243 }
249 text[textIndex] = 0; 244 text[textIndex] = 0;
250 write_label_var( 30, 700, ME_Y_LINE1, &FontT48, text); 245 write_label_var( 30, 700, ME_Y_LINE1, &FontT48, text);
251 246
247 /* MotionCtrl */
248 textIndex = 0;
249
250 text[textIndex++] = TXT_2BYTE;
251 text[textIndex++] = TXT2BYTE_MotionCtrl;
252 text[textIndex++] = ' ';
253 text[textIndex++] = ' ';
254 text[textIndex++] = TXT_2BYTE;
255 switch(settingsGetPointer()->MotionDetection)
256 {
257 case MOTION_DETECT_OFF:
258 text[textIndex++] = TXT2BYTE_MoCtrlNone;
259 break;
260 case MOTION_DETECT_MOVE:
261 text[textIndex++] = TXT2BYTE_MoCtrlPitch;
262 break;
263 case MOTION_DETECT_SECTOR:
264 text[textIndex++] = TXT2BYTE_MoCtrlSector;
265 break;
266 case MOTION_DETECT_SCROLL:
267 text[textIndex++] = TXT2BYTE_MoCtrlScroll;
268 break;
269 default:
270 snprintf(&text[4],2,"%u",settingsGetPointer()->MotionDetection);
271 textIndex++;
272 break;
273 }
274 text[textIndex] = 0;
275 write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text);
276
252 if(distance < 0.5) 277 if(distance < 0.5)
253 { 278 {
254 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03); 279 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03);
255 if(pSettings->viewPortMode >> 4) 280 if(pSettings->viewPortMode >> 4)
256 { 281 {
267 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_MenuTopBackground); 292 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_MenuTopBackground);
268 } 293 }
269 } 294 }
270 resetFocusState(); /* no other instance shall be impacted by the local detection */ 295 resetFocusState(); /* no other instance shall be impacted by the local detection */
271 } 296 }
272
273 } 297 }
274 298
275 void openEdit_Custom(uint8_t line) 299 void openEdit_Custom(uint8_t line)
276 { 300 {
277 set_globalState_Menu_Line(line); 301 set_globalState_Menu_Line(line);
286 break; 310 break;
287 case 3: openEdit_CustomviewDivemode(cv_changelist); 311 case 3: openEdit_CustomviewDivemode(cv_changelist);
288 break; 312 break;
289 case 4: openEdit_CustomviewDivemode(cv_changelist_BS); 313 case 4: openEdit_CustomviewDivemode(cv_changelist_BS);
290 break; 314 break;
291 case 5: openEdit_MotionCtrl(); 315 case 5: openEdit_ViewPort();
292 break; 316 break;
293 case 6: openEdit_ViewPort();
294 break;
295 } 317 }
296 } 318 }
297 319
298 /* Private functions ---------------------------------------------------------*/ 320 /* Private functions ---------------------------------------------------------*/
299 void openEdit_Customview(void) 321 void openEdit_Customview(void)
367 389
368 void openEdit_ViewPort(void) 390 void openEdit_ViewPort(void)
369 { 391 {
370 refresh_ViewPort(); 392 refresh_ViewPort();
371 393
372 write_field_button(StMCustom6_CViewPortCalib, 400, 700, ME_Y_LINE3, &FontT48, ""); 394 write_field_button(StMCustom5_CViewPortCalib, 400, 700, ME_Y_LINE2, &FontT48, "");
373 write_field_button(StMCustom6_CViewPortLayout, 400, 700, ME_Y_LINE5, &FontT48, ""); 395 write_field_button(StMCustom5_CViewPortLayout, 400, 700, ME_Y_LINE3, &FontT48, "");
374 write_field_button(StMCustom6_CViewPortAmbient, 400, 700, ME_Y_LINE6, &FontT48, ""); 396 write_field_button(StMCustom5_CViewPortAmbient, 400, 700, ME_Y_LINE4, &FontT48, "");
375 397 write_field_button(StMCustom5_CViewPortControl, 400, 700, ME_Y_LINE6, &FontT48, "");
376 setEvent(StMCustom6_CViewPortCalib, (uint32_t)OnAction_CViewPortCalib); 398
377 setEvent(StMCustom6_CViewPortLayout, (uint32_t)OnAction_CViewPortLayout); 399
378 setEvent(StMCustom6_CViewPortAmbient, (uint32_t)OnAction_CViewPortAmbient); 400 setEvent(StMCustom5_CViewPortCalib, (uint32_t)OnAction_CViewPortCalib);
401 setEvent(StMCustom5_CViewPortLayout, (uint32_t)OnAction_CViewPortLayout);
402 setEvent(StMCustom5_CViewPortAmbient, (uint32_t)OnAction_CViewPortAmbient);
403 setEvent(StMCustom5_CViewPortControl, (uint32_t)OnAction_CViewPortControl);
379 } 404 }
380 405
381 406
382 char customview_TXT2BYTE_helper(uint8_t customViewId) 407 char customview_TXT2BYTE_helper(uint8_t customViewId)
383 { 408 {
668 return UPDATE_DIVESETTINGS; 693 return UPDATE_DIVESETTINGS;
669 } 694 }
670 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 695 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
671 { 696 {
672 SSettings* pSettings = settingsGetPointer(); 697 SSettings* pSettings = settingsGetPointer();
673 pSettings->viewPortMode = (pSettings->viewPortMode + 1) & 0xF3; 698 if(((pSettings->viewPortMode +1) & 0x03) <= MAX_BACKLIGHT_BOOST)
699 {
700 pSettings->viewPortMode++;
701 }
702 else
703 {
704 pSettings->viewPortMode &= 0xFC;
705 }
674 706
675 return UPDATE_DIVESETTINGS; 707 return UPDATE_DIVESETTINGS;
676 } 708 }
677 709
678 710 uint8_t OnAction_CViewPortControl(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
711 {
712 uint8_t newValue = 0;
713 SSettings *pSettings = settingsGetPointer();
714
715 switch(pSettings->MotionDetection)
716 {
717 case MOTION_DETECT_OFF:
718 newValue = MOTION_DETECT_MOVE;
719 break;
720 case MOTION_DETECT_MOVE:
721 newValue = MOTION_DETECT_SECTOR;
722 break;
723 case MOTION_DETECT_SECTOR:
724 newValue = MOTION_DETECT_SCROLL;
725 break;
726 case MOTION_DETECT_SCROLL:
727 newValue = MOTION_DETECT_OFF;
728 break;
729 default:
730 newValue = MOTION_DETECT_OFF;
731 break;
732 }
733 pSettings->MotionDetection = newValue;
734 return UPDATE_DIVESETTINGS;
735 }
679 736
680 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist) 737 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist)
681 { 738 {
682 739
683 SSettings *pSettings = settingsGetPointer(); 740 SSettings *pSettings = settingsGetPointer();