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