Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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