comparison Discovery/Src/tMenu.c @ 110:cc8e24374b83 FlipDisplay

Added option to handled mirrored display to existing functions
author Ideenmodellierer
date Tue, 01 Jan 2019 21:02:17 +0100
parents 8f8ea3a32e82
children 871baf20776b
comparison
equal deleted inserted replaced
109:65a6e352ce08 110:cc8e24374b83
47 #include "tMenuSetpoint.h" 47 #include "tMenuSetpoint.h"
48 #include "tMenuSystem.h" 48 #include "tMenuSystem.h"
49 #include "tMenuXtra.h" 49 #include "tMenuXtra.h"
50 50
51 /* Private types -------------------------------------------------------------*/ 51 /* Private types -------------------------------------------------------------*/
52 #define MAXPAGES 10 52 #define MAXPAGES 10
53 #define CURSOR_HIGH 25
54 #define TAB_HEADER_HIGH 25
55 #define TAB_BAR_HIGH 5
56 #define MENU_WDW_HIGH 390
57 #define KEY_LABEL_HIGH 25 /* Height of the label used for the the user keys */
53 58
54 typedef struct 59 typedef struct
55 { 60 {
56 uint32_t StartAddressForPage[MAXPAGES+1]; 61 uint32_t StartAddressForPage[MAXPAGES+1];
57 uint8_t lineMemoryForNavigationForPage[MAXPAGES+1]; 62 uint8_t lineMemoryForNavigationForPage[MAXPAGES+1];
121 126
122 void tM_init(void) 127 void tM_init(void)
123 { 128 {
124 uint8_t i; 129 uint8_t i;
125 130
131 SSettings* pSettings;
132 pSettings = settingsGetPointer();
133
126 tMdesignCursor.FBStartAdress = getFrame(3); 134 tMdesignCursor.FBStartAdress = getFrame(3);
127 tMdesignCursor.ImageHeight = 390; 135 tMdesignCursor.ImageHeight = 390;
128 tMdesignCursor.ImageWidth = 800; 136 tMdesignCursor.ImageWidth = 800;
129 tMdesignCursor.LayerIndex = 0; 137 tMdesignCursor.LayerIndex = 0;
130 138
153 tMwindow.WindowNumberOfTextLines = 6; 161 tMwindow.WindowNumberOfTextLines = 6;
154 tMwindow.WindowLineSpacing = 65; 162 tMwindow.WindowLineSpacing = 65;
155 tMwindow.WindowTab = 400; 163 tMwindow.WindowTab = 400;
156 tMwindow.WindowX0 = 20; 164 tMwindow.WindowX0 = 20;
157 tMwindow.WindowX1 = 779; 165 tMwindow.WindowX1 = 779;
158 tMwindow.WindowY0 = 4 + 25; 166
159 tMwindow.WindowY1 = 390 + 25; 167 if(!pSettings->FlipDisplay)
160 168 {
169 tMwindow.WindowY0 = 4 + KEY_LABEL_HIGH;
170 tMwindow.WindowY1 = 390 + KEY_LABEL_HIGH;
171 }
172 else
173 {
174 tMwindow.WindowY0 = 480 - MENU_WDW_HIGH - TAB_HEADER_HIGH;// - TAB_BAR_HIGH;
175 tMwindow.WindowY1 = 480 - TAB_HEADER_HIGH - TAB_BAR_HIGH;
176 }
161 actual_menu_content = MENU_UNDEFINED; 177 actual_menu_content = MENU_UNDEFINED;
162 } 178 }
163 179
164 void tM_refresh(char *text, uint8_t *textPointer, uint8_t line, const char content[6]) 180 void tM_refresh(char *text, uint8_t *textPointer, uint8_t line, const char content[6])
165 { 181 {
194 void tM_rebuild_menu_after_tComm(void) 210 void tM_rebuild_menu_after_tComm(void)
195 { 211 {
196 tM_rebuild_pages(); 212 tM_rebuild_pages();
197 } 213 }
198 214
199 # 215 void tM_check_content(void)
200 void tM_check_content(void)
201 { 216 {
202 uint8_t mode = 0; 217 uint8_t mode = 0;
203 218
204 if(stateUsed->mode == MODE_DIVE) 219 if(stateUsed->mode == MODE_DIVE)
205 { 220 {
270 tMenu_write(page, text, subtext); 285 tMenu_write(page, text, subtext);
271 286
272 localtext[0] = TXT_2BYTE; 287 localtext[0] = TXT_2BYTE;
273 localtext[1] = TXT2BYTE_ButtonBack; 288 localtext[1] = TXT2BYTE_ButtonBack;
274 localtext[2] = 0; 289 localtext[2] = 0;
275 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); 290 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
276 291
277 localtext[0] = '\001'; 292 localtext[0] = '\001';
278 localtext[1] = TXT_2BYTE; 293 localtext[1] = TXT_2BYTE;
279 localtext[2] = TXT2BYTE_ButtonEnter; 294 localtext[2] = TXT2BYTE_ButtonEnter;
280 localtext[3] = 0; 295 localtext[3] = 0;
281 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); 296 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
282 297
283 localtext[0] = '\002'; 298 localtext[0] = '\002';
284 localtext[1] = TXT_2BYTE; 299 localtext[1] = TXT_2BYTE;
285 localtext[2] = TXT2BYTE_ButtonNext; 300 localtext[2] = TXT2BYTE_ButtonNext;
286 localtext[3] = 0; 301 localtext[3] = 0;
287 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); 302 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
288 303
289 // gfx_write_page_number(&tMscreen ,menu.pageCountNumber[page],menu.pageCountTotal,0); 304 // gfx_write_page_number(&tMscreen ,menu.pageCountNumber[page],menu.pageCountTotal,0);
290 305
291 if(page == menu.pageMemoryForNavigation) 306 if(page == menu.pageMemoryForNavigation)
292 GFX_SetFrameTop(tMscreen.FBStartAdress); 307 GFX_SetFrameTop(tMscreen.FBStartAdress);
386 tMenu_write(page, text, subtext); 401 tMenu_write(page, text, subtext);
387 402
388 localtext[0] = TXT_2BYTE; 403 localtext[0] = TXT_2BYTE;
389 localtext[1] = TXT2BYTE_ButtonBack; 404 localtext[1] = TXT2BYTE_ButtonBack;
390 localtext[2] = 0; 405 localtext[2] = 0;
391 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); 406 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
392 407
393 localtext[0] = '\001'; 408 localtext[0] = '\001';
394 localtext[1] = TXT_2BYTE; 409 localtext[1] = TXT_2BYTE;
395 localtext[2] = TXT2BYTE_ButtonEnter; 410 localtext[2] = TXT2BYTE_ButtonEnter;
396 localtext[3] = 0; 411 localtext[3] = 0;
397 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); 412 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
398 413
399 localtext[0] = '\002'; 414 localtext[0] = '\002';
400 localtext[1] = TXT_2BYTE; 415 localtext[1] = TXT_2BYTE;
401 localtext[2] = TXT2BYTE_ButtonNext; 416 localtext[2] = TXT2BYTE_ButtonNext;
402 localtext[3] = 0; 417 localtext[3] = 0;
403 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); 418 write_content_simple(&tMscreen, 0, 800, 480-KEY_LABEL_HIGH, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
404 } 419 }
405 420
406 /* 421 /*
407 _Bool skipCCRpage(uint8_t page) 422 _Bool skipCCRpage(uint8_t page)
408 { 423 {
780 795
781 796
782 void openMenu(uint8_t freshWithFlipPages) 797 void openMenu(uint8_t freshWithFlipPages)
783 { 798 {
784 uint8_t page, line; 799 uint8_t page, line;
800 SSettings* pSettings;
801 pSettings = settingsGetPointer();
785 802
786 callerID = get_globalState(); 803 callerID = get_globalState();
787 804
788 findValidPosition(&page, &line); 805 findValidPosition(&page, &line);
789 if((page == 0) || (line == 0)) 806 if((page == 0) || (line == 0))
816 833
817 } 834 }
818 835
819 GFX_SetFrameTop(menu.StartAddressForPage[page]); 836 GFX_SetFrameTop(menu.StartAddressForPage[page]);
820 /* new test for 3button design */ 837 /* new test for 3button design */
821 if(freshWithFlipPages) 838
822 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390); 839 if(!pSettings->FlipDisplay)
823 else 840 {
824 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); 841 if(freshWithFlipPages)
842 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
843 else
844 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
845 }
846 else
847 {
848 if(freshWithFlipPages)
849 {
850 GFX_SetFrameBottom((tMdesignSolo.FBStartAdress), 0, 480-390-KEY_LABEL_HIGH, 800, 390); //- (25 * 2 * 800), 0, 25, 800, 390);
851 }
852 else
853 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress + (390 - 65 *(line)) *2), 0,480-390-KEY_LABEL_HIGH, 800, 390); //480-390-KEY_LABEL_HIGH + 65*2*(line - 1)
854 }
855
825 } 856 }
826 857
827 void block_diluent_handler(_Bool Unblock) 858 void block_diluent_handler(_Bool Unblock)
828 { 859 {
829 SStateList list; 860 SStateList list;
854 885
855 886
856 void nextPage(void) 887 void nextPage(void)
857 { 888 {
858 uint8_t page, line; 889 uint8_t page, line;
890
891 SSettings* pSettings;
892 pSettings = settingsGetPointer();
859 893
860 menu.pageMemoryForNavigation += 1; 894 menu.pageMemoryForNavigation += 1;
861 895
862 findValidPosition(&page, &line); 896 findValidPosition(&page, &line);
863 menu.pageMemoryForNavigation = page; 897 menu.pageMemoryForNavigation = page;
871 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 1)); 905 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 1));
872 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1)); 906 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1));
873 907
874 GFX_SetFrameTop(menu.StartAddressForPage[page]); 908 GFX_SetFrameTop(menu.StartAddressForPage[page]);
875 /* new test for 3button design */ 909 /* new test for 3button design */
876 //GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); 910 //GFX_SetFrameBottom((.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
877 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390); 911 if(!pSettings->FlipDisplay)
912 {
913 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
914 }
915 else
916 {
917 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 65, 800, 390);
918 }
878 } 919 }
879 920
880 921
881 void nextLine(void) 922 void nextLine(void)
882 { 923 {
883 uint8_t page, line; 924 uint8_t page, line;
925 SSettings* pSettings;
926 pSettings = settingsGetPointer();
884 927
885 page = menu.pageMemoryForNavigation; 928 page = menu.pageMemoryForNavigation;
886 menu.lineMemoryForNavigationForPage[page] += 1; 929 menu.lineMemoryForNavigationForPage[page] += 1;
887 930
888 findValidPosition(&page, &line); 931 findValidPosition(&page, &line);
889 menu.lineMemoryForNavigationForPage[page] = line; 932 menu.lineMemoryForNavigationForPage[page] = line;
890 933
891 /* new test for 3button design */ 934 /* new test for 3button design */
892 menu.modeFlipPages = 0; 935 menu.modeFlipPages = 0;
893 936 if(!pSettings->FlipDisplay)
894 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); 937 {
938 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
939 }
940 else
941 {
942 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress)+ (390 - 65 *(line)) *2, 0, 480-390-KEY_LABEL_HIGH, 800, 390);
943 }
895 } 944 }
896 945
897 946
898 void stepBackMenu(void) 947 void stepBackMenu(void)
899 { 948 {
900 if(menu.modeFlipPages == 0) 949 if(menu.modeFlipPages == 0)
901 { 950 {
902 menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation] = 0; 951 menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation] = 0;
903 menu.modeFlipPages = 1; 952 menu.modeFlipPages = 1;
904 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390); 953 if(!settingsGetPointer()->FlipDisplay)
905 } 954 {
906 else 955 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390);
956 }
957 else
958 {
959 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 480-390-KEY_LABEL_HIGH, 800, 390);
960 }
961 }
962 else
963 {
907 exitMenu(); 964 exitMenu();
965 }
908 } 966 }
909 967
910 968
911 void exitMenu(void) 969 void exitMenu(void)
912 { 970 {
1021 { 1079 {
1022 uint8_t al8[2]; 1080 uint8_t al8[2];
1023 uint16_t al88; 1081 uint16_t al88;
1024 }; 1082 };
1025 1083
1084 uint16_t* prunning = *ppDestination;
1085
1026 union al88_u color_seperator; 1086 union al88_u color_seperator;
1027 union al88_u color_unselected; 1087 union al88_u color_unselected;
1028 int i; 1088 int i;
1029 1089
1030 color_seperator.al8[0] = CLUT_MenuLineUnselectedSeperator; 1090 color_seperator.al8[0] = CLUT_MenuLineUnselectedSeperator;
1031 color_unselected.al8[0] = CLUT_MenuLineUnselected; 1091 color_unselected.al8[0] = CLUT_MenuLineUnselected;
1032 1092
1033 color_seperator.al8[1] = 0xFF; 1093 color_seperator.al8[1] = 0xFF;
1034 color_unselected.al8[1] = 0xFF; 1094 color_unselected.al8[1] = 0xFF;
1035 1095
1036 *(__IO uint16_t*)*ppDestination = color_seperator.al88; 1096 *(__IO uint16_t*)prunning++ = color_seperator.al88;
1037 *ppDestination += 2; 1097 *(__IO uint16_t*)prunning++ = color_seperator.al88;
1038 *(__IO uint16_t*)*ppDestination = color_seperator.al88;
1039 *ppDestination += 2;
1040 1098
1041 for(i = 61; i > 0; i--) 1099 for(i = 61; i > 0; i--)
1042 { 1100 {
1043 *(__IO uint16_t*)*ppDestination = color_unselected.al88; 1101 *(__IO uint16_t*)prunning++ = color_unselected.al88;
1044 *ppDestination += 2; 1102 }
1045 } 1103
1046 1104 *(__IO uint16_t*)prunning++ = color_seperator.al88;
1047 *(__IO uint16_t*)*ppDestination = color_seperator.al88; 1105 *(__IO uint16_t*)prunning++ = color_seperator.al88;
1048 *ppDestination += 2; 1106
1049 *(__IO uint16_t*)*ppDestination = color_seperator.al88; 1107 *ppDestination = prunning;
1050 *ppDestination += 2;
1051 } 1108 }
1052 1109
1053 1110
1054 void draw_tMdesignSubSelected(uint32_t *ppDestination) 1111 void draw_tMdesignSubSelected(uint32_t *ppDestination)
1055 { 1112 {
1127 draw_tMdesignSubSelectedBorder(&pDestination); 1184 draw_tMdesignSubSelectedBorder(&pDestination);
1128 else 1185 else
1129 draw_tMdesignSubSelected(&pDestination); 1186 draw_tMdesignSubSelected(&pDestination);
1130 } 1187 }
1131 1188
1189 /* Draw menu background boxes which are visible if nothing is selected */
1132 pDestination = tMdesignSolo.FBStartAdress; 1190 pDestination = tMdesignSolo.FBStartAdress;
1133 1191
1134 for(j = 801; j > 0; j--) 1192 for(j = 801; j > 0; j--)
1135 { 1193 {
1136 for(i = 6; i > 0; i--) 1194 for(i = 6; i > 0; i--)
1149 uint16_t al88; 1207 uint16_t al88;
1150 }; 1208 };
1151 union al88_u color_top; 1209 union al88_u color_top;
1152 int i,j, k, k4text; 1210 int i,j, k, k4text;
1153 uint32_t pBackup; 1211 uint32_t pBackup;
1154 uint32_t pDestination; 1212 uint16_t* pDestination;
1155 uint8_t colorText; 1213 uint8_t colorText;
1156 uint16_t positionText; 1214 uint16_t positionText;
1157 uint8_t pageText; 1215 uint8_t pageText;
1158 1216
1159 const char text8max[MAXPAGES+1][8] = 1217 const char text8max[MAXPAGES+1][8] =
1228 /* 1286 /*
1229 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k],colorText); 1287 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k],colorText);
1230 if((text8max[k][0] == 0) && (menu.pageCountNumber[k-1] == 0)) 1288 if((text8max[k][0] == 0) && (menu.pageCountNumber[k-1] == 0))
1231 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k-1],colorText); 1289 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k-1],colorText);
1232 */ 1290 */
1233 pDestination += 2 * 5 * 480; 1291 /* Draw color bars */
1234 1292 if(!settingsGetPointer()->FlipDisplay)
1235 for(j = 60; j > 0; j--)
1236 { 1293 {
1237 pDestination += (390 + 26)* 2; 1294 pDestination += 5 * 480;
1238 1295
1239 // for(i = 64; i > 0; i--) 1296 for(j = 60; j > 0; j--)
1240 for(i = 16; i > 0; i--) 1297 {
1241 { 1298 pDestination += (390 + 26);
1242 *(__IO uint16_t*)pDestination = color_top.al88; 1299
1243 pDestination += 2; 1300 for(i = 16; i > 0; i--)
1244 } 1301 {
1245 pDestination += 2 * 48; 1302 *(__IO uint16_t*)pDestination++ = color_top.al88;
1246 } 1303 }
1247 1304 pDestination += 48;
1248 pDestination += 2 * 5 * 480; 1305 }
1249 positionText += 70; 1306
1250 1307 pDestination += 5 * 480;
1251 if((k == 4) || ((k == 6) && (menu.pageCountNumber[5] == 0))) 1308 positionText += 70;
1252 { 1309
1253 pDestination += 2 * 70 * 480; 1310 if((k == 4) || ((k == 6) && (menu.pageCountNumber[5] == 0)))
1254 positionText += 70; 1311 {
1255 } 1312 pDestination += 70 * 480;
1256 1313 positionText += 70;
1257 if(spacing[k]) 1314 }
1258 { 1315
1259 pDestination += 35 * 2 * 480; 1316 if(spacing[k])
1260 positionText += 35; 1317 {
1261 } 1318 pDestination += 35 * 480;
1319 positionText += 35;
1320 }
1321 }
1322 else
1323 {
1324 pDestination += (800 - 5)* 480;
1325
1326 for(j = 60; j > 0; j--)
1327 {
1328 pDestination -= (390 + 26);
1329
1330 for(i = 16; i > 0; i--)
1331 {
1332 *(__IO uint16_t*)pDestination-- = color_top.al88;
1333 }
1334 pDestination -= 48;
1335 }
1336
1337 pDestination -= (800) * 480;
1338 positionText += 70;
1339
1340 if((k == 4) || ((k == 6) && (menu.pageCountNumber[5] == 0)))
1341 {
1342 pDestination -= 70 * 480;
1343 positionText += 70;
1344 }
1345
1346 if(spacing[k])
1347 {
1348 pDestination -= 35 * 480;
1349 positionText += 35;
1350 }
1351 }
1262 } 1352 }
1263 } 1353 }
1264 tMscreen.FBStartAdress = pBackup; 1354 tMscreen.FBStartAdress = pBackup;
1265 } 1355 }