Mercurial > public > ostc4
comparison Discovery/Src/tMenu.c @ 167:5e41365ff0d8 cleanup-1
cleanup: local data and functions can be static (tMenu)
Most of the changes in this commit are making code that is only used
in this file (compilation unit) static. Careful reading the changes show
a little more. Like, removing commented code (as any code change can be
found the repository, so nothing is really lost), or removing
obvious looking useless code (callerID).
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Fri, 08 Mar 2019 13:47:52 +0100 |
parents | b7689d9e888a |
children | 842f57bbaaad |
comparison
equal
deleted
inserted
replaced
166:255eedad4155 | 167:5e41365ff0d8 |
---|---|
69 } SMenuMemory; | 69 } SMenuMemory; |
70 | 70 |
71 /* Exported variables --------------------------------------------------------*/ | 71 /* Exported variables --------------------------------------------------------*/ |
72 | 72 |
73 /* Announced Private variables -----------------------------------------------*/ | 73 /* Announced Private variables -----------------------------------------------*/ |
74 GFX_DrawCfgScreen tMdesignSolo; | 74 static GFX_DrawCfgScreen tMdesignSolo; |
75 GFX_DrawCfgScreen tMdesignCursor; | 75 static GFX_DrawCfgScreen tMdesignCursor; |
76 | 76 |
77 /* Private variables ---------------------------------------------------------*/ | 77 /* Private variables ---------------------------------------------------------*/ |
78 GFX_DrawCfgWindow tMwindow; | 78 static GFX_DrawCfgWindow tMwindow; |
79 GFX_DrawCfgScreen tMscreen; | 79 static GFX_DrawCfgScreen tMscreen; |
80 | 80 |
81 uint32_t FramebufferStartAddressForPage[10]; | 81 static SMenuMemory menu; |
82 | |
83 SMenuMemory menu; | |
84 | |
85 uint32_t callerID; | |
86 | 82 |
87 uint8_t actual_menu_content = MENU_UNDEFINED; | 83 uint8_t actual_menu_content = MENU_UNDEFINED; |
88 | 84 |
89 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/ | |
90 | |
91 /* Private function prototypes -----------------------------------------------*/ | 85 /* Private function prototypes -----------------------------------------------*/ |
92 void draw_tMheader(uint8_t page); | 86 static void draw_tMheader(uint8_t page); |
93 void draw_tMcursorDesign(void); | 87 static void draw_tMcursorDesign(void); |
94 | 88 |
95 void draw_tMdesignSubUnselected(uint32_t *ppDestination); | 89 static void draw_tMdesignSubUnselected(uint32_t *ppDestination); |
96 void draw_tMdesignSubSelected(uint32_t *ppDestination); | 90 static void draw_tMdesignSubSelected(uint32_t *ppDestination); |
97 void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination); | 91 static void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination); |
98 void tMenu_write(uint8_t page, char *text, char *subtext); | 92 static void tMenu_write(uint8_t page, char *text, char *subtext); |
99 | 93 |
100 void clean_line_actual_page(void); | 94 static void clean_line_actual_page(void); |
101 void tM_build_pages(void); | 95 void tM_build_pages(void); |
102 | 96 |
103 void gotoMenuEdit(void); | 97 static void gotoMenuEdit(void); |
104 | 98 |
105 /* Exported functions --------------------------------------------------------*/ | 99 /* Exported functions --------------------------------------------------------*/ |
106 | 100 |
107 GFX_DrawCfgScreen * get_PointerMenuCursorScreen(void) | 101 GFX_DrawCfgScreen * get_PointerMenuCursorScreen(void) |
108 { | 102 { |
232 tM_rebuild_pages(); | 226 tM_rebuild_pages(); |
233 } | 227 } |
234 } | 228 } |
235 | 229 |
236 | 230 |
237 void clean_line_actual_page(void) | 231 static void clean_line_actual_page(void) |
238 { | 232 { |
239 uint8_t line, page; | 233 uint8_t line, page; |
240 | 234 |
241 page = menu.pageMemoryForNavigation; | 235 page = menu.pageMemoryForNavigation; |
242 line = menu.lineMemoryForNavigationForPage[page]; | 236 line = menu.lineMemoryForNavigationForPage[page]; |
247 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | 241 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; |
248 GFX_clean_line(&tMwindow, line); | 242 GFX_clean_line(&tMwindow, line); |
249 } | 243 } |
250 | 244 |
251 | 245 |
252 void update_content_actual_page(char *text, uint16_t tab, char *subtext) | 246 static void update_content_actual_page(char *text, uint16_t tab, char *subtext) |
253 { | 247 { |
254 uint8_t page; | 248 uint8_t page; |
255 | 249 |
256 page = menu.pageMemoryForNavigation; | 250 page = menu.pageMemoryForNavigation; |
257 | 251 |
263 | 257 |
264 tMenu_write(page, text, subtext); | 258 tMenu_write(page, text, subtext); |
265 } | 259 } |
266 | 260 |
267 | 261 |
268 void clean_line(uint8_t page, uint8_t line) | 262 static void update_content_with_new_frame(uint8_t page, char *text, uint16_t tab, char *subtext) |
269 { | |
270 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
271 GFX_clean_line(&tMwindow, line); | |
272 } | |
273 | |
274 void update_content_with_new_frame(uint8_t page, char *text, uint16_t tab, char *subtext) | |
275 { | 263 { |
276 char localtext[32]; | 264 char localtext[32]; |
277 | 265 |
278 uint32_t rememberPage = menu.StartAddressForPage[page]; | 266 uint32_t rememberPage = menu.StartAddressForPage[page]; |
279 menu.StartAddressForPage[page] = getFrame(5); | 267 menu.StartAddressForPage[page] = getFrame(5); |
309 if(page == menu.pageMemoryForNavigation) | 297 if(page == menu.pageMemoryForNavigation) |
310 GFX_SetFrameTop(tMscreen.FBStartAdress); | 298 GFX_SetFrameTop(tMscreen.FBStartAdress); |
311 releaseFrame(5,rememberPage); | 299 releaseFrame(5,rememberPage); |
312 } | 300 } |
313 | 301 |
314 void update_content(uint8_t page, char *text, uint16_t tab, char *subtext) | |
315 { | |
316 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
317 if(tab == 0) | |
318 tMwindow.WindowTab = 400; | |
319 else | |
320 tMwindow.WindowTab = tab; | |
321 | |
322 tMenu_write(page, text, subtext); | |
323 } | |
324 | |
325 | 302 |
326 void tM_create_pagenumbering(void) | 303 void tM_create_pagenumbering(void) |
327 { | 304 { |
328 menu.pageCountTotal = 0; | 305 menu.pageCountTotal = 0; |
329 | 306 |
336 } | 313 } |
337 } | 314 } |
338 } | 315 } |
339 | 316 |
340 | 317 |
341 void tM_build_page(uint32_t id, char *text, uint16_t tab, char *subtext) | 318 static void tM_build_page(uint32_t id, char *text, uint16_t tab, char *subtext) |
342 { | 319 { |
343 uint8_t linesFound; | 320 uint8_t linesFound; |
344 uint16_t i; | 321 uint16_t i; |
345 SStateList idList; | 322 SStateList idList; |
346 uint8_t page; | 323 uint8_t page; |
435 } | 412 } |
436 return 0; | 413 return 0; |
437 } | 414 } |
438 */ | 415 */ |
439 | 416 |
440 void findValidPosition(uint8_t *pageOuput, uint8_t *lineOutput) | 417 static void findValidPosition(uint8_t *pageOuput, uint8_t *lineOutput) |
441 { | 418 { |
442 uint8_t page = 0; | 419 uint8_t page = 0; |
443 uint8_t line = 0; | 420 uint8_t line = 0; |
444 uint8_t first = 0; | 421 uint8_t first = 0; |
445 | 422 |
486 | 463 |
487 *pageOuput = page; | 464 *pageOuput = page; |
488 *lineOutput = line; | 465 *lineOutput = line; |
489 } | 466 } |
490 | 467 |
491 /* | 468 |
492 void tM_insert_page_numbers(void) | 469 static void tM_add(uint32_t id) |
493 { | |
494 uint8_t page, line, pageMemoryBackup, pageFirst, total; | |
495 GFX_DrawCfgScreen tTscreen; | |
496 | |
497 tTscreen.FBStartAdress = 0; | |
498 tTscreen.ImageHeight = 480; | |
499 tTscreen.ImageWidth = 800; | |
500 tTscreen.LayerIndex = 1; | |
501 | |
502 pageMemoryBackup = menu.pageMemoryForNavigation; | |
503 | |
504 menu.pageMemoryForNavigation = 1; | |
505 findValidPosition(&page, &line); | |
506 pageFirst = page; | |
507 total = 0; | |
508 | |
509 do | |
510 { | |
511 total++; | |
512 menu.pageMemoryForNavigation += 1; | |
513 findValidPosition(&page, &line); | |
514 } | |
515 while((pageFirst != page) && (total < MAXPAGES)); | |
516 | |
517 menu.pageCountTotal = total; | |
518 menu.pageMemoryForNavigation = 0; | |
519 for(int i = 1; i<= total; i++) | |
520 { | |
521 menu.pageMemoryForNavigation += 1; | |
522 findValidPosition(&page, &line); | |
523 tTscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
524 menu.pageCountNumber[page] = i; | |
525 gfx_write_page_number(&tTscreen ,i,total,0); | |
526 } | |
527 | |
528 menu.pageMemoryForNavigation = pageMemoryBackup; | |
529 } | |
530 */ | |
531 | |
532 void tM_add(uint32_t id) | |
533 { | 470 { |
534 SStateList idList; | 471 SStateList idList; |
535 uint8_t page; | 472 uint8_t page; |
536 | 473 |
537 get_idSpecificStateList(id, &idList); | 474 get_idSpecificStateList(id, &idList); |
801 { | 738 { |
802 uint8_t page, line; | 739 uint8_t page, line; |
803 SSettings* pSettings; | 740 SSettings* pSettings; |
804 pSettings = settingsGetPointer(); | 741 pSettings = settingsGetPointer(); |
805 | 742 |
806 callerID = get_globalState(); | |
807 | |
808 findValidPosition(&page, &line); | 743 findValidPosition(&page, &line); |
809 if((page == 0) || (line == 0)) | 744 if((page == 0) || (line == 0)) |
810 return; | 745 return; |
811 | 746 |
812 menu.pageMemoryForNavigation = page; | 747 menu.pageMemoryForNavigation = page; |
856 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) | 791 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) |
857 } | 792 } |
858 | 793 |
859 } | 794 } |
860 | 795 |
861 void block_diluent_handler(_Bool Unblock) | 796 static void block_diluent_handler(_Bool Unblock) |
862 { | 797 { |
863 SStateList list; | 798 SStateList list; |
864 static uint8_t linesAvailableForPageDiluent = 0; | 799 static uint8_t linesAvailableForPageDiluent = 0; |
865 get_idSpecificStateList(StMCG, &list); | 800 get_idSpecificStateList(StMCG, &list); |
866 | 801 |
885 { | 820 { |
886 block_diluent_handler(1); | 821 block_diluent_handler(1); |
887 } | 822 } |
888 | 823 |
889 | 824 |
890 void nextPage(void) | 825 static void nextPage(void) |
891 { | 826 { |
892 uint8_t page, line; | 827 uint8_t page, line; |
893 | 828 |
894 SSettings* pSettings; | 829 SSettings* pSettings; |
895 pSettings = settingsGetPointer(); | 830 pSettings = settingsGetPointer(); |
920 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 65, 800, 390); | 855 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 65, 800, 390); |
921 } | 856 } |
922 } | 857 } |
923 | 858 |
924 | 859 |
925 void nextLine(void) | 860 static void nextLine(void) |
926 { | 861 { |
927 uint8_t page, line; | 862 uint8_t page, line; |
928 SSettings* pSettings; | 863 SSettings* pSettings; |
929 pSettings = settingsGetPointer(); | 864 pSettings = settingsGetPointer(); |
930 | 865 |
945 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress)+ (390 - 65 *(line)) *2, 0, 480-390-KEY_LABEL_HIGH, 800, 390); | 880 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress)+ (390 - 65 *(line)) *2, 0, 480-390-KEY_LABEL_HIGH, 800, 390); |
946 } | 881 } |
947 } | 882 } |
948 | 883 |
949 | 884 |
950 void stepBackMenu(void) | 885 static void stepBackMenu(void) |
951 { | 886 { |
952 if(menu.modeFlipPages == 0) | 887 if(menu.modeFlipPages == 0) |
953 { | 888 { |
954 menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation] = 0; | 889 menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation] = 0; |
955 menu.modeFlipPages = 1; | 890 menu.modeFlipPages = 1; |
973 { | 908 { |
974 set_globalState_tHome(); | 909 set_globalState_tHome(); |
975 } | 910 } |
976 | 911 |
977 | 912 |
978 void stepForwardMenu(void) | 913 static void stepForwardMenu(void) |
979 { | 914 { |
980 if(menu.modeFlipPages == 1) | 915 if(menu.modeFlipPages == 1) |
981 { | 916 { |
982 nextLine(); | 917 nextLine(); |
983 } | 918 } |
984 else | 919 else |
985 gotoMenuEdit(); | 920 gotoMenuEdit(); |
986 } | 921 } |
987 | 922 |
988 void gotoMenuEdit(void) | 923 static void gotoMenuEdit(void) |
989 { | 924 { |
990 uint8_t line; | 925 uint8_t line; |
991 | 926 |
992 line = menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation]; | 927 line = menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation]; |
993 | 928 |
1052 break; | 987 break; |
1053 } | 988 } |
1054 /* tMC_OC_Gas(StMOG1, pSettings); */ | 989 /* tMC_OC_Gas(StMOG1, pSettings); */ |
1055 } | 990 } |
1056 | 991 |
1057 void timeoutTestMenu(uint32_t seconds_since_last_button_press) | 992 static void tMenu_write(uint8_t page, char *text, char *subtext) |
1058 { | |
1059 } | |
1060 | |
1061 void tMenu_write(uint8_t page, char *text, char *subtext) | |
1062 { | 993 { |
1063 if(page > MAXPAGES) | 994 if(page > MAXPAGES) |
1064 return; | 995 return; |
1065 if(menu.linesAvailableForPage[page] == 0) | 996 if(menu.linesAvailableForPage[page] == 0) |
1066 return; | 997 return; |
1074 } | 1005 } |
1075 | 1006 |
1076 | 1007 |
1077 /* Private functions ---------------------------------------------------------*/ | 1008 /* Private functions ---------------------------------------------------------*/ |
1078 | 1009 |
1079 void draw_tMdesignSubUnselected(uint32_t *ppDestination) | 1010 static void draw_tMdesignSubUnselected(uint32_t *ppDestination) |
1080 { | 1011 { |
1081 union al88_u | 1012 union al88_u |
1082 { | 1013 { |
1083 uint8_t al8[2]; | 1014 uint8_t al8[2]; |
1084 uint16_t al88; | 1015 uint16_t al88; |
1109 | 1040 |
1110 *ppDestination = (uint32_t)prunning; | 1041 *ppDestination = (uint32_t)prunning; |
1111 } | 1042 } |
1112 | 1043 |
1113 | 1044 |
1114 void draw_tMdesignSubSelected(uint32_t *ppDestination) | 1045 static void draw_tMdesignSubSelected(uint32_t *ppDestination) |
1115 { | 1046 { |
1116 union al88_u | 1047 union al88_u |
1117 { | 1048 { |
1118 uint8_t al8[2]; | 1049 uint8_t al8[2]; |
1119 uint16_t al88; | 1050 uint16_t al88; |
1145 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | 1076 *(__IO uint16_t*)*ppDestination = color_seperator.al88; |
1146 *ppDestination += 2; | 1077 *ppDestination += 2; |
1147 } | 1078 } |
1148 | 1079 |
1149 | 1080 |
1150 void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination) | 1081 static void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination) |
1151 { | 1082 { |
1152 union al88_u | 1083 union al88_u |
1153 { | 1084 { |
1154 uint8_t al8[2]; | 1085 uint8_t al8[2]; |
1155 uint16_t al88; | 1086 uint16_t al88; |
1168 *ppDestination += 2; | 1099 *ppDestination += 2; |
1169 } | 1100 } |
1170 } | 1101 } |
1171 | 1102 |
1172 | 1103 |
1173 void draw_tMcursorDesign(void) | 1104 static void draw_tMcursorDesign(void) |
1174 { | 1105 { |
1175 int i,j; | 1106 int i,j; |
1176 uint32_t pDestination; | 1107 uint32_t pDestination; |
1177 | 1108 |
1178 pDestination = tMdesignCursor.FBStartAdress; | 1109 pDestination = tMdesignCursor.FBStartAdress; |
1200 } | 1131 } |
1201 } | 1132 } |
1202 } | 1133 } |
1203 | 1134 |
1204 | 1135 |
1205 void draw_tMheader(uint8_t page) | 1136 static void draw_tMheader(uint8_t page) |
1206 { | 1137 { |
1207 union al88_u | 1138 union al88_u |
1208 { | 1139 { |
1209 uint8_t al8[2]; | 1140 uint8_t al8[2]; |
1210 uint16_t al88; | 1141 uint16_t al88; |