Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1734 | - | 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 | |||
35 | #include "cpu.h" |
||
36 | #include <avr/io.h> |
||
37 | #include <inttypes.h> |
||
38 | #include <stdlib.h> |
||
39 | #include <avr/pgmspace.h> |
||
40 | #include <avr/wdt.h> |
||
41 | #include <util/delay.h> |
||
42 | |||
43 | #include "main.h" |
||
44 | #include "lcd.h" |
||
45 | #include "parameter.h" |
||
46 | #include "menu.h" |
||
47 | #include "display.h" |
||
48 | #include "debug.h" |
||
49 | #include "timer.h" |
||
50 | #include "osd.h" |
||
51 | #include "motortest.h" |
||
52 | #include "gps.h" |
||
53 | #include "eeprom.h" |
||
54 | #include "setup.h" |
||
55 | #include "uart1.h" |
||
56 | #include "mk-data-structs.h" |
||
57 | #include "Wi232.h" |
||
58 | #include "servo.h" |
||
59 | #include "tools.h" |
||
60 | #include "connect.h" |
||
61 | #include "lipo.h" |
||
62 | #include "messages.h" |
||
63 | #include "bluetooth.h" |
||
64 | #include "followme.h" |
||
65 | #include "stick.h" // MartinR |
||
66 | |||
67 | |||
68 | // #define ITEMS_NC 8 //MartinR: so war es |
||
69 | #define ITEMS_NC 9 //MartinR: |
||
70 | |||
71 | prog_char param_menuitems_nc[ITEMS_NC][NUM_LANG][18]= // zeilen,zeichen+1 |
||
72 | |||
73 | |||
74 | // German, English, French, Netherlands |
||
75 | /* // MartinR: so war es |
||
76 | { |
||
77 | {"OSD ","OSD ","OSD ","OSD "}, |
||
78 | {"3D Lage ","3D angeles ","3D location ","3D locatie "}, |
||
79 | {"MK Display ","MK Display ","MK Display ","MK Display "}, |
||
80 | {"Parameter \x1d","Parameter \x1d","Parameter \x1d","Parameters \x1d"}, |
||
81 | {"Debug Data ","Debug Data ","Debug Data ","Debug Data "}, |
||
82 | {"GPS Info ","GPS Info ","GPS Info ","GPS Info "}, |
||
83 | {"Follow Me ","Follow Me ","Follow Me ","Follow Me "}, |
||
84 | {"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
||
85 | }; |
||
86 | */ |
||
87 | // MartinR: geändert |
||
88 | { |
||
89 | {"Joystick ","Joystick ","Joystick ","Joystick "}, |
||
90 | {"OSD ","OSD ","OSD ","OSD "}, |
||
91 | {"3D Lage ","3D angeles ","3D location ","3D locatie "}, |
||
92 | {"GPS Info ","GPS Info ","GPS Info ","GPS Info "}, |
||
93 | {"Follow Me ","Follow Me ","Follow Me ","Follow Me "}, |
||
94 | {"MK Display ","MK Display ","MK Display ","MK Display "}, |
||
95 | {"Parameter \x1d","Parameter \x1d","Parameter \x1d","Parameter \x1d"}, |
||
96 | {"Debug Data ","Debug Data ","Debug Data ","Debug Data "}, |
||
97 | {"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
||
98 | }; |
||
99 | |||
100 | |||
101 | #define ITEMS_FC 5 |
||
102 | |||
103 | prog_char param_menuitems_fc[ITEMS_FC][NUM_LANG][18]= // zeilen,zeichen+1 |
||
104 | { |
||
105 | {"Joystick ","Joystick ","Joystick ","Joystick "}, |
||
106 | //{"OSD ","OSD ","OSD ","OSD "}, |
||
107 | //{"3D Lage ","3D angeles ","3D location ","3D locatie "}, |
||
108 | //{"GPS Info ","GPS Info ","GPS Info ","GPS Info "}, |
||
109 | //{"Follow Me ","Follow Me ","Follow Me ","Follow Me "}, |
||
110 | {"MK Display ","MK Display ","MK Display ","MK Display "}, |
||
111 | {"Parameter \x1d","Parameter \x1d","Parameter \x1d","Parameter \x1d"}, |
||
112 | {"Debug Data ","Debug Data ","Debug Data ","Debug Data "}, |
||
113 | {"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
||
114 | }; |
||
115 | |||
116 | |||
117 | //#define ITEMS_NO 6 // MartinR: so war es |
||
118 | #define ITEMS_NO 2 // MartinR: |
||
119 | |||
120 | prog_char param_menuitems_no[ITEMS_NO][NUM_LANG][18]= // zeilen,zeichen+1 |
||
121 | /* // MartinR: so war es |
||
122 | { |
||
123 | {"BL-Ctrl. Tester ","BL-Ctrl. Tester ","BL-Ctrl. Tester ","BL-Ctrl. Tester "}, |
||
124 | {"Servo Tester ","Servo Tester ","Servo Tester ","Servo Tester "}, |
||
125 | {"PC BT > Kopter ","PC BT > Kopter ","PC BT > Kopter ","PC BT > Kopter "}, |
||
126 | {"PC USB > Kopter ","PC USB > Kopter ","PC USB > Kopter ","PC USB > Kopter "}, |
||
127 | {"PKT Setup \x1d","PKT Setup \x1d","PKT Setup \x1d","PKT Setup \x1d"}, |
||
128 | {"PKT Version ","PKT Version ","PKT Version ","PKT Versie "}, |
||
129 | }; |
||
130 | */ |
||
131 | // MartinR: geändert |
||
132 | { |
||
133 | {"Joystick ","Joystick ","Joystick ","Joystick "}, |
||
134 | //{"OSD ","OSD ","OSD ","OSD "}, |
||
135 | //{"3D Lage ","3D angeles ","3D location ","3D locatie "}, |
||
136 | //{"GPS Info ","GPS Info ","GPS Info ","GPS Info "}, |
||
137 | //{"Follow Me ","Follow Me ","Follow Me ","Follow Me "}, |
||
138 | //{"MK Display ","MK Display ","MK Display ","MK Display "}, |
||
139 | //{"Parameter \x1d","Parameter \x1d","Parameter \x1d","Parameter \x1d"}, |
||
140 | //{"Debug Data ","Debug Data ","Debug Data ","Debug Data "}, |
||
141 | {"PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d","PKT Tools \x1d"}, |
||
142 | }; |
||
143 | |||
144 | |||
145 | #define ITEMS_CR 9 |
||
146 | |||
147 | prog_char param_copyright[ITEMS_CR][22]= // zeilen,zeichen+1 |
||
148 | { |
||
149 | " ", |
||
150 | "(C) GNU GPL License ", |
||
151 | " NO WARRANTY ", |
||
152 | " ", |
||
153 | "2008 Thomas Kaiser ", |
||
154 | "2009-2010 Peter Mack ", |
||
155 | "2010 Sebastian Boehm ", |
||
156 | "2012 Chr. Brandtner &", |
||
157 | " Harald Bongartz ", |
||
158 | }; |
||
159 | |||
160 | |||
161 | //-------------------------------------------------------------- |
||
162 | // print cursor |
||
163 | void menu_set_cursor (uint8_t before, uint8_t line, uint8_t pos) |
||
164 | { |
||
165 | lcd_printp_at (pos, before, PSTR(" "), 0); |
||
166 | lcd_printp_at (pos, line, PSTR("\x1d"), 0); |
||
167 | } |
||
168 | |||
169 | |||
170 | // F�r Seting-Auswahl ------------------------------------------ |
||
171 | // |
||
172 | uint8_t menu_choose (uint8_t min, uint8_t max, uint8_t pos, uint8_t start) |
||
173 | { |
||
174 | uint8_t line = start; |
||
175 | uint8_t before = start; |
||
176 | |||
177 | uint8_t k; |
||
178 | |||
179 | menu_set_cursor (line, line, pos); |
||
180 | |||
181 | do |
||
182 | { |
||
183 | if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
184 | { |
||
185 | if (line < max) |
||
186 | line ++; |
||
187 | else |
||
188 | line = max; |
||
189 | // line = min; // Wenn wiederholen soll |
||
190 | } |
||
191 | |||
192 | if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
193 | { |
||
194 | if (line > min) |
||
195 | line --; |
||
196 | else |
||
197 | line = min; |
||
198 | // line = max; // Wenn wiederholen soll |
||
199 | } |
||
200 | |||
201 | if (line != before) |
||
202 | { |
||
203 | menu_set_cursor (before, line, pos); |
||
204 | before = line; |
||
205 | } |
||
206 | } |
||
207 | while (!(k = get_key_press ((1 << KEY_ENTER) | (1 << KEY_ESC)))); |
||
208 | |||
209 | if (k & (1 << KEY_ESC)) |
||
210 | line = 255; |
||
211 | |||
212 | return line; |
||
213 | } |
||
214 | |||
215 | // F�r Setup und Parameter ------------------------------------------ |
||
216 | // |
||
217 | uint8_t menu_choose2 (uint8_t min, uint8_t max, uint8_t start, uint8_t return_at_start, uint8_t return_at_end) |
||
218 | { |
||
219 | uint8_t pos = 1; |
||
220 | uint8_t line = start; |
||
221 | uint8_t before = start; |
||
222 | |||
223 | uint8_t k; |
||
224 | |||
225 | menu_set_cursor (line, line, pos); |
||
226 | |||
227 | do |
||
228 | { |
||
229 | if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
230 | { |
||
231 | if (line < max) |
||
232 | line ++; |
||
233 | else |
||
234 | { |
||
235 | if(return_at_end == 1) |
||
236 | return 254; |
||
237 | else |
||
238 | line = max; |
||
239 | // line = min; // Wenn wiederholen soll |
||
240 | } |
||
241 | } |
||
242 | |||
243 | if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
244 | { |
||
245 | if (line > min) |
||
246 | line --; |
||
247 | else |
||
248 | { |
||
249 | if(return_at_start == 1) |
||
250 | return 253; |
||
251 | else |
||
252 | line = min; |
||
253 | // line = max; // Wenn wiederholen soll |
||
254 | } |
||
255 | } |
||
256 | |||
257 | if (line != before) |
||
258 | { |
||
259 | menu_set_cursor (before, line, pos); |
||
260 | before = line; |
||
261 | } |
||
262 | } |
||
263 | while (!(k = get_key_press ((1 << KEY_ENTER) | (1 << KEY_ESC)))); |
||
264 | |||
265 | if (k & (1 << KEY_ESC)) |
||
266 | line = 255; |
||
267 | |||
268 | return line; |
||
269 | } |
||
270 | |||
271 | // F�r das Hauptmenue ------------------------------------------ |
||
272 | // |
||
273 | uint8_t menu_choose3 (uint8_t min, uint8_t max,uint8_t start, uint8_t return_at_start, uint8_t return_at_end) |
||
274 | { |
||
275 | uint8_t pos = 1; |
||
276 | uint8_t line = start; |
||
277 | uint8_t before = start; |
||
278 | |||
279 | menu_set_cursor (line, line, pos); |
||
280 | |||
281 | do |
||
282 | { |
||
283 | |||
284 | if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
285 | { |
||
286 | if (line < max) |
||
287 | line ++; |
||
288 | else |
||
289 | { |
||
290 | if(return_at_end == 1) |
||
291 | return 254; |
||
292 | else |
||
293 | line = max; |
||
294 | // line = min; // Wenn wiederholen soll |
||
295 | } |
||
296 | } |
||
297 | |||
298 | if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
299 | { |
||
300 | if (line > min) |
||
301 | line --; |
||
302 | else |
||
303 | { |
||
304 | if(return_at_start == 1) |
||
305 | return 253; |
||
306 | else |
||
307 | line = min; |
||
308 | // line = max; // Wenn wiederholen soll |
||
309 | } |
||
310 | } |
||
311 | |||
312 | if (get_key_long (1 << KEY_ESC)) |
||
313 | { |
||
314 | get_key_press(KEY_ALL); |
||
315 | return 250; |
||
316 | } |
||
317 | |||
318 | if(get_key_long (1 << KEY_ENTER)) |
||
319 | { |
||
320 | get_key_press(KEY_ALL); |
||
321 | return 251; |
||
322 | } |
||
323 | |||
324 | if (get_key_short (1 << KEY_ESC)) |
||
325 | { |
||
326 | get_key_press(KEY_ALL); |
||
327 | return 252; |
||
328 | } |
||
329 | |||
330 | if (line != before) |
||
331 | { |
||
332 | menu_set_cursor (before, line, pos); |
||
333 | before = line; |
||
334 | } |
||
335 | #ifdef HWVERSION3_9 |
||
336 | #ifndef ohne_Lipo // MartinR |
||
337 | show_Lipo(); |
||
338 | #endif |
||
339 | #endif |
||
340 | } |
||
341 | while (!(get_key_short (1 << KEY_ENTER))); |
||
342 | |||
343 | return line; |
||
344 | } |
||
345 | |||
346 | //-------------------------------------------------------------- |
||
347 | // |
||
348 | void main_menu (void) |
||
349 | { |
||
350 | uint8_t ii = 0; |
||
351 | uint8_t offset = 0; |
||
352 | uint8_t size = 0; |
||
353 | uint8_t Save_hardware = 0; |
||
354 | uint8_t dmode = 0; |
||
355 | uint8_t target_pos = 1; |
||
356 | uint8_t val =0; |
||
357 | |||
358 | Save_hardware = hardware; |
||
359 | |||
360 | #ifdef HWVERSION3_9 |
||
361 | #ifndef ohne_Lipo // MartinR |
||
362 | // MartinR: von HAL_HW3_9.c hierher verschoben |
||
363 | ADC_Init(); // ADC für Lipomessung |
||
364 | #endif |
||
365 | #endif |
||
366 | |||
367 | |||
368 | get_key_press(KEY_ALL); |
||
369 | |||
370 | while(1) |
||
371 | { |
||
372 | if (Debug==1) |
||
373 | hardware = NC; |
||
374 | if (Debug==0) |
||
375 | hardware = Save_hardware; |
||
376 | if(hardware == NO) |
||
377 | size = ITEMS_NO ; |
||
378 | if(hardware == NC) |
||
379 | size = ITEMS_NC ; |
||
380 | if(hardware == FC) |
||
381 | size = ITEMS_FC ; |
||
382 | |||
383 | lcd_cls (); |
||
384 | lcd_printp_at (0, 0, PSTR("PKT-Tool FC "), 2); |
||
385 | lcd_printp_at (12, 0, PSTR(FC_Version), 2); |
||
386 | |||
387 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
388 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
389 | // lcd_printp_at (12, 7, PSTR("Aus "), 0); |
||
390 | lcd_puts_at(12, 7, strGet(OFF), 0); |
||
391 | |||
392 | |||
393 | while(2) |
||
394 | { |
||
395 | |||
396 | ii = 0; |
||
397 | if(offset > 0) |
||
398 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
399 | |||
400 | for(ii = 0;ii < 6 ; ii++) |
||
401 | { |
||
402 | if((ii+offset) < size) |
||
403 | { |
||
404 | if(hardware == NC) |
||
405 | lcd_printp_at(3,ii+1,param_menuitems_nc[ii+offset][DisplayLanguage], 0); |
||
406 | else if(hardware == FC) |
||
407 | lcd_printp_at(3,ii+1,param_menuitems_fc[ii+offset][DisplayLanguage], 0); |
||
408 | else |
||
409 | lcd_printp_at(3,ii+1,param_menuitems_no[ii+offset][DisplayLanguage], 0); |
||
410 | } |
||
411 | |||
412 | if((ii == 5)&&(ii+offset < (size-1))) |
||
413 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
414 | #ifdef HWVERSION3_9 |
||
415 | #ifndef ohne_Lipo // MartinR |
||
416 | show_Lipo(); |
||
417 | #endif |
||
418 | #endif |
||
419 | } |
||
420 | |||
421 | if(dmode == 0) |
||
422 | { |
||
423 | if(offset == 0) |
||
424 | { |
||
425 | if(size > 6) |
||
426 | val = menu_choose3 (1, 5, target_pos,0,1); //menu_choose3 (min, max, start, return_at_start, return_at_end) |
||
427 | else |
||
428 | val = menu_choose3 (1, size, target_pos,0,0); |
||
429 | } |
||
430 | else |
||
431 | val = menu_choose3 (2, 5, target_pos,1,1); |
||
432 | } |
||
433 | |||
434 | if(dmode == 1) |
||
435 | { |
||
436 | if(offset+7 > size) |
||
437 | val = menu_choose3 (2, 6, target_pos,1,0); |
||
438 | else |
||
439 | val = menu_choose3 (2, 5, target_pos,1,1); |
||
440 | } |
||
441 | |||
442 | if(val == 254) |
||
443 | { |
||
444 | offset++; |
||
445 | dmode = 1; |
||
446 | target_pos = 5; |
||
447 | } |
||
448 | else if(val == 253) |
||
449 | { |
||
450 | offset--; |
||
451 | dmode = 0; |
||
452 | target_pos = 2; |
||
453 | } |
||
454 | #if defined HWVERSION3_9 |
||
455 | else if(val == 252) |
||
456 | { |
||
457 | |||
458 | lcd_cls(); |
||
459 | // lcd_printp_at (0, 2, PSTR(" PKT ausschalten?"),0); |
||
460 | lcd_puts_at(0, 2, strGet(SHUTDOWN), 0); |
||
461 | // lcd_printp_at (12, 7, PSTR("Nein Ja"),0); |
||
462 | lcd_puts_at(12, 7, strGet(YESNO), 0); |
||
463 | while(1) |
||
464 | { |
||
465 | if (get_key_press (1 << KEY_ENTER)) |
||
466 | clr_V_On(); // Spannung abschalten |
||
467 | |||
468 | if (get_key_short (1 << KEY_ESC)) |
||
469 | { |
||
470 | get_key_press(KEY_ALL); |
||
471 | lcd_cls(); |
||
472 | lcd_printp_at (0, 0, PSTR("PKT-Tool FC "), 2); |
||
473 | lcd_printp_at (12, 0,PSTR(FC_Version), 2); |
||
474 | // show_Lipo(); |
||
475 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
476 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
477 | // lcd_printp_at (12, 7, PSTR("Aus "), 0); |
||
478 | lcd_puts_at(12, 7, strGet(OFF), 0); |
||
479 | break; |
||
480 | } |
||
481 | } |
||
482 | } |
||
483 | else if(val == 251) |
||
484 | { |
||
485 | PC_Fast_Connect(); |
||
486 | return; |
||
487 | } |
||
488 | #endif |
||
489 | else if(val == 250) |
||
490 | { |
||
491 | // Test_HB(); |
||
492 | Test_Language(); |
||
493 | return; |
||
494 | } |
||
495 | else |
||
496 | break; |
||
497 | } |
||
498 | |||
499 | target_pos = val; |
||
500 | // MartinR: !!!!!!!!!!!!!!!!!!! |
||
501 | #ifdef HWVERSION3_9 |
||
502 | if(hardware == NC) |
||
503 | { |
||
504 | if((val+offset) == 1 ) |
||
505 | joystick(); |
||
506 | if((val+offset) == 2 ) |
||
507 | osd(OSD_Mode); |
||
508 | if((val+offset) == 3 ) |
||
509 | osd(THREE_D_Mode); |
||
510 | if((val+offset) == 4 ) |
||
511 | gps(); |
||
512 | if((val+offset) == 5 ) |
||
513 | FollowMe(); |
||
514 | if((val+offset) == 6 ) |
||
515 | display_data(); |
||
516 | if((val+offset) == 7 ) |
||
517 | edit_parameter(); |
||
518 | |||
519 | if((val+offset) == 8 ) |
||
520 | //TODO: Debug an FC087 anpassen |
||
521 | display_debug(); |
||
522 | |||
523 | if((val+offset) == 9 ) |
||
524 | PKT_Tools(); |
||
525 | } |
||
526 | #endif |
||
527 | |||
528 | if(hardware == FC) |
||
529 | { |
||
530 | if((val+offset) == 1 ) |
||
531 | joystick(); |
||
532 | if((val+offset) == 2 ) |
||
533 | display_data(); |
||
534 | if((val+offset) == 3 ) |
||
535 | edit_parameter(); |
||
536 | if((val+offset) == 4 ) |
||
537 | //TODO: Debug an FC087 anpassen |
||
538 | display_debug(); |
||
539 | if((val+offset) == 5 ) |
||
540 | PKT_Tools(); |
||
541 | } |
||
542 | |||
543 | |||
544 | if(hardware == NO) |
||
545 | { |
||
546 | /* // MartinR: so war es |
||
547 | if((val+offset) == 1 ) |
||
548 | motor_test(FC_Mode); |
||
549 | if((val+offset) == 2 ) |
||
550 | servo_test(); |
||
551 | #ifdef HWVERSION3_9 |
||
552 | if (U02SV2 == 0) |
||
553 | { |
||
554 | if((val+offset) == 3 ) |
||
555 | { |
||
556 | if (BTIsSlave==true) |
||
557 | { |
||
558 | Port_BT2Wi(); |
||
559 | } |
||
560 | else |
||
561 | { |
||
562 | bt_set_mode(BLUETOOTH_SLAVE); |
||
563 | Port_BT2Wi(); |
||
564 | } |
||
565 | } |
||
566 | if((val+offset) == 4 ) |
||
567 | Port_USB2Wi(); |
||
568 | } |
||
569 | else if (U02SV2 == 1) |
||
570 | { |
||
571 | if((val+offset) == 3 ) |
||
572 | |||
573 | { |
||
574 | if (BTIsSlave==true) |
||
575 | { |
||
576 | Port_BT2FC(); |
||
577 | } |
||
578 | else |
||
579 | { |
||
580 | bt_set_mode(BLUETOOTH_SLAVE); |
||
581 | Port_BT2FC(); |
||
582 | |||
583 | } |
||
584 | } |
||
585 | |||
586 | if((val+offset) == 4 ) |
||
587 | Port_USB2FC(); |
||
588 | } |
||
589 | #else |
||
590 | if((val+offset) == 3 ) |
||
591 | Show_Error_HW(); |
||
592 | if((val+offset) == 4 ) |
||
593 | Show_Error_HW(); |
||
594 | #endif |
||
595 | if((val+offset) == 5 ) |
||
596 | PKT_Setup(); |
||
597 | if((val+offset) == 6 ) |
||
598 | Show_Version(); |
||
599 | */ |
||
600 | if((val+offset) == 1 ) |
||
601 | joystick(); |
||
602 | if((val+offset) == 2 ) |
||
603 | PKT_Tools(); |
||
604 | } |
||
605 | |||
606 | |||
607 | } |
||
608 | } |
||
609 | |||
610 | |||
611 | //-------------------------------------------------------------- |
||
612 | // |
||
613 | void Update_PKT (void) |
||
614 | { |
||
615 | lcd_cls(); |
||
616 | lcd_printp_at (0, 0, PSTR(" PKT Update "),2); |
||
617 | // lcd_printp_at (0, 1, PSTR("Connect PC to PKT-USB"),0); |
||
618 | lcd_puts_at(0, 1, strGet(UPDATE1), 0); |
||
619 | // lcd_printp_at (0, 2, PSTR("Press 'Start' on PKT "),0); |
||
620 | lcd_puts_at(0, 2, strGet(UPDATE2), 0); |
||
621 | lcd_printp_at (0, 3, PSTR("Start avrdude.exe "),0); |
||
622 | lcd_printp_at (0, 4, PSTR("-pm1284p -cavr109 "),0); |
||
623 | lcd_printp_at (0, 5, PSTR("-Pcom? -b115200 "),0); |
||
624 | lcd_printp_at (0, 6, PSTR("-Uflash:w:FILE.hex:a "),0); |
||
625 | // avrdude -pm1284p -cavr109 -P/dev/ttyUSB1 -b115200 -V -Uflash:w:Dateiname.hex:a |
||
626 | |||
627 | // lcd_printp_at (0, 7, PSTR(" Ende Start"), 0); |
||
628 | lcd_puts_at(0, 7, strGet(ENDSTART), 0); |
||
629 | |||
630 | do |
||
631 | { |
||
632 | if (get_key_press (1 << KEY_ESC)) |
||
633 | { |
||
634 | get_key_press(KEY_ALL); |
||
635 | return; |
||
636 | } |
||
637 | } |
||
638 | while (!(get_key_press (1 << KEY_ENTER))); |
||
639 | { |
||
640 | |||
641 | // start bootloader with Reset, Hold KEY_ENTER*/ |
||
642 | wdt_enable( WDTO_250MS ); |
||
643 | while (1) |
||
644 | {;} |
||
645 | } |
||
646 | } |
||
647 | |||
648 | |||
649 | //-------------------------------------------------------------- |
||
650 | // |
||
651 | void Show_Error_HW (void) |
||
652 | { |
||
653 | lcd_cls (); |
||
654 | lcd_printp_at (0, 2, PSTR(" Mit dieser Hardware"), 0); |
||
655 | lcd_printp_at (0, 3, PSTR(" nicht möglich!"), 0); |
||
656 | lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
657 | |||
658 | while (!get_key_press (1 << KEY_ESC)); |
||
659 | get_key_press(KEY_ALL); |
||
660 | return; |
||
661 | } |
||
662 | |||
663 | |||
664 | //-------------------------------------------------------------- |
||
665 | // |
||
666 | void Show_Version (void) |
||
667 | { |
||
668 | uint8_t ii = 0; |
||
669 | uint8_t size = ITEMS_CR; |
||
670 | uint8_t page = 0; |
||
671 | |||
672 | lcd_cls (); |
||
673 | |||
674 | lcd_printp_at (0, 0, PSTR("PKT Tool V. "), 2); |
||
675 | lcd_printp_at (13,0, PSTR(PKTSWVersion),2); |
||
676 | // lcdPuts(Msg(MSG_VERSION1)); |
||
677 | // lcd_printp_at (0, 0, Msg(MSG_VERSION1), 2); |
||
678 | // lcd_printp_at (0, 1, PSTR("für FC ver "), 2); |
||
679 | // lcd_printp_at (12,1, PSTR(FC_Version),2); |
||
680 | lcd_printp_at (0, 1, PSTR(" "), 2); //um die ganze Zeile schwarz zu füllen. |
||
681 | lcd_puts_at(0, 1, strGet(START_MSG2), 2); |
||
682 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
683 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
684 | |||
685 | while(1) |
||
686 | { |
||
687 | for(ii = 0;ii < 3 ; ii++) |
||
688 | if((ii + page) < size) |
||
689 | lcd_printp_at(0,ii + 3,param_copyright[ii + page], 0); |
||
690 | |||
691 | if (page == 0) |
||
692 | { |
||
693 | lcd_printp_at (0, 2, PSTR(" "), 0); |
||
694 | lcd_printp_at (0, 6, PSTR("\x13"), 0); |
||
695 | } |
||
696 | |||
697 | if (page > 0 && page < (size - 3)) |
||
698 | { |
||
699 | lcd_printp_at (0, 2, PSTR("\x12"), 0); |
||
700 | lcd_printp_at (0, 6, PSTR("\x13"), 0); |
||
701 | } |
||
702 | |||
703 | if (page >= (size - 3)) |
||
704 | { |
||
705 | lcd_printp_at (0, 2, PSTR("\x12"), 0); |
||
706 | lcd_printp_at (0, 6, PSTR(" "), 0); |
||
707 | } |
||
708 | |||
709 | |||
710 | if (get_key_press (1 << KEY_PLUS)) |
||
711 | if (page < size - 3) |
||
712 | page++; |
||
713 | |||
714 | if (get_key_press (1 << KEY_MINUS)) |
||
715 | if (page > 0) |
||
716 | page--; |
||
717 | |||
718 | if (get_key_press (1 << KEY_ESC) || get_key_press (1 << KEY_ENTER)) |
||
719 | { |
||
720 | get_key_press(KEY_ALL); |
||
721 | return; |
||
722 | } |
||
723 | } |
||
724 | } |
||
725 | |||
726 |