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