Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2136 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2013 Oliver Gemesi * |
||
3 | * * |
||
4 | * This program is free software; you can redistribute it and/or modify * |
||
5 | * it under the terms of the GNU General Public License as published by * |
||
6 | * the Free Software Foundation; either version 2 of the License. * |
||
7 | * * |
||
8 | * This program is distributed in the hope that it will be useful, * |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
11 | * GNU General Public License for more details. * |
||
12 | * * |
||
13 | * You should have received a copy of the GNU General Public License * |
||
14 | * along with this program; if not, write to the * |
||
15 | * Free Software Foundation, Inc., * |
||
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
17 | *****************************************************************************/ |
||
18 | |||
19 | //############################################################################ |
||
20 | //# HISTORY osddata.c |
||
21 | //# |
||
22 | //# 14.06.2014 OG |
||
23 | //# - chg: Menu_OSDData() - Bezeichnung von "OSD Daten" und "BL Daten" geaendert |
||
24 | //# zu "OSD Statistik" und "BL Statistik" |
||
25 | //# |
||
26 | //# 11.05.2014 OG |
||
27 | //# - chg: Text von SHOWMKERROR_de, SHOWMKERROR_en etwas gekuerzt |
||
28 | //# - chg: Titel von Scrollbox-Listen angepasst |
||
29 | //# - chg: Menu_OSDData() umgestellt auf MenuCtrl_SetTitleFromParentItem() |
||
30 | //# -> die Menues 'erben' damit ihren Titel vom aufrufenden Menuepunkt |
||
31 | //# |
||
32 | //# 30.03.2014 OG |
||
33 | //# - chg: Sprache Hollaendisch vollstaendig entfernt |
||
34 | //# - chg: MenuCtrl_PushML_P() umgestellt auf MenuCtrl_PushML2_P() |
||
35 | //# |
||
36 | //# 29.03.2014 OG |
||
37 | //# - chg: Menu_OSDData() del: MenuCtrl_SetShowBatt() wegen Aenderung Default auf true |
||
38 | //# - chg: ask_delete_data() - Layout und Optimierung |
||
39 | //# - add: OSDDATA_ShowLastGPSPosition() |
||
40 | //# - del: OSDDATA_ShowLastGPS() |
||
41 | //# |
||
42 | //# 12.02.2014 OG |
||
43 | //# - del: die includes zu den alten parameter... entfernt |
||
44 | //# |
||
45 | //# 24.01.2014 OG |
||
46 | //# - fix: OSDDATA_ClearAllData(): Beep wenn Daten geloescht werden |
||
47 | //# (wie bei den anderen Löschungen) |
||
48 | //# |
||
49 | //# 30.06.2013 OG |
||
50 | //# - add: Gesamtstrom-Mittelwert in OSDDATA_Statistics() und OSDDATA_BLStatistics() |
||
51 | //# - chg: Benamung Statistik-Var's von mid_* auf avg_* geaendert |
||
52 | //# - chg: Funktionsnamen geaendert |
||
53 | //# |
||
54 | //# 19.06.2013 OG |
||
55 | //# - add: last Flytime in OSDDATA_Statistics() |
||
56 | //# - chg: Reihenfolge in OSDDATA_Statistics() und zusaetzliche Trennline |
||
57 | //# - add: max Current (Gesamt) in OSDDATA_Statistics() |
||
58 | //# |
||
59 | //# 16.06.2013 OG |
||
60 | //# - fix: "min. Voltage" Anzeige in OSDDATA_Statistics() (war veschoben) |
||
61 | //# |
||
62 | //# 13.06.2013 OG |
||
63 | //# - chg: Uebersetzungen von CB in ask_delete_data() aufgenommen |
||
64 | //# - chg: GPS-Menuetitel geaendert |
||
65 | //# - fix: include pkt.h |
||
66 | //# |
||
67 | //# 11.06.2013 OG |
||
68 | //# - chg: ask_delete_data() erweitert um Info was geloescht wird & Layout (TODO: Uebersetzungen) |
||
69 | //# - add: Mittelwertanzeige fuer BL-Strom |
||
70 | //# - add: Anzahl BL-Statistik-Datenpakete (nur wenn USE_OSD_SCREEN_DEBUG) |
||
71 | //# - add: OSDDATA_BLStatistic() - die BL-Daten wurden in eigene Anzeigefunktion verschoben |
||
72 | //# - add: OSDDATA_ClearAllData() - alle Daten loeschen |
||
73 | //# - add: OSDDATA_ShowLastGPS() - letzte GPS-Position anzeigen |
||
74 | //# - add: Menu_OSDData() - ehemals in menu.c jetzt hier |
||
75 | //# - chg: PKT_CtrlHook() noch an einigen Stellen eingefuegt |
||
76 | //# - fix: ctrl_osddata() clear screen vor ScrollBox_Refresh |
||
77 | //# |
||
78 | //# 15.05.2013 OG |
||
79 | //# - chg: OSDDATA_Statistics() umgestellt auf calc_BLmax() (aus osd.c) |
||
80 | //# |
||
81 | //# 04.05.2013 OG |
||
82 | //# - chg: angepasst auf xutils.c |
||
83 | //# - add: weitere Anzeigen in OSD_Statistics() |
||
84 | //# - add: Content in OSDDATA_UserGPS() und OSDDATA_MkError() |
||
85 | //# |
||
86 | //# 28.04.2013 OG |
||
87 | //# - chg: auf die neuen Features von xprintf angepasst (siehe utils/xstring.c) |
||
88 | //# |
||
89 | //# 21.04.2013 Cebra |
||
90 | //# - chg: Texte "Datenlöschen" in messages.c aufgenommen |
||
91 | //# |
||
92 | //# 20.04.2013 OG - NEU |
||
93 | //############################################################################ |
||
94 | |||
95 | #include "../cpu.h" |
||
96 | #include <avr/io.h> |
||
97 | #include <inttypes.h> |
||
98 | #include <stdlib.h> |
||
99 | #include <avr/pgmspace.h> |
||
100 | #include <util/delay.h> |
||
101 | #include <string.h> |
||
102 | |||
103 | #include "../main.h" |
||
104 | #include "../lcd/lcd.h" |
||
105 | #include "../timer/timer.h" |
||
106 | #include "../uart/usart.h" |
||
107 | #include "../eeprom/eeprom.h" |
||
108 | #include "../messages.h" |
||
109 | #include "../sound/pwmsine8bit.h" |
||
110 | #include "../mk-data-structs.h" |
||
111 | #include "../osd/osd.h" |
||
112 | #include "../utils/scrollbox.h" |
||
113 | #include "../utils/xutils.h" |
||
114 | #include "../utils/menuctrl.h" |
||
115 | #include "../pkt/pkt.h" |
||
116 | #include "../lipo/lipo.h" |
||
117 | #include "../mk/mkbase.h" |
||
118 | |||
119 | |||
120 | #define INIT_STATISTIC 1 |
||
121 | #define INIT_MKERROR 2 |
||
122 | #define INIT_USERGPS 3 |
||
123 | #define INIT_LASTPOS 4 |
||
124 | #define INIT_ALLDATA 5 |
||
125 | |||
126 | |||
127 | //----------------------- |
||
128 | // Menu_OSDDATA |
||
129 | //----------------------- |
||
130 | #define ID_SHOWSTATISTIK 1 |
||
131 | #define ID_SHOWBLSTATISTIK 2 |
||
132 | #define ID_SHOWMKERROR 3 |
||
133 | #define ID_SHOWUSERGPS 4 |
||
134 | #define ID_SHOWLASTGPS 5 |
||
135 | #define ID_CLEARALLDATA 6 |
||
136 | |||
137 | |||
138 | //static const char SHOWSTATISTIK_de[] PROGMEM = "OSD Daten"; |
||
139 | //static const char SHOWSTATISTIK_en[] PROGMEM = "OSD data"; |
||
140 | |||
141 | //static const char SHOWBLSTATISTIK_de[] PROGMEM = "BL Daten"; |
||
142 | //static const char SHOWBLSTATISTIK_en[] PROGMEM = "BL data"; |
||
143 | |||
144 | static const char SHOWSTATISTIK_de[] PROGMEM = "OSD Statistik"; |
||
145 | static const char SHOWSTATISTIK_en[] PROGMEM = "OSD statistics"; |
||
146 | |||
147 | static const char SHOWBLSTATISTIK_de[] PROGMEM = "BL Statistik"; |
||
148 | static const char SHOWBLSTATISTIK_en[] PROGMEM = "BL statistics"; |
||
149 | |||
150 | static const char SHOWMKERROR_de[] PROGMEM = "MK Fehler"; |
||
151 | static const char SHOWMKERROR_en[] PROGMEM = "MK errors"; |
||
152 | |||
153 | static const char SHOWUSERGPS_de[] PROGMEM = "GPS Userdaten"; |
||
154 | static const char SHOWUSERGPS_en[] PROGMEM = "GPS userdata"; |
||
155 | |||
156 | static const char SHOWLASTGPS_de[] PROGMEM = "GPS letzte Pos."; |
||
157 | static const char SHOWLASTGPS_en[] PROGMEM = "GPS last pos."; |
||
158 | |||
159 | static const char CLEARALLDATA_de[] PROGMEM = "LÖSCHE alle Daten"; |
||
160 | static const char CLEARALLDATA_en[] PROGMEM = "DELETE all data"; |
||
161 | |||
162 | |||
163 | |||
164 | //############################################################################ |
||
165 | |||
166 | |||
167 | |||
168 | //-------------------------------------------------------------- |
||
169 | //-------------------------------------------------------------- |
||
170 | uint8_t ask_delete_data( uint8_t initcode ) |
||
171 | { |
||
172 | uint8_t refresh = true; |
||
173 | |||
174 | clear_key_all(); |
||
175 | |||
176 | set_beep ( 60, 0xffff, BeepNormal); |
||
177 | |||
178 | while( true ) |
||
179 | { |
||
180 | //-------------------------------------- |
||
181 | // screen refresh |
||
182 | //-------------------------------------- |
||
183 | if( refresh ) |
||
184 | { |
||
185 | lcd_cls(); |
||
186 | |||
187 | lcd_frect( 0, 0, 127, 7, 1); // Headline: Box fill Black |
||
188 | lcdx_printp_at( 1, 0, strGet(DELETE), MINVERS, 0,0); // Titel |
||
189 | show_Lipo(); // LiPo anzeigen |
||
190 | |||
191 | lcd_rect_round( 0, 20, 127, 27, 1, R2); // Rahmen fuer Benutzerfrage |
||
192 | |||
193 | switch( initcode ) |
||
194 | { |
||
195 | case INIT_STATISTIC: lcdx_printp_center( 2, strGet(STAT_OSDBL), MNORMAL, 0,9); break; |
||
196 | case INIT_MKERROR : lcdx_printp_center( 2, strGet(STAT_ERROR), MNORMAL, 0,9); break; |
||
197 | case INIT_USERGPS : lcdx_printp_center( 2, strGet(STAT_GPS) , MNORMAL, 0,9); break; |
||
198 | case INIT_LASTPOS : lcdx_printp_center( 2, strGet(STAT_POS) , MNORMAL, 0,9); break; |
||
199 | case INIT_ALLDATA : lcdx_printp_center( 2, strGet(STAT_ALL) , MNORMAL, 0,9); break; |
||
200 | } |
||
201 | |||
202 | lcdx_printp_center( 4, strGet(DELETE), MNORMAL, 0,4); // "löschen?" |
||
203 | |||
204 | lcd_printp_at( 0, 7, strGet(START_LASTPOS2) , MNORMAL); // Keyline: "löschen Nein" |
||
205 | |||
206 | refresh = false; |
||
207 | } |
||
208 | |||
209 | //-------------------------------------- |
||
210 | // Update vom Updatetool angefordert? |
||
211 | //-------------------------------------- |
||
212 | if( PKT_CtrlHook() ) |
||
213 | { |
||
214 | refresh = true; |
||
215 | } |
||
216 | |||
217 | //-------------------------------------- |
||
218 | // loeschen |
||
219 | //-------------------------------------- |
||
220 | if( get_key_press(1 << KEY_MINUS) ) |
||
221 | { |
||
222 | clear_key_all(); |
||
223 | return true; // Rueckgabe: true = loeschen |
||
224 | } |
||
225 | |||
226 | |||
227 | //-------------------------------------- |
||
228 | // Ende |
||
229 | //-------------------------------------- |
||
230 | if( get_key_press(1 << KEY_ENTER) ) |
||
231 | { |
||
232 | clear_key_all(); |
||
233 | return false; // Rueckgabe: false = nicht loeschen |
||
234 | } |
||
235 | } |
||
236 | } |
||
237 | |||
238 | |||
239 | |||
240 | //-------------------------------------------------------------- |
||
241 | //-------------------------------------------------------------- |
||
242 | void ctrl_osddata( uint8_t isdata, uint8_t initcode ) |
||
243 | { |
||
244 | uint8_t key = 0; |
||
245 | |||
246 | if( !isdata ) ScrollBox_Push_P( MNORMAL, PSTR(" no data...") ); |
||
247 | |||
248 | ScrollBox_SetKey( KEY_ENTER, " Del" ); |
||
249 | |||
250 | do |
||
251 | { |
||
252 | key = ScrollBox_Show(); |
||
253 | |||
254 | if( key == KEY_ENTER ) |
||
255 | { |
||
256 | if( ask_delete_data(initcode) ) |
||
257 | { |
||
258 | switch( initcode ) |
||
259 | { |
||
260 | case INIT_STATISTIC: STAT_Init(); break; |
||
261 | case INIT_MKERROR: MKErr_Log_Init(); break; |
||
262 | case INIT_USERGPS: GPS_User_Init(); break; |
||
263 | } |
||
264 | |||
265 | set_beep ( 400, 0xffff, BeepNormal); |
||
266 | key = 0; // exit |
||
267 | } |
||
268 | else |
||
269 | { |
||
270 | lcd_cls(); |
||
271 | ScrollBox_Refresh(); |
||
272 | } |
||
273 | } |
||
274 | |||
275 | } while( key ); |
||
276 | } |
||
277 | |||
278 | |||
279 | |||
280 | //-------------------------------------------------------------- |
||
281 | // add_statistic_head() |
||
282 | // |
||
283 | // fuegt Basisdaten den OSD- und BL-Listen hinzu |
||
284 | //-------------------------------------------------------------- |
||
285 | void add_statistic_head( void ) |
||
286 | { |
||
287 | PKTdatetime_t dtlocal; |
||
288 | |||
289 | //--------------------------- |
||
290 | // begin: date/time |
||
291 | //--------------------------- |
||
292 | UTCdatetime2local( &dtlocal, &Config.OSD_Statistic.begin_StatTime ); |
||
293 | ScrollBox_Push_P( MNORMAL, PSTR("Begin: %02u:%02u %02u.%02u."), |
||
294 | (uint16_t)(dtlocal.seconds/3600), (uint16_t)(dtlocal.seconds/60%60), |
||
295 | //lcd_printp_at( 3, 3, strGet(DELETEDATA), MNORMAL); // "Daten loeschen?" |
||
296 | dtlocal.day, dtlocal.month |
||
297 | ); |
||
298 | |||
299 | //--------------------------- |
||
300 | // end: date/time |
||
301 | //--------------------------- |
||
302 | UTCdatetime2local( &dtlocal, &Config.OSD_Statistic.end_StatTime ); |
||
303 | ScrollBox_Push_P( MNORMAL, PSTR("End: %02u:%02u %02u.%02u."), |
||
304 | (uint16_t)(dtlocal.seconds/3600), (uint16_t)(dtlocal.seconds/60%60), |
||
305 | dtlocal.day, dtlocal.month |
||
306 | ); |
||
307 | |||
308 | //+++++++++++++++++++++++++++ |
||
309 | // TRENNER |
||
310 | //+++++++++++++++++++++++++++ |
||
311 | ScrollBox_PushLine(); |
||
312 | } |
||
313 | |||
314 | |||
315 | |||
316 | //-------------------------------------------------------------- |
||
317 | // zeigt aufgezeichnete OSD-Daten an |
||
318 | //-------------------------------------------------------------- |
||
319 | void OSDDATA_Statistics( void ) |
||
320 | { |
||
321 | int16_t v; |
||
322 | osd_BLmax_t blmax; |
||
323 | |||
324 | lcd_cls(); |
||
325 | |||
326 | if( !ScrollBox_Create(25) ) |
||
327 | return; // kein RAM mehr |
||
328 | |||
329 | //+++++++++++++++++++++++++++ |
||
330 | // max. der BL's ermitteln |
||
331 | //+++++++++++++++++++++++++++ |
||
332 | calc_BLmax( &blmax ); |
||
333 | |||
334 | ScrollBox_Push_P( MINVERS, PSTR(" OSD Data") ); |
||
335 | |||
336 | //--------------------------- |
||
337 | // Basisanzeige der Stat-Liste |
||
338 | //--------------------------- |
||
339 | add_statistic_head(); |
||
340 | |||
341 | //--------------------------- |
||
342 | // last Flytime |
||
343 | //--------------------------- |
||
344 | ScrollBox_Push_P( MNORMAL, PSTR(" Last Fly %02u:%02u min"), (Config.OSD_Statistic.last_FlyTime/60), (Config.OSD_Statistic.last_FlyTime%60) ); |
||
345 | |||
346 | //--------------------------- |
||
347 | // max. Altitude |
||
348 | //--------------------------- |
||
349 | v = Config.OSD_Statistic.max_Altimeter / (30 / AltimeterAdjust); |
||
350 | ScrollBox_Push_P( MNORMAL, PSTR("%cAltitude%7d m"), SYMBOL_MAX, v ); |
||
351 | |||
352 | //--------------------------- |
||
353 | // max. Distance |
||
354 | //--------------------------- |
||
355 | ScrollBox_Push_P( MNORMAL, PSTR("%cDistance%7u m"), SYMBOL_MAX, Config.OSD_Statistic.max_Distance/10 ); |
||
356 | |||
357 | //--------------------------- |
||
358 | // max. Ground-Speed |
||
359 | //--------------------------- |
||
360 | v = (uint16_t) (((uint32_t) Config.OSD_Statistic.max_GroundSpeed * (uint32_t) 90) / (uint32_t) 250); |
||
361 | ScrollBox_Push_P( MNORMAL, PSTR("%cGrnd.Speed%3.1d kmh"), SYMBOL_MAX, v ); |
||
362 | |||
363 | //--------------------------- |
||
364 | // max. Vert.-Speed |
||
365 | //--------------------------- |
||
366 | v = Config.OSD_Statistic.max_TopSpeed; |
||
367 | v = (v*36/100); // cm/s -> km/h*10 |
||
368 | ScrollBox_Push_P( MNORMAL, PSTR("%cVert.Speed%3.1d kmh"), SYMBOL_MAX, v ); |
||
369 | |||
370 | |||
371 | //+++++++++++++++++++++++++++ |
||
372 | // TRENNER |
||
373 | //+++++++++++++++++++++++++++ |
||
374 | ScrollBox_PushLine(); |
||
375 | |||
376 | |||
377 | //--------------------------- |
||
378 | // Used Capacity |
||
379 | //--------------------------- |
||
380 | ScrollBox_Push_P( MNORMAL, PSTR(" Capacity%7d mAh"), Config.OSD_Statistic.max_Capacity ); |
||
381 | |||
382 | //--------------------------- |
||
383 | // max. Current |
||
384 | //--------------------------- |
||
385 | ScrollBox_Push_P( MNORMAL, PSTR("%cCurrent%6.1d A"), SYMBOL_MAX, Config.OSD_Statistic.max_Current ); |
||
386 | |||
387 | //--------------------------- |
||
388 | // avg. Current |
||
389 | //--------------------------- |
||
390 | ScrollBox_Push_P( MNORMAL, PSTR("%cCurrent%6.1d A"), SYMBOL_AVG, (uint8_t)(Config.OSD_Statistic.avg_Current/100) ); |
||
391 | |||
392 | //--------------------------- |
||
393 | // BL-Detected |
||
394 | //--------------------------- |
||
395 | //ScrollBox_Push_P( MNORMAL, PSTR(" BL Detected%4d"), Config.OSD_Statistic.BL_Count ); |
||
396 | |||
397 | //--------------------------- |
||
398 | // max. BL-Current |
||
399 | //--------------------------- |
||
400 | ScrollBox_Push_P( MNORMAL, PSTR("%cBL%1d Curr.%4.1u A"), SYMBOL_MAX, blmax.max_BL_Current_Index+1, blmax.max_BL_Current ); |
||
401 | |||
402 | //--------------------------- |
||
403 | // max. BL-Temp |
||
404 | //--------------------------- |
||
405 | ScrollBox_Push_P( MNORMAL, PSTR("%cBL%1d Temp. %5u %cC"), SYMBOL_MAX, blmax.max_BL_Temp_Index+1, blmax.max_BL_Temp, SYMBOL_BIGDEGREE ); |
||
406 | |||
407 | //--------------------------- |
||
408 | // min. Voltage |
||
409 | //--------------------------- |
||
410 | v = (Config.OSD_Statistic.min_UBat == 255) ? 0 : Config.OSD_Statistic.min_UBat; |
||
411 | ScrollBox_Push_P( MNORMAL, PSTR("%cVoltage%6.1d V"), SYMBOL_MIN, v ); |
||
412 | |||
413 | |||
414 | //+++++++++++++++++++++++++++ |
||
415 | // TRENNER |
||
416 | //+++++++++++++++++++++++++++ |
||
417 | ScrollBox_PushLine(); |
||
418 | |||
419 | |||
420 | //--------------------------- |
||
421 | // max. RC-Quality |
||
422 | //--------------------------- |
||
423 | ScrollBox_Push_P( MNORMAL, PSTR("%cRC-Quality%5d"), SYMBOL_MAX, Config.OSD_Statistic.max_RCQuality ); |
||
424 | |||
425 | //--------------------------- |
||
426 | // min. RC-Quality |
||
427 | //--------------------------- |
||
428 | v = (Config.OSD_Statistic.min_RCQuality==255) ? 0 : Config.OSD_Statistic.min_RCQuality; |
||
429 | ScrollBox_Push_P( MNORMAL, PSTR("%cRC-Quality%5d"), SYMBOL_MIN, v ); |
||
430 | |||
431 | |||
432 | //--------------------------- |
||
433 | // max. Nick |
||
434 | //--------------------------- |
||
435 | ScrollBox_Push_P( MNORMAL, PSTR("%cNick%11d %c"), SYMBOL_MAX, Config.OSD_Statistic.max_AngleNick, SYMBOL_SMALLDEGREE ); |
||
436 | |||
437 | //--------------------------- |
||
438 | // min. Nick |
||
439 | //--------------------------- |
||
440 | v = (Config.OSD_Statistic.min_AngleNick==126) ? 0 : Config.OSD_Statistic.min_AngleNick; |
||
441 | ScrollBox_Push_P( MNORMAL, PSTR("%cNick%11d %c"), SYMBOL_MIN, v, SYMBOL_SMALLDEGREE ); |
||
442 | |||
443 | //--------------------------- |
||
444 | // max. Roll |
||
445 | //--------------------------- |
||
446 | ScrollBox_Push_P( MNORMAL, PSTR("%cRoll%11d %c"), SYMBOL_MAX, Config.OSD_Statistic.max_AngleRoll, SYMBOL_SMALLDEGREE ); |
||
447 | |||
448 | //--------------------------- |
||
449 | // min. Roll |
||
450 | //--------------------------- |
||
451 | v = (Config.OSD_Statistic.min_AngleRoll==126) ? 0 : Config.OSD_Statistic.min_AngleRoll; |
||
452 | ScrollBox_Push_P( MNORMAL, PSTR("%cRoll%11d %c"), SYMBOL_MIN, v, SYMBOL_SMALLDEGREE ); |
||
453 | |||
454 | |||
455 | //+++++++++++++++++++++++++++ |
||
456 | // TRENNER |
||
457 | //+++++++++++++++++++++++++++ |
||
458 | ScrollBox_PushLine(); |
||
459 | |||
460 | ctrl_osddata( true, INIT_STATISTIC ); |
||
461 | |||
462 | ScrollBox_Destroy(); // free memory |
||
463 | } |
||
464 | |||
465 | |||
466 | |||
467 | //-------------------------------------------------------------- |
||
468 | // zeigt aufgezeichnete BL-Daten an |
||
469 | //-------------------------------------------------------------- |
||
470 | void OSDDATA_StatisticsBL( void ) |
||
471 | { |
||
472 | uint8_t i; |
||
473 | osd_BLmax_t blmax; |
||
474 | |||
475 | lcd_cls(); |
||
476 | |||
477 | #ifdef USE_OSD_SCREEN_DEBUG |
||
478 | if( !ScrollBox_Create(10 + (Config.OSD_Statistic.BL_Count*6)) ) |
||
479 | return; // kein RAM mehr |
||
480 | #else |
||
481 | if( !ScrollBox_Create(10 + (Config.OSD_Statistic.BL_Count*4)) ) |
||
482 | return; // kein RAM mehr |
||
483 | #endif |
||
484 | |||
485 | //+++++++++++++++++++++++++++ |
||
486 | // max. der BL's ermitteln |
||
487 | //+++++++++++++++++++++++++++ |
||
488 | calc_BLmax( &blmax ); |
||
489 | |||
490 | ScrollBox_Push_P( MINVERS, PSTR(" BL Data") ); |
||
491 | |||
492 | //--------------------------- |
||
493 | // Basisanzeige der Stat-Liste |
||
494 | //--------------------------- |
||
495 | add_statistic_head(); |
||
496 | |||
497 | //--------------------------- |
||
498 | // max. Current |
||
499 | //--------------------------- |
||
500 | ScrollBox_Push_P( MNORMAL, PSTR("%cCurrent%6.1d A"), SYMBOL_MAX, Config.OSD_Statistic.max_Current ); |
||
501 | |||
502 | //--------------------------- |
||
503 | // avg. Current |
||
504 | //--------------------------- |
||
505 | ScrollBox_Push_P( MNORMAL, PSTR("%cCurrent%6.1d A"), SYMBOL_AVG, (uint8_t)(Config.OSD_Statistic.avg_Current/100) ); |
||
506 | |||
507 | //--------------------------- |
||
508 | // BL-Detected |
||
509 | //--------------------------- |
||
510 | //ScrollBox_Push_P( MNORMAL, PSTR("BL Detected %4d"), Config.OSD_Statistic.BL_Count ); |
||
511 | |||
512 | //--------------------------- |
||
513 | // max. BL-Current |
||
514 | //--------------------------- |
||
515 | ScrollBox_Push_P( MNORMAL, PSTR("%cBL%1d Current%2.1u A"), SYMBOL_MAX, blmax.max_BL_Current_Index+1, blmax.max_BL_Current ); |
||
516 | |||
517 | //--------------------------- |
||
518 | // max. BL-Temp |
||
519 | //--------------------------- |
||
520 | ScrollBox_Push_P( MNORMAL, PSTR("%cBL%1d Temp. %5u %cC" ), SYMBOL_MAX, blmax.max_BL_Temp_Index+1, blmax.max_BL_Temp, SYMBOL_BIGDEGREE ); |
||
521 | |||
522 | |||
523 | //+++++++++++++++++++++++++++ |
||
524 | // TRENNER |
||
525 | //+++++++++++++++++++++++++++ |
||
526 | ScrollBox_PushLine(); |
||
527 | |||
528 | //--------------------------- |
||
529 | // LIST: BL-Data |
||
530 | //--------------------------- |
||
531 | if( Config.OSD_Statistic.BL_Count > 0 ) |
||
532 | { |
||
533 | ScrollBox_Push_P( MINVERS, PSTR(" BL Data") ); |
||
534 | |||
535 | for( i=0; i < Config.OSD_Statistic.BL_Count; i++) |
||
536 | { |
||
537 | ScrollBox_Push_P( MNORMAL, PSTR("%1d:%cCurrent%4.1u A"), (i+1), SYMBOL_MAX, (uint8_t)(Config.OSD_Statistic.BL[i].max_Current) ); |
||
538 | ScrollBox_Push_P( MNORMAL, PSTR(" %cCurrent%4.1u A" ), SYMBOL_AVG, (uint8_t)(Config.OSD_Statistic.BL[i].avg_Current/100) ); |
||
539 | ScrollBox_Push_P( MNORMAL, PSTR(" %cTemp.%8u %cC" ), SYMBOL_MAX, (uint8_t)(Config.OSD_Statistic.BL[i].max_Temp), SYMBOL_BIGDEGREE ); |
||
540 | |||
541 | #ifdef USE_OSD_SCREEN_DEBUG |
||
542 | ScrollBox_Push_P( MNORMAL, PSTR(" RX-Pkg.%7u"), Config.OSD_Statistic.BL[i].count ); |
||
543 | //ScrollBox_Push_P( MNORMAL, PSTR(" MC%12u A" ), Config.OSD_Statistic.BL[i].avg_Current ); |
||
544 | #endif |
||
545 | |||
546 | //+++++++++++++++++++++++++++ |
||
547 | // TRENNER |
||
548 | //+++++++++++++++++++++++++++ |
||
549 | ScrollBox_PushLine(); |
||
550 | } |
||
551 | } |
||
552 | |||
553 | ctrl_osddata( true, INIT_STATISTIC ); |
||
554 | |||
555 | ScrollBox_Destroy(); // free memory |
||
556 | } |
||
557 | |||
558 | |||
559 | |||
560 | //-------------------------------------------------------------- |
||
561 | // zeigt aufgezeichnete Benutzer-GPS-Daten an |
||
562 | //-------------------------------------------------------------- |
||
563 | void OSDDATA_UserGPS( void ) |
||
564 | { |
||
565 | uint8_t i; |
||
566 | uint8_t isdata = 0; |
||
567 | PKTdatetime_t dtlocal; |
||
568 | |||
569 | lcd_cls(); |
||
570 | |||
571 | if( !ScrollBox_Create( (MAX_GPS_USER*4) + 5 ) ) // Speicher reservieren |
||
572 | return; // kein RAM mehr |
||
573 | |||
574 | ScrollBox_Push_P( MINVERS, PSTR(" GPS Userdata") ); |
||
575 | |||
576 | for( i=0; i<MAX_GPS_USER; i++) |
||
577 | { |
||
578 | if( Config.GPS_User[i].GPSData.Latitude != 0) // nur gueltige GPS-Koordinaten anzeigen |
||
579 | { |
||
580 | isdata = 1; |
||
581 | |||
582 | ScrollBox_PushLine(); |
||
583 | |||
584 | //----------------------------------- |
||
585 | // Zeile 1: Nummer / Datum / Zeit |
||
586 | //----------------------------------- |
||
587 | UTCdatetime2local( &dtlocal, &Config.GPS_User[i].timestamp ); |
||
588 | ScrollBox_Push_P( MNORMAL, PSTR("%02u.%02u.%04u %02u:%02u:%02u"), |
||
589 | dtlocal.day, dtlocal.month, dtlocal.year, |
||
590 | (uint16_t)(dtlocal.seconds/3600), (uint16_t)(dtlocal.seconds/60%60), (uint16_t)(dtlocal.seconds%60) |
||
591 | ); |
||
592 | |||
593 | /* |
||
594 | sec = (uint16_t)(Config.GPS_User[i].timestamp.seconds); // Sekunden |
||
595 | ScrollBox_Push_P( MNORMAL, PSTR("%02u.%02u.%04u %02u:%02u:%02u"), |
||
596 | Config.MKErr_Log[i].set_Time.day, Config.MKErr_Log[i].set_Time.month, Config.MKErr_Log[i].set_Time.year, |
||
597 | (uint16_t)(sec/3600), (uint16_t)(sec/60%60), (uint16_t)(sec%60) |
||
598 | ); |
||
599 | |||
600 | // Alternative Anzeige von Datum/Zeit: |
||
601 | min = (uint16_t)(Config.GPS_User[i].timestamp.seconds/60); // Minuten |
||
602 | ScrollBox_Push_P( MNORMAL, PSTR("%02u: %02u:%02u %02u.%02u.%02u"), i+1, |
||
603 | (uint16_t)(min/60), (uint16_t)(min%60), |
||
604 | Config.GPS_User[i].timestamp.day, Config.GPS_User[i].timestamp.month, Config.GPS_User[i].timestamp.year%100 |
||
605 | ); |
||
606 | |||
607 | // Alternative Anzeige von Datum/Zeit: |
||
608 | ScrollBox_Push_P( MNORMAL, PSTR("%02u: %02u:%02u %02u.%02u.%04u"), i+1, |
||
609 | (uint16_t)(min/60), (uint16_t)(min%60), |
||
610 | Config.GPS_User[i].timestamp.day, Config.GPS_User[i].timestamp.month, Config.GPS_User[i].timestamp.year |
||
611 | ); |
||
612 | |||
613 | // Alternative Anzeige von Datum/Zeit: |
||
614 | ScrollBox_Push_P( MNORMAL, PSTR("%02u: %02u.%02u.%04u %02u:%02u"), i+1, |
||
615 | Config.GPS_User[i].timestamp.day, Config.GPS_User[i].timestamp.month, Config.GPS_User[i].timestamp.year, |
||
616 | (uint16_t)(min/60), (uint16_t)(min%60) |
||
617 | ); |
||
618 | */ |
||
619 | //----------------------------------- |
||
620 | // Zeile 2: Hoehe (GPS/Barymetrisch) |
||
621 | //----------------------------------- |
||
622 | ScrollBox_Push_P( MNORMAL, PSTR("%7d mG%5.1d mB"), |
||
623 | (Config.GPS_User[i].GPSData.Altitude/1000), // GPS-Hoehe in m |
||
624 | (Config.GPS_User[i].Altimeter / (3 / AltimeterAdjust)) ); // Barymetrische-Hoehe in dm |
||
625 | |||
626 | //----------------------------------- |
||
627 | // Zeile 3: Koordinaten (Lat/Long) |
||
628 | //----------------------------------- |
||
629 | ScrollBox_Push_P( MNORMAL, PSTR("%3.6ld%3.6ld"), |
||
630 | Config.GPS_User[i].GPSData.Latitude/10, |
||
631 | Config.GPS_User[i].GPSData.Longitude/10 ); |
||
632 | } |
||
633 | } |
||
634 | ScrollBox_PushLine(); |
||
635 | |||
636 | |||
637 | ctrl_osddata( isdata, INIT_USERGPS ); |
||
638 | |||
639 | ScrollBox_Destroy(); // free memory |
||
640 | } |
||
641 | |||
642 | |||
643 | |||
644 | //-------------------------------------------------------------- |
||
645 | // OSDDATA_MkError() |
||
646 | // |
||
647 | // zeigt aufgezeichnete MK-Fehler an |
||
648 | //-------------------------------------------------------------- |
||
649 | void OSDDATA_MkError( void ) |
||
650 | { |
||
651 | uint8_t i; |
||
652 | uint8_t isdata = 0; |
||
653 | PKTdatetime_t dtlocal; |
||
654 | |||
655 | lcd_cls(); |
||
656 | |||
657 | if( !ScrollBox_Create( (MAX_MKERR_LOG*4) + 3 ) ) // Speicher reservieren |
||
658 | return; // kein RAM mehr |
||
659 | |||
660 | ScrollBox_Push_P( MINVERS, PSTR(" MK Errors") ); |
||
661 | |||
662 | for( i=0; i<MAX_MKERR_LOG; i++) |
||
663 | { |
||
664 | if( Config.MKErr_Log[i].Errorcode != 0) // nur vorhandene Errorcodes anzeigen |
||
665 | { |
||
666 | isdata = 1; |
||
667 | |||
668 | ScrollBox_PushLine(); |
||
669 | |||
670 | //----------------------------------- |
||
671 | // Zeile 1: Zeit / Datum |
||
672 | //----------------------------------- |
||
673 | UTCdatetime2local( &dtlocal, &Config.MKErr_Log[i].set_Time ); |
||
674 | ScrollBox_Push_P( MNORMAL, PSTR("%02u:%02u:%02u %02u.%02u.%04u"), |
||
675 | (uint16_t)(dtlocal.seconds/3600), (uint16_t)(dtlocal.seconds/60%60), (uint16_t)(dtlocal.seconds%60), |
||
676 | dtlocal.day, dtlocal.month, dtlocal.year |
||
677 | ); |
||
678 | |||
679 | //----------------------------------- |
||
680 | // Zeile 2: Error Code |
||
681 | //----------------------------------- |
||
682 | ScrollBox_Push_P( MNORMAL, PSTR(" Code %02u"), Config.MKErr_Log[i].Errorcode ); |
||
683 | |||
684 | //----------------------------------- |
||
685 | // Zeile 3: Error Text |
||
686 | //----------------------------------- |
||
687 | ScrollBox_Push_P( MNORMAL, PSTR("%20S"), pgm_read_word(&mkerrortext[Config.MKErr_Log[i].Errorcode]) ); |
||
688 | } |
||
689 | } |
||
690 | ScrollBox_PushLine(); |
||
691 | |||
692 | ctrl_osddata( isdata, INIT_MKERROR ); |
||
693 | |||
694 | ScrollBox_Destroy(); // free memory |
||
695 | } |
||
696 | |||
697 | |||
698 | |||
699 | //-------------------------------------------------------------- |
||
700 | // OSDDATA_ShowLastGPSPosition() |
||
701 | // |
||
702 | // zeigt die letzte aufgezeichnete GPS-Position an. |
||
703 | // Möglichkeit zum loeschen der GPS-Pos ist vorhanden. |
||
704 | //-------------------------------------------------------------- |
||
705 | void OSDDATA_ShowLastGPSPosition( void ) |
||
706 | { |
||
707 | uint8_t redraw = true; |
||
708 | |||
709 | clear_key_all(); |
||
710 | |||
711 | while( true ) |
||
712 | { |
||
713 | //------------------------ |
||
714 | // Screen neu zeichnen |
||
715 | //------------------------ |
||
716 | if( redraw ) |
||
717 | { |
||
718 | PKT_TitlePKT(); // Titel mit PKT-Version anzeigen (und clearcsreen) |
||
719 | |||
720 | lcdx_printp_at(3, 1, strGet(START_LASTPOS) , MNORMAL, 0,4); // "Letzte Position" |
||
721 | lcdx_printp_at(3, 2, strGet(START_LASTPOS3), MNORMAL, 0,4); // "Google Eingabe" |
||
722 | |||
723 | //---- |
||
724 | lcd_frect( 0, (4*7)+4, 127, 7, 1); // Rect: Invers |
||
725 | lcdx_printp_at(1, 3, strGet(START_LASTPOS1), MINVERS, 0,8); // "Breitengr Längengr" |
||
726 | |||
727 | writex_gpspos( 1, 4, Config.LastLatitude , MNORMAL, 0,10); // Anzeige: Breitengrad |
||
728 | writex_gpspos( 12, 4, Config.LastLongitude, MNORMAL, -1,10); // Anzeige: Laengengrad |
||
729 | |||
730 | lcd_rect( 0, (3*8)+7, 127, (2*8)+4, 1); // Rahmen |
||
731 | |||
732 | //lcd_printp_at(0, 7, strGet(START_LASTPOS2), MNORMAL); // Keyline |
||
733 | lcd_printp_at(12, 7, strGet(KEYLINE4) , MNORMAL); // Keyline |
||
734 | lcd_printp_at(18, 7, PSTR("Del") , MNORMAL); // Keyline |
||
735 | |||
736 | redraw = false; |
||
737 | } |
||
738 | |||
739 | |||
740 | //------------------------ |
||
741 | // LiPo Spannung zeigen |
||
742 | //------------------------ |
||
743 | show_Lipo(); |
||
744 | |||
745 | |||
746 | //------------------------ |
||
747 | // Tasten abfragen |
||
748 | //------------------------ |
||
749 | if( get_key_press (1 << KEY_ESC) ) // Ende |
||
750 | { |
||
751 | break; |
||
752 | } |
||
753 | |||
754 | if( (get_key_press (1 << KEY_ENTER)) ) // Del |
||
755 | { |
||
756 | if( ask_delete_data(INIT_LASTPOS) ) |
||
757 | { |
||
758 | set_beep ( 400, 0xffff, BeepNormal); |
||
759 | WriteLastPosition( 0x00000000, 0x00000000 ); // letzte GPS Position loeschen |
||
760 | break; // und beenden |
||
761 | } |
||
762 | redraw = true; |
||
763 | } |
||
764 | |||
765 | |||
766 | //------------------------ |
||
767 | // ggf. auf PKT-Update reagieren |
||
768 | //------------------------ |
||
769 | if( PKT_CtrlHook() ) |
||
770 | { |
||
771 | redraw = true; |
||
772 | } |
||
773 | } |
||
774 | |||
775 | clear_key_all(); |
||
776 | } |
||
777 | |||
778 | |||
779 | |||
780 | |||
781 | //-------------------------------------------------------------- |
||
782 | // OSDDATA_ClearAllData() |
||
783 | // |
||
784 | // löscht alle erhobenen Daten |
||
785 | //-------------------------------------------------------------- |
||
786 | void OSDDATA_ClearAllData( void ) |
||
787 | { |
||
788 | if( ask_delete_data( INIT_ALLDATA ) ) |
||
789 | { |
||
790 | STAT_Init(); |
||
791 | MKErr_Log_Init(); |
||
792 | GPS_User_Init(); // loeschen: User GPS |
||
793 | WriteLastPosition( 0x00000000, 0x00000000 ); // loeschen: letzte GPS Position |
||
794 | |||
795 | set_beep ( 400, 0xffff, BeepNormal); |
||
796 | } |
||
797 | } |
||
798 | |||
799 | |||
800 | |||
801 | //-------------------------------------------------------------- |
||
802 | // Menue fuer osddata |
||
803 | //-------------------------------------------------------------- |
||
804 | #ifdef USE_OSDDATA |
||
805 | void Menu_OSDData( void ) |
||
806 | { |
||
807 | //--------------- |
||
808 | // Create |
||
809 | //--------------- |
||
810 | MenuCtrl_Create(); |
||
811 | MenuCtrl_SetTitleFromParentItem(); // "OSD Daten" |
||
812 | //MenuCtrl_SetTitle_P( PSTR("OSD Daten") ); |
||
813 | //MenuCtrl_SetShowBatt( true ); |
||
814 | |||
815 | |||
816 | //--------------- |
||
817 | // Menuitems |
||
818 | //--------------- |
||
819 | MenuCtrl_PushML2_P( ID_SHOWSTATISTIK , MENU_ITEM, &OSDDATA_Statistics, SHOWSTATISTIK_de , SHOWSTATISTIK_en ); |
||
820 | MenuCtrl_PushML2_P( ID_SHOWBLSTATISTIK, MENU_ITEM, &OSDDATA_StatisticsBL, SHOWBLSTATISTIK_de, SHOWBLSTATISTIK_en ); |
||
821 | MenuCtrl_PushML2_P( ID_SHOWMKERROR , MENU_ITEM, &OSDDATA_MkError, SHOWMKERROR_de , SHOWMKERROR_en ); |
||
822 | MenuCtrl_PushML2_P( ID_SHOWUSERGPS , MENU_ITEM, &OSDDATA_UserGPS, SHOWUSERGPS_de , SHOWUSERGPS_en ); |
||
823 | MenuCtrl_PushML2_P( ID_SHOWLASTGPS , MENU_ITEM, &OSDDATA_ShowLastGPSPosition, SHOWLASTGPS_de , SHOWLASTGPS_en ); |
||
824 | MenuCtrl_PushML2_P( ID_CLEARALLDATA , MENU_ITEM, &OSDDATA_ClearAllData, CLEARALLDATA_de , CLEARALLDATA_en ); |
||
825 | |||
826 | //--------------- |
||
827 | // Control |
||
828 | //--------------- |
||
829 | MenuCtrl_Control( MENUCTRL_EVENT ); |
||
830 | |||
831 | //--------------- |
||
832 | // Destroy |
||
833 | //--------------- |
||
834 | MenuCtrl_Destroy(); |
||
835 | } |
||
836 | #endif |
||
837 | |||
838 |