Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
730 | woggle | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * * |
||
5 | * This program is free software; you can redistribute it and/or modify * |
||
6 | * it under the terms of the GNU General Public License as published by * |
||
7 | * the Free Software Foundation; either version 2 of the License. * |
||
8 | * * |
||
9 | * This program is distributed in the hope that it will be useful, * |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
12 | * GNU General Public License for more details. * |
||
13 | * * |
||
14 | * You should have received a copy of the GNU General Public License * |
||
15 | * along with this program; if not, write to the * |
||
16 | * Free Software Foundation, Inc., * |
||
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
18 | * * |
||
19 | *****************************************************************************/ |
||
20 | |||
21 | #include <avr/io.h> |
||
22 | #include <avr/pgmspace.h> |
||
23 | #include <util/delay.h> |
||
24 | #include <string.h> |
||
25 | #include <stdlib.h> |
||
26 | |||
27 | #include "main.h" |
||
28 | #include "lcd.h" |
||
29 | #include "timer.h" |
||
30 | #include "usart.h" |
||
31 | #include "parameter.h" |
||
32 | #include "menu.h" |
||
33 | |||
34 | #include "mk-data-structs.h" |
||
35 | |||
36 | #define TIMEOUT 500 // 5 sec |
||
37 | |||
38 | mk_param_struct_t *mk_param_struct; |
||
39 | |||
40 | uint8_t array[8]; |
||
41 | |||
42 | prog_uchar p_menus[12][11]= |
||
43 | { |
||
44 | "Config ", |
||
45 | "Channels ", |
||
46 | "Stick ", |
||
47 | "Hight ", |
||
48 | "Gyro ", |
||
49 | "Looping ", |
||
50 | "Camera ", |
||
51 | "Misc. ", |
||
52 | "User ", |
||
53 | "Coupling ", |
||
54 | "Config(2) ", |
||
55 | "Loopingset" |
||
56 | }; |
||
57 | |||
58 | |||
59 | // Diese Tabelle ordnet die eingelesenen Parameter den Menü-Seiten zu |
||
60 | |||
61 | prog_uchar p_menu_number[67]= |
||
62 | { |
||
63 | 2, 2, 2, 2, 2, 2, 2, 2, // Die ersten 8 Parameter werden auf Menüseite 2 angezeigt (=Kanalzuordnungen) |
||
64 | 0, 4, 4, 4, 4, 4, 4, 3, |
||
65 | 3, 3, 8, 8, 8, 8, 5, 5, |
||
66 | 8,8,8,0,5,9,9,9, |
||
67 | 9,7,7,7,7,7,7,6, |
||
68 | 6,6,10,10,6,6,5,5, |
||
69 | 5,9,9,9,9,0,7,11, |
||
70 | 11,11,11,12,12, 12, |
||
71 | 12,12,12,12,12 |
||
72 | |||
73 | }; |
||
74 | |||
75 | prog_uchar p_limits[199]= // Limits f¸r die Parameter |
||
76 | { |
||
77 | 1,8,2, // 2:Nick (3) |
||
78 | 1,8,2, // 2:Roll (4) |
||
79 | 1,8,2, // 2:Gas (2) |
||
80 | 1,8,2, // 2:Gier (1) |
||
81 | 1,8,2, // 2:Poti1 (6) |
||
82 | 1,8,2, // 2:Poti2 (6) |
||
83 | 1,8,2, // 2:Poti3 (7) |
||
84 | 1,8,2, // 2:Poti4 (5) |
||
85 | 0,0,0, // 1:Config |
||
86 | 0,255,4, // 4:Höhe MinGas (30) |
||
87 | 0,255,4, // 4:Luftdruck_D (30) |
||
88 | 0,255,4, // 4:MaxHöhe (Setpoint?) (Poti4) |
||
89 | 0,255,4, // 4:Höhe_P (10) |
||
90 | 0,50,4, // 4:Höhe Verst‰rkung (3) |
||
91 | 0,255,4, // 4:Höhe Z-acc (30) |
||
92 | 0,6,3, // 3:Nick/Roll P (3) |
||
93 | 0,64,3, // 3:Nick/Roll D (4) |
||
94 | 0,20,3, // 3:Gier_P (6) |
||
95 | 0,32,8, // 8:Min.Gas (15) |
||
96 | 33,250,8, // 8:Max.Gas (250) |
||
97 | 0,50,8, // 5:Gyro-Acc Faktor (30) |
||
98 | 0,255,8, // 8:Kompass-Wirkung (128) |
||
99 | 0,0,5, // 5:Gyro-P (80) |
||
100 | 0,0,5, // 5:Gyro-I (120) |
||
101 | 0,250,8, // 8:Unterspannung (94) |
||
102 | 0,250,8, // 8:Not-Gas Zeit (20) |
||
103 | 0,250,8, // 8:Not-Gas (35) |
||
104 | 0,1,0, // Ufo-Ausrichtung (X +) |
||
105 | 0,255,5, // I-Faktor (32) |
||
106 | 0,255,9, // 9:User1 (80) |
||
107 | 0,255,9, // 9:User2 (0) |
||
108 | 0,255,9, // 9:User3 |
||
109 | 0,255,9, // 9:User4 |
||
110 | 0,255,7, // 7:Servo Nick Control (100) |
||
111 | 0,250,7, // 7:Servo Nick Compensation (40) |
||
112 | 0,250,7, // 7:Servo Nick min (50) |
||
113 | 0,250,7, // 7:Servo Nick max (150) |
||
114 | 0,25,7, // 7:Servo Nick refrsh (5) |
||
115 | 0,255,6, // 6:Loop Gas Limit (50) |
||
116 | 0,250,6, // 6:Loop Ansprechschwelle (90) |
||
117 | 0,250,6, // 6:Loop Hysterese (50) |
||
118 | 0,255,10, // 10:Achskopplung (90) |
||
119 | 0,255,10, // 10:Achsgegenkopplung (5) |
||
120 | 0,250,6, // 6:Turnover Nick (100) |
||
121 | 0,250,6, // 6:Turnover Roll (100) |
||
122 | 0,250,5, // 5: Gyro-Abgleich (Comp.) (32) |
||
123 | 0,250,5, // 5: Drift (4) |
||
124 | 0,255,5, // 5: Dynamic stability (75) |
||
125 | 0,255,9, // 9:User5 |
||
126 | 0,255,9, // 9:User6 |
||
127 | 0,255,9, // 9:User7 |
||
128 | 0,255,9, // 9:User8 (0) |
||
129 | |||
130 | 0,0,1, // 6:Loop Config (0) |
||
131 | 0,1,7 // 7:Servo Nick Compensation Invert (0) |
||
132 | |||
133 | }; |
||
134 | |||
135 | prog_char bin_parameter[12][16] = // Die bin‰r kodierten Parametern werden getrennt behandelt. |
||
136 | { |
||
137 | "Loop up ", |
||
138 | "Loop down ", |
||
139 | "Loop left ", |
||
140 | "Loop right ", |
||
141 | "Höhenregler ", // 8 |
||
142 | "Höhenschalter ", |
||
143 | "Headhold ", |
||
144 | "Kompass ", |
||
145 | "KompassFix ", |
||
146 | "GPS ", |
||
147 | "Achsenkopplung ", |
||
148 | "Drehrate " |
||
149 | }; |
||
150 | |||
151 | prog_char parameter[54][16]= |
||
152 | { |
||
153 | "Nick ", // 0 (3) |
||
154 | "Roll ", // 1 (4) |
||
155 | "Gas ", // (2) |
||
156 | "Gier ", // (1) |
||
157 | "Poti1 ", // (6) |
||
158 | "Poti2 ", // (6) |
||
159 | "Poti3 ", // (7) |
||
160 | "Poti4 ", // 7 (5) |
||
161 | "Config ", // 8 |
||
162 | "Höhe_MinGas ", // 9 (30) |
||
163 | "Luftdruck_D ", // 10 Wert : 0-250 (30) |
||
164 | "MaxHöhe ", // 11 Wert : 0-250 251 -> Poti1 (Poti4) |
||
165 | "Höhe_P ", // 12 Wert : 0-32 (10) |
||
166 | "Höhe_Verstaerk", // 13 Wert : 0-50 |
||
167 | "Höhe_ACC_Wirk.", // 14 Wert : 0-250 (30) |
||
168 | "Stick_P ", // 15 Wert : 1-6 |
||
169 | "Stick_D ", // 16 Wert : 0-64 |
||
170 | "Gier_P ", // 17 Wert : 1-20 POTI(?) |
||
171 | "Gas_Min ", // 17 Wert : 0-32 |
||
172 | "Gas_Max ", // 18 Wert : 33-250 |
||
173 | "GyroAccFaktor ", // 19 Wert : 1-64 |
||
174 | "KompassWirkung ", // 20 Wert : 0-250 |
||
175 | "Gyro_P ", // 21 Wert : 0-250 |
||
176 | "Gyro_I ", // 22 Wert : 0-250 |
||
177 | "Unterspannung ", // 23 Wert : 0-250 |
||
178 | "NotGas ", // 24 Wert : 0-250 // Gaswert bei Empangsverlust |
||
179 | "NotGasZeit ", // 25 Wert : 0-250 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
||
180 | "UfoAusrichtung ", // 26 X oder + Formation |
||
181 | "I_Faktor ", // 27 = 32; |
||
182 | "UserParam1 ", // 28 = 32 * 4; //zur freien Verwendung |
||
183 | "UserParam2 ", // 29 zur freien Verwendung |
||
184 | "UserParam3 ", // 30 zur freien Verwendung |
||
185 | "UserParam4 ", // 31 zur freien Verwendung |
||
186 | "ServoNickCtrl ", // 32 Wert : 0-250 // Stellung des Servos |
||
187 | "ServoNickComp ", // 33 Wert : 0-250 // Einfluss Gyro/Servo |
||
188 | "ServoNickMin ", // 34 Wert : 0-250 // Anschlag |
||
189 | "ServoNickMax ", // 35 Wert : 0-250 // Anschlag |
||
190 | "ServoNickRefrsh", // 36 |
||
191 | "LoopGasLimit ", // 37 |
||
192 | "LoopThreshold ", // 38 Wert: 0-250 Schwelle f¸r Stickausschlag |
||
193 | "LoopHysterese ", // 39 |
||
194 | "AchsKopplung ", // 40 |
||
195 | "AchsGegenKoppl.", // 41 |
||
196 | "WinklUmschlNick", // 42 |
||
197 | "WinklUmschlRoll", // 43 |
||
198 | "GyroAccAbgleich", // 44 1/k |
||
199 | "Driftkomp ", // 45 |
||
200 | "DynamicStabilit", // 47 |
||
201 | "UserParam5 ", // 48 zur freien Verwendung |
||
202 | "UserParam6 ", // 49 zur freien Verwendung |
||
203 | "UserParam7 ", // 50 zur freien Verwendung |
||
204 | "UserParam8 ", // 51 zur freien Verwendung |
||
205 | "LoopConfig ", // 52 Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
||
206 | "ServoNickCompIn" // 53 Wert : 0-250 // Richtung Einfluss Gyro/Servo |
||
207 | // "Name " // 54 |
||
208 | }; |
||
209 | |||
210 | |||
211 | |||
212 | |||
213 | void binary (uint8_t data, uint8_t *feld) // Wandelt eine 8-Bit Zahl in eine Bin‰rzahl um (Array mit 8 Elementen) |
||
214 | { // Wird f¸r die Flags (Loop + Grundkonfiguration) benˆtigt |
||
215 | uint8_t i; |
||
216 | |||
217 | i=0; |
||
218 | for (i = 0; i < 8; i++) |
||
219 | { |
||
220 | if ((1 << i) & data) |
||
221 | feld[i] = 1; |
||
222 | else |
||
223 | feld[i] = 0; |
||
224 | } |
||
225 | } |
||
226 | |||
227 | uint8_t bindec (uint8_t *feld) // wandelt eine Bin‰rzahl (im Array) in eine 8-Bit Zahl |
||
228 | { // Wird f¸r die Flags (Loop + Grundkonfiguration) benˆtigt |
||
229 | uint8_t i; |
||
230 | uint8_t result; |
||
231 | |||
232 | result = 0; |
||
233 | for (i = 0; i < 8; i++) |
||
234 | { |
||
235 | if (feld[i] == 1) |
||
236 | result += 1 << i; |
||
237 | } |
||
238 | return result; |
||
239 | } |
||
240 | |||
241 | |||
242 | |||
243 | |||
244 | void decimal (uint8_t data, uint8_t *text) // wandelt Wert in rechtsbündigen Text um |
||
245 | { // (schneller/kleiner als printf()) |
||
246 | text[0] = data/100; |
||
247 | data -= (text[0] * 100); |
||
248 | text[1] = data/10; |
||
249 | data -= (text[1] *10); |
||
250 | text[2] = data + 0x30; |
||
251 | text[0] += 0x30; |
||
252 | text[1] += 0x30; |
||
253 | |||
254 | if (text[0] == 0x30) |
||
255 | { |
||
256 | text[0] = 0x20; |
||
257 | if (text[1] == 0x30) |
||
258 | text[1] = 0x20; |
||
259 | } |
||
260 | text[3] = 0x00; |
||
261 | } |
||
262 | |||
263 | uint8_t show_parameter (uint8_t number) // Zeigt eine Parameter-Seite an und gibt die ausgew‰hlte Zeile zur¸ck |
||
264 | { |
||
265 | #if 0 |
||
266 | uint8_t i; |
||
267 | uint8_t line; |
||
268 | uint8_t text[25]; |
||
269 | uint8_t bin[8]; |
||
270 | |||
271 | line = 0; |
||
272 | |||
273 | if (number > 1) |
||
274 | { |
||
275 | for (i = 0; i<66; i++) |
||
276 | { |
||
277 | if (pgm_read_byte(p_limits+i*3+2) == number) |
||
278 | { |
||
279 | array[line] = i; |
||
280 | decimal(buffer[i],text); |
||
281 | lcd_print_at(0,line,text,0); |
||
282 | lcd_printp_at (5,line,parameter[i],0); |
||
283 | if (line <= 7) |
||
284 | line++; |
||
285 | } |
||
286 | } |
||
287 | } |
||
288 | else |
||
289 | { // Sonderf‰lle: Bin‰re Eingabe |
||
290 | if (number == 1) |
||
291 | { |
||
292 | binary(buffer[52],bin); // Loop-Config |
||
293 | text[1] = 0x00; |
||
294 | for (i = 0; i < 4; i++) |
||
295 | { |
||
296 | text[0] = bin[i] + 0x30; |
||
297 | lcd_print_at (0, i, text, 0); |
||
298 | lcd_printp_at (5, i, bin_parameter[i], 0); |
||
299 | } |
||
300 | |||
301 | } |
||
302 | if (number == 0) |
||
303 | { |
||
304 | binary (buffer[8], bin); // Config |
||
305 | text[1] = 0x00; |
||
306 | for (i = 0; i < 8; i++) |
||
307 | { |
||
308 | text[0] = bin[i] + 0x30; |
||
309 | lcd_print_at (0, i, text, 0); |
||
310 | lcd_printp_at (5, i, bin_parameter[i + 4], 0); |
||
311 | } |
||
312 | } |
||
313 | |||
314 | |||
315 | } |
||
316 | return line; |
||
317 | #endif |
||
318 | } |
||
319 | |||
320 | void edit_parameter2 (uint8_t page, uint8_t lines) // ƒndern der Parameter einer Seite |
||
321 | { |
||
322 | #if 0 |
||
323 | uint8_t line; |
||
324 | uint8_t par; |
||
325 | uint8_t min; |
||
326 | uint8_t max; |
||
327 | uint8_t text[10]; |
||
328 | uint8_t bin[8]; |
||
329 | |||
330 | if (page > 1) // "normale" Parameter-Seiten |
||
331 | { |
||
332 | line = menu_choose(0,lines-1,4); |
||
333 | if (line != 255) // Wenn line == 255, wurde Escape gedr¸ckt |
||
334 | { |
||
335 | par = buffer[array[line]]; |
||
336 | min = pgm_read_byte(p_limits + par * 3); |
||
337 | max = pgm_read_byte(p_limits + par * 3 + 1); |
||
338 | |||
339 | lcd_printp_at(4,line,PSTR("-"),0); |
||
340 | |||
341 | while (key != key_nokey); |
||
342 | |||
343 | do |
||
344 | { |
||
345 | if (key == key_minus) |
||
346 | { |
||
347 | //if (par > min) // ‹berpr¸fung der Parameter auf Bereichs¸berschreitung derzeit deaktiviert |
||
348 | par --; |
||
349 | } |
||
350 | if (key == key_plus) |
||
351 | { |
||
352 | //if (par < max) |
||
353 | par ++; |
||
354 | } |
||
355 | |||
356 | decimal(par,text); |
||
357 | lcd_print_at(0,line,text,0); |
||
358 | |||
359 | timer = 20; |
||
360 | while (timer > 0); |
||
361 | } |
||
362 | while ((key != 0x04) && (key != 0x08)); |
||
363 | |||
364 | if (key == 0x08) |
||
365 | buffer[array[line]] = par; |
||
366 | } |
||
367 | } |
||
368 | |||
369 | if (page == 1) // Spezialfall: Loop-Config (einzelne Bits setzen / lˆschen) |
||
370 | { |
||
371 | binary(buffer[52],bin); |
||
372 | text[1] = 0x00; |
||
373 | |||
374 | line = menu_choose(0,3,4); |
||
375 | if (line != 255) // Wenn line == 255, wurde Escape gedr¸ckt |
||
376 | { |
||
377 | par = bin[line]; |
||
378 | |||
379 | lcd_printp_at(4,line,PSTR("-"),0); |
||
380 | |||
381 | do |
||
382 | { |
||
383 | |||
384 | if (key == key_minus) |
||
385 | { |
||
386 | par = 0x00; |
||
387 | } |
||
388 | if (key == key_plus) |
||
389 | { |
||
390 | par = 0x01; |
||
391 | } |
||
392 | |||
393 | text[0] = par+0x30; |
||
394 | lcd_print_at(0,line,text,0); |
||
395 | timer = 20; |
||
396 | while (timer > 0); |
||
397 | |||
398 | |||
399 | } |
||
400 | while ((key != key_enter) && (key != key_esc)); |
||
401 | |||
402 | if (key == key_enter) |
||
403 | { |
||
404 | bin[line] = par; |
||
405 | buffer[52] = bindec(bin); |
||
406 | } |
||
407 | |||
408 | lcd_cls(); |
||
409 | decimal(buffer[52],text); |
||
410 | lcd_print(text,0); |
||
411 | timer = 200; |
||
412 | while(timer > 0); |
||
413 | } |
||
414 | } |
||
415 | if (page == 0) // Spezialfall: Allgemeine Konfiguration (einzelne Bits setzen/lˆschen) |
||
416 | { |
||
417 | binary(buffer[8],bin); |
||
418 | text[1] = 0x00; |
||
419 | |||
420 | line = menu_choose(0,7,4); |
||
421 | if (line != 255) // Wenn line == 255, wurde Escape gedr¸ckt |
||
422 | { |
||
423 | par = bin[line]; |
||
424 | |||
425 | lcd_printp_at(4,line,PSTR("-"),0); |
||
426 | |||
427 | do |
||
428 | { |
||
429 | |||
430 | if (key == key_minus) |
||
431 | { |
||
432 | par = 0x00; |
||
433 | } |
||
434 | if (key == key_plus) |
||
435 | { |
||
436 | par = 0x01; |
||
437 | } |
||
438 | |||
439 | text[0] = par+0x30; |
||
440 | lcd_print_at(0,line,text,0); |
||
441 | timer = 20; |
||
442 | while (timer > 0); |
||
443 | |||
444 | |||
445 | } |
||
446 | while ((key != key_enter) && (key != key_esc)); |
||
447 | |||
448 | if (key == key_enter) |
||
449 | { |
||
450 | bin[line] = par; |
||
451 | buffer[8] = bindec(bin); |
||
452 | } |
||
453 | |||
454 | lcd_cls(); |
||
455 | decimal(buffer[8],text); |
||
456 | lcd_print(text,0); |
||
457 | timer = 200; |
||
458 | while(timer > 0); |
||
459 | } |
||
460 | } |
||
461 | #endif |
||
462 | } |
||
463 | |||
464 | |||
465 | void edit_parameter1 (void) |
||
466 | { |
||
467 | uint8_t cmd; |
||
468 | uint8_t setting = 0xff; |
||
469 | |||
470 | mode = 'P'; // Settings |
||
471 | |||
472 | lcd_cls (); |
||
473 | |||
474 | //mode = 'Q'; // Settings |
||
475 | _delay_ms (50); |
||
476 | rxd_buffer_locked = FALSE; |
||
477 | timer = TIMEOUT; |
||
478 | |||
479 | LED2_ON; |
||
480 | //SendOutData ('q', ADDRESS_FC, 1, &setting, 1); |
||
481 | SendOutData ('p', ADDRESS_FC, 1); |
||
482 | while (!rxd_buffer_locked && timer); |
||
483 | if (timer) |
||
484 | { |
||
485 | LED3_ON; |
||
486 | Decode64 (); |
||
487 | #if 0 |
||
488 | mk_param_struct = (mk_param_struct_t *) pRxData + 2; |
||
489 | |||
490 | lcd_printp (PSTR("Current Setting: "), 0); |
||
491 | lcd_write_number_u (*pRxData); |
||
492 | |||
493 | lcd_printp (PSTR("Setting Version: "), 0); |
||
494 | lcd_write_number_u (*pRxData+1); |
||
495 | #endif |
||
496 | LED3_OFF; |
||
497 | } |
||
498 | else |
||
499 | { // timeout occured |
||
500 | lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
||
501 | |||
502 | timer = 100; |
||
503 | while (timer > 0); |
||
504 | return; |
||
505 | } |
||
506 | LED2_OFF; |
||
507 | |||
508 | // after all work is done... |
||
509 | rxd_buffer_locked = FALSE; |
||
510 | |||
511 | #if 0 |
||
512 | uint8_t page; // 12 Pages |
||
513 | uint8_t text[15]; |
||
514 | uint8_t lines; |
||
515 | uint8_t parameter; |
||
516 | |||
517 | lcd_cls (); |
||
518 | |||
519 | lcd_printp (PSTR("Load Setting\r\n"), 0); |
||
520 | lcd_printp (PSTR(" 1:\r\n"), 0); |
||
521 | lcd_printp (PSTR(" 2:\r\n"), 0); |
||
522 | lcd_printp (PSTR(" 3:\r\n"), 0); |
||
523 | lcd_printp (PSTR(" 4:\r\n"), 0); |
||
524 | lcd_printp (PSTR(" 5:\r\n"), 0); |
||
525 | |||
526 | parameter = menu_choose (1, 5, 0); |
||
527 | |||
528 | page = 2; |
||
529 | if (read_parameter (parameter) == 1) |
||
530 | { |
||
531 | lcd_printp_at (0, 6, PSTR("Timeout"), 0); |
||
532 | } |
||
533 | else |
||
534 | { |
||
535 | do |
||
536 | { |
||
537 | lcd_cls (); |
||
538 | utoa (page, text, 10); |
||
539 | lcd_print (text, 0); |
||
540 | timer = 50; |
||
541 | |||
542 | while (timer > 0); |
||
543 | |||
544 | lcd_cls (); |
||
545 | |||
546 | lines = show_parameter (page); |
||
547 | |||
548 | while (key == key_nokey); |
||
549 | if (key == key_plus) |
||
550 | page++; |
||
551 | if (key == key_minus) |
||
552 | page--; |
||
553 | |||
554 | if (page == 255) |
||
555 | page = 12; |
||
556 | |||
557 | if (page > 12) |
||
558 | page = 0; |
||
559 | |||
560 | if (key == key_enter) |
||
561 | edit_parameter2 (page, lines); |
||
562 | |||
563 | } |
||
564 | while (key != key_esc); |
||
565 | |||
566 | lcd_cls (); |
||
567 | lcd_printp (PSTR("Parameter speichern?\r\n ja\r\n nein"), 0); |
||
568 | |||
569 | lines = menu_choose (1, 2, 0); |
||
570 | |||
571 | if (lines == 1 ) |
||
572 | { |
||
573 | lcd_printp (PSTR("\r\n--->"), 0); |
||
574 | write_parameter (5); // Sicherheitshalber wird derzeit ausschliefllich auf Parametersatz 5 gesichert. |
||
575 | lcd_printp (PSTR("\r\nParameter gespeichert"), 0); |
||
576 | } |
||
577 | else |
||
578 | { |
||
579 | lcd_printp (PSTR("\r\nNicht gespeichert"), 0); |
||
580 | } |
||
581 | } |
||
582 | timer = 100; |
||
583 | while (timer > 0); |
||
584 | #endif |
||
585 | } |
||
586 | |||
587 | void display_page (uint8_t page) |
||
588 | { |
||
589 | lcd_cls (); |
||
590 | |||
591 | switch (page) |
||
592 | { |
||
593 | case 0: |
||
594 | lcd_printp (PSTR("Current Setting: "), 0); |
||
595 | lcd_write_number_u (*pRxData); |
||
596 | |||
597 | lcd_printp (PSTR("\r\nSetting Version: "), 0); |
||
598 | lcd_write_number_u (*(pRxData + 1)); |
||
599 | #if 0 |
||
600 | lcd_printp (PSTR("\r\nRxDataLen: "), 0); |
||
601 | lcd_write_number_u (RxDataLen); |
||
602 | |||
603 | lcd_printp (PSTR("\r\nRxBytes: "), 0); |
||
604 | lcd_write_number_u (ReceivedBytes); |
||
605 | #endif |
||
606 | break; |
||
607 | |||
608 | case 1: |
||
609 | lcd_printp (PSTR("Pitch: "), 0); |
||
610 | lcd_write_number_u (mk_param_struct->Kanalbelegung[0]); |
||
611 | |||
612 | lcd_printp (PSTR("Yaw : "), 0); |
||
613 | lcd_write_number_u (mk_param_struct->Kanalbelegung[1]); |
||
614 | |||
615 | lcd_printp (PSTR("Nick : "), 0); |
||
616 | lcd_write_number_u (mk_param_struct->Kanalbelegung[2]); |
||
617 | |||
618 | lcd_printp (PSTR("Roll : "), 0); |
||
619 | lcd_write_number_u (mk_param_struct->Kanalbelegung[3]); |
||
620 | |||
621 | lcd_printp (PSTR("Poti1: "), 0); |
||
622 | lcd_write_number_u (mk_param_struct->Kanalbelegung[4]); |
||
623 | |||
624 | lcd_printp (PSTR("Poti2: "), 0); |
||
625 | lcd_write_number_u (mk_param_struct->Kanalbelegung[5]); |
||
626 | |||
627 | lcd_printp (PSTR("Poti3: "), 0); |
||
628 | lcd_write_number_u (mk_param_struct->Kanalbelegung[6]); |
||
629 | |||
630 | lcd_printp (PSTR("Poti4: "), 0); |
||
631 | lcd_write_number_u (mk_param_struct->Kanalbelegung[7]); |
||
632 | break; |
||
633 | } |
||
634 | } |
||
635 | |||
636 | |||
637 | void edit_parameter (void) |
||
638 | { |
||
639 | uint8_t cmd; |
||
640 | uint8_t sett = 0xff; // current active parameter set |
||
641 | uint8_t page = 0; |
||
642 | |||
643 | SwitchToFC(); |
||
644 | |||
645 | mode = 'Q'; // Settings |
||
646 | |||
647 | lcd_cls (); |
||
648 | |||
649 | _delay_ms (50); |
||
650 | rxd_buffer_locked = FALSE; |
||
651 | timer = TIMEOUT; |
||
652 | |||
653 | SendOutData ('q', ADDRESS_FC, 1, &sett, 1); |
||
654 | while (!rxd_buffer_locked && timer); |
||
655 | if (timer) |
||
656 | { |
||
657 | Decode64 (); |
||
658 | mk_param_struct = (mk_param_struct_t *) pRxData + 2; |
||
659 | |||
660 | display_page (page); |
||
661 | |||
662 | if (get_key_press (1 << KEY_MINUS)) |
||
663 | { |
||
664 | page--; |
||
665 | } |
||
666 | else if (get_key_press (1 << KEY_PLUS)) |
||
667 | { |
||
668 | page++; |
||
669 | } |
||
670 | |||
671 | } |
||
672 | else |
||
673 | { // timeout occured |
||
674 | lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
||
675 | |||
676 | timer = 100; |
||
677 | while (timer > 0); |
||
678 | return; |
||
679 | } |
||
680 | |||
681 | // after all work is done... |
||
682 | //rxd_buffer_locked = FALSE; |
||
683 | while (!get_key_press (1 << KEY_ESC)); // ESC |
||
684 | |||
685 | mode = 0; |
||
686 | rxd_buffer_locked = FALSE; |
||
687 | } |