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