Added compass calibration variables to EEPROM and CLI

This commit is contained in:
Jonas Holmberg 2016-12-05 09:59:14 +01:00
parent 12278e3866
commit 702853d67c
4 changed files with 22 additions and 2 deletions

View File

@ -201,6 +201,10 @@ typedef enum {
EEPROM_FLAG_ACCELTUNE_FINE_ROLL, EEPROM_FLAG_ACCELTUNE_FINE_ROLL,
EEPROM_FLAG_ACCELTUNE_FINE_PITCH, EEPROM_FLAG_ACCELTUNE_FINE_PITCH,
/* Compass calibration */
EEPROM_FLAG_COMPASSTUNE_MAGNET_MAX,
EEPROM_FLAG_COMPASSTUNE_MAGNET_MIN,
/* Counts the amount of system settings */ /* Counts the amount of system settings */
EEPROM_SYS_COUNT EEPROM_SYS_COUNT
} EEPROM_SYS_ID_t; } EEPROM_SYS_ID_t;

View File

@ -9,6 +9,7 @@ void calibrate_compass();
void calculate_heading(); void calculate_heading();
extern int MagnetMax[3];
extern int MagnetMin[3];
#endif //DRIVERS_COMPASS_H #endif //DRIVERS_COMPASS_H

View File

@ -26,6 +26,7 @@
#include "drivers/motors.h" #include "drivers/motors.h"
#include "drivers/accel_gyro.h" #include "drivers/accel_gyro.h"
#include "Flight/pid.h" #include "Flight/pid.h"
#include "drivers/compass.h"
#define cliActivateCharacter 35 #define cliActivateCharacter 35
#define commandValueError 0xFFFFFFFFFFFFFFFF #define commandValueError 0xFFFFFFFFFFFFFFFF
@ -1554,7 +1555,7 @@ void cliRun()
if (ReceiveBinaryDecision(121,110)) if (ReceiveBinaryDecision(121,110))
{ {
TransmitBack("Starting calibration! \n\n\r"); TransmitBack("Starting calibration! \n\n\r");
TransmitBack("NOT IMPLEMENTED! \n\n\r"); calibrate_compass();
TransmitBack("Calibration complete! \n\n\r"); TransmitBack("Calibration complete! \n\n\r");
} }
else else

View File

@ -25,6 +25,7 @@
#include "drivers/motormix.h" #include "drivers/motormix.h"
#include "drivers/motors.h" #include "drivers/motors.h"
#include "Flight/pid.h" #include "Flight/pid.h"
#include "drivers/compass.h"
/* Reads the EEPROM version from EEPROM - Is compared to EEPROM_SYS_VERSION */ /* Reads the EEPROM version from EEPROM - Is compared to EEPROM_SYS_VERSION */
uint8_t stored_eeprom_identifier; uint8_t stored_eeprom_identifier;
@ -282,6 +283,19 @@ EEPROM_DATA_t eeprom_sys_Arr[EEPROM_SYS_COUNT] = {
.size = sizeof(float), .size = sizeof(float),
.dataPtr = &(accPitchFineTune), .dataPtr = &(accPitchFineTune),
}, },
/* Compass calibration */
[EEPROM_FLAG_COMPASSTUNE_MAGNET_MAX] =
{
.size = sizeof(MagnetMax),
.dataPtr = &(MagnetMax),
},
[EEPROM_FLAG_COMPASSTUNE_MAGNET_MIN] =
{
.size = sizeof(MagnetMin),
.dataPtr = &(MagnetMin),
},
}; };
/* Data pointers and sizes for profile content */ /* Data pointers and sizes for profile content */