Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1470 | - | 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 <avr/interrupt.h> |
||
38 | #include <avr/pgmspace.h> |
||
39 | #include <string.h> |
||
40 | #include <stdlib.h> |
||
41 | #include <stdbool.h> |
||
42 | #include <util/delay.h> |
||
43 | #include "main.h" |
||
44 | #include "setup.h" |
||
45 | #include "lcd.h" |
||
46 | #include "menu.h" |
||
47 | #include "servo.h" |
||
48 | #include "motortest.h" |
||
49 | #include "eeprom.h" |
||
50 | #include "timer.h" |
||
51 | #include "connect.h" |
||
52 | #ifdef HWVERSION3_9 |
||
53 | #include "HAL_HW3_9.h" |
||
54 | #endif |
||
55 | #ifdef HWVERSION1_3 |
||
56 | #include "HAL_HW1_3.h" |
||
57 | #endif |
||
58 | //#include "voltmeter.h" |
||
59 | #include "lipo.h" |
||
60 | #include "messages.h" |
||
61 | |||
62 | //-------------------------------------------------------------- |
||
63 | #define ITEMS_PKT 6 |
||
64 | |||
65 | prog_char tools_menuitems_pkt[ITEMS_PKT][NUM_LANG][18]= // zeilen,zeichen+1 |
||
66 | // German, English, French, Netherlands |
||
67 | { |
||
68 | {"Motor Tester ","Motor Tester ","Motor Tester ","Motor Tester "}, |
||
69 | {"Servo Tester ","Servo Tester ","Servo Tester ","Servo Tester "}, |
||
70 | {"PC BT > Kopter ","PC BT > Kopter ","PC BT > Kopter ","PC BT > Kopter "}, |
||
71 | {"PC USB > Kopter ","PC USB > Kopter ","PC USB > Kopter ","PC USB > Kopter "}, |
||
72 | {"PKT Setup \x1d","PKT Setup \x1d","PKT Setup \x1d","PKT Setup \x1d"}, |
||
73 | {"PKT Version ","PKT Version ","PKT Version ","PKT Version "}, |
||
74 | }; |
||
75 | |||
76 | |||
77 | //-------------------------------------------------------------- |
||
78 | void PKT_Tools (void) |
||
79 | { |
||
80 | uint8_t ii = 0; |
||
81 | uint8_t Offset = 0; |
||
82 | uint8_t size = 0; |
||
83 | size = ITEMS_PKT ; |
||
84 | uint8_t dmode = 0; |
||
85 | uint8_t target_pos = 1; |
||
86 | uint8_t val; |
||
87 | |||
88 | val = 0; |
||
89 | |||
90 | while(1) |
||
91 | { |
||
92 | lcd_cls (); |
||
93 | lcd_printp_at (0, 0, PSTR(" PKT-Tools "), 2); |
||
94 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
95 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
96 | |||
97 | while(2) |
||
98 | { |
||
99 | ii = 0; |
||
100 | if(Offset > 0) |
||
101 | { |
||
102 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
103 | } |
||
104 | for(ii = 0;ii < 6 ; ii++) |
||
105 | { |
||
106 | if((ii+Offset) < size) |
||
107 | { |
||
108 | lcd_printp_at(3,ii+1,tools_menuitems_pkt[ii+Offset][DisplayLanguage], 0); |
||
109 | } |
||
110 | if((ii == 5)&&(ii+Offset < (size-1))) |
||
111 | { |
||
112 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
113 | } |
||
114 | } |
||
115 | if(dmode == 0) |
||
116 | { |
||
117 | if(Offset == 0) |
||
118 | { |
||
119 | if(size > 6) |
||
120 | { |
||
121 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
122 | } |
||
123 | else |
||
124 | { |
||
125 | val = menu_choose2 (1, size, target_pos,0,0); |
||
126 | } |
||
127 | } |
||
128 | else |
||
129 | { |
||
130 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
131 | } |
||
132 | } |
||
133 | if(dmode == 1) |
||
134 | { |
||
135 | if(Offset+7 > size) |
||
136 | { |
||
137 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
138 | } |
||
139 | else |
||
140 | { |
||
141 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
142 | } |
||
143 | } |
||
144 | if(val == 254) |
||
145 | { |
||
146 | Offset++; |
||
147 | dmode = 1; |
||
148 | target_pos = 5; |
||
149 | } |
||
150 | else if(val == 253) |
||
151 | { |
||
152 | Offset--; |
||
153 | dmode = 0; |
||
154 | target_pos = 2; |
||
155 | } |
||
156 | else if(val == 255) |
||
157 | { |
||
158 | return; |
||
159 | } |
||
160 | else |
||
161 | { |
||
162 | break; |
||
163 | } |
||
164 | |||
165 | } |
||
166 | target_pos = val; |
||
167 | |||
168 | if((val+Offset) == 1 ) |
||
169 | motor_test(FC_Mode); |
||
170 | if((val+Offset) == 2 ) |
||
171 | servo_test(); |
||
172 | #ifdef HWVERSION3_9 |
||
173 | if(U02SV2 == 0) |
||
174 | { |
||
175 | if((val+Offset) == 3 ) |
||
176 | Port_BT2Wi(); |
||
177 | if((val+Offset) == 4 ) |
||
178 | Port_USB2Wi(); |
||
179 | } |
||
180 | else if(U02SV2 == 1) |
||
181 | { |
||
182 | if((val+Offset) == 3 ) |
||
183 | Port_BT2FC(); |
||
184 | if((val+Offset) == 4 ) |
||
185 | Port_USB2FC(); |
||
186 | } |
||
187 | #else |
||
188 | if((val+Offset) == 3 ) |
||
189 | Show_Error_HW(); |
||
190 | if((val+Offset) == 4 ) |
||
191 | Show_Error_HW(); |
||
192 | #endif |
||
193 | if((val+Offset) == 5) |
||
194 | PKT_Setup(); |
||
195 | if((val+Offset) == 6) |
||
196 | Show_Version(); |
||
197 | } |
||
198 | } |
||
199 | |||
200 | |||
201 | //-------------------------------------------------------------- |
||
202 | // |
||
203 | void PC_Fast_Connect (void) |
||
204 | { |
||
205 | uint8_t value = 1; |
||
206 | |||
207 | while(1) |
||
208 | { |
||
209 | lcd_cls(); |
||
210 | // lcd_printp_at (0, 0, PSTR(" PC-Quick-Verbindung "), 2); |
||
211 | lcd_puts_at(0, 8, strGet(TOOLS1), 2); |
||
212 | lcd_printp_at (3, 3, PSTR("PC BT > Kopter"), 0); |
||
213 | lcd_printp_at (3, 4, PSTR("PC USB > Kopter"), 0); |
||
214 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
215 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
216 | // lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
217 | |||
218 | while(2) |
||
219 | { |
||
220 | if(value == 1) |
||
221 | { |
||
222 | lcd_printp_at (1, 3, PSTR("\x1d"), 0); |
||
223 | lcd_printp_at (1, 4, PSTR(" "), 0); |
||
224 | } |
||
225 | else |
||
226 | { |
||
227 | lcd_printp_at (1, 3, PSTR(" "), 0); |
||
228 | lcd_printp_at (1, 4, PSTR("\x1d"), 0); |
||
229 | } |
||
230 | |||
231 | if(get_key_press (1 << KEY_MINUS)) |
||
232 | value = 1; |
||
233 | |||
234 | if(get_key_press (1 << KEY_PLUS)) |
||
235 | value = 2; |
||
236 | |||
237 | |||
238 | if(get_key_short (1 << KEY_ENTER)) |
||
239 | { |
||
240 | #ifdef HWVERSION3_9 |
||
241 | if(U02SV2 == 0) |
||
242 | { |
||
243 | if(value == 1) |
||
244 | Port_BT2Wi(); |
||
245 | if(value == 2) |
||
246 | Port_USB2Wi(); |
||
247 | } |
||
248 | else if(U02SV2 == 1) |
||
249 | { |
||
250 | if(value == 1) |
||
251 | Port_BT2FC(); |
||
252 | if(value == 2) |
||
253 | Port_USB2FC(); |
||
254 | } |
||
255 | #else |
||
256 | if(value == 1) |
||
257 | Show_Error_HW(); |
||
258 | if(value == 2) |
||
259 | Show_Error_HW(); |
||
260 | #endif |
||
261 | break; |
||
262 | } |
||
263 | |||
264 | if(get_key_press (1 << KEY_ESC)) |
||
265 | { |
||
266 | get_key_press(KEY_ALL); |
||
267 | return; |
||
268 | } |
||
269 | |||
270 | } |
||
271 | } |
||
272 | } |
||
273 | |||
274 | |||
275 | void Test_HB (void) // bleibt für Tests |
||
276 | { |
||
277 | // ADC_Init(); |
||
278 | // |
||
279 | // uint16_t volt_avg = 0; |
||
280 | //// uint64_t volt_tmp = 0; |
||
281 | // uint16_t Balken = 0; |
||
282 | |||
283 | |||
284 | lcd_cls(); |
||
285 | lcd_printp_at(12, 7, PSTR("Ende"), 0); |
||
286 | |||
287 | // lcd_rect(104, 0, 23, 8, 1); // Rahmen |
||
288 | |||
289 | do |
||
290 | { |
||
291 | // |
||
292 | // |
||
293 | if(samples>4095) |
||
294 | { |
||
295 | // write_ndigit_number_u(0, 4, accumulator, 5, 0); |
||
296 | oversampled(); |
||
297 | volt_avg = Vin; |
||
298 | } |
||
299 | // // write_ndigit_number_u(0, 3, samples, 5, 0); |
||
300 | // |
||
301 | //// write_ndigit_number_u(0, 1, Vin, 5, 0); |
||
302 | // _delay_ms(50); |
||
303 | |||
304 | show_Lipo(); |
||
305 | |||
306 | write_ndigit_number_u_100th(5, 5, volt_avg, 0, 0); |
||
307 | lcd_printp_at(10, 5, PSTR("Volt"), 0); |
||
308 | // |
||
309 | // |
||
310 | // |
||
311 | write_ndigit_number_u(0, 6, Lipo_UOffset, 5, 0); |
||
312 | // write_ndigit_number_u(15, 6, WarnCount, 4, 0); |
||
313 | //// write_ndigit_number_u(10, 5, Vcorr, 4, 0); |
||
314 | |||
315 | |||
316 | if (get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) |
||
317 | { |
||
318 | Lipo_UOffset = Lipo_UOffset +10; |
||
319 | } |
||
320 | |||
321 | if (get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS),3)) |
||
322 | { |
||
323 | Lipo_UOffset = Lipo_UOffset -10; |
||
324 | } |
||
325 | // |
||
326 | } |
||
327 | |||
328 | |||
329 | while(!get_key_press (1 << KEY_ESC)); |
||
330 | get_key_press(KEY_ALL); |
||
331 | return; |
||
332 | } |