Subversion Repositories NaviCtrl

Rev

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

Rev 743 Rev 767
Line 467... Line 467...
467
                        if(Compass_CalState != OldCalState) // avoid continously writing of eeprom!
467
                        if(Compass_CalState != OldCalState) // avoid continously writing of eeprom!
468
                        {
468
                        {
469
                                switch(NCMAG_SensorType)
469
                                switch(NCMAG_SensorType)
470
                                {
470
                                {
471
                                        case TYPE_HMC5843:
471
                                        case TYPE_HMC5843:
472
                                                UART1_PutString("\r\nFinished: HMC5843 calibration\n\r");
472
                                                UART1_PutString("\r\nFinished: HMC5843 calibration\r\n");
473
                                                MinCalibration = HMC5843_CALIBRATION_RANGE;
473
                                                MinCalibration = HMC5843_CALIBRATION_RANGE;
474
                                                break;
474
                                                break;
Line 475... Line 475...
475
 
475
 
476
                                        case TYPE_LSM303DLH:
476
                                        case TYPE_LSM303DLH:
477
                                        case TYPE_LSM303DLM:
477
                                        case TYPE_LSM303DLM:
478
                                        case TYPE_LSM303D:
478
                                        case TYPE_LSM303D:
479
                                        default:
479
                                        default:
480
                                                UART1_PutString("\r\nFinished: LSM303 calibration\n\r");
480
                                                UART1_PutString("\r\nFinished: LSM303 calibration\r\n");
481
                                                MinCalibration = LSM303_CALIBRATION_RANGE;
481
                                                MinCalibration = LSM303_CALIBRATION_RANGE;
482
                                                break;
482
                                                break;
483
                                }
483
                                }
484
                                if(EarthMagneticStrengthTheoretic)
484
                                if(EarthMagneticStrengthTheoretic)
485
                                {
485
                                {
486
                                        MinCalibration = (MinCalibration * EarthMagneticStrengthTheoretic) / 50;
486
                                        MinCalibration = (MinCalibration * EarthMagneticStrengthTheoretic) / 50;
487
                                        sprintf(msg, "Earth field on your location should be: %iuT\r\n",EarthMagneticStrengthTheoretic);
487
                                        sprintf(msg, "Earth field on your location should be: %iuT\r\n",EarthMagneticStrengthTheoretic);
488
                                        UART1_PutString(msg);
488
                                        UART1_PutString(msg);
489
                                }
489
                                }
Line 490... Line 490...
490
                            else UART1_PutString("without GPS\n\r");
490
                            else UART1_PutString("without GPS\r\n");
491
 
491
 
492
                                if(Zmin2 < Zmin) Zmin = Zmin2;
492
                                if(Zmin2 < Zmin) Zmin = Zmin2;
493
                                if(Zmax2 > Zmax) Zmax = Zmax2;
493
                                if(Zmax2 > Zmax) Zmax = Zmax2;
Line 506... Line 506...
506
                                else
506
                                else
507
                                if((Calibration.MagX.Range > MinCalibration) && (Calibration.MagY.Range > MinCalibration) && (Calibration.MagZ.Range > MinCalibration))
507
                                if((Calibration.MagX.Range > MinCalibration) && (Calibration.MagY.Range > MinCalibration) && (Calibration.MagZ.Range > MinCalibration))
508
                                {
508
                                {
509
                                        NCMAG_IsCalibrated = NCMag_CalibrationWrite(Compass_I2CPort);
509
                                        NCMAG_IsCalibrated = NCMag_CalibrationWrite(Compass_I2CPort);
510
                                        BeepTime = 2500;
510
                                        BeepTime = 2500;
511
                                        UART1_PutString("\r\n-> Calibration okay <-\n\r");
511
                                        UART1_PutString("\r\n-> Calibration okay <-\r\n");
512
                                        SpeakHoTT = SPEAK_MIKROKOPTER;
512
                                        SpeakHoTT = SPEAK_MIKROKOPTER;
513
                                }
513
                                }
514
                                else
514
                                else
515
                                {
515
                                {
516
                                        SpeakHoTT = SPEAK_ERR_CALIBARTION;
516
                                        SpeakHoTT = SPEAK_ERR_CALIBARTION;
Line 1262... Line 1262...
1262
                }
1262
                }
1263
        }
1263
        }
1264
                // if we got an answer to id request
1264
                // if we got an answer to id request
1265
                if(retval)
1265
                if(retval)
1266
                {
1266
                {
1267
                        u8 n1[] = "\n\r HMC5843";
1267
                        u8 n1[] = "\r\n HMC5843";
1268
                        u8 n2[] = "\n\r LSM303DLH";
1268
                        u8 n2[] = "\r\n LSM303DLH";
1269
                        u8 n3[] = "\n\r LSM303DLM";
1269
                        u8 n3[] = "\r\n LSM303DLM";
1270
                        u8 n4[] = "\n\r LSM303D";
1270
                        u8 n4[] = "\r\n LSM303D";
1271
                        u8 n5[] = "\n\r ??";
1271
                        u8 n5[] = "\r\n ??";
1272
                        u8* pn = n5;
1272
                        u8* pn = n5;
Line 1273... Line 1273...
1273
 
1273
 
1274
                        switch(NCMAG_SensorType)
1274
                        switch(NCMAG_SensorType)
1275
                        {
1275
                        {
Line 1322... Line 1322...
1322
                                                UART1_PutString(msg);
1322
                                                UART1_PutString(msg);
1323
                                                if(NCMAG_IsCalibrated) // check against calibration data orientation
1323
                                                if(NCMAG_IsCalibrated) // check against calibration data orientation
1324
                                                {
1324
                                                {
1325
                                                        if(NCMAG_Orientation != Calibration.Version >> 4)
1325
                                                        if(NCMAG_Orientation != Calibration.Version >> 4)
1326
                                                        {
1326
                                                        {
1327
                                                                sprintf(msg, "\n\r Warning: calibrated orientation was %d !",Calibration.Version >> 4);
1327
                                                                sprintf(msg, "\r\n Warning: calibrated orientation was %d !",Calibration.Version >> 4);
1328
                                                                UART1_PutString(msg);
1328
                                                                UART1_PutString(msg);
1329
//NCMAG_IsCalibrated = 0; // force new calibration!
1329
//NCMAG_IsCalibrated = 0; // force new calibration!
1330
                                                        }
1330
                                                        }
1331
                                                }
1331
                                                }
1332
                                        }
1332
                                        }
Line 1349... Line 1349...
1349
                                // initialize magnetic sensor configuration
1349
                                // initialize magnetic sensor configuration
1350
                                NCMAG_ConfigureSensor();
1350
                                NCMAG_ConfigureSensor();
1351
                        }
1351
                        }
1352
                        else
1352
                        else
1353
                        {
1353
                        {
1354
                                UART1_PutString("\n\r Not compatible!");
1354
                                UART1_PutString("\r\n Not compatible!");
1355
                                UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_INCOMPATIBLE;
1355
                                UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_INCOMPATIBLE;
1356
                                LED_RED_ON;
1356
                                LED_RED_ON;
1357
                        }
1357
                        }
1358
                }
1358
                }
1359
                else // nothing found
1359
                else // nothing found