Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1917 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
||
5 | * Copyright (C) 2011 Harald Bongartz * |
||
6 | * * |
||
7 | * This program is free software; you can redistribute it and/or modify * |
||
8 | * it under the terms of the GNU General Public License as published by * |
||
9 | * the Free Software Foundation; either version 2 of the License. * |
||
10 | * * |
||
11 | * This program is distributed in the hope that it will be useful, * |
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
14 | * GNU General Public License for more details. * |
||
15 | * * |
||
16 | * You should have received a copy of the GNU General Public License * |
||
17 | * along with this program; if not, write to the * |
||
18 | * Free Software Foundation, Inc., * |
||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
20 | * * |
||
21 | * * |
||
22 | * Credits to: * |
||
23 | * Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
||
24 | * http://www.mikrokopter.de * |
||
25 | * Gregor "killagreg" Stobrawa for his version of the MK code * |
||
26 | * Thomas Kaiser "thkais" for the original project. See * |
||
27 | * http://www.ft-fanpage.de/mikrokopter/ * |
||
28 | * http://forum.mikrokopter.de/topic-4061-1.html * |
||
29 | * Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
||
30 | * http://www.mylifesucks.de/oss/c-osd/ * |
||
31 | * Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
||
32 | *****************************************************************************/ |
||
33 | //############################################################################ |
||
34 | //# HISTORY menu.c |
||
35 | //# |
||
36 | //# 10.03.2013 Cebra |
||
37 | //# - add: menu_select, gemeinsame Routine für alle Setupmenüs |
||
38 | //############################################################################ |
||
39 | |||
40 | #include "cpu.h" |
||
41 | #include <avr/io.h> |
||
42 | #include <inttypes.h> |
||
43 | #include <stdlib.h> |
||
44 | #include <avr/pgmspace.h> |
||
45 | #include <avr/wdt.h> |
||
46 | #include <util/delay.h> |
||
47 | |||
48 | #include "main.h" |
||
49 | #include "lcd/lcd.h" |
||
50 | #include "parameter.h" |
||
51 | #include "menu.h" |
||
52 | #include "display.h" |
||
53 | #include "debug.h" |
||
54 | #include "timer/timer.h" |
||
55 | #include "osd/osd.h" |
||
56 | #include "motortest/motortest.h" |
||
57 | #include "gps/gps.h" |
||
58 | #include "eeprom/eeprom.h" |
||
59 | #include "setup/setup.h" |
||
60 | #include "uart/uart1.h" |
||
61 | #include "mk-data-structs.h" |
||
62 | #include "wi232/Wi232.h" |
||
63 | #include "tracking/servo.h" |
||
64 | #include "tools.h" |
||
65 | #include "connect.h" |
||
66 | #include "lipo/lipo.h" |
||
67 | #include "messages.h" |
||
68 | #include "bluetooth/bluetooth.h" |
||
69 | #include "followme/followme.h" |
||
70 | #include "tracking/ng_servo.h" |
||
71 | #include "tracking/tracking.h" |
||
72 | #include "stick/stick.h" |
||
73 | |||
74 | |||
75 | //// Variablen für die Menüsteuerung |
||
76 | uint8_t ii = 0; |
||
77 | uint8_t offset = 0; |
||
78 | uint8_t size = 0; |
||
79 | uint8_t dmode = 0; |
||
80 | uint8_t target_pos = 1; |
||
81 | uint8_t val; |
||
82 | |||
83 | |||
84 | |||
85 | |||
86 | |||
87 | #define ITEMS_NC 9 |
||
88 | |||
89 | const prog_char param_menuitems_nc[ITEMS_NC][NUM_LANG][18]= // zeilen,zeichen+1 |
||
90 | |||
91 | |||
92 | // German, English, French, Netherlands |
||
93 | { |
||
94 | {"OSD ","OSD ","OSD "}, |
||
95 | {"MK Display ","MK Display ","MK Display "}, |
||
96 | {"Tracking ","Tracking ","Tracking "}, |
||
97 | {"Parameter \x1d","Parameter \x1d","Parameters \x1d"}, |
||
98 | {"Debug Data ","Debug Data ","Debug Data "}, |
||
99 | {"GPS Info ","GPS Info ","GPS Info "}, |
||
100 | {"Follow Me ","Follow Me ","Follow Me "}, |
||
101 | {"Joystick ","Joystick ","Joystick "}, |
||
102 | {"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
||
103 | }; |
||
104 | |||
105 | |||
106 | #define ITEMS_FC 5 |
||
107 | |||
108 | const prog_char param_menuitems_fc[ITEMS_FC][NUM_LANG][18]= // zeilen,zeichen+1 |
||
109 | { |
||
110 | {"Joystick ","Joystick ","Joystick "}, // MartinR |
||
111 | {"MK Display ","MK Display ","MK Display "}, |
||
112 | {"Parameter \x1d","Parameter \x1d","Parameter \x1d"}, |
||
113 | {"Debug Data ","Debug Data ","Debug Data "}, |
||
114 | {"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
||
115 | }; |
||
116 | |||
117 | |||
118 | #define ITEMS_NO 6 |
||
119 | |||
120 | const prog_char param_menuitems_no[ITEMS_NO][NUM_LANG][18]= // zeilen,zeichen+1 |
||
121 | { |
||
122 | |||
123 | |||
124 | {"Suche Mikrokopter","search Mikrokopt ","search Mikrokopt "}, |
||
125 | {"BL-Ctrl. Tester ","BL-Ctrl. Tester ","BL-Ctrl. Tester "}, |
||
126 | {"PC BT > Kopter ","PC BT > Kopter ","PC BT > Kopter "}, |
||
127 | {"PC USB > Kopter ","PC USB > Kopter ","PC USB > Kopter "}, |
||
128 | {"PKT Setup \x1d","PKT Setup \x1d","PKT Setup \x1d"}, |
||
129 | {"PKT Version ","PKT Version ","PKT Versie "}, |
||
130 | }; |
||
131 | |||
132 | |||
133 | #define ITEMS_CR 12 |
||
134 | |||
135 | const prog_char param_copyright[ITEMS_CR][22]= // zeilen,zeichen+1 |
||
136 | { |
||
137 | " ", |
||
138 | "(C) GNU GPL License ", |
||
139 | " NO WARRANTY ", |
||
140 | " ", |
||
141 | "2008 Thomas Kaiser ", |
||
142 | "2009-2010 Peter Mack ", |
||
143 | "2010 Sebastian Boehm ", |
||
144 | "2012 Chr. Brandtner &", |
||
145 | " Harald Bongartz ", |
||
146 | "2012 gebad ", |
||
147 | "2012 Martin Runkel ", |
||
148 | "2013 Oliver Gemesi " |
||
149 | }; |
||
150 | |||
151 | uint8_t menu_select(const char menuitem[][NUM_LANG][18],uint8_t size, uint8_t targetpos) |
||
152 | { |
||
153 | |||
154 | ii = 0; |
||
155 | offset = 0; |
||
156 | dmode = 0; |
||
157 | uint8_t target_pos = targetpos; |
||
158 | target_pos = targetpos; |
||
159 | val = 0; |
||
160 | |||
161 | while(2) |
||
162 | { |
||
163 | ii = 0; |
||
164 | if(offset > 0) |
||
165 | { |
||
166 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
167 | } |
||
168 | for(ii = 0;ii < 6 ; ii++) |
||
169 | { |
||
170 | if((ii+offset) < size) |
||
171 | { |
||
172 | lcd_printp_at(3,ii+1,menuitem[ii+offset][Config.DisplayLanguage], 0); |
||
173 | } |
||
174 | if((ii == 5)&&(ii+offset < (size-1))) |
||
175 | { |
||
176 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
177 | } |
||
178 | } |
||
179 | if(dmode == 0) |
||
180 | { |
||
181 | if(offset == 0) |
||
182 | { |
||
183 | if(size > 6) |
||
184 | { |
||
185 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
186 | } |
||
187 | else |
||
188 | { |
||
189 | val = menu_choose2 (1, size, target_pos,0,0); |
||
190 | } |
||
191 | } |
||
192 | else |
||
193 | { |
||
194 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
195 | } |
||
196 | } |
||
197 | if(dmode == 1) |
||
198 | { |
||
199 | if(offset+7 > size) |
||
200 | { |
||
201 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
202 | } |
||
203 | else |
||
204 | { |
||
205 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
206 | } |
||
207 | } |
||
208 | if(val == 254) |
||
209 | { |
||
210 | offset++; |
||
211 | dmode = 1; |
||
212 | target_pos = 5; |
||
213 | } |
||
214 | else if(val == 253) |
||
215 | { |
||
216 | offset--; |
||
217 | dmode = 0; |
||
218 | target_pos = 2; |
||
219 | } |
||
220 | else if(val == 255) |
||
221 | { |
||
222 | break; |
||
223 | } |
||
224 | else |
||
225 | { |
||
226 | break; |
||
227 | } |
||
228 | |||
229 | } |
||
230 | |||
231 | |||
232 | return val; |
||
233 | |||
234 | } |
||
235 | |||
236 | //-------------------------------------------------------------- |
||
237 | // print cursor |
||
238 | void menu_set_cursor (uint8_t before, uint8_t line, uint8_t pos) |
||
239 | { |
||
240 | lcd_printp_at (pos, before, PSTR(" "), 0); |
||
241 | lcd_printp_at (pos, line, PSTR("\x1d"), 0); |
||
242 | } |
||
243 | |||
244 | |||
245 | // F�r Seting-Auswahl ------------------------------------------ |
||
246 | // |
||
247 | uint8_t menu_choose (uint8_t min, uint8_t max, uint8_t pos, uint8_t start) |
||
248 | { |
||
249 | uint8_t line = start; |
||
250 | uint8_t before = start; |
||
251 | |||
252 | uint8_t k; |
||
253 | |||
254 | menu_set_cursor (line, line, pos); |
||
255 | |||
256 | do |
||
257 | { |
||
258 | if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
259 | { |
||
260 | if (line < max) |
||
261 | line ++; |
||
262 | else |
||
263 | line = max; |
||
264 | // line = min; // Wenn wiederholen soll |
||
265 | } |
||
266 | |||
267 | if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
268 | { |
||
269 | if (line > min) |
||
270 | line --; |
||
271 | else |
||
272 | line = min; |
||
273 | // line = max; // Wenn wiederholen soll |
||
274 | } |
||
275 | |||
276 | if (line != before) |
||
277 | { |
||
278 | menu_set_cursor (before, line, pos); |
||
279 | before = line; |
||
280 | } |
||
281 | } |
||
282 | while (!(k = get_key_press ((1 << KEY_ENTER) | (1 << KEY_ESC)))); |
||
283 | |||
284 | if (k & (1 << KEY_ESC)) |
||
285 | line = 255; |
||
286 | |||
287 | return line; |
||
288 | } |
||
289 | |||
290 | // F�r Setup und Parameter ------------------------------------------ |
||
291 | // |
||
292 | uint8_t menu_choose2 (uint8_t min, uint8_t max, uint8_t start, uint8_t return_at_start, uint8_t return_at_end) |
||
293 | { |
||
294 | uint8_t pos = 1; |
||
295 | uint8_t line = start; |
||
296 | uint8_t before = start; |
||
297 | |||
298 | uint8_t k; |
||
299 | |||
300 | menu_set_cursor (line, line, pos); |
||
301 | |||
302 | do |
||
303 | { |
||
304 | if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
305 | { |
||
306 | if (line < max) |
||
307 | line ++; |
||
308 | else |
||
309 | { |
||
310 | if(return_at_end == 1) |
||
311 | return 254; |
||
312 | else |
||
313 | line = max; |
||
314 | // line = min; // Wenn wiederholen soll |
||
315 | } |
||
316 | } |
||
317 | |||
318 | if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
319 | { |
||
320 | if (line > min) |
||
321 | line --; |
||
322 | else |
||
323 | { |
||
324 | if(return_at_start == 1) |
||
325 | return 253; |
||
326 | else |
||
327 | line = min; |
||
328 | // line = max; // Wenn wiederholen soll |
||
329 | } |
||
330 | } |
||
331 | |||
332 | if (line != before) |
||
333 | { |
||
334 | menu_set_cursor (before, line, pos); |
||
335 | before = line; |
||
336 | } |
||
337 | } |
||
338 | while (!(k = get_key_press ((1 << KEY_ENTER) | (1 << KEY_ESC)))); |
||
339 | |||
340 | if (k & (1 << KEY_ESC)) |
||
341 | line = 255; |
||
342 | |||
343 | return line; |
||
344 | } |
||
345 | |||
346 | // F�r das Hauptmenue ------------------------------------------ |
||
347 | // |
||
348 | uint8_t menu_choose3 (uint8_t min, uint8_t max,uint8_t start, uint8_t return_at_start, uint8_t return_at_end) |
||
349 | { |
||
350 | uint8_t pos = 1; |
||
351 | uint8_t line = start; |
||
352 | uint8_t before = start; |
||
353 | |||
354 | menu_set_cursor (line, line, pos); |
||
355 | |||
356 | do |
||
357 | { |
||
358 | |||
359 | if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
360 | { |
||
361 | if (line < max) |
||
362 | line ++; |
||
363 | else |
||
364 | { |
||
365 | if(return_at_end == 1) |
||
366 | return 254; |
||
367 | else |
||
368 | line = max; |
||
369 | // line = min; // Wenn wiederholen soll |
||
370 | } |
||
371 | } |
||
372 | |||
373 | if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
374 | { |
||
375 | if (line > min) |
||
376 | line --; |
||
377 | else |
||
378 | { |
||
379 | if(return_at_start == 1) |
||
380 | return 253; |
||
381 | else |
||
382 | line = min; |
||
383 | // line = max; // Wenn wiederholen soll |
||
384 | } |
||
385 | } |
||
386 | |||
387 | if (get_key_long (1 << KEY_ESC)) |
||
388 | { |
||
389 | get_key_press(KEY_ALL); |
||
390 | return 250; |
||
391 | } |
||
392 | |||
393 | if(get_key_long (1 << KEY_ENTER)) |
||
394 | { |
||
395 | get_key_press(KEY_ALL); |
||
396 | return 251; |
||
397 | } |
||
398 | |||
399 | if (get_key_short (1 << KEY_ESC)) |
||
400 | { |
||
401 | get_key_press(KEY_ALL); |
||
402 | return 252; |
||
403 | } |
||
404 | |||
405 | if (line != before) |
||
406 | { |
||
407 | menu_set_cursor (before, line, pos); |
||
408 | before = line; |
||
409 | } |
||
410 | #ifdef HWVERSION3_9 |
||
411 | show_Lipo(); |
||
412 | #endif |
||
413 | } |
||
414 | while (!(get_key_short (1 << KEY_ENTER))); |
||
415 | |||
416 | return line; |
||
417 | } |
||
418 | |||
419 | //-------------------------------------------------------------- |
||
420 | // |
||
421 | void main_menu (void) |
||
422 | { |
||
423 | uint8_t ii = 0; |
||
424 | uint8_t offset = 0; |
||
425 | uint8_t size = 0; |
||
426 | uint8_t Save_hardware = 0; |
||
427 | uint8_t dmode = 0; |
||
428 | uint8_t target_pos = 1; |
||
429 | uint8_t val =0; |
||
430 | |||
431 | Save_hardware = hardware; |
||
432 | |||
433 | get_key_press(KEY_ALL); |
||
434 | |||
435 | while(1) |
||
436 | { |
||
437 | if (Config.Debug==1) |
||
438 | hardware = NC; |
||
439 | if (Config.Debug==0) |
||
440 | hardware = Save_hardware; |
||
441 | if(hardware == NO) |
||
442 | size = ITEMS_NO ; |
||
443 | if(hardware == NC) |
||
444 | size = ITEMS_NC ; |
||
445 | if(hardware == FC) |
||
446 | size = ITEMS_FC ; |
||
447 | |||
448 | lcd_cls (); |
||
449 | lcd_printp_at (0, 0, PSTR("PKT-Tool FC "), 2); |
||
450 | lcd_printp_at (12, 0, PSTR(FC_Version), 2); |
||
451 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
452 | lcd_puts_at(12, 7, strGet(OFF), 0); |
||
453 | |||
454 | |||
455 | while(2) |
||
456 | { |
||
457 | |||
458 | ii = 0; |
||
459 | if(offset > 0) |
||
460 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
461 | |||
462 | for(ii = 0;ii < 6 ; ii++) |
||
463 | { |
||
464 | if((ii+offset) < size) |
||
465 | { |
||
466 | if(hardware == NC) |
||
467 | lcd_printp_at(3,ii+1,param_menuitems_nc[ii+offset][Config.DisplayLanguage], 0); |
||
468 | else if(hardware == FC) |
||
469 | lcd_printp_at(3,ii+1,param_menuitems_fc[ii+offset][Config.DisplayLanguage], 0); |
||
470 | else |
||
471 | lcd_printp_at(3,ii+1,param_menuitems_no[ii+offset][Config.DisplayLanguage], 0); |
||
472 | } |
||
473 | |||
474 | if((ii == 5)&&(ii+offset < (size-1))) |
||
475 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
476 | |||
477 | show_Lipo(); |
||
478 | |||
479 | } |
||
480 | |||
481 | if(dmode == 0) |
||
482 | { |
||
483 | if(offset == 0) |
||
484 | { |
||
485 | if(size > 6) |
||
486 | val = menu_choose3 (1, 5, target_pos,0,1); //menu_choose3 (min, max, start, return_at_start, return_at_end) |
||
487 | else |
||
488 | val = menu_choose3 (1, size, target_pos,0,0); |
||
489 | } |
||
490 | else |
||
491 | val = menu_choose3 (2, 5, target_pos,1,1); |
||
492 | } |
||
493 | |||
494 | if(dmode == 1) |
||
495 | { |
||
496 | if(offset+7 > size) |
||
497 | val = menu_choose3 (2, 6, target_pos,1,0); |
||
498 | else |
||
499 | val = menu_choose3 (2, 5, target_pos,1,1); |
||
500 | } |
||
501 | |||
502 | if(val == 254) |
||
503 | { |
||
504 | offset++; |
||
505 | dmode = 1; |
||
506 | target_pos = 5; |
||
507 | } |
||
508 | else if(val == 253) |
||
509 | { |
||
510 | offset--; |
||
511 | dmode = 0; |
||
512 | target_pos = 2; |
||
513 | } |
||
514 | |||
515 | else if(val == 252) |
||
516 | { |
||
517 | |||
518 | lcd_cls(); |
||
519 | // lcd_printp_at (0, 2, PSTR(" PKT ausschalten?"),0); |
||
520 | lcd_puts_at(0, 2, strGet(SHUTDOWN), 0); |
||
521 | // lcd_printp_at (12, 7, PSTR("Nein Ja"),0); |
||
522 | lcd_puts_at(12, 7, strGet(YESNO), 0); |
||
523 | while(1) |
||
524 | { |
||
525 | if (get_key_press (1 << KEY_ENTER)) |
||
526 | { |
||
527 | WriteParameter(); // am Ende alle Parameter sichern |
||
528 | clr_V_On(); // Spannung abschalten |
||
529 | } |
||
530 | |||
531 | if (get_key_short (1 << KEY_ESC)) |
||
532 | { |
||
533 | get_key_press(KEY_ALL); |
||
534 | lcd_cls(); |
||
535 | lcd_printp_at (0, 0, PSTR("PKT-Tool FC "), 2); |
||
536 | lcd_printp_at (12, 0,PSTR(FC_Version), 2); |
||
537 | // show_Lipo(); |
||
538 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
539 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
540 | // lcd_printp_at (12, 7, PSTR("Aus "), 0); |
||
541 | lcd_puts_at(12, 7, strGet(OFF), 0); |
||
542 | break; |
||
543 | } |
||
544 | } |
||
545 | } |
||
546 | else if(val == 251) |
||
547 | { |
||
548 | PC_Fast_Connect(); |
||
549 | return; |
||
550 | } |
||
551 | |||
552 | else if(val == 250) |
||
553 | { |
||
554 | // Test_HB(); |
||
555 | // Test_Language(); |
||
556 | return; |
||
557 | } |
||
558 | else |
||
559 | break; |
||
560 | } |
||
561 | |||
562 | target_pos = val; |
||
563 | |||
564 | |||
565 | if(hardware == NC) |
||
566 | { |
||
567 | if((val+offset) == 1 ) |
||
568 | osd(OSD_Mode); |
||
569 | if((val+offset) == 2 ) |
||
570 | display_data(); |
||
571 | if((val+offset) == 3 ) |
||
572 | PKT_tracking(); |
||
573 | if((val+offset) == 4 ) |
||
574 | edit_parameter(); |
||
575 | #ifdef HWVERSION3_9 |
||
576 | if((val+offset) == 5 ) |
||
577 | |||
578 | #ifdef analognames |
||
579 | display_debug(); |
||
580 | #else |
||
581 | { |
||
582 | copy_line(7); |
||
583 | lcd_printp_at (0, 7, PSTR(" not possible "),0); |
||
584 | _delay_ms(1000); |
||
585 | paste_line(7); |
||
586 | } |
||
587 | #endif |
||
588 | if((val+offset) == 6 ) |
||
589 | gps(); |
||
590 | #endif |
||
591 | |||
592 | if((val+offset) == 7 ) |
||
593 | FollowMe(); |
||
594 | |||
595 | if((val+offset) == 8 ) |
||
596 | joystick(); |
||
597 | if((val+offset) == 9 ) |
||
598 | PKT_Tools(); |
||
599 | |||
600 | } |
||
601 | |||
602 | |||
603 | if(hardware == FC) |
||
604 | { |
||
605 | if((val+offset) == 1 ) |
||
606 | joystick(); |
||
607 | if((val+offset) == 2 ) |
||
608 | display_data(); |
||
609 | if((val+offset) == 3 ) |
||
610 | edit_parameter(); |
||
611 | if((val+offset) == 4 ) |
||
612 | #ifdef analognames |
||
613 | display_debug(); |
||
614 | #else |
||
615 | { |
||
616 | copy_line(7); |
||
617 | lcd_printp_at (0, 7, PSTR(" not possible "),0); |
||
618 | _delay_ms(1000); |
||
619 | paste_line(7); |
||
620 | } |
||
621 | #endif |
||
622 | |||
623 | if((val+offset) == 4 ) |
||
624 | PKT_Tools(); |
||
625 | |||
626 | } |
||
627 | |||
628 | |||
629 | if(hardware == NO) |
||
630 | { |
||
631 | if((val+offset) == 1 ) |
||
632 | if (searchMK()){ |
||
633 | Save_hardware = hardware; |
||
634 | continue; |
||
635 | } |
||
636 | |||
637 | if((val+offset) == 2 ) |
||
638 | motor_test(FC_Mode); |
||
639 | |||
640 | #ifdef HWVERSION3_9 |
||
641 | if (Config.U02SV2 == 0) |
||
642 | { |
||
643 | if((val+offset) == 3 ) |
||
644 | Port_BT2Wi(); |
||
645 | if((val+offset) == 4 ) |
||
646 | Port_USB2Wi(); |
||
647 | } |
||
648 | else if (Config.U02SV2 == 1) |
||
649 | { |
||
650 | if((val+offset) == 3 ) |
||
651 | Port_BT2FC(); |
||
652 | if((val+offset) == 4 ) |
||
653 | Port_USB2FC(); |
||
654 | } |
||
655 | #else |
||
656 | if((val+offset) == 3 ) |
||
657 | Show_Error_HW(); |
||
658 | if((val+offset) == 4 ) |
||
659 | Show_Error_HW(); |
||
660 | #endif |
||
661 | if((val+offset) == 5 ) |
||
662 | PKT_Setup(); |
||
663 | if((val+offset) == 6 ) |
||
664 | Show_Version(); |
||
665 | |||
666 | } |
||
667 | |||
668 | |||
669 | } |
||
670 | } |
||
671 | |||
672 | |||
673 | //-------------------------------------------------------------- |
||
674 | // |
||
675 | void Update_PKT (void) |
||
676 | { |
||
677 | lcd_cls(); |
||
678 | lcd_printp_at (0, 0, PSTR(" PKT Update "),2); |
||
679 | lcd_puts_at(0, 1, strGet(UPDATE1), 0); |
||
680 | lcd_puts_at(0, 2, strGet(UPDATE2), 0); |
||
681 | lcd_printp_at (0, 3, PSTR("Start avrdude.exe "),0); |
||
682 | lcd_printp_at (0, 4, PSTR("-pm1284p -cavr109 "),0); |
||
683 | lcd_printp_at (0, 5, PSTR("-Pcom? -b115200 "),0); |
||
684 | lcd_printp_at (0, 6, PSTR("-Uflash:w:FILE.hex:a "),0); |
||
685 | lcd_puts_at(0, 7, strGet(ENDSTART), 0); |
||
686 | |||
687 | do |
||
688 | { |
||
689 | if (get_key_press (1 << KEY_ESC)) |
||
690 | { |
||
691 | get_key_press(KEY_ALL); |
||
692 | return; |
||
693 | } |
||
694 | } |
||
695 | while (!(get_key_press (1 << KEY_ENTER))); |
||
696 | { |
||
697 | |||
698 | // start bootloader with Reset, Hold KEY_ENTER*/ |
||
699 | wdt_enable( WDTO_250MS ); |
||
700 | while (1) |
||
701 | {;} |
||
702 | } |
||
703 | } |
||
704 | |||
705 | |||
706 | //-------------------------------------------------------------- |
||
707 | // |
||
708 | void Show_Error_HW (void) |
||
709 | { |
||
710 | lcd_cls (); |
||
711 | lcd_printp_at (0, 2, PSTR(" Mit dieser Hardware"), 0); |
||
712 | lcd_printp_at (0, 3, PSTR(" nicht möglich!"), 0); |
||
713 | lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
714 | |||
715 | while (!get_key_press (1 << KEY_ESC)); |
||
716 | get_key_press(KEY_ALL); |
||
717 | return; |
||
718 | } |
||
719 | |||
720 | |||
721 | //-------------------------------------------------------------- |
||
722 | // |
||
723 | void Show_Version (void) |
||
724 | { |
||
725 | uint8_t ii = 0; |
||
726 | uint8_t size = ITEMS_CR; |
||
727 | uint8_t page = 0; |
||
728 | |||
729 | lcd_cls (); |
||
730 | |||
731 | lcd_printp_at (0, 0, PSTR("PKT Tool V. "), 2); |
||
732 | lcd_printp_at (13,0, PSTR(PKTSWVersion),2); |
||
733 | lcd_printp_at (0, 1, PSTR(" "), 2); //um die ganze Zeile schwarz zu füllen. |
||
734 | lcd_puts_at(0, 1, strGet(START_MSG2), 2); |
||
735 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
736 | |||
737 | while(1) |
||
738 | { |
||
739 | for(ii = 0;ii < 3 ; ii++) |
||
740 | if((ii + page) < size) |
||
741 | lcd_printp_at(0,ii + 3,param_copyright[ii + page], 0); |
||
742 | |||
743 | if (page == 0) |
||
744 | { |
||
745 | lcd_printp_at (0, 2, PSTR(" "), 0); |
||
746 | lcd_printp_at (0, 6, PSTR("\x13"), 0); |
||
747 | } |
||
748 | |||
749 | if (page > 0 && page < (size - 3)) |
||
750 | { |
||
751 | lcd_printp_at (0, 2, PSTR("\x12"), 0); |
||
752 | lcd_printp_at (0, 6, PSTR("\x13"), 0); |
||
753 | } |
||
754 | |||
755 | if (page >= (size - 3)) |
||
756 | { |
||
757 | lcd_printp_at (0, 2, PSTR("\x12"), 0); |
||
758 | lcd_printp_at (0, 6, PSTR(" "), 0); |
||
759 | } |
||
760 | |||
761 | |||
762 | if (get_key_press (1 << KEY_PLUS)) |
||
763 | if (page < size - 3) |
||
764 | page++; |
||
765 | |||
766 | if (get_key_press (1 << KEY_MINUS)) |
||
767 | if (page > 0) |
||
768 | page--; |
||
769 | |||
770 | if (get_key_press (1 << KEY_ESC) || get_key_press (1 << KEY_ENTER)) |
||
771 | { |
||
772 | get_key_press(KEY_ALL); |
||
773 | return; |
||
774 | } |
||
775 | } |
||
776 | } |
||
777 | |||
778 |