Mercurial > public > ostc4
annotate Discovery/Src/tMenu.c @ 67:9714e1f0dea0
Bugfix: FutureTTS and Fahrenheit not displayed correct
author | Ideenmodellierer |
---|---|
date | Wed, 22 Aug 2018 11:35:05 +0200 |
parents | 8f8ea3a32e82 |
children | cc8e24374b83 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenu.c | |
5 /// \brief Major menu with extra page 0 for edit functionality since V0.0.2 | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 30-April-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 #include "tMenu.h" | |
31 | |
32 #include "gfx_fonts.h" | |
33 #include "tHome.h" | |
34 #include "tMenuDeco.h" | |
35 #include "tMenuDecoParameter.h" | |
36 #include "tMenuEditDeco.h" | |
37 #include "tMenuEditDecoParameter.h" | |
38 #include "tMenuEditGasOC.h" | |
39 #include "tMenuEditHardware.h" | |
40 #include "tMenuEditPlanner.h" | |
41 #include "tMenuEditSetpoint.h" | |
42 #include "tMenuEditSystem.h" | |
43 #include "tMenuEditXtra.h" | |
44 #include "tMenuGas.h" | |
45 #include "tMenuHardware.h" | |
46 #include "tMenuPlanner.h" | |
47 #include "tMenuSetpoint.h" | |
48 #include "tMenuSystem.h" | |
49 #include "tMenuXtra.h" | |
50 | |
51 /* Private types -------------------------------------------------------------*/ | |
52 #define MAXPAGES 10 | |
53 | |
54 typedef struct | |
55 { | |
56 uint32_t StartAddressForPage[MAXPAGES+1]; | |
57 uint8_t lineMemoryForNavigationForPage[MAXPAGES+1]; | |
58 uint8_t pageMemoryForNavigation; | |
59 uint8_t linesAvailableForPage[MAXPAGES+1]; | |
60 uint8_t pagesAvailable; | |
61 uint8_t pageCountNumber[MAXPAGES+1]; | |
62 uint8_t pageCountTotal; | |
63 uint8_t modeFlipPages; | |
64 } SMenuMemory; | |
65 | |
66 /* Exported variables --------------------------------------------------------*/ | |
67 | |
68 /* Announced Private variables -----------------------------------------------*/ | |
69 GFX_DrawCfgScreen tMdesignSolo; | |
70 GFX_DrawCfgScreen tMdesignCursor; | |
71 | |
72 /* Private variables ---------------------------------------------------------*/ | |
73 GFX_DrawCfgWindow tMwindow; | |
74 GFX_DrawCfgScreen tMscreen; | |
75 | |
76 uint32_t FramebufferStartAddressForPage[10]; | |
77 | |
78 SMenuMemory menu; | |
79 | |
80 uint32_t callerID; | |
81 | |
82 uint8_t actual_menu_content = MENU_UNDEFINED; | |
83 | |
84 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/ | |
85 | |
86 /* Private function prototypes -----------------------------------------------*/ | |
87 void draw_tMheader(uint8_t page); | |
88 void draw_tMcursorDesign(void); | |
89 | |
90 void draw_tMdesignSubUnselected(uint32_t *ppDestination); | |
91 void draw_tMdesignSubSelected(uint32_t *ppDestination); | |
92 void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination); | |
93 void tMenu_write(uint8_t page, char *text, char *subtext); | |
94 | |
95 void clean_line_actual_page(void); | |
96 void tM_build_pages(void); | |
97 | |
98 void gotoMenuEdit(void); | |
99 | |
100 /* Exported functions --------------------------------------------------------*/ | |
101 | |
102 GFX_DrawCfgScreen * get_PointerMenuCursorScreen(void) | |
103 { | |
104 return &tMdesignCursor; | |
105 } | |
106 | |
107 | |
108 GFX_DrawCfgScreen * get_PointerMenuCursorDesignSoloScreen(void) | |
109 { | |
110 return &tMdesignSolo; | |
111 } | |
112 | |
113 | |
114 void nextline(char * text, uint8_t *textPointer) | |
115 { | |
116 text[(*textPointer)++] = '\n'; | |
117 text[(*textPointer)++] = '\r'; | |
118 text[*textPointer] = 0; | |
119 } | |
120 | |
121 | |
122 void tM_init(void) | |
123 { | |
124 uint8_t i; | |
125 | |
126 tMdesignCursor.FBStartAdress = getFrame(3); | |
127 tMdesignCursor.ImageHeight = 390; | |
128 tMdesignCursor.ImageWidth = 800; | |
129 tMdesignCursor.LayerIndex = 0; | |
130 | |
131 tMdesignSolo.FBStartAdress = getFrame(4); | |
132 tMdesignSolo.ImageHeight = 390; | |
133 tMdesignSolo.ImageWidth = 800; | |
134 tMdesignSolo.LayerIndex = 0; | |
135 | |
136 menu.pagesAvailable = 0; | |
137 menu.pageMemoryForNavigation = 0; | |
138 for(i=0;i<=MAXPAGES;i++) | |
139 { | |
140 menu.lineMemoryForNavigationForPage[i] = 0; | |
141 menu.StartAddressForPage[i] = 0; | |
142 menu.linesAvailableForPage[i] = 0; | |
143 } | |
144 | |
145 tMscreen.FBStartAdress = 0; | |
146 tMscreen.ImageHeight = 480; | |
147 tMscreen.ImageWidth = 800; | |
148 tMscreen.LayerIndex = 1; | |
149 | |
150 draw_tMcursorDesign(); | |
151 | |
152 tMwindow.Image = &tMscreen; | |
153 tMwindow.WindowNumberOfTextLines = 6; | |
154 tMwindow.WindowLineSpacing = 65; | |
155 tMwindow.WindowTab = 400; | |
156 tMwindow.WindowX0 = 20; | |
157 tMwindow.WindowX1 = 779; | |
158 tMwindow.WindowY0 = 4 + 25; | |
159 tMwindow.WindowY1 = 390 + 25; | |
160 | |
161 actual_menu_content = MENU_UNDEFINED; | |
162 } | |
163 | |
164 void tM_refresh(char *text, uint8_t *textPointer, uint8_t line, const char content[6]) | |
165 { | |
166 for(uint8_t i=0; i<6; i++) | |
167 { | |
168 if(((line == 0) || (line == i)) && content[i]) | |
169 { | |
170 text[(*textPointer)++] = content[i]; | |
171 } | |
172 text[(*textPointer)++] = '\n'; | |
173 text[(*textPointer)++] = '\r'; | |
174 text[*textPointer] = 0; | |
175 } | |
176 } | |
177 | |
178 | |
179 void tM_rebuild_pages(void) | |
180 { | |
181 menu.pagesAvailable = 0; | |
182 // menu.pageMemoryForNavigation = 0; | |
183 for(int i=0;i<=MAXPAGES;i++) | |
184 { | |
185 menu.lineMemoryForNavigationForPage[i] = 0; | |
186 menu.linesAvailableForPage[i] = 0; | |
187 menu.StartAddressForPage[i] = 0; // only with GFX_forceReleaseFramesWithId(5); !!!!! | |
188 } | |
189 GFX_forceReleaseFramesWithId(5); | |
190 tM_build_pages(); | |
191 } | |
192 | |
193 | |
194 void tM_rebuild_menu_after_tComm(void) | |
195 { | |
196 tM_rebuild_pages(); | |
197 } | |
198 | |
199 # | |
200 void tM_check_content(void) | |
201 { | |
202 uint8_t mode = 0; | |
203 | |
204 if(stateUsed->mode == MODE_DIVE) | |
205 { | |
206 if(stateUsed == stateRealGetPointer()) | |
207 mode = MENU_DIVE_REAL; | |
208 else | |
209 mode = MENU_DIVE_SIM; | |
210 } | |
211 else | |
212 mode = MENU_SURFACE; | |
213 | |
214 if(actual_menu_content != mode) | |
215 { | |
216 actual_menu_content = mode; | |
217 tM_rebuild_pages(); | |
218 } | |
219 } | |
220 | |
221 | |
222 void clean_line_actual_page(void) | |
223 { | |
224 uint8_t line, page; | |
225 | |
226 page = menu.pageMemoryForNavigation; | |
227 line = menu.lineMemoryForNavigationForPage[page]; | |
228 | |
229 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
230 GFX_clean_line(&tMwindow, line); | |
231 } | |
232 | |
233 | |
234 void update_content_actual_page(char *text, uint16_t tab, char *subtext) | |
235 { | |
236 uint8_t page; | |
237 | |
238 page = menu.pageMemoryForNavigation; | |
239 | |
240 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
241 if(tab == 0) | |
242 tMwindow.WindowTab = 400; | |
243 else | |
244 tMwindow.WindowTab = tab; | |
245 | |
246 tMenu_write(page, text, subtext); | |
247 } | |
248 | |
249 | |
250 void clean_line(uint8_t page, uint8_t line) | |
251 { | |
252 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
253 GFX_clean_line(&tMwindow, line); | |
254 } | |
255 | |
256 void update_content_with_new_frame(uint8_t page, char *text, uint16_t tab, char *subtext) | |
257 { | |
258 char localtext[32]; | |
259 | |
260 uint32_t rememberPage = menu.StartAddressForPage[page]; | |
261 menu.StartAddressForPage[page] = getFrame(5); | |
262 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
263 | |
264 if(tab == 0) | |
265 tMwindow.WindowTab = 400; | |
266 else | |
267 tMwindow.WindowTab = tab; | |
268 | |
269 draw_tMheader(page); | |
270 tMenu_write(page, text, subtext); | |
271 | |
272 localtext[0] = TXT_2BYTE; | |
273 localtext[1] = TXT2BYTE_ButtonBack; | |
274 localtext[2] = 0; | |
275 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
276 | |
277 localtext[0] = '\001'; | |
278 localtext[1] = TXT_2BYTE; | |
279 localtext[2] = TXT2BYTE_ButtonEnter; | |
280 localtext[3] = 0; | |
281 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
282 | |
283 localtext[0] = '\002'; | |
284 localtext[1] = TXT_2BYTE; | |
285 localtext[2] = TXT2BYTE_ButtonNext; | |
286 localtext[3] = 0; | |
287 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
288 | |
289 // gfx_write_page_number(&tMscreen ,menu.pageCountNumber[page],menu.pageCountTotal,0); | |
290 | |
291 if(page == menu.pageMemoryForNavigation) | |
292 GFX_SetFrameTop(tMscreen.FBStartAdress); | |
293 releaseFrame(5,rememberPage); | |
294 } | |
295 | |
296 void update_content(uint8_t page, char *text, uint16_t tab, char *subtext) | |
297 { | |
298 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
299 if(tab == 0) | |
300 tMwindow.WindowTab = 400; | |
301 else | |
302 tMwindow.WindowTab = tab; | |
303 | |
304 tMenu_write(page, text, subtext); | |
305 } | |
306 | |
307 | |
308 void tM_create_pagenumbering(void) | |
309 { | |
310 menu.pageCountTotal = 0; | |
311 | |
312 for(int i=0;i<=MAXPAGES;i++) | |
313 { | |
314 if(menu.pageCountNumber[i]) | |
315 { | |
316 menu.pageCountTotal++; | |
317 menu.pageCountNumber[i] = menu.pageCountTotal; | |
318 } | |
319 } | |
320 } | |
321 | |
322 | |
323 void tM_build_page(uint32_t id, char *text, uint16_t tab, char *subtext) | |
324 { | |
325 uint8_t linesFound; | |
326 uint16_t i; | |
327 SStateList idList; | |
328 uint8_t page; | |
329 | |
330 char localtext[32]; | |
331 | |
332 if(menu.pagesAvailable > MAXPAGES) | |
333 return; | |
334 | |
335 get_idSpecificStateList(id, &idList); | |
336 | |
337 if(idList.base != BaseMenu) | |
338 return; | |
339 | |
340 if(idList.page == 0) | |
341 return; | |
342 | |
343 if(idList.page > MAXPAGES) | |
344 return; | |
345 | |
346 page = idList.page; | |
347 | |
348 if(!menu.pageCountNumber[page]) | |
349 return; | |
350 | |
351 if(menu.pagesAvailable == 0) | |
352 tM_create_pagenumbering(); | |
353 | |
354 if(*text == 0) | |
355 return; | |
356 | |
357 linesFound = 1; | |
358 | |
359 if(menu.StartAddressForPage[page]) | |
360 releaseFrame(5,menu.StartAddressForPage[page]); | |
361 | |
362 menu.StartAddressForPage[page] = getFrame(5); | |
363 | |
364 if(menu.StartAddressForPage[page] == 0) | |
365 return; | |
366 | |
367 i = 0; | |
368 while((i < MAX_PAGE_TEXTSIZE) && text[i]) | |
369 { | |
370 if((text[i] == '\n') && ((i + 2) < MAX_PAGE_TEXTSIZE) && text[i+1] && text[i+2]) | |
371 linesFound += 1; | |
372 i++; | |
373 } | |
374 | |
375 menu.linesAvailableForPage[page] = linesFound; | |
376 menu.pagesAvailable++; /* even if it was used before */ | |
377 | |
378 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
379 if(tab == 0) | |
380 tMwindow.WindowTab = 400; | |
381 else | |
382 tMwindow.WindowTab = tab; | |
383 | |
384 draw_tMheader(page); | |
385 | |
386 tMenu_write(page, text, subtext); | |
387 | |
388 localtext[0] = TXT_2BYTE; | |
389 localtext[1] = TXT2BYTE_ButtonBack; | |
390 localtext[2] = 0; | |
391 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
392 | |
393 localtext[0] = '\001'; | |
394 localtext[1] = TXT_2BYTE; | |
395 localtext[2] = TXT2BYTE_ButtonEnter; | |
396 localtext[3] = 0; | |
397 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
398 | |
399 localtext[0] = '\002'; | |
400 localtext[1] = TXT_2BYTE; | |
401 localtext[2] = TXT2BYTE_ButtonNext; | |
402 localtext[3] = 0; | |
403 write_content_simple(&tMscreen, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
404 } | |
405 | |
406 /* | |
407 _Bool skipCCRpage(uint8_t page) | |
408 { | |
409 if(menu.ccrOnlyContentForPage[page]) | |
410 { | |
411 if(actual_menu_content == MENU_SURFACE) | |
412 { | |
413 SSettings *data = settingsGetPointer(); | |
414 if((data->dive_mode != DIVEMODE_CCR) && data->hideCCRinOCmode) | |
415 return 1; | |
416 } | |
417 } | |
418 return 0; | |
419 } | |
420 */ | |
421 | |
422 void findValidPosition(uint8_t *pageOuput, uint8_t *lineOutput) | |
423 { | |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
424 uint8_t page = 0; |
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
425 uint8_t line = 0; |
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
426 uint8_t first = 0; |
38 | 427 |
428 *pageOuput = 0; | |
429 *lineOutput = 0; | |
430 | |
431 /* test */ | |
432 if(menu.pagesAvailable == 0) | |
433 return; | |
434 | |
435 for(int i=1;i<=MAXPAGES;i++) | |
436 { | |
437 if((menu.pageCountNumber[i] != 0) | |
438 && (menu.linesAvailableForPage[i] != 0) | |
439 && (menu.StartAddressForPage[i] != 0)) | |
440 { | |
441 first = i; | |
442 break; | |
443 } | |
444 } | |
445 | |
446 /* select */ | |
447 if(menu.pageMemoryForNavigation > MAXPAGES) | |
448 menu.pageMemoryForNavigation = first; | |
449 | |
450 page = menu.pageMemoryForNavigation; | |
451 | |
452 if(page == 0) | |
453 page = first; | |
454 | |
455 while((page <= MAXPAGES) && ((menu.linesAvailableForPage[page] == 0) || (menu.StartAddressForPage[page] == 0) || (menu.pageCountNumber[page] == 0))) | |
456 page += 1; | |
457 | |
458 if(page > MAXPAGES) | |
459 page = first; | |
460 | |
461 line = menu.lineMemoryForNavigationForPage[page]; | |
462 | |
463 if(line == 0) | |
464 line = 1; | |
465 | |
466 if(line > menu.linesAvailableForPage[page]) | |
467 line = 1; | |
468 | |
469 *pageOuput = page; | |
470 *lineOutput = line; | |
471 } | |
472 | |
473 /* | |
474 void tM_insert_page_numbers(void) | |
475 { | |
476 uint8_t page, line, pageMemoryBackup, pageFirst, total; | |
477 GFX_DrawCfgScreen tTscreen; | |
478 | |
479 tTscreen.FBStartAdress = 0; | |
480 tTscreen.ImageHeight = 480; | |
481 tTscreen.ImageWidth = 800; | |
482 tTscreen.LayerIndex = 1; | |
483 | |
484 pageMemoryBackup = menu.pageMemoryForNavigation; | |
485 | |
486 menu.pageMemoryForNavigation = 1; | |
487 findValidPosition(&page, &line); | |
488 pageFirst = page; | |
489 total = 0; | |
490 | |
491 do | |
492 { | |
493 total++; | |
494 menu.pageMemoryForNavigation += 1; | |
495 findValidPosition(&page, &line); | |
496 } | |
497 while((pageFirst != page) && (total < MAXPAGES)); | |
498 | |
499 menu.pageCountTotal = total; | |
500 menu.pageMemoryForNavigation = 0; | |
501 for(int i = 1; i<= total; i++) | |
502 { | |
503 menu.pageMemoryForNavigation += 1; | |
504 findValidPosition(&page, &line); | |
505 tTscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
506 menu.pageCountNumber[page] = i; | |
507 gfx_write_page_number(&tTscreen ,i,total,0); | |
508 } | |
509 | |
510 menu.pageMemoryForNavigation = pageMemoryBackup; | |
511 } | |
512 */ | |
513 | |
514 void tM_add(uint32_t id) | |
515 { | |
516 SStateList idList; | |
517 uint8_t page; | |
518 | |
519 get_idSpecificStateList(id, &idList); | |
520 | |
521 page = idList.page; | |
522 | |
523 if(page > MAXPAGES) | |
524 return; | |
525 | |
526 menu.pageCountNumber[page] = 1; | |
527 } | |
528 | |
529 | |
530 void tM_build_pages(void) | |
531 { | |
532 char text[MAX_PAGE_TEXTSIZE]; | |
533 char subtext[MAX_PAGE_TEXTSIZE]; | |
534 uint32_t id; | |
535 uint16_t tabPosition; | |
536 SSettings *pSettings = settingsGetPointer(); | |
537 | |
538 menu.pagesAvailable = 0; | |
539 for(int i=0;i<=MAXPAGES;i++) | |
540 menu.pageCountNumber[i] = 0; | |
541 | |
542 tabPosition = 400; | |
543 *text = 0; | |
544 *subtext = 0; | |
545 | |
546 /* 2015 Feb 02, hw | |
547 * max 8 Menu Pages | |
548 */ | |
549 | |
550 | |
551 tM_add(StMSYS); //now in both modes | |
552 if(actual_menu_content == MENU_SURFACE) | |
553 { | |
554 tM_add(StMDECO); | |
555 tM_add(StMHARD); | |
556 // tM_add(StMSYS); now in both modes | |
557 } | |
558 else | |
559 { | |
560 tM_add(StMXTRA); | |
561 } | |
562 if(actual_menu_content == MENU_SURFACE) | |
563 { | |
564 tM_add(StMPLAN); | |
565 } | |
566 // if((pSettings->dive_mode != DIVEMODE_Gauge) && (pSettings->dive_mode != DIVEMODE_Apnea)) | |
567 // { | |
568 tM_add(StMOG); | |
569 tM_add(StMDECOP); | |
570 // } | |
571 if((pSettings->dive_mode == DIVEMODE_CCR) || (stateUsed->diveSettings.ccrOption == 1)) | |
572 { | |
573 tM_add(StMCG); | |
574 tM_add(StMSP); | |
575 } | |
576 | |
577 id = tMOG_refresh(0, text, &tabPosition, subtext); | |
578 tM_build_page(id, text, tabPosition, subtext); | |
579 | |
580 id = tMCG_refresh(0, text, &tabPosition, subtext); | |
581 tM_build_page(id, text, tabPosition, subtext); | |
582 | |
583 id = tMSP_refresh(0, text, &tabPosition, subtext); | |
584 tM_build_page(id, text, tabPosition, subtext); | |
585 | |
586 id = tMXtra_refresh(0, text, &tabPosition, subtext); | |
587 tM_build_page(id, text, tabPosition, subtext); | |
588 | |
589 id = tMPlanner_refresh(0, text, &tabPosition, subtext); | |
590 tM_build_page(id, text, tabPosition, subtext); | |
591 | |
592 id = tMDeco_refresh(0, text, &tabPosition, subtext); | |
593 tM_build_page(id, text, tabPosition, subtext); | |
594 | |
595 id = tMDecoParameters_refresh(0, text, &tabPosition, subtext); | |
596 tM_build_page(id, text, tabPosition, subtext); | |
597 | |
598 id = tMPlanner_refresh(0, text, &tabPosition, subtext); | |
599 tM_build_page(id, text, tabPosition, subtext); | |
600 | |
601 id = tMHardware_refresh(0, text, &tabPosition, subtext); | |
602 tM_build_page(id, text, tabPosition, subtext); | |
603 | |
604 id = tMSystem_refresh(0, text, &tabPosition, subtext); | |
605 tM_build_page(id, text, tabPosition, subtext); | |
606 } | |
607 | |
608 | |
609 void tM_refresh_live_content(void) | |
610 { | |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
611 uint8_t page = 0; |
38 | 612 char text[MAX_PAGE_TEXTSIZE]; |
613 char subtext[MAX_PAGE_TEXTSIZE]; | |
614 uint16_t tabPosition; | |
615 | |
616 // if(menu.modeFlipPages == 0) | |
617 // return; | |
618 | |
619 if((get_globalState() == StMSYS) && (actual_menu_content == MENU_SURFACE)) | |
620 { | |
621 page = menu.pageMemoryForNavigation; | |
622 tMSystem_refresh(0, text, &tabPosition, subtext); | |
623 update_content_with_new_frame(page, text, tabPosition, subtext); | |
624 } | |
625 else | |
626 if(get_globalState() == StMHARD) | |
627 { | |
628 page = menu.pageMemoryForNavigation; | |
629 tMHardware_refresh(0, text, &tabPosition, subtext); | |
630 update_content_with_new_frame(page, text, tabPosition, subtext); | |
631 } | |
632 | |
633 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
634 tHome_show_lost_connection_count(&tMscreen); | |
635 /* | |
636 SStateList idList; | |
637 if(actual_menu_content == MENU_SURFACE) | |
638 { | |
639 page = menu.pageMemoryForNavigation; | |
640 get_idSpecificStateList(StMSYS, &idList); | |
641 if(page == idList.page) | |
642 { | |
643 tMSystem_refresh(0, text, &tabPosition, subtext); | |
644 update_content_with_new_frame(page, text, tabPosition, subtext); | |
645 } | |
646 } | |
647 */ | |
648 } | |
649 | |
650 | |
651 /* new frame only! */ | |
652 void updateSpecificMenu(uint32_t id) | |
653 { | |
654 uint8_t page; | |
655 SStateList idList; | |
656 | |
657 char text[MAX_PAGE_TEXTSIZE]; | |
658 char subtext[MAX_PAGE_TEXTSIZE]; | |
659 uint16_t tabPosition; | |
660 | |
661 *subtext = 0; | |
662 *text = 0; | |
663 tabPosition = 400; | |
664 | |
665 get_idSpecificStateList(id, &idList); | |
666 page = idList.page; | |
667 | |
668 switch(id) | |
669 { | |
670 case StMOG: | |
671 tMOG_refresh(0, text, &tabPosition, subtext); | |
672 update_content_with_new_frame(page, text, tabPosition, subtext); | |
673 break; | |
674 case StMCG: | |
675 tMCG_refresh(0, text, &tabPosition, subtext); | |
676 update_content_with_new_frame(page, text, tabPosition, subtext); | |
677 break; | |
678 case StMSP: | |
679 tMSP_refresh(0, text, &tabPosition, subtext); | |
680 update_content_with_new_frame(page, text, tabPosition, subtext); | |
681 break; | |
682 default: | |
683 break; | |
684 } | |
685 } | |
686 | |
687 | |
688 void updateMenu(void) | |
689 { | |
690 uint8_t page, line; | |
691 | |
692 char text[MAX_PAGE_TEXTSIZE]; | |
693 char subtext[MAX_PAGE_TEXTSIZE]; | |
694 uint16_t tabPosition; | |
695 | |
696 *subtext = 0; | |
697 *text = 0; | |
698 tabPosition = 400; | |
699 | |
700 page = menu.pageMemoryForNavigation; | |
701 line = menu.lineMemoryForNavigationForPage[page]; | |
702 | |
703 switch(get_globalState()) | |
704 { | |
705 case StMOG: | |
706 tMOG_refresh(0, text, &tabPosition, subtext); | |
707 update_content_with_new_frame(page, text, tabPosition, subtext); | |
708 break; | |
709 case StMCG: | |
710 tMCG_refresh(0, text, &tabPosition, subtext); | |
711 update_content_with_new_frame(page, text, tabPosition, subtext); | |
712 break; | |
713 case StMSP: | |
714 tMSP_refresh(0, text, &tabPosition, subtext); | |
715 update_content_with_new_frame(page, text, tabPosition, subtext); | |
716 break; | |
717 case StMXTRA: | |
718 tMXtra_refresh(0, text, &tabPosition, subtext); | |
719 update_content_with_new_frame(page, text, tabPosition, subtext); | |
720 break; | |
721 case StMDECO: | |
722 if((line == 1) || (line == 3)) // dive mode or ppO2 limits (the later for correct MOD in gaslists) | |
723 { | |
724 tM_rebuild_pages(); | |
725 menu.lineMemoryForNavigationForPage[page] = line; // fix 160623 | |
726 GFX_SetFrameTop(menu.StartAddressForPage[page]); | |
727 } | |
728 else | |
729 { | |
730 tMDeco_refresh(line, text, &tabPosition, subtext); | |
731 clean_line_actual_page(); | |
732 update_content_actual_page(text, tabPosition, subtext); | |
733 } | |
734 break; | |
735 case StMDECOP: | |
736 tMDecoParameters_refresh(line, text, &tabPosition, subtext); | |
737 clean_line_actual_page(); | |
738 update_content_actual_page(text, tabPosition, subtext); | |
739 break; | |
740 case StMPLAN: | |
741 tMPlanner_refresh(line, text, &tabPosition, subtext); | |
742 clean_line_actual_page(); | |
743 update_content_actual_page(text, tabPosition, subtext); | |
744 break; | |
745 case StMHARD: | |
746 tMHardware_refresh(line, text, &tabPosition, subtext); | |
747 clean_line_actual_page(); | |
748 update_content_actual_page(text, tabPosition, subtext); | |
749 break; | |
750 case StMSYS: | |
751 if((line == 2) || (line == 3) || (line == 6)) | |
752 { | |
753 tM_rebuild_pages(); | |
754 menu.lineMemoryForNavigationForPage[page] = line; // fix 160623 | |
755 GFX_SetFrameTop(menu.StartAddressForPage[page]); | |
756 menu.lineMemoryForNavigationForPage[page] = line; | |
757 } | |
758 else | |
759 { | |
760 tMSystem_refresh(line, text, &tabPosition, subtext); | |
761 clean_line_actual_page(); | |
762 update_content_actual_page(text, tabPosition, subtext); | |
763 } | |
764 break; | |
765 default: | |
766 break; | |
767 } | |
768 } | |
769 | |
770 void openMenu_first_page_with_OC_gas_update(void) | |
771 { | |
772 menu.pageMemoryForNavigation = 1; | |
773 for(int i=0;i<=MAXPAGES;i++) | |
774 menu.lineMemoryForNavigationForPage[i] = 0; | |
775 | |
776 set_globalState(StMOG); | |
777 updateMenu(); | |
778 openMenu(1); | |
779 } | |
780 | |
781 | |
782 void openMenu(uint8_t freshWithFlipPages) | |
783 { | |
784 uint8_t page, line; | |
785 | |
786 callerID = get_globalState(); | |
787 | |
788 findValidPosition(&page, &line); | |
789 if((page == 0) || (line == 0)) | |
790 return; | |
791 | |
792 menu.pageMemoryForNavigation = page; | |
793 /* new test for 3button design */ | |
794 if(freshWithFlipPages) | |
795 { | |
796 menu.lineMemoryForNavigationForPage[page] = 0; | |
797 menu.modeFlipPages = 1; | |
798 } | |
799 else | |
800 { | |
801 menu.lineMemoryForNavigationForPage[page] = line; | |
802 menu.modeFlipPages = 0; | |
803 } | |
804 | |
805 set_globalState_Menu_Page(page); | |
806 | |
807 | |
808 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 1)); | |
809 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1)); | |
810 | |
811 | |
812 if(((page == 6) || (page == 8)) && (menu.pageCountNumber[page-1] == 0)) | |
813 { | |
814 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 2)); | |
815 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 2)); | |
816 | |
817 } | |
818 | |
819 GFX_SetFrameTop(menu.StartAddressForPage[page]); | |
820 /* new test for 3button design */ | |
821 if(freshWithFlipPages) | |
822 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390); | |
823 else | |
824 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); | |
825 } | |
826 | |
827 void block_diluent_handler(_Bool Unblock) | |
828 { | |
829 SStateList list; | |
830 static uint8_t linesAvailableForPageDiluent = 0; | |
831 get_idSpecificStateList(StMCG, &list); | |
832 | |
833 if(Unblock && linesAvailableForPageDiluent) | |
834 { | |
835 menu.linesAvailableForPage[list.page] = linesAvailableForPageDiluent; | |
836 } | |
837 else | |
838 { | |
839 linesAvailableForPageDiluent = menu.linesAvailableForPage[list.page]; | |
840 menu.linesAvailableForPage[list.page] = 0; | |
841 } | |
842 } | |
843 | |
844 void block_diluent_page(void) | |
845 { | |
846 block_diluent_handler(0); | |
847 } | |
848 | |
849 | |
850 void unblock_diluent_page(void) | |
851 { | |
852 block_diluent_handler(1); | |
853 } | |
854 | |
855 | |
856 void nextPage(void) | |
857 { | |
858 uint8_t page, line; | |
859 | |
860 menu.pageMemoryForNavigation += 1; | |
861 | |
862 findValidPosition(&page, &line); | |
863 menu.pageMemoryForNavigation = page; | |
864 /* new test for 3button design */ | |
865 //menu.lineMemoryForNavigationForPage[page] = line; | |
866 menu.lineMemoryForNavigationForPage[page] = 0; | |
867 menu.modeFlipPages = 1; | |
868 | |
869 set_globalState_Menu_Page(page); | |
870 | |
871 change_CLUT_entry(CLUT_MenuLineSelectedSides, (CLUT_MenuPageGasOC + page - 1)); | |
872 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1)); | |
873 | |
874 GFX_SetFrameTop(menu.StartAddressForPage[page]); | |
875 /* new test for 3button design */ | |
876 //GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); | |
877 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390); | |
878 } | |
879 | |
880 | |
881 void nextLine(void) | |
882 { | |
883 uint8_t page, line; | |
884 | |
885 page = menu.pageMemoryForNavigation; | |
886 menu.lineMemoryForNavigationForPage[page] += 1; | |
887 | |
888 findValidPosition(&page, &line); | |
889 menu.lineMemoryForNavigationForPage[page] = line; | |
890 | |
891 /* new test for 3button design */ | |
892 menu.modeFlipPages = 0; | |
893 | |
894 GFX_SetFrameBottom((tMdesignCursor.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); | |
895 } | |
896 | |
897 | |
898 void stepBackMenu(void) | |
899 { | |
900 if(menu.modeFlipPages == 0) | |
901 { | |
902 menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation] = 0; | |
903 menu.modeFlipPages = 1; | |
904 GFX_SetFrameBottom(tMdesignSolo.FBStartAdress, 0, 25, 800, 390); | |
905 } | |
906 else | |
907 exitMenu(); | |
908 } | |
909 | |
910 | |
911 void exitMenu(void) | |
912 { | |
913 set_globalState_tHome(); | |
914 } | |
915 | |
916 | |
917 void stepForwardMenu(void) | |
918 { | |
919 if(menu.modeFlipPages == 1) | |
920 { | |
921 nextLine(); | |
922 } | |
923 else | |
924 gotoMenuEdit(); | |
925 } | |
926 | |
927 void gotoMenuEdit(void) | |
928 { | |
929 uint8_t line; | |
930 | |
931 line = menu.lineMemoryForNavigationForPage[menu.pageMemoryForNavigation]; | |
932 | |
933 switch(get_globalState()) | |
934 { | |
935 case StMOG: | |
936 openEdit_GasOC(line); | |
937 break; | |
938 case StMCG: | |
939 openEdit_GasCC(line); | |
940 break; | |
941 case StMSP: | |
942 openEdit_Setpoint(line); | |
943 break; | |
944 case StMXTRA: | |
945 openEdit_Xtra(line); | |
946 break; | |
947 case StMDECO: | |
948 openEdit_Deco(line); | |
949 break; | |
950 case StMDECOP: | |
951 openEdit_DecoParameter(line); | |
952 break; | |
953 case StMPLAN: | |
954 openEdit_Planner(line); | |
955 break; | |
956 case StMHARD: | |
957 openEdit_Hardware(line); | |
958 break; | |
959 case StMSYS: | |
960 openEdit_System(line); | |
961 break; | |
962 default: | |
963 break; | |
964 } | |
965 } | |
966 | |
967 | |
968 void sendActionToMenu(uint8_t sendAction) | |
969 { | |
970 switch(sendAction) | |
971 { | |
972 case ACTION_BUTTON_ENTER: | |
973 stepForwardMenu(); | |
974 break; | |
975 case ACTION_BUTTON_NEXT: | |
976 if(menu.modeFlipPages) | |
977 nextPage(); | |
978 else | |
979 nextLine(); | |
980 break; | |
981 case ACTION_TIMEOUT: | |
982 case ACTION_MODE_CHANGE: | |
983 case ACTION_BUTTON_BACK: | |
984 /* new test for 3button design */ | |
985 stepBackMenu(); | |
986 break; | |
987 default: | |
988 break; | |
989 case ACTION_IDLE_TICK: | |
990 case ACTION_IDLE_SECOND: | |
991 break; | |
992 } | |
993 /* tMC_OC_Gas(StMOG1, pSettings); */ | |
994 } | |
995 | |
996 void timeoutTestMenu(uint32_t seconds_since_last_button_press) | |
997 { | |
998 } | |
999 | |
1000 void tMenu_write(uint8_t page, char *text, char *subtext) | |
1001 { | |
1002 if(page > MAXPAGES) | |
1003 return; | |
1004 if(menu.linesAvailableForPage[page] == 0) | |
1005 return; | |
1006 | |
1007 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
1008 GFX_write_string(&FontT48, &tMwindow, text,1); | |
1009 if((*subtext) && (menu.linesAvailableForPage[page] < 6)) | |
1010 { | |
1011 GFX_write_string(&FontT42, &tMwindow, subtext, (menu.linesAvailableForPage[page] + 1)); | |
1012 } | |
1013 } | |
1014 | |
1015 | |
1016 /* Private functions ---------------------------------------------------------*/ | |
1017 | |
1018 void draw_tMdesignSubUnselected(uint32_t *ppDestination) | |
1019 { | |
1020 union al88_u | |
1021 { | |
1022 uint8_t al8[2]; | |
1023 uint16_t al88; | |
1024 }; | |
1025 | |
1026 union al88_u color_seperator; | |
1027 union al88_u color_unselected; | |
1028 int i; | |
1029 | |
1030 color_seperator.al8[0] = CLUT_MenuLineUnselectedSeperator; | |
1031 color_unselected.al8[0] = CLUT_MenuLineUnselected; | |
1032 | |
1033 color_seperator.al8[1] = 0xFF; | |
1034 color_unselected.al8[1] = 0xFF; | |
1035 | |
1036 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1037 *ppDestination += 2; | |
1038 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1039 *ppDestination += 2; | |
1040 | |
1041 for(i = 61; i > 0; i--) | |
1042 { | |
1043 *(__IO uint16_t*)*ppDestination = color_unselected.al88; | |
1044 *ppDestination += 2; | |
1045 } | |
1046 | |
1047 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1048 *ppDestination += 2; | |
1049 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1050 *ppDestination += 2; | |
1051 } | |
1052 | |
1053 | |
1054 void draw_tMdesignSubSelected(uint32_t *ppDestination) | |
1055 { | |
1056 union al88_u | |
1057 { | |
1058 uint8_t al8[2]; | |
1059 uint16_t al88; | |
1060 }; | |
1061 | |
1062 union al88_u color_selected; | |
1063 union al88_u color_seperator; | |
1064 int i; | |
1065 | |
1066 color_selected.al8[0] = CLUT_MenuLineSelected; | |
1067 color_selected.al8[1] = 0xFF; | |
1068 | |
1069 color_seperator.al8[0] = CLUT_MenuLineSelectedSeperator; | |
1070 color_seperator.al8[1] = 0xFF; | |
1071 | |
1072 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1073 *ppDestination += 2; | |
1074 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1075 *ppDestination += 2; | |
1076 | |
1077 for(i = 61; i > 0; i--) | |
1078 { | |
1079 *(__IO uint16_t*)*ppDestination = color_selected.al88; | |
1080 *ppDestination += 2; | |
1081 } | |
1082 | |
1083 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1084 *ppDestination += 2; | |
1085 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1086 *ppDestination += 2; | |
1087 } | |
1088 | |
1089 | |
1090 void draw_tMdesignSubSelectedBorder(uint32_t *ppDestination) | |
1091 { | |
1092 union al88_u | |
1093 { | |
1094 uint8_t al8[2]; | |
1095 uint16_t al88; | |
1096 }; | |
1097 | |
1098 union al88_u color_selected_sides; | |
1099 | |
1100 int i; | |
1101 | |
1102 color_selected_sides.al8[0] = CLUT_MenuLineSelectedSides; | |
1103 color_selected_sides.al8[1] = 0xFF; | |
1104 | |
1105 for(i = 65; i > 0; i--) | |
1106 { | |
1107 *(__IO uint16_t*)*ppDestination = color_selected_sides.al88; | |
1108 *ppDestination += 2; | |
1109 } | |
1110 } | |
1111 | |
1112 | |
1113 void draw_tMcursorDesign(void) | |
1114 { | |
1115 int i,j; | |
1116 uint32_t pDestination; | |
1117 | |
1118 pDestination = tMdesignCursor.FBStartAdress; | |
1119 | |
1120 for(j = 801; j > 0; j--) | |
1121 { | |
1122 for(i = 5; i > 0; i--) | |
1123 { | |
1124 draw_tMdesignSubUnselected(&pDestination); | |
1125 } | |
1126 if((j > 787) || (j < 17)) | |
1127 draw_tMdesignSubSelectedBorder(&pDestination); | |
1128 else | |
1129 draw_tMdesignSubSelected(&pDestination); | |
1130 } | |
1131 | |
1132 pDestination = tMdesignSolo.FBStartAdress; | |
1133 | |
1134 for(j = 801; j > 0; j--) | |
1135 { | |
1136 for(i = 6; i > 0; i--) | |
1137 { | |
1138 draw_tMdesignSubUnselected(&pDestination); | |
1139 } | |
1140 } | |
1141 } | |
1142 | |
1143 | |
1144 void draw_tMheader(uint8_t page) | |
1145 { | |
1146 union al88_u | |
1147 { | |
1148 uint8_t al8[2]; | |
1149 uint16_t al88; | |
1150 }; | |
1151 union al88_u color_top; | |
1152 int i,j, k, k4text; | |
1153 uint32_t pBackup; | |
1154 uint32_t pDestination; | |
1155 uint8_t colorText; | |
1156 uint16_t positionText; | |
1157 uint8_t pageText; | |
1158 | |
1159 const char text8max[MAXPAGES+1][8] = | |
1160 { "", | |
1161 "OC", | |
1162 "CC", | |
1163 "SP", | |
1164 "DATA", | |
1165 "DECO", | |
1166 "", | |
1167 "SYS", | |
1168 "", | |
1169 "SIM", | |
1170 "" | |
1171 }; | |
1172 | |
1173 const _Bool spacing[MAXPAGES+1] = | |
1174 { 0, | |
1175 0, // behind OC | |
1176 0, // behind CC | |
1177 1, // behind SP | |
1178 1, // behind DATA | |
1179 0, // behind DECO1 | |
1180 1, // behind DECO2 | |
1181 0, // behind SYS1 | |
1182 1, // behind SYS2 | |
1183 1, // behind SIM | |
1184 0 | |
1185 }; | |
1186 | |
1187 pBackup = tMscreen.FBStartAdress; | |
1188 tMscreen.FBStartAdress = menu.StartAddressForPage[page]; | |
1189 pDestination = menu.StartAddressForPage[page]; | |
1190 positionText = 10; | |
1191 pageText = page; | |
1192 | |
1193 gfx_write_page_number(&tMscreen ,menu.pageCountNumber[page],menu.pageCountTotal,0); | |
1194 | |
1195 while((text8max[pageText][0] == 0) && (pageText > 1)) | |
1196 { | |
1197 pageText--; | |
1198 } | |
1199 | |
1200 for(k = 1; k <= MAXPAGES; k++) | |
1201 { | |
1202 if(menu.pageCountNumber[k] != 0) | |
1203 { | |
1204 k4text = k; // new hw 170522 | |
1205 if((text8max[k][0] == 0) && (menu.pageCountNumber[k-1] == 0)) | |
1206 k4text = k-1; | |
1207 | |
1208 color_top.al8[0] = CLUT_MenuPageGasOC + k - 1; | |
1209 if(k4text == page) | |
1210 { | |
1211 color_top.al8[1] = 0xFF; | |
1212 } | |
1213 else | |
1214 { | |
1215 color_top.al8[1] = 0x50; | |
1216 } | |
1217 | |
1218 if(k4text == pageText) | |
1219 { | |
1220 colorText = CLUT_Font020; | |
1221 } | |
1222 else | |
1223 { | |
1224 colorText = CLUT_Font021; | |
1225 } | |
1226 | |
1227 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k4text],colorText); | |
1228 /* | |
1229 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k],colorText); | |
1230 if((text8max[k][0] == 0) && (menu.pageCountNumber[k-1] == 0)) | |
1231 write_content_simple(&tMscreen,positionText,775,0,&FontT42,text8max[k-1],colorText); | |
1232 */ | |
1233 pDestination += 2 * 5 * 480; | |
1234 | |
1235 for(j = 60; j > 0; j--) | |
1236 { | |
1237 pDestination += (390 + 26)* 2; | |
1238 | |
1239 // for(i = 64; i > 0; i--) | |
1240 for(i = 16; i > 0; i--) | |
1241 { | |
1242 *(__IO uint16_t*)pDestination = color_top.al88; | |
1243 pDestination += 2; | |
1244 } | |
1245 pDestination += 2 * 48; | |
1246 } | |
1247 | |
1248 pDestination += 2 * 5 * 480; | |
1249 positionText += 70; | |
1250 | |
1251 if((k == 4) || ((k == 6) && (menu.pageCountNumber[5] == 0))) | |
1252 { | |
1253 pDestination += 2 * 70 * 480; | |
1254 positionText += 70; | |
1255 } | |
1256 | |
1257 if(spacing[k]) | |
1258 { | |
1259 pDestination += 35 * 2 * 480; | |
1260 positionText += 35; | |
1261 } | |
1262 } | |
1263 } | |
1264 tMscreen.FBStartAdress = pBackup; | |
1265 } |