Mercurial > public > ostc4
annotate Discovery/Src/tInfoLog.c @ 539:d784f281833a
Added inertia simulation for compass heading:
In previous version calculated compass values were directly used for visualization of the compass. This causes a fast changing (jumping) of values. With the inertia introduction the compass behalfs more like an analog compass. The final value is reached slowly and the displayed values are more stable.
For configuration a new menu item has been added to the compass menu allowing to switch inertia off (default), small and large inertia simulation
author | Ideenmodellierer |
---|---|
date | Sat, 10 Oct 2020 16:59:18 +0200 |
parents | 1f557e5f4b5a |
children | 1c95f811967c |
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; | |
259 | |
260 if(INFOLOGscreen.FBStartAdress) | |
261 releaseFrame(15,INFOLOGscreen.FBStartAdress); | |
262 INFOLOGscreen.FBStartAdress = getFrame(15); | |
263 | |
264 infolog.page += 1; | |
265 infolog.linesAvailableForPage = 0; | |
266 | |
267 if((infolog.page < 1) || (infolog.page > 43)) /* max with 256 entries */ | |
268 infolog.page = 1; | |
269 | |
270 | |
271 text[0] = '\001'; | |
272 text[1] = TXT_Logbook; | |
273 text[2] = 0; | |
274 gfx_write_topline_simple(&INFOLOGscreen, text, CLUT_InfoPageLogbook); | |
275 | |
276 *text = 0; | |
277 if(!logbook_getHeader((infolog.page - 1) * 6,&logbookHeader)) | |
278 { | |
279 infolog.page = 1; | |
280 if(!logbook_getHeader((infolog.page - 1) * 6,&logbookHeader)) | |
281 { | |
282 infolog.page = 255; | |
283 infolog.linesAvailableForPage = 0; | |
284 text[0] = TXT_LogbookEmpty; | |
285 text[1] = 0; | |
286 } | |
287 } | |
288 | |
289 if((*text == 0) && (infolog.maxpages > 1)) | |
290 { | |
291 snprintf(text,8, "\002" "%u/%u", infolog.page, infolog.maxpages); | |
292 gfx_write_topline_simple(&INFOLOGscreen, text, CLUT_InfoPageLogbook); | |
293 *text = 0; | |
294 } | |
295 | |
296 if(*text == 0) | |
297 { | |
298 infolog.line = 0; | |
299 textPointer = 0; | |
300 if(settingsGetPointer()->date_format == DDMMYY) | |
301 { | |
302 day = 0; | |
303 month = 1; | |
304 } | |
305 else | |
306 { | |
307 day = 1; | |
308 month = 0; | |
309 } | |
310 for(i = 0; i < 6; i++) | |
311 { | |
312 if(i) | |
313 { | |
314 if(!logbook_getHeader(((infolog.page - 1) * 6) + i, &logbookHeader)) | |
315 break; | |
316 } | |
317 infolog.linesAvailableForPage += 1; | |
318 uint16_t divetime = logbookHeader.diveTimeMinutes; | |
319 uint16_t maxDepthMeter = logbookHeader.maxDepth/100; | |
320 uint16_t maxDepthSubmeter = (logbookHeader.maxDepth - maxDepthMeter * 100)/10; | |
321 uint16_t number = ((infolog.page - 1) * 6) + i + 1; | |
322 if(settingsGetPointer()->logbookOffset) | |
323 { | |
324 if(number <= settingsGetPointer()->logbookOffset) | |
325 number = settingsGetPointer()->logbookOffset + 1 - number; | |
326 } | |
327 date[day] = logbookHeader.dateDay; | |
328 date[month] = logbookHeader.dateMonth; | |
329 | |
330 text[textPointer++] = '\034';// monospaced space large size mode | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
469
diff
changeset
|
331 textPointer += snprintf(&text[textPointer], 20,"\031%04u \020", number); |
38 | 332 /* if(number < 1000) |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
469
diff
changeset
|
333 textPointer += snprintf(&text[textPointer], 20,"\031%2u \020", number); |
38 | 334 else |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
469
diff
changeset
|
335 textPointer += snprintf(&text[textPointer], 20,"\031\016\016%3u \017\020", number); |
38 | 336 */ |
337 textPointer += snprintf(&text[textPointer], 20,"%02d.%02d ",date[0],date[1]); | |
338 textPointer += snprintf(&text[textPointer], 20,"%02d:%02d ",logbookHeader.timeHour,logbookHeader.timeMinute); | |
339 switch(logbookHeader.decoModel) | |
340 { | |
341 case 1: | |
342 textPointer += snprintf(&text[textPointer],20,"\016\016 GF \017"); | |
343 break; | |
344 case 2: | |
345 textPointer += snprintf(&text[textPointer],20,"\016\016 VPM \017"); | |
346 break; | |
347 default: | |
348 textPointer += snprintf(&text[textPointer],20,"\016\016 * \017"); | |
349 break; | |
350 } | |
351 | |
352 if(settingsGetPointer()->nonMetricalSystem) | |
353 { | |
354 float maxDepthFeet = 0; | |
355 maxDepthFeet = unit_depth_float(((float)logbookHeader.maxDepth)/100); | |
356 textPointer += snprintf(&text[textPointer], 20,"%3.0f\016\016ft\017 ", maxDepthFeet); | |
357 } | |
358 else | |
359 { | |
360 textPointer += snprintf(&text[textPointer], 20,"%3d.%d\016\016m\017 ", maxDepthMeter,maxDepthSubmeter); | |
361 } | |
362 textPointer += snprintf(&text[textPointer], 20,"%3d'\n\r", divetime); | |
363 } | |
364 } | |
365 GFX_write_string(&FontT48, &INFOLOGwindow, text,1); | |
366 | |
367 if(infolog.linesAvailableForPage > 1) | |
368 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
369 else if(infolog.page == 255) | |
370 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,0,0); | |
371 else | |
372 tInfo_write_buttonTextline(&INFOLOGscreen, TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | |
373 | |
374 GFX_SetFrameTop(INFOLOGscreen.FBStartAdress); | |
375 set_globalState_Log_Page(infolog.page); | |
376 } | |
377 | |
378 | |
379 void tInfoLog_nextLine(void) | |
380 { | |
381 if(infolog.linesAvailableForPage == 0) | |
382 return; | |
383 | |
384 infolog.line += 1; | |
385 if(infolog.line > infolog.linesAvailableForPage) | |
386 infolog.line = 1; | |
387 | |
388 infolog.modeFlipPages = 0; | |
389 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
390 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
391 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
392 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
|
393 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
394 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
395 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
396 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
|
397 } |
38 | 398 } |
399 | |
400 | |
401 void showLogExit(void) | |
402 { | |
403 GFX_SetFrameTop(INFOLOGscreen.FBStartAdress); | |
404 GFX_SetFrameBottom((pMenuCursor->FBStartAdress) + 65*2*(infolog.line - 1), 0, 25, 800, 390); | |
405 set_globalState_Log_Page(infolog.page); | |
406 } | |
407 | |
408 | |
409 void showLog(void) | |
410 { | |
411 uint8_t stepBack; | |
412 | |
413 if(infolog.page == 255) | |
414 return; | |
415 | |
416 stepBack = (6 * (infolog.page - 1)) + infolog.line - 1; | |
417 //build_logbook_test(); | |
418 show_logbook_test(1, stepBack); | |
419 } | |
420 | |
421 | |
422 void showNextLogPage(void) | |
423 { | |
424 uint8_t stepBack; | |
425 | |
426 if(infolog.page == 255) | |
427 return; | |
428 | |
429 stepBack = (6 * (infolog.page - 1)) + infolog.line - 1; | |
430 //build_logbook_test(); | |
431 show_logbook_test(0, stepBack); | |
432 } | |
433 |