Mercurial > public > ostc4
annotate Discovery/Src/tInfoLog.c @ 585:4dfdf230d8ba
Reduced view angle and number of vusiualized custom views in setor mode:
With the previous angle of 40 it was hard to read the top as well as the bottom view. Also the amount of views was to much => reduced angle and number of max used custom views
author | Ideenmodellierer |
---|---|
date | Sun, 13 Dec 2020 18:29:12 +0100 |
parents | 701ead8dddab |
children | eecb52ab1fce |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tInfoLog.c | |
5 /// \brief Main Template file for Menu Page Deco | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 31-July-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 "tInfoLog.h" | |
31 | |
32 #include "gfx_fonts.h" | |
33 #include "logbook.h" | |
34 #include "show_logbook.h" | |
35 #include "tHome.h" | |
36 #include "tInfo.h" | |
37 #include "tMenu.h" | |
38 #include "unit.h" | |
452
b90ddf57f7f1
Added compile variant enabling the reset of profile sample information:
ideenmodellierer
parents:
186
diff
changeset
|
39 #include "externLogbookFlash.h" |
b90ddf57f7f1
Added compile variant enabling the reset of profile sample information:
ideenmodellierer
parents:
186
diff
changeset
|
40 #include "configuration.h" |
38 | 41 |
42 /* Exported variables --------------------------------------------------------*/ | |
43 | |
44 /* Private types -------------------------------------------------------------*/ | |
45 typedef struct | |
46 { | |
47 uint8_t page; | |
48 uint8_t line; | |
49 uint8_t linesAvailableForPage; | |
50 uint8_t modeFlipPages; | |
51 uint8_t maxpages; | |
52 } SInfoLogMemory; | |
53 | |
54 /* Private variables ---------------------------------------------------------*/ | |
55 GFX_DrawCfgScreen INFOLOGscreen; | |
56 GFX_DrawCfgScreen *pMenuCursor, *pMenuCursorDesignSolo; | |
57 GFX_DrawCfgWindow INFOLOGwindow; | |
58 | |
59 SInfoLogMemory infolog; | |
60 | |
61 /* Private function prototypes -----------------------------------------------*/ | |
62 void tInfoLog_BuildAndShowNextPage(void); | |
63 void tInfoLog_nextLine(void); | |
64 void showLog(void); | |
65 void showNextLogPage(void); | |
66 void stepBackInfo(void); | |
67 void stepForwardInfo(void); | |
68 void showLogExit(void); | |
69 | |
70 /* Exported functions --------------------------------------------------------*/ | |
71 void tInfoLog_init(void) | |
72 { | |
73 INFOLOGscreen.FBStartAdress = 0; | |
74 INFOLOGscreen.ImageHeight = 480; | |
75 INFOLOGscreen.ImageWidth = 800; | |
76 INFOLOGscreen.LayerIndex = 1; | |
77 | |
78 INFOLOGwindow.Image = &INFOLOGscreen; | |
79 INFOLOGwindow.WindowNumberOfTextLines = 6; | |
80 INFOLOGwindow.WindowLineSpacing = 65; | |
81 INFOLOGwindow.WindowTab = 400; | |
82 INFOLOGwindow.WindowX0 = 20; | |
83 INFOLOGwindow.WindowX1 = 779; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
84 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
85 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
86 INFOLOGwindow.WindowY0 = 4 + 25; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
87 INFOLOGwindow.WindowY1 = 390 + 25; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
88 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
89 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
90 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
91 INFOLOGwindow.WindowY0 = 479 - 390; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
92 INFOLOGwindow.WindowY1 = 479 - 25; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
93 } |
38 | 94 } |
95 | |
96 | |
97 void openInfoLogLastDive(void) | |
98 { | |
99 infolog.page = 0; | |
100 SLogbookHeader logbookHeader; | |
101 if(logbook_getHeader(0,&logbookHeader)) | |
102 { | |
103 set_globalState(StILOGSHOW); // all the rest with zeros | |
104 infolog.page = 1; | |
105 infolog.line = 1; | |
106 show_logbook_test(1, 0); | |
107 } | |
108 else | |
109 openLog(0); | |
110 } | |
111 | |
112 | |
113 void openLog(_Bool recallKeepPage) | |
114 { | |
115 if(recallKeepPage && infolog.page) | |
116 infolog.page--; | |
117 else | |
118 infolog.page = 0; | |
119 | |
120 infolog.modeFlipPages = 1; | |
121 set_globalState_Log_Page(infolog.page); | |
122 infolog.maxpages = (logbook_getNumberOfHeaders() + 5) / 6; | |
123 tInfoLog_BuildAndShowNextPage(); | |
124 | |
125 pMenuCursor = get_PointerMenuCursorScreen(); | |
126 pMenuCursorDesignSolo = get_PointerMenuCursorDesignSoloScreen(); | |
127 | |
128 change_CLUT_entry(CLUT_MenuLineSelectedSides, CLUT_InfoPageLogbook); | |
129 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, CLUT_InfoPageLogbook); | |
130 | |
131 //GFX_ResetLayer(TOP_LAYER); | |
132 //GFX_ResetLayer(BACKGRD_LAYER); | |
133 | |
134 if(infolog.page == 255) | |
135 GFX_SetFrameBottom((INFOLOGscreen.FBStartAdress), 0, 0, 800, 480); | |
136 else | |
137 { | |
138 // very old: GFX_SetFrameBottom((pMenuCursor->FBStartAdress), 0, 0, 800, 390); | |
139 // no, set cursor to firt line instead with tInfoLog_nextLine() GFX_SetFrameBottom((pMenuCursorDesignSolo->FBStartAdress), 0, 25, 800, 390); | |
140 tInfoLog_nextLine(); | |
141 } | |
142 } | |
143 | |
144 | |
145 void sendActionToInfoLogList(uint8_t sendAction) | |
146 { | |
147 switch(sendAction) | |
148 { | |
149 case ACTION_BUTTON_ENTER: | |
150 stepForwardInfo(); | |
151 break; | |
152 case ACTION_BUTTON_NEXT: | |
153 | |
154 if(infolog.modeFlipPages) | |
155 { | |
156 tInfoLog_BuildAndShowNextPage(); | |
157 // GFX_SetFrameBottom((pMenuCursor->FBStartAdress), 0, 25, 800, 390); | |
158 } | |
159 else | |
160 tInfoLog_nextLine(); | |
161 break; | |
162 case ACTION_TIMEOUT: | |
163 case ACTION_MODE_CHANGE: | |
164 case ACTION_BUTTON_BACK: | |
165 stepBackInfo(); | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
110
diff
changeset
|
166 break; |
38 | 167 default: |
168 break; | |
169 case ACTION_IDLE_TICK: | |
170 case ACTION_IDLE_SECOND: | |
171 break; | |
172 } | |
173 } | |
174 | |
175 | |
176 void sendActionToInfoLogShow(uint8_t sendAction) | |
177 { | |
178 switch(sendAction) | |
179 { | |
180 case ACTION_BUTTON_ENTER: | |
181 break; | |
182 case ACTION_BUTTON_NEXT: | |
183 showNextLogPage(); | |
184 break; | |
185 case ACTION_TIMEOUT: | |
186 case ACTION_MODE_CHANGE: | |
187 case ACTION_BUTTON_BACK: | |
188 if(get_globalState() == StILOGSHOW) // no page nor line | |
189 { | |
190 openLog(1); | |
191 } | |
192 else | |
193 { | |
194 showLogExit(); | |
195 } | |
196 show_logbook_exit(); | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
110
diff
changeset
|
197 break; |
38 | 198 default: |
199 break; | |
200 case ACTION_IDLE_TICK: | |
201 case ACTION_IDLE_SECOND: | |
202 break; | |
203 } | |
204 } | |
205 | |
206 | |
207 /* Private functions ---------------------------------------------------------*/ | |
208 | |
209 void exitLog(void) | |
210 { | |
211 //set_globalState_tHome(); | |
212 exitInfo(); | |
213 releaseFrame(15,INFOLOGscreen.FBStartAdress); | |
214 } | |
215 | |
216 | |
217 void stepBackInfo(void) | |
218 { | |
219 if(infolog.modeFlipPages == 0) | |
220 { | |
221 infolog.line = 0; | |
222 infolog.modeFlipPages = 1; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
223 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
224 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
225 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
226 GFX_SetFrameBottom(pMenuCursorDesignSolo->FBStartAdress, 0, 25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
227 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
228 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
229 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
230 GFX_SetFrameBottom(pMenuCursorDesignSolo->FBStartAdress, 0, 65, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
231 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
232 |
38 | 233 } |
234 else | |
235 exitLog(); | |
236 } | |
237 | |
238 | |
239 void stepForwardInfo(void) | |
240 { | |
241 if(infolog.modeFlipPages == 1) | |
242 { | |
243 tInfoLog_nextLine(); | |
244 } | |
245 else | |
246 showLog(); | |
247 } | |
248 | |
249 | |
250 void tInfoLog_BuildAndShowNextPage(void) | |
251 { | |
252 char text[MAX_PAGE_TEXTSIZE]; | |
253 uint16_t textPointer = 0; | |
254 SLogbookHeader logbookHeader; | |
255 // uint16_t divetime = logbookHeader.diveTimeMinutes; | |
256 // uint16_t maxDepth = logbookHeader.maxDepth/100; | |
257 int i = 0; | |
258 uint8_t date[2], month,day; | |
567 | 259 char timeSuffix; |
260 uint8_t hours; | |
38 | 261 |
262 if(INFOLOGscreen.FBStartAdress) | |
263 releaseFrame(15,INFOLOGscreen.FBStartAdress); | |
264 INFOLOGscreen.FBStartAdress = getFrame(15); | |
265 | |
266 infolog.page += 1; | |
267 infolog.linesAvailableForPage = 0; | |
268 | |
269 if((infolog.page < 1) || (infolog.page > 43)) /* max with 256 entries */ | |
270 infolog.page = 1; | |
271 | |
272 | |
273 text[0] = '\001'; | |
274 text[1] = TXT_Logbook; | |
275 text[2] = 0; | |
276 gfx_write_topline_simple(&INFOLOGscreen, text, CLUT_InfoPageLogbook); | |
277 | |
278 *text = 0; | |
279 if(!logbook_getHeader((infolog.page - 1) * 6,&logbookHeader)) | |
280 { | |
281 infolog.page = 1; | |
282 if(!logbook_getHeader((infolog.page - 1) * 6,&logbookHeader)) | |
283 { | |
284 infolog.page = 255; | |
285 infolog.linesAvailableForPage = 0; | |
286 text[0] = TXT_LogbookEmpty; | |
287 text[1] = 0; | |
288 } | |
289 } | |
290 | |
291 if((*text == 0) && (infolog.maxpages > 1)) | |
292 { | |
293 snprintf(text,8, "\002" "%u/%u", infolog.page, infolog.maxpages); | |
294 gfx_write_topline_simple(&INFOLOGscreen, text, CLUT_InfoPageLogbook); | |
295 *text = 0; | |
296 } | |
297 | |
298 if(*text == 0) | |
299 { | |
300 infolog.line = 0; | |
301 textPointer = 0; | |
302 if(settingsGetPointer()->date_format == DDMMYY) | |
303 { | |
304 day = 0; | |
305 month = 1; | |
306 } | |
307 else | |
308 { | |
309 day = 1; | |
310 month = 0; | |
311 } | |
312 for(i = 0; i < 6; i++) | |
313 { | |
314 if(i) | |
315 { | |
316 if(!logbook_getHeader(((infolog.page - 1) * 6) + i, &logbookHeader)) | |
317 break; | |
318 } | |
319 infolog.linesAvailableForPage += 1; | |
320 uint16_t divetime = logbookHeader.diveTimeMinutes; | |
321 uint16_t maxDepthMeter = logbookHeader.maxDepth/100; | |
322 uint16_t maxDepthSubmeter = (logbookHeader.maxDepth - maxDepthMeter * 100)/10; | |
323 uint16_t number = ((infolog.page - 1) * 6) + i + 1; | |
324 if(settingsGetPointer()->logbookOffset) | |
325 { | |
326 if(number <= settingsGetPointer()->logbookOffset) | |
327 number = settingsGetPointer()->logbookOffset + 1 - number; | |
328 } | |
329 date[day] = logbookHeader.dateDay; | |
330 date[month] = logbookHeader.dateMonth; | |
331 | |
332 text[textPointer++] = '\034';// monospaced space large size mode | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
469
diff
changeset
|
333 textPointer += snprintf(&text[textPointer], 20,"\031%04u \020", number); |
38 | 334 /* if(number < 1000) |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
469
diff
changeset
|
335 textPointer += snprintf(&text[textPointer], 20,"\031%2u \020", number); |
38 | 336 else |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
469
diff
changeset
|
337 textPointer += snprintf(&text[textPointer], 20,"\031\016\016%3u \017\020", number); |
38 | 338 */ |
339 textPointer += snprintf(&text[textPointer], 20,"%02d.%02d ",date[0],date[1]); | |
567 | 340 |
341 if (settingsGetPointer()->amPMTime) | |
342 { | |
343 if (logbookHeader.timeHour > 11) | |
344 { | |
345 timeSuffix = 'P'; | |
346 } | |
347 else | |
348 { | |
349 timeSuffix = 'A'; | |
350 } | |
351 | |
352 if (logbookHeader.timeHour % 12 == 0) | |
353 { | |
354 hours = 12; | |
355 } | |
356 else | |
357 { | |
358 hours = (logbookHeader.timeHour % 12); | |
359 } | |
360 | |
361 textPointer += snprintf(&text[textPointer], 20,"%02d:%02d\016\016%cM\017", hours,logbookHeader.timeMinute, timeSuffix); | |
362 } | |
363 else | |
364 { | |
365 textPointer += snprintf(&text[textPointer], 20,"%02d:%02d ",logbookHeader.timeHour,logbookHeader.timeMinute); | |
366 } | |
367 | |
38 | 368 switch(logbookHeader.decoModel) |
369 { | |
370 case 1: | |
570 | 371 if(!settingsGetPointer()->nonMetricalSystem) /* safe space to avoid cursor overlap */ |
372 { | |
373 if(settingsGetPointer()->amPMTime) | |
374 { | |
375 textPointer += snprintf(&text[textPointer],20,"\016\016 GF \017"); | |
376 } | |
377 else | |
378 { | |
379 textPointer += snprintf(&text[textPointer],20,"\016\016GF \017"); | |
380 } | |
381 } | |
382 else | |
383 { | |
384 textPointer += snprintf(&text[textPointer],20,"\016\016 GF \017"); | |
385 } | |
38 | 386 break; |
387 case 2: | |
388 textPointer += snprintf(&text[textPointer],20,"\016\016 VPM \017"); | |
389 break; | |
390 default: | |
391 textPointer += snprintf(&text[textPointer],20,"\016\016 * \017"); | |
392 break; | |
393 } | |
394 | |
395 if(settingsGetPointer()->nonMetricalSystem) | |
396 { | |
397 float maxDepthFeet = 0; | |
398 maxDepthFeet = unit_depth_float(((float)logbookHeader.maxDepth)/100); | |
399 textPointer += snprintf(&text[textPointer], 20,"%3.0f\016\016ft\017 ", maxDepthFeet); | |
400 } | |
401 else | |
402 { | |
570 | 403 textPointer += snprintf(&text[textPointer], 20,"%3d.%d\016\016m \017", maxDepthMeter,maxDepthSubmeter); |
38 | 404 } |
567 | 405 textPointer += snprintf(&text[textPointer], 20,"%3d\016\016min\017\n\r", divetime); |
406 | |
38 | 407 } |
408 } | |
409 GFX_write_string(&FontT48, &INFOLOGwindow, text,1); | |
410 | |
411 if(infolog.linesAvailableForPage > 1) | |
412 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
413 else if(infolog.page == 255) | |
414 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,0,0); | |
415 else | |
416 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | |
417 | |
418 GFX_SetFrameTop(INFOLOGscreen.FBStartAdress); | |
419 set_globalState_Log_Page(infolog.page); | |
420 } | |
421 | |
422 | |
423 void tInfoLog_nextLine(void) | |
424 { | |
425 if(infolog.linesAvailableForPage == 0) | |
426 return; | |
427 | |
428 infolog.line += 1; | |
429 if(infolog.line > infolog.linesAvailableForPage) | |
430 infolog.line = 1; | |
431 | |
432 infolog.modeFlipPages = 0; | |
433 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
434 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
435 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
436 GFX_SetFrameBottom((pMenuCursor->FBStartAdress) + 65*2*(infolog.line - 1), 0, 25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
437 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
438 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
439 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
440 GFX_SetFrameBottom((pMenuCursor->FBStartAdress)+ (390 - 65 *(infolog.line)) *2, 0, 480-390-25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
441 } |
38 | 442 } |
443 | |
444 | |
445 void showLogExit(void) | |
446 { | |
447 GFX_SetFrameTop(INFOLOGscreen.FBStartAdress); | |
448 GFX_SetFrameBottom((pMenuCursor->FBStartAdress) + 65*2*(infolog.line - 1), 0, 25, 800, 390); | |
449 set_globalState_Log_Page(infolog.page); | |
450 } | |
451 | |
452 | |
453 void showLog(void) | |
454 { | |
455 uint8_t stepBack; | |
456 | |
457 if(infolog.page == 255) | |
458 return; | |
459 | |
460 stepBack = (6 * (infolog.page - 1)) + infolog.line - 1; | |
461 //build_logbook_test(); | |
462 show_logbook_test(1, stepBack); | |
463 } | |
464 | |
465 | |
466 void showNextLogPage(void) | |
467 { | |
468 uint8_t stepBack; | |
469 | |
470 if(infolog.page == 255) | |
471 return; | |
472 | |
473 stepBack = (6 * (infolog.page - 1)) + infolog.line - 1; | |
474 //build_logbook_test(); | |
475 show_logbook_test(0, stepBack); | |
476 } | |
477 |