comparison Discovery/Src/tMenuEditCustom.c @ 520:970d8040c0e3

Moved custom view menu to new tab: In previous version old location of custom views was kept for easier development. After establishing new tab the old implementation has been removed from MenuSystem unit.
author Ideenmodellierer
date Tue, 08 Sep 2020 21:24:14 +0200
parents 218ac999e96b
children e221cf762f45
comparison
equal deleted inserted replaced
519:2c49561c8062 520:970d8040c0e3
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 41
42 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */ 42 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */
43 #define CV_SUBPAGE_MAX (2u) /* max number of customer view selection pages */
43 44
44 static uint8_t customviewsSubpage = 0; 45 static uint8_t customviewsSubpage = 0;
45 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */ 46 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */
46 static const uint8_t* pcv_curchangelist; 47 static const uint8_t* pcv_curchangelist;
47 /* Private function prototypes -----------------------------------------------*/ 48 /* Private function prototypes -----------------------------------------------*/
48 void openEdit_Customview2(void); 49 void openEdit_Customview(void);
49 void refresh_Customviews2(void); 50 void refresh_Customviews(void);
50 /* Announced function prototypes -----------------------------------------------*/ 51 /* Announced function prototypes -----------------------------------------------*/
51 uint8_t OnAction_CViewTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 52 uint8_t OnAction_CViewTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
52 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 53 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
53 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 54 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
54 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 55 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
55 56 uint8_t OnAction_ExtraDisplay (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
56 57 uint8_t OnAction_MotionCtrl (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
57 /* Exported functions --------------------------------------------------------*/ 58 /* Exported functions --------------------------------------------------------*/
58 59
59 60
60 61
61 62
62 void refresh_Customviews2(void) 63 void refresh_Customviews(void)
63 { 64 {
64 char text[32]; 65 char text[32];
65 uint8_t textpointer = 0; 66 uint8_t textpointer = 0;
66 67
67 // header 68 // header
260 261
261 switch(line) 262 switch(line)
262 { 263 {
263 case 1: 264 case 1:
264 default: 265 default:
265 openEdit_Customview2(); 266 openEdit_Customview();
266 break; 267 break;
267 case 2: 268 case 2:
268 openEdit_CustomviewDivemode2(cv_changelist); 269 openEdit_CustomviewDivemode(cv_changelist);
269 break; 270 break;
270 case 3: 271 case 3:
271 openEdit_CustomviewDivemode2(cv_changelist_BS); 272 openEdit_CustomviewDivemode(cv_changelist_BS);
272 break; 273 break;
273 } 274 }
274 } 275 }
275 276
276 /* Private functions ---------------------------------------------------------*/ 277 /* Private functions ---------------------------------------------------------*/
277 void openEdit_Customview2(void) 278 void openEdit_Customview(void)
278 { 279 {
279 refresh_Customviews2(); 280 refresh_Customviews();
280 281
281 write_field_button(StMCustom1_CViewTimeout, 400, 700, ME_Y_LINE1, &FontT48, ""); 282 write_field_button(StMCustom1_CViewTimeout, 400, 700, ME_Y_LINE1, &FontT48, "");
282 write_field_button(StMCustom1_CViewStandard, 400, 700, ME_Y_LINE2, &FontT48, ""); 283 write_field_button(StMCustom1_CViewStandard, 400, 700, ME_Y_LINE2, &FontT48, "");
283 284
284 write_field_button(StMCustom1_CornerTimeout, 400, 700, ME_Y_LINE3, &FontT48, ""); 285 write_field_button(StMCustom1_CornerTimeout, 400, 700, ME_Y_LINE3, &FontT48, "");
285 write_field_button(StMCustom1_CornerStandard, 400, 700, ME_Y_LINE4, &FontT48, ""); 286 write_field_button(StMCustom1_CornerStandard, 400, 700, ME_Y_LINE4, &FontT48, "");
286 287
287 // write_field_button(StMCustom1_ExtraDisplay, 400, 700, ME_Y_LINE5, &FontT48, ""); 288 write_field_button(StMCustom1_ExtraDisplay, 400, 700, ME_Y_LINE5, &FontT48, "");
288 // write_field_button(StMCustom1_MotionCtrl, 400, 700, ME_Y_LINE6, &FontT48, ""); 289 write_field_button(StMCustom1_MotionCtrl, 400, 700, ME_Y_LINE6, &FontT48, "");
289 290
290 setEvent(StMCustom1_CViewTimeout, (uint32_t)OnAction_CViewTimeout); 291 setEvent(StMCustom1_CViewTimeout, (uint32_t)OnAction_CViewTimeout);
291 setEvent(StMCustom1_CViewStandard, (uint32_t)OnAction_CViewStandard); 292 setEvent(StMCustom1_CViewStandard, (uint32_t)OnAction_CViewStandard);
292 293
293 setEvent(StMCustom1_CornerTimeout, (uint32_t)OnAction_CornerTimeout); 294 setEvent(StMCustom1_CornerTimeout, (uint32_t)OnAction_CornerTimeout);
294 setEvent(StMCustom1_CornerStandard, (uint32_t)OnAction_CornerStandard); 295 setEvent(StMCustom1_CornerStandard, (uint32_t)OnAction_CornerStandard);
295 296
296 // setEvent(StMCustom1_ExtraDisplay, (uint32_t)OnAction_ExtraDisplay); 297 setEvent(StMCustom1_ExtraDisplay, (uint32_t)OnAction_ExtraDisplay);
297 // setEvent(StMCustom1_MotionCtrl, (uint32_t)OnAction_MotionCtrl); 298 setEvent(StMCustom1_MotionCtrl, (uint32_t)OnAction_MotionCtrl);
298 } 299 }
299 300
300 char customview_TXT2BYTE_helper2(uint8_t customViewId) 301 char customview_TXT2BYTE_helper(uint8_t customViewId)
301 { 302 {
302 char text = 0; 303 char text = 0;
303 304
304 switch(customViewId) 305 switch(customViewId)
305 { 306 {
357 } 358 }
358 return text; 359 return text;
359 } 360 }
360 361
361 362
362 uint8_t OnAction_CViewTimeout2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 363 uint8_t OnAction_CViewTimeout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
363 { 364 {
364 uint8_t value; 365 uint8_t value;
365 value = settingsGetPointer()->tX_customViewTimeout; 366 value = settingsGetPointer()->tX_customViewTimeout;
366 367
367 if(value < 5) 368 if(value < 5)
384 settingsGetPointer()->tX_customViewTimeout = value; 385 settingsGetPointer()->tX_customViewTimeout = value;
385 return UPDATE_DIVESETTINGS; 386 return UPDATE_DIVESETTINGS;
386 } 387 }
387 388
388 389
389 uint8_t OnAction_CViewStandard2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 390 uint8_t OnAction_CViewStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
390 { 391 {
391 uint8_t newValue; 392 uint8_t newValue;
392 switch(settingsGetPointer()->tX_customViewPrimary) 393 switch(settingsGetPointer()->tX_customViewPrimary)
393 { 394 {
394 case CVIEW_sensors: 395 case CVIEW_sensors:
426 settingsGetPointer()->tX_customViewPrimary = newValue; 427 settingsGetPointer()->tX_customViewPrimary = newValue;
427 return UPDATE_DIVESETTINGS; 428 return UPDATE_DIVESETTINGS;
428 } 429 }
429 430
430 431
431 uint8_t OnAction_CornerTimeout2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 432 uint8_t OnAction_CornerTimeout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
432 { 433 {
433 uint8_t value; 434 uint8_t value;
434 value = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout; 435 value = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout;
435 436
436 if(value < 5) 437 if(value < 5)
453 settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout = value; 454 settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout = value;
454 return UPDATE_DIVESETTINGS; 455 return UPDATE_DIVESETTINGS;
455 } 456 }
456 457
457 458
458 uint8_t OnAction_CornerStandard2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 459 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
459 { 460 {
460 uint8_t value; 461 uint8_t value;
461 value = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary; 462 value = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary;
462 463
463 value += 1; 464 value += 1;
512 } 513 }
513 514
514 515
515 uint8_t OnAction_Customview_NextPage(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 516 uint8_t OnAction_Customview_NextPage(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
516 { 517 {
517 uint8_t id_next = 0;
518 customviewsSubpage++; 518 customviewsSubpage++;
519 if(customviewsSubpage == customviewsSubpageMax) 519 if(customviewsSubpage == customviewsSubpageMax)
520 { 520 {
521 customviewsSubpage = 0; 521 customviewsSubpage = 0;
522 } 522 }
523 resetMenuEdit(CLUT_MenuPageCustomView); /* rebuild page */ 523 resetMenuEdit(CLUT_MenuPageCustomView); /* rebuild page */
524 openEdit_CustomviewDivemode2(pcv_curchangelist); 524 openEdit_CustomviewDivemode(pcv_curchangelist);
525 525
526 tMenuEdit_select(StMCustom2_CViewSelection6); 526 tMenuEdit_select(StMCustom2_CViewSelection6);
527 return UPDATE_DIVESETTINGS; 527 return UPDATE_DIVESETTINGS;
528 } 528 }
529 529
530 void openEdit_CustomviewDivemode2(const uint8_t* pcv_changelist) 530 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist)
531 { 531 {
532 532
533 SSettings *pSettings = settingsGetPointer(); 533 SSettings *pSettings = settingsGetPointer();
534 char text[MAX_PAGE_TEXTSIZE]; 534 char text[MAX_PAGE_TEXTSIZE];
535 uint8_t textPointer = 0; 535 uint8_t textPointer = 0;
538 uint8_t i; 538 uint8_t i;
539 539
540 customviewsSubpageMax = (tHome_getNumberOfAvailableCVs(pcv_changelist) / CV_PER_PAGE) + 1; 540 customviewsSubpageMax = (tHome_getNumberOfAvailableCVs(pcv_changelist) / CV_PER_PAGE) + 1;
541 pcv_curchangelist = pcv_changelist; 541 pcv_curchangelist = pcv_changelist;
542 542
543 CustomviewDivemode2_refresh(pcv_changelist); 543 CustomviewDivemode_refresh(pcv_changelist);
544 544
545 545
546 text[0] = '\001'; 546 text[0] = '\001';
547 text[1] = TXT_2BYTE; 547 text[1] = TXT_2BYTE;
548 text[2] = TXT2BYTE_SelectCustomviews; 548 text[2] = TXT2BYTE_SelectCustomviews;
566 else 566 else
567 { 567 {
568 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id); 568 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id);
569 } 569 }
570 text[textPointer++] = ' '; 570 text[textPointer++] = ' ';
571 textPointer += snprintf(&text[textPointer], 60, "%c%c\n\r", TXT_2BYTE, customview_TXT2BYTE_helper2(id)); 571 textPointer += snprintf(&text[textPointer], 60, "%c%c\n\r", TXT_2BYTE, customview_TXT2BYTE_helper(id));
572 572
573 switch(i) 573 switch(i)
574 { 574 {
575 case 0: write_field_button(StMCustom2_CViewSelection1, 30, 800, ME_Y_LINE1, &FontT48, ""); 575 case 0: write_field_button(StMCustom2_CViewSelection1, 30, 800, ME_Y_LINE1, &FontT48, "");
576 break; 576 break;
651 }; 651 };
652 } 652 }
653 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 653 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
654 } 654 }
655 655
656 656 void openEdit_CustomviewDivemodeMenu(uint8_t line)
657 void CustomviewDivemode2_refresh() 657 {
658 static uint8_t customviewsSubpage = 0;
659 SSettings *pSettings = settingsGetPointer();
660 extern _Bool WriteSettings;
661 char text[MAX_PAGE_TEXTSIZE];
662 uint16_t tabPosition;
663 uint32_t id;
664
665
666 if((line == 6) || (cv_changelist[customviewsSubpage * 5 + line-1] == CVIEW_END)) /* select next set of views */
667 {
668 customviewsSubpage++;
669 if(customviewsSubpage == CV_SUBPAGE_MAX)
670 {
671 customviewsSubpage = 0;
672 }
673 set_CustomsviewsSubpage(customviewsSubpage);
674 /* rebuild the selection page with the next set of customer views */
675 id = tMSystem_refresh(0, text, &tabPosition, NULL);
676 tM_build_page(id, text, tabPosition, NULL);
677 openMenu(0);
678 }
679 else
680 {
681 pSettings->cv_configuration ^= 1 << (cv_changelist[customviewsSubpage * 5 + line-1]);
682 if(t7_GetEnabled_customviews() == 0)
683 {
684 pSettings->cv_configuration ^= (1 << CVIEW_noneOrDebug);
685 }
686 InitMotionDetection(); /* consider new view setup for view selection by motion */
687 exitMenuEdit_to_Menu_with_Menu_Update();
688 }
689 }
690
691 uint8_t OnAction_ExtraDisplay (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
692 {
693 uint8_t newValue;
694
695 newValue = settingsGetPointer()->extraDisplay + 1;
696 if(newValue == EXTRADISPLAY_DECOGAME) /* Decogame not yet implemented */
697 {
698 newValue++;
699 }
700 if(newValue >= EXTRADISPLAY_END)
701 {
702 newValue = EXTRADISPLAY_none;
703 }
704 settingsGetPointer()->extraDisplay = newValue;
705 return UNSPECIFIC_RETURN;
706 }
707
708
709
710 uint8_t OnAction_MotionCtrl (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
711 {
712 uint8_t newValue;
713 switch(settingsGetPointer()->MotionDetection)
714 {
715 case MOTION_DETECT_OFF:
716 newValue = MOTION_DETECT_MOVE;
717 break;
718 case MOTION_DETECT_MOVE:
719 newValue = MOTION_DETECT_SECTOR;
720 break;
721 case MOTION_DETECT_SECTOR:
722 newValue = MOTION_DETECT_SCROLL;
723 break;
724 case MOTION_DETECT_SCROLL:
725 newValue = MOTION_DETECT_OFF;
726 break;
727 default:
728 newValue = MOTION_DETECT_OFF;
729 break;
730 }
731 settingsGetPointer()->MotionDetection = newValue;
732 InitMotionDetection();
733 return UNSPECIFIC_RETURN;
734 }
735
736 void CustomviewDivemode_refresh()
658 { 737 {
659 SSettings *pSettings = settingsGetPointer(); 738 SSettings *pSettings = settingsGetPointer();
660 char text[MAX_PAGE_TEXTSIZE]; 739 char text[MAX_PAGE_TEXTSIZE];
661 uint8_t textPointer = 0; 740 uint8_t textPointer = 0;
662 uint32_t id; 741 uint32_t id;
687 else 766 else
688 { 767 {
689 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id); 768 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id);
690 } 769 }
691 text[textPointer++] = ' '; 770 text[textPointer++] = ' ';
692 textPointer += snprintf(&text[textPointer], 60, "%c%c\n\r", TXT_2BYTE, customview_TXT2BYTE_helper2(id)); 771 textPointer += snprintf(&text[textPointer], 60, "%c%c\n\r", TXT_2BYTE, customview_TXT2BYTE_helper(id));
693 772
694 switch(i) 773 switch(i)
695 { 774 {
696 case 0: write_label_var( 30, 800, ME_Y_LINE1, &FontT48, text); 775 case 0: write_label_var( 30, 800, ME_Y_LINE1, &FontT48, text);
697 break; 776 break;