Mercurial > public > ostc4
annotate Discovery/Src/tInfoLog.c @ 149:e1d66bc78f9a FlipDisplay
Eliminate warnings
author | Ideenmodellierer |
---|---|
date | Sat, 02 Mar 2019 17:42:06 +0100 |
parents | cc8e24374b83 |
children | f11f0bf6ef2d |
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" | |
39 | |
40 /* Exported variables --------------------------------------------------------*/ | |
41 | |
42 /* Private types -------------------------------------------------------------*/ | |
43 typedef struct | |
44 { | |
45 uint8_t page; | |
46 uint8_t line; | |
47 uint8_t linesAvailableForPage; | |
48 uint8_t modeFlipPages; | |
49 uint8_t maxpages; | |
50 } SInfoLogMemory; | |
51 | |
52 /* Private variables ---------------------------------------------------------*/ | |
53 GFX_DrawCfgScreen INFOLOGscreen; | |
54 GFX_DrawCfgScreen *pMenuCursor, *pMenuCursorDesignSolo; | |
55 GFX_DrawCfgWindow INFOLOGwindow; | |
56 | |
57 SInfoLogMemory infolog; | |
58 | |
59 /* Private function prototypes -----------------------------------------------*/ | |
60 void nextLineInfoLog(void); | |
61 void tInfoLog_BuildAndShowNextPage(void); | |
62 void tInfoLog_nextLine(void); | |
63 void showLog(void); | |
64 void showNextLogPage(void); | |
65 void stepBackInfo(void); | |
66 void stepForwardInfo(void); | |
67 void showLogExit(void); | |
68 | |
69 /* Exported functions --------------------------------------------------------*/ | |
70 void tInfoLog_init(void) | |
71 { | |
72 INFOLOGscreen.FBStartAdress = 0; | |
73 INFOLOGscreen.ImageHeight = 480; | |
74 INFOLOGscreen.ImageWidth = 800; | |
75 INFOLOGscreen.LayerIndex = 1; | |
76 | |
77 INFOLOGwindow.Image = &INFOLOGscreen; | |
78 INFOLOGwindow.WindowNumberOfTextLines = 6; | |
79 INFOLOGwindow.WindowLineSpacing = 65; | |
80 INFOLOGwindow.WindowTab = 400; | |
81 INFOLOGwindow.WindowX0 = 20; | |
82 INFOLOGwindow.WindowX1 = 779; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
83 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
84 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
85 INFOLOGwindow.WindowY0 = 4 + 25; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
86 INFOLOGwindow.WindowY1 = 390 + 25; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
87 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
88 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
89 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
90 INFOLOGwindow.WindowY0 = 479 - 390; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
91 INFOLOGwindow.WindowY1 = 479 - 25; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
92 } |
38 | 93 } |
94 | |
95 | |
96 void openInfoLogLastDive(void) | |
97 { | |
98 infolog.page = 0; | |
99 SLogbookHeader logbookHeader; | |
100 if(logbook_getHeader(0,&logbookHeader)) | |
101 { | |
102 set_globalState(StILOGSHOW); // all the rest with zeros | |
103 infolog.page = 1; | |
104 infolog.line = 1; | |
105 show_logbook_test(1, 0); | |
106 } | |
107 else | |
108 openLog(0); | |
109 } | |
110 | |
111 | |
112 void openLog(_Bool recallKeepPage) | |
113 { | |
114 if(recallKeepPage && infolog.page) | |
115 infolog.page--; | |
116 else | |
117 infolog.page = 0; | |
118 | |
119 infolog.modeFlipPages = 1; | |
120 set_globalState_Log_Page(infolog.page); | |
121 infolog.maxpages = (logbook_getNumberOfHeaders() + 5) / 6; | |
122 tInfoLog_BuildAndShowNextPage(); | |
123 | |
124 pMenuCursor = get_PointerMenuCursorScreen(); | |
125 pMenuCursorDesignSolo = get_PointerMenuCursorDesignSoloScreen(); | |
126 | |
127 change_CLUT_entry(CLUT_MenuLineSelectedSides, CLUT_InfoPageLogbook); | |
128 change_CLUT_entry(CLUT_MenuLineSelectedSeperator, CLUT_InfoPageLogbook); | |
129 | |
130 //GFX_ResetLayer(TOP_LAYER); | |
131 //GFX_ResetLayer(BACKGRD_LAYER); | |
132 | |
133 if(infolog.page == 255) | |
134 GFX_SetFrameBottom((INFOLOGscreen.FBStartAdress), 0, 0, 800, 480); | |
135 else | |
136 { | |
137 // very old: GFX_SetFrameBottom((pMenuCursor->FBStartAdress), 0, 0, 800, 390); | |
138 // no, set cursor to firt line instead with tInfoLog_nextLine() GFX_SetFrameBottom((pMenuCursorDesignSolo->FBStartAdress), 0, 25, 800, 390); | |
139 tInfoLog_nextLine(); | |
140 } | |
141 } | |
142 | |
143 | |
144 void sendActionToInfoLogList(uint8_t sendAction) | |
145 { | |
146 switch(sendAction) | |
147 { | |
148 case ACTION_BUTTON_ENTER: | |
149 stepForwardInfo(); | |
150 break; | |
151 case ACTION_BUTTON_NEXT: | |
152 | |
153 if(infolog.modeFlipPages) | |
154 { | |
155 tInfoLog_BuildAndShowNextPage(); | |
156 // GFX_SetFrameBottom((pMenuCursor->FBStartAdress), 0, 25, 800, 390); | |
157 } | |
158 else | |
159 tInfoLog_nextLine(); | |
160 break; | |
161 case ACTION_TIMEOUT: | |
162 case ACTION_MODE_CHANGE: | |
163 case ACTION_BUTTON_BACK: | |
164 stepBackInfo(); | |
165 default: | |
166 break; | |
167 case ACTION_IDLE_TICK: | |
168 case ACTION_IDLE_SECOND: | |
169 break; | |
170 } | |
171 } | |
172 | |
173 | |
174 void sendActionToInfoLogShow(uint8_t sendAction) | |
175 { | |
176 switch(sendAction) | |
177 { | |
178 case ACTION_BUTTON_ENTER: | |
179 break; | |
180 case ACTION_BUTTON_NEXT: | |
181 showNextLogPage(); | |
182 break; | |
183 case ACTION_TIMEOUT: | |
184 case ACTION_MODE_CHANGE: | |
185 case ACTION_BUTTON_BACK: | |
186 if(get_globalState() == StILOGSHOW) // no page nor line | |
187 { | |
188 openLog(1); | |
189 } | |
190 else | |
191 { | |
192 showLogExit(); | |
193 } | |
194 show_logbook_exit(); | |
195 default: | |
196 break; | |
197 case ACTION_IDLE_TICK: | |
198 case ACTION_IDLE_SECOND: | |
199 break; | |
200 } | |
201 } | |
202 | |
203 | |
204 /* Private functions ---------------------------------------------------------*/ | |
205 | |
206 void exitLog(void) | |
207 { | |
208 //set_globalState_tHome(); | |
209 exitInfo(); | |
210 releaseFrame(15,INFOLOGscreen.FBStartAdress); | |
211 } | |
212 | |
213 | |
214 void stepBackInfo(void) | |
215 { | |
216 if(infolog.modeFlipPages == 0) | |
217 { | |
218 infolog.line = 0; | |
219 infolog.modeFlipPages = 1; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
220 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
221 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
222 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
223 GFX_SetFrameBottom(pMenuCursorDesignSolo->FBStartAdress, 0, 25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
224 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
225 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
226 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
227 GFX_SetFrameBottom(pMenuCursorDesignSolo->FBStartAdress, 0, 65, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
228 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
229 |
38 | 230 } |
231 else | |
232 exitLog(); | |
233 } | |
234 | |
235 | |
236 void stepForwardInfo(void) | |
237 { | |
238 if(infolog.modeFlipPages == 1) | |
239 { | |
240 tInfoLog_nextLine(); | |
241 } | |
242 else | |
243 showLog(); | |
244 } | |
245 | |
246 | |
247 void tInfoLog_BuildAndShowNextPage(void) | |
248 { | |
249 char text[MAX_PAGE_TEXTSIZE]; | |
250 uint16_t textPointer = 0; | |
251 SLogbookHeader logbookHeader; | |
252 // uint16_t divetime = logbookHeader.diveTimeMinutes; | |
253 // uint16_t maxDepth = logbookHeader.maxDepth/100; | |
254 int i = 0; | |
255 uint8_t date[2], month,day; | |
256 | |
257 if(INFOLOGscreen.FBStartAdress) | |
258 releaseFrame(15,INFOLOGscreen.FBStartAdress); | |
259 INFOLOGscreen.FBStartAdress = getFrame(15); | |
260 | |
261 infolog.page += 1; | |
262 infolog.linesAvailableForPage = 0; | |
263 | |
264 if((infolog.page < 1) || (infolog.page > 43)) /* max with 256 entries */ | |
265 infolog.page = 1; | |
266 | |
267 | |
268 text[0] = '\001'; | |
269 text[1] = TXT_Logbook; | |
270 text[2] = 0; | |
271 gfx_write_topline_simple(&INFOLOGscreen, text, CLUT_InfoPageLogbook); | |
272 | |
273 *text = 0; | |
274 if(!logbook_getHeader((infolog.page - 1) * 6,&logbookHeader)) | |
275 { | |
276 infolog.page = 1; | |
277 if(!logbook_getHeader((infolog.page - 1) * 6,&logbookHeader)) | |
278 { | |
279 infolog.page = 255; | |
280 infolog.linesAvailableForPage = 0; | |
281 text[0] = TXT_LogbookEmpty; | |
282 text[1] = 0; | |
283 } | |
284 } | |
285 | |
286 if((*text == 0) && (infolog.maxpages > 1)) | |
287 { | |
288 snprintf(text,8, "\002" "%u/%u", infolog.page, infolog.maxpages); | |
289 gfx_write_topline_simple(&INFOLOGscreen, text, CLUT_InfoPageLogbook); | |
290 *text = 0; | |
291 } | |
292 | |
293 if(*text == 0) | |
294 { | |
295 infolog.line = 0; | |
296 textPointer = 0; | |
297 if(settingsGetPointer()->date_format == DDMMYY) | |
298 { | |
299 day = 0; | |
300 month = 1; | |
301 } | |
302 else | |
303 { | |
304 day = 1; | |
305 month = 0; | |
306 } | |
307 for(i = 0; i < 6; i++) | |
308 { | |
309 if(i) | |
310 { | |
311 if(!logbook_getHeader(((infolog.page - 1) * 6) + i, &logbookHeader)) | |
312 break; | |
313 } | |
314 infolog.linesAvailableForPage += 1; | |
315 uint16_t divetime = logbookHeader.diveTimeMinutes; | |
316 uint16_t maxDepthMeter = logbookHeader.maxDepth/100; | |
317 uint16_t maxDepthSubmeter = (logbookHeader.maxDepth - maxDepthMeter * 100)/10; | |
318 uint16_t number = ((infolog.page - 1) * 6) + i + 1; | |
319 if(settingsGetPointer()->logbookOffset) | |
320 { | |
321 if(number <= settingsGetPointer()->logbookOffset) | |
322 number = settingsGetPointer()->logbookOffset + 1 - number; | |
323 } | |
324 date[day] = logbookHeader.dateDay; | |
325 date[month] = logbookHeader.dateMonth; | |
326 | |
327 text[textPointer++] = '\034';// monospaced space large size mode | |
328 textPointer += snprintf(&text[textPointer], 20,"\021%04u \020", number); | |
329 /* if(number < 1000) | |
330 textPointer += snprintf(&text[textPointer], 20,"\021%2u \020", number); | |
331 else | |
332 textPointer += snprintf(&text[textPointer], 20,"\021\016\016%3u \017\020", number); | |
333 */ | |
334 textPointer += snprintf(&text[textPointer], 20,"%02d.%02d ",date[0],date[1]); | |
335 textPointer += snprintf(&text[textPointer], 20,"%02d:%02d ",logbookHeader.timeHour,logbookHeader.timeMinute); | |
336 switch(logbookHeader.decoModel) | |
337 { | |
338 case 1: | |
339 textPointer += snprintf(&text[textPointer],20,"\016\016 GF \017"); | |
340 break; | |
341 case 2: | |
342 textPointer += snprintf(&text[textPointer],20,"\016\016 VPM \017"); | |
343 break; | |
344 default: | |
345 textPointer += snprintf(&text[textPointer],20,"\016\016 * \017"); | |
346 break; | |
347 } | |
348 | |
349 if(settingsGetPointer()->nonMetricalSystem) | |
350 { | |
351 float maxDepthFeet = 0; | |
352 maxDepthFeet = unit_depth_float(((float)logbookHeader.maxDepth)/100); | |
353 textPointer += snprintf(&text[textPointer], 20,"%3.0f\016\016ft\017 ", maxDepthFeet); | |
354 } | |
355 else | |
356 { | |
357 textPointer += snprintf(&text[textPointer], 20,"%3d.%d\016\016m\017 ", maxDepthMeter,maxDepthSubmeter); | |
358 } | |
359 textPointer += snprintf(&text[textPointer], 20,"%3d'\n\r", divetime); | |
360 } | |
361 } | |
362 GFX_write_string(&FontT48, &INFOLOGwindow, text,1); | |
363 | |
364 if(infolog.linesAvailableForPage > 1) | |
365 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
366 else if(infolog.page == 255) | |
367 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,0,0); | |
368 else | |
369 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | |
370 | |
371 GFX_SetFrameTop(INFOLOGscreen.FBStartAdress); | |
372 set_globalState_Log_Page(infolog.page); | |
373 } | |
374 | |
375 | |
376 void tInfoLog_nextLine(void) | |
377 { | |
378 if(infolog.linesAvailableForPage == 0) | |
379 return; | |
380 | |
381 infolog.line += 1; | |
382 if(infolog.line > infolog.linesAvailableForPage) | |
383 infolog.line = 1; | |
384 | |
385 infolog.modeFlipPages = 0; | |
386 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
387 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
388 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
389 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
|
390 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
391 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
392 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
393 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
|
394 } |
38 | 395 } |
396 | |
397 | |
398 void showLogExit(void) | |
399 { | |
400 GFX_SetFrameTop(INFOLOGscreen.FBStartAdress); | |
401 GFX_SetFrameBottom((pMenuCursor->FBStartAdress) + 65*2*(infolog.line - 1), 0, 25, 800, 390); | |
402 set_globalState_Log_Page(infolog.page); | |
403 } | |
404 | |
405 | |
406 void showLog(void) | |
407 { | |
408 uint8_t stepBack; | |
409 | |
410 if(infolog.page == 255) | |
411 return; | |
412 | |
413 stepBack = (6 * (infolog.page - 1)) + infolog.line - 1; | |
414 //build_logbook_test(); | |
415 show_logbook_test(1, stepBack); | |
416 } | |
417 | |
418 | |
419 void showNextLogPage(void) | |
420 { | |
421 uint8_t stepBack; | |
422 | |
423 if(infolog.page == 255) | |
424 return; | |
425 | |
426 stepBack = (6 * (infolog.page - 1)) + infolog.line - 1; | |
427 //build_logbook_test(); | |
428 show_logbook_test(0, stepBack); | |
429 } | |
430 | |
431 |