Subversion Repositories NaviCtrl

Rev

Rev 486 | Rev 498 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 486 Rev 489
Line 66... Line 66...
66
#include "menu.h"
66
#include "menu.h"
67
#include "uart1.h"
67
#include "uart1.h"
68
#include "ncmag.h"
68
#include "ncmag.h"
69
#include "logging.h"
69
#include "logging.h"
70
#include "settings.h"
70
#include "settings.h"
71
#include "gpx.h"
-
 
Line 72... Line 71...
72
 
71
 
73
u8 DispPtr = 0;
72
u8 DispPtr = 0;
Line 86... Line 85...
86
{
85
{
87
        u8 i;
86
        u8 i;
88
        for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
87
        for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
89
}
88
}
Line 90... Line -...
90
 
-
 
91
 
89
 
92
// Display with 20 characters in 4 lines
90
// Display with 20 characters in 4 lines
93
void Menu_Update(u8 Keys)
91
void Menu_Update(u8 Keys)
94
{
92
{
95
        s32 i1,i2;
93
        s32 i1,i2;
Line 113... Line 111...
113
        switch(MenuItem)
111
        switch(MenuItem)
114
        {
112
        {
115
                // Version Info
113
                // Version Info
116
                case 0:
114
                case 0:
117
                        LCD_printfxy(0,0,"++  Navi-Ctrl  ++");
115
                        LCD_printfxy(0,0,"++  Navi-Ctrl  ++");
118
                        LCD_printfxy(0,1,"HW V%d.%d SW V%d.%02d%c", (Version_HW & 0x7f)/10, (Version_HW & 0x7f)%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH);
116
                        LCD_printfxy(0,1,"HW V%d.%d SW V%d.%02d%c", (Version_HW & 0x7F)/10, (Version_HW & 0x7F)%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH);
Line 119... Line 117...
119
 
117
 
120
            if(ErrorCode)
118
            if(ErrorCode)
121
                        {
119
                        {
122
                                LCD_printfxy(0,2,"Error: %d",ErrorCode);
120
                                LCD_printfxy(0,2,"Error: %d",ErrorCode);
123
                LCD_printfxy(0,3,"%s",ErrorMSG);
121
                LCD_printfxy(0,3,"%s",ErrorMSG);
124
                        }
122
                        }
125
                        else
123
                        else
126
                        {                                  
124
                        {
127
                         LCD_printfxy(0,3,"(c) HiSystems GmbH");
125
                         LCD_printfxy(0,3,"(c) HiSystems GmbH");
128
                         LCD_printfxy(0,2,"%s",ErrorMSG);
126
                         LCD_printfxy(0,2,"%s",ErrorMSG);
129
                        }
127
                        }
130
                        break;
128
                        break;
Line 356... Line 354...
356
                        break;
354
                        break;
357
                case 14: // gyros from FC
355
                case 14: // gyros from FC
358
                        LCD_printfxy(0,0,"GyroNick:  %4i", FromFlightCtrl.GyroNick);
356
                        LCD_printfxy(0,0,"GyroNick:  %4i", FromFlightCtrl.GyroNick);
359
            LCD_printfxy(0,1,"GyroRoll:  %4i", FromFlightCtrl.GyroRoll);
357
            LCD_printfxy(0,1,"GyroRoll:  %4i", FromFlightCtrl.GyroRoll);
360
                        LCD_printfxy(0,2,"GyroYaw:   %4i", FromFlightCtrl.GyroYaw);
358
                        LCD_printfxy(0,2,"GyroYaw:   %4i", FromFlightCtrl.GyroYaw);
361
                        if(FC_is_Calibrated) LCD_printfxy(0,3,"Calibrated    ") else LCD_printfxy(0,3,"not calibrated");
359
                        if(FC_is_Calibrated)    LCD_printfxy(0,3,"Calibrated    ")
-
 
360
                        else                                    LCD_printfxy(0,3,"not calibrated");
362
                        break;
361
                        break;
363
                case 15:
362
                case 15:
364
//                      LCD_printfxy(0,0,"Ubat:   %2i.%1i V", FC.BAT_Voltage/10, FC.BAT_Voltage%10);
363
//                      LCD_printfxy(0,0,"Ubat:   %2i.%1i V", FC.BAT_Voltage/10, FC.BAT_Voltage%10);
365
                        LCD_printfxy(0,0,"Compass:    %3i", FromFlightCtrl.GyroHeading / 10);
364
                        LCD_printfxy(0,0,"Compass:    %3i", FromFlightCtrl.GyroHeading / 10);
366
                        LCD_printfxy(0,1,"Man.-Offset:%3i", FC.FromFC_CompassOffset / 10);
365
                        LCD_printfxy(0,1,"Man.-Offset:%3i", FC.FromFC_CompassOffset / 10);
367
                        if(FC.FromFC_DisableDeclination)
366
                        if(FC.FromFC_DisableDeclination)
368
                        {
367
                        {
369
                         LCD_printfxy(0,2,"Mag.Declinat.:disabl");
368
                                LCD_printfxy(0,2,"Mag.Declinat.:disabl");
370
                        }
369
                        }
371
                        else
370
                        else
372
                        {
371
                        {
373
                         if(GeoMagDec < 0) sign = '-';
372
                                if(GeoMagDec < 0) sign = '-';
374
                         else sign = '+';
373
                                else sign = '+';
375
                         LCD_printfxy(0,2,"Mag.Declinat.:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
374
                                LCD_printfxy(0,2,"Mag.Declinat.:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
376
                        }
375
                        }
377
                        LCD_printfxy(0,3,"True Compass: %3i", GyroCompassCorrected/10);
376
                        LCD_printfxy(0,3,"True Compass: %3i", GyroCompassCorrected/10);
378
            break;
377
            break;
379
                case 16: // User Parameter
378
                case 16: // User Parameter
380
                        LCD_printfxy(0,0,"UP1:%3i  UP2:%3i",Parameter.User1,Parameter.User2);
379
                        LCD_printfxy(0,0,"UP1:%3i  UP2:%3i",Parameter.User1,Parameter.User2);
Line 411... Line 410...
411
 
410
 
412
                                        case 5:
411
                                        case 5:
413
                                                LCD_printfxy(7,1,"data saved");
412
                                                LCD_printfxy(7,1,"data saved");
414
                                                LCD_printfxy(8,3,"      (END) ");
413
                                                LCD_printfxy(8,3,"      (END) ");
415
                                                break;
414
                                                break;
416
                                       
415
 
417
                                        default:
416
                                        default:
418
                                                break;
417
                                                break;
419
                                }
418
                                }
420
                        }
419
                        }
Line 425... Line 424...
425
                                LCD_printfxy(0,0,"Magnetic Field");
424
                                LCD_printfxy(0,0,"Magnetic Field");
426
                                LCD_printfxy(0,1,"X:%5i",MagVector.X);
425
                                LCD_printfxy(0,1,"X:%5i",MagVector.X);
427
                                LCD_printfxy(0,2,"Y:%5i",MagVector.Y);
426
                                LCD_printfxy(0,2,"Y:%5i",MagVector.Y);
428
                                LCD_printfxy(0,3,"Z:%5i",MagVector.Z);
427
                                LCD_printfxy(0,3,"Z:%5i",MagVector.Z);
429
                                LCD_printfxy(8,1,"Field:%3i",EarthMagneticField/5);
428
                                LCD_printfxy(8,1,"Field:%3i",EarthMagneticField/5);
430
                                if(I2C_CompassPort == I2C_EXTERN_0) LCD_printfxy(11,2,"Extern %d",ExtCompassOrientation) else LCD_printfxy(11,2,"Intern");
429
                                if(Compass_I2CPort == NCMAG_PORT_EXTERN)        LCD_printfxy(11,2,"Extern")
-
 
430
                                else                                                                            LCD_printfxy(11,2,"Intern");
431
//                              LCD_printfxy(8,2,"Dec:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
431
//                              LCD_printfxy(8,2,"Dec:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
432
//                              LCD_printfxy(8,3,"Inc:%2i", EarthMagneticInclination);
432
//                              LCD_printfxy(8,3,"Inc:%2i", EarthMagneticInclination);
433
                                LCD_printfxy(15,3,"(CAL)");
433
                                LCD_printfxy(15,3,"(CAL)");
434
                        }
434
                        }
435
                        if(Keys & KEY4) //  next step
435
                        if(Keys & KEY4) //  next step
Line 437... Line 437...
437
                                if(Compass_CalState <5) Compass_SetCalState(Compass_CalState+1);
437
                                if(Compass_CalState <5) Compass_SetCalState(Compass_CalState+1);
438
                                else Compass_SetCalState(0);
438
                                else Compass_SetCalState(0);
439
                        }
439
                        }
440
                        if(Keys & KEY3)Compass_SetCalState(0);  // cancel
440
                        if(Keys & KEY3)Compass_SetCalState(0);  // cancel
441
                        break;
441
                        break;
442
                case 19:
442
                case 19:
443
                        if(GeoMagDec < 0) sign = '-';
443
                        if(GeoMagDec < 0) sign = '-';
444
                        else sign = '+';
444
                        else sign = '+';
445
                                LCD_printfxy(0,0,"Magnetic Field");
445
                                LCD_printfxy(0,0,"Magnetic Field");
446
                                LCD_printfxy(0,1,"Field:%3i (Percent)",EarthMagneticField/5);
446
                                LCD_printfxy(0,1,"Field:%3i (Percent)",EarthMagneticField/5);
447
                                LCD_printfxy(0,2,"Declination:%c%i.%1i ", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
447
                                LCD_printfxy(0,2,"Declination:%c%i.%1i ", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
448
                                LCD_printfxy(0,3,"Inclination:%2i (%2i)", EarthMagneticInclination,     EarthMagneticInclinationTheoretic);
448
                                LCD_printfxy(0,3,"Inclination:%2i (%2i)", EarthMagneticInclination,     EarthMagneticInclinationTheoretic);
449
                        break;
449
                        break;
450
                case 20:
450
                case 20:
451
                        LCD_printfxy(0,0,"SD-Setting      ");
451
                        LCD_printfxy(0,0,"SD-Setting      ");
452
                        LCD_printfxy(0,2,"WP-Dynamic:%4i ",WaypointAcceleration);
452
                        LCD_printfxy(0,2,"WP-Dynamic:%4i ",WaypointAcceleration);
453
                        break;
453
                        break;
454
                case 21:
454
                case 21:
455
                        LCD_printfxy(0,0,"CPU Processing  ");
455
                        LCD_printfxy(0,0,"CPU Processing  ");
456
                        LCD_printfxy(0,2,"GPS-Data:  %2i.%iHz ",FreqNewGpsDataIn5Sec/10, FreqNewGpsDataIn5Sec%10);
456
                        LCD_printfxy(0,2,"GPS-Data:  %2i.%iHz ",FreqNewGpsDataIn5Sec/10, FreqNewGpsDataIn5Sec%10);
457
                        LCD_printfxy(0,3,"GPS-Update:%2i.%iHz ",FreqGpsProcessedIn5Sec/10, FreqGpsProcessedIn5Sec%10);
457
                        LCD_printfxy(0,3,"GPS-Update:%2i.%iHz ",FreqGpsProcessedIn5Sec/10, FreqGpsProcessedIn5Sec%10);
458
                        if(FreqNewGpsDataIn5Sec >= 48 && FreqNewGpsDataIn5Sec <= 52) LCD_printfxy(18,2,"OK") else LCD_printfxy(18,2,"!!");
458
                        if(FreqNewGpsDataIn5Sec >= 48 && FreqNewGpsDataIn5Sec <= 52) LCD_printfxy(18,2,"OK") else LCD_printfxy(18,2,"!!");
459
                        if(FreqGpsProcessedIn5Sec >= 350) LCD_printfxy(18,3,"OK") else LCD_printfxy(18,3,"!!");
459
                        if(FreqGpsProcessedIn5Sec >= 350) LCD_printfxy(18,3,"OK") else LCD_printfxy(18,3,"!!");
460
                        break;
460
                        break;
461
                case 22:
461
                case 22:
462
           LCD_printfxy(0,0,"BL Current" );
462
                        LCD_printfxy(0,0,"BL Current" );
463
           LCD_printfxy(11,3,"(in 0.1A)" );
463
                        LCD_printfxy(11,3,"(in 0.1A)" );
464
                   for(i1 = 0; i1 < 3; i1++)
464
                        for(i1 = 0; i1 < 3; i1++)
465
                    {
465
                        {
466
                     LCD_printfxy(0,i1+1,"%3d %3d %3d %3d ",BL3_Current(i1*4),BL3_Current(i1*4+1),BL3_Current(i1*4+2),BL3_Current(i1*4+3));
466
                     LCD_printfxy(0,i1+1,"%3d %3d %3d %3d ",BL3_Current(i1*4),BL3_Current(i1*4+1),BL3_Current(i1*4+2),BL3_Current(i1*4+3));
467
                         if(Motor[4 + i1 * 4].State == 0) break;
467
                         if(Motor[4 + i1 * 4].State == 0) break;
468
                        }                      
468
                        }
469
                        break;
469
                        break;
-
 
470
 
470
                case 23:
471
                case 23:
471
           LCD_printfxy(0,0,"Ext. Compass" );
472
                        LCD_printfxy(0,0,"Ext. Compass" );
472
                          if(I2C_CompassPort == I2C_EXTERN_0)
473
                        if(Compass_I2CPort == NCMAG_PORT_EXTERN)
473
                           {
474
                        {
474
                             u8 tmp;
475
                             u8 tmp;
475
                         LCD_printfxy(0,1,"ACC  X      Y      Z");
476
                         LCD_printfxy(0,1,"ACC  X      Y      Z");
476
                         LCD_printfxy(0,2," %5d  %5d  %5d",AccRawVector.X/40,AccRawVector.Y/40,AccRawVector.Z/40);
477
                         LCD_printfxy(0,2," %5d  %5d  %5d", AccVector.X/40, AccVector.Y/40, AccVector.Z/40);
477
                                 tmp = GetExtCompassOrientation();
478
                                 tmp = NCMAG_GetOrientationFromAcc();
478
                                 LCD_printfxy(0,3,"Orientat.: ");
479
                                 LCD_printfxy(0,3,"Orientat.: ");
479
                                 if(!tmp) LCD_printfxy(11,3,"??") else LCD_printfxy(11,3,"%2d",tmp);
480
                                 if(!tmp) LCD_printfxy(11,3,"??") else LCD_printfxy(11,3,"%2d",tmp);
480
                                 LCD_printfxy(15,3,"(%d)",ExtCompassOrientation);
481
                                 LCD_printfxy(15,3,"(%d)",NCMAG_Orientation);
481
                           }
482
                        }
482
                           else
483
                        else
483
                           {
484
                        {
484
                            LCD_printfxy(0,1,"Not connected");
485
                                LCD_printfxy(0,1,"Not connected");
485
                           }
486
                        }
486
                        break;
487
                        break;
487
                default:
488
                default:
488
                        //MaxMenuItem = MenuItem - 1;
489
                        //MaxMenuItem = MenuItem - 1;
489
                        MenuItem = 0;
490
                        MenuItem = 0;
490
                        break;
491
                        break;