comparison Discovery/Src/tMenuEditCustom.c @ 852:b2aad621aeb0 Evo_2_23

Bugfix Selection of custom views: In case less than 5 views were displayed on a page it could happen that the cursor was put in a wrong position in case the next page was selected. Rootcause was the setting of the element events which was only update in case the menu was entered via the open function.
author Ideenmodellierer
date Thu, 07 Mar 2024 21:46:49 +0100
parents 70092f552f5a
children 2225c467f1e9
comparison
equal deleted inserted replaced
851:9f487ad38170 852:b2aad621aeb0
55 void openEdit_Customview(void); 55 void openEdit_Customview(void);
56 void openEdit_BigScreen(void); 56 void openEdit_BigScreen(void);
57 void openEdit_MotionCtrl(void); 57 void openEdit_MotionCtrl(void);
58 void openEdit_ViewPort(void); 58 void openEdit_ViewPort(void);
59 void refresh_Customviews(void); 59 void refresh_Customviews(void);
60 void setMenuContentStructure();
60 char customview_TXT2BYTE_helper(uint8_t customViewId); 61 char customview_TXT2BYTE_helper(uint8_t customViewId);
61 char customviewBF_TXT2BYTE_helper(uint8_t customViewId); 62 char customviewBF_TXT2BYTE_helper(uint8_t customViewId);
62 /* Announced function prototypes -----------------------------------------------*/ 63 /* Announced function prototypes -----------------------------------------------*/
63 uint8_t OnAction_CViewTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 64 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); 65 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
759 } 760 }
760 761
761 762
762 uint8_t OnAction_Customview_NextPage(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 763 uint8_t OnAction_Customview_NextPage(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
763 { 764 {
765 resetMenuContentStructure();
764 customviewsSubpage++; 766 customviewsSubpage++;
767
765 if(customviewsSubpage == customviewsSubpageMax) 768 if(customviewsSubpage == customviewsSubpageMax)
766 { 769 {
767 customviewsSubpage = 0; 770 customviewsSubpage = 0;
768 } 771 setMenuContentStructure();
772 tMenuEdit_select(StMCustom3_CViewSelection6);
773 }
774 else
775 {
776 setMenuContentStructure();
777 }
778
769 CustomviewDivemode_refresh(); 779 CustomviewDivemode_refresh();
770 return UPDATE_DIVESETTINGS; 780 return UPDATE_DIVESETTINGS;
771 } 781 }
772 782
773 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 783 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
854 pSettings->viewPortMode &= 0x9F; /* 1001 1111 */ 864 pSettings->viewPortMode &= 0x9F; /* 1001 1111 */
855 pSettings->viewPortMode |= (newValue << 5); 865 pSettings->viewPortMode |= (newValue << 5);
856 return UPDATE_DIVESETTINGS; 866 return UPDATE_DIVESETTINGS;
857 } 867 }
858 868
859 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist) 869 void setMenuContentStructure()
860 { 870 {
861
862 SSettings *pSettings = settingsGetPointer();
863 char text[MAX_PAGE_TEXTSIZE]; 871 char text[MAX_PAGE_TEXTSIZE];
864 uint8_t textPointer = 0; 872 uint8_t textPointer = 0;
865 uint32_t id; 873 uint32_t id;
866 874
867 uint8_t i; 875 uint8_t i;
868 uint8_t endID = CVIEW_END; 876 uint8_t endID = CVIEW_END;
869 877 SSettings *pSettings = settingsGetPointer();
870 if(pcv_changelist == cv_changelist_BS) 878
879 if(pcv_curchangelist == cv_changelist_BS)
871 { 880 {
872 endID = CVIEW_T3_END; 881 endID = CVIEW_T3_END;
873 } 882 }
874 883
875 resetMenuEdit(CLUT_MenuPageCustomView); 884 for(i=0; i<5;i++) /* fill maximum 5 items and leave last one for sub page selection */
876 customviewsSubpageMax = (tHome_getNumberOfAvailableCVs(pcv_changelist) / CV_PER_PAGE) + 1; 885 {
877 886 textPointer = 0;
878 if(pcv_curchangelist != pcv_changelist) /* new selection base? => reset page index */ 887 id = pcv_curchangelist[customviewsSubpage * 5 + i];
879 { 888 if(id == endID) /* last list item? */
880 customviewsSubpage = 0; 889 {
881 } 890 break;
882 pcv_curchangelist = pcv_changelist; 891 }
883 892 else
884 CustomviewDivemode_refresh(pcv_changelist); 893 {
885 894 if(pcv_curchangelist == cv_changelist)
886 for(i=0; i<5;i++) /* fill maximum 5 items and leave last one for sub page selection */ 895 {
887 { 896 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_configuration,id);
888 textPointer = 0; 897 }
889 id = pcv_changelist[customviewsSubpage * 5 + i]; 898 else
890 if(id == endID) /* last list item? */ 899 {
891 { 900 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id);
892 break; 901 }
893 }
894 else
895 {
896 if(pcv_changelist == cv_changelist)
897 {
898 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_configuration,id);
899 }
900 else
901 {
902 text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id);
903 }
904 text[textPointer++] = ' '; 902 text[textPointer++] = ' ';
905 textPointer += snprintf(&text[textPointer], 60, "%c%c\n\r", TXT_2BYTE, customview_TXT2BYTE_helper(id)); 903 textPointer += snprintf(&text[textPointer], 60, "%c%c\n\r", TXT_2BYTE, customview_TXT2BYTE_helper(id));
906 904
907 switch(i) 905 switch(i)
908 { 906 {
917 case 4: write_field_button(StMCustom3_CViewSelection5, 30, 800, ME_Y_LINE5, &FontT48, ""); 915 case 4: write_field_button(StMCustom3_CViewSelection5, 30, 800, ME_Y_LINE5, &FontT48, "");
918 break; 916 break;
919 default: 917 default:
920 break; 918 break;
921 } 919 }
922 } 920 }
923 } 921 }
924 for(;i<5;i++) /* clear empty lines in case menu shows less than 5 entries */ 922 for(;i<5;i++) /* clear empty lines in case menu shows less than 5 entries */
925 { 923 {
926 switch(i) 924 switch(i)
927 { 925 {
928 case 0: write_label_var( 30, 800, ME_Y_LINE1, &FontT48, ""); 926 case 0: write_label_var( 30, 800, ME_Y_LINE1, &FontT48, "");
929 break; 927 break;
930 case 1: write_label_var( 30, 800, ME_Y_LINE2, &FontT48, ""); 928 case 1: write_label_var( 30, 800, ME_Y_LINE2, &FontT48, "");
931 break; 929 break;
932 case 2: write_label_var( 30, 800, ME_Y_LINE3, &FontT48, ""); 930 case 2: write_label_var( 30, 800, ME_Y_LINE3, &FontT48, "");
933 break; 931 break;
934 case 3: write_label_var( 30, 800, ME_Y_LINE4, &FontT48, ""); 932 case 3: write_label_var( 30, 800, ME_Y_LINE4, &FontT48, "");
935 break; 933 break;
936 case 4: write_label_var( 30, 800, ME_Y_LINE5, &FontT48, ""); 934 case 4: write_label_var( 30, 800, ME_Y_LINE5, &FontT48, "");
937 break; 935 break;
938 default: 936 default:
939 break; 937 break;
940 }; 938 };
941 } 939 }
942 if(customviewsSubpageMax != 1) 940
943 { 941 if(customviewsSubpageMax != 1)
944 textPointer = 0; 942 {
945 text[textPointer++] = TXT_2BYTE; 943 textPointer = 0;
946 text[textPointer++] = TXT2BYTE_ButtonNext; 944 text[textPointer++] = TXT_2BYTE;
947 text[textPointer] = 0; 945 text[textPointer++] = TXT2BYTE_ButtonNext;
948 write_field_button(StMCustom3_CViewSelection6, 30, 800, ME_Y_LINE6, &FontT48, text); 946 text[textPointer] = 0;
949 } 947 write_field_button(StMCustom3_CViewSelection6, 30, 800, ME_Y_LINE6, &FontT48, text);
950 948 }
951 /* because of the ID handling inside of the functions, all buttons needs to be assigned before the events may be set => have the same loop twice */ 949
952 for(i=0; i<5;i++) /* fill maximum 5 items and leave last one for sub page selection */ 950 /* because of the ID handling inside of the functions, all buttons needs to be assigned before the events may be set => have the same loop twice */
953 { 951 for(i=0; i<5;i++) /* fill maximum 5 items and leave last one for sub page selection */
954 id = pcv_changelist[customviewsSubpage * 5 + i]; 952 {
955 if(id == endID) /* last list item? */ 953 id = pcv_curchangelist[customviewsSubpage * 5 + i];
956 { 954 if(id == endID) /* last list item? */
957 break; 955 {
958 } 956 break;
959 else 957 }
960 { 958 else
959 {
961 switch(i) 960 switch(i)
962 { 961 {
963 case 0: setEvent(StMCustom3_CViewSelection1, (uint32_t)OnAction_Customview_Toggle); 962 case 0: setEvent(StMCustom3_CViewSelection1, (uint32_t)OnAction_Customview_Toggle);
964 break; 963 break;
965 case 1: setEvent(StMCustom3_CViewSelection2, (uint32_t)OnAction_Customview_Toggle); 964 case 1: setEvent(StMCustom3_CViewSelection2, (uint32_t)OnAction_Customview_Toggle);
973 972
974 default: 973 default:
975 break; 974 break;
976 } 975 }
977 976
978 } 977 }
979 } 978 }
980 if(customviewsSubpageMax != 1) 979 if(customviewsSubpageMax != 1)
981 { 980 {
982 setEvent(StMCustom3_CViewSelection6,(uint32_t)OnAction_Customview_NextPage); 981 setEvent(StMCustom3_CViewSelection6,(uint32_t)OnAction_Customview_NextPage);
983 } 982 }
984 983 }
985 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 984 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist)
985 {
986 resetMenuEdit(CLUT_MenuPageCustomView);
987 customviewsSubpageMax = (tHome_getNumberOfAvailableCVs(pcv_changelist) / CV_PER_PAGE) + 1;
988
989 if(pcv_curchangelist != pcv_changelist) /* new selection base? => reset page index */
990 {
991 customviewsSubpage = 0;
992 }
993 pcv_curchangelist = pcv_changelist;
994
995 setMenuContentStructure();
996
997 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
986 } 998 }
987 999
988 void openEdit_CustomviewDivemodeMenu(uint8_t line) 1000 void openEdit_CustomviewDivemodeMenu(uint8_t line)
989 { 1001 {
990 static uint8_t customviewsSubpage = 0; 1002 static uint8_t customviewsSubpage = 0;