- activatre auto load calibration data - give possibility to force update in navigation getCourseCorrection - added drive mode for compass calibration - removed compass calibration manualControl
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
/**
|
|
* @file calibrateCompass.h
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2023-05-23
|
|
*
|
|
* @copyright Copyright (c) 2023
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QMC5883LCompass.h>
|
|
#include <Preferences.h>
|
|
#include <iostream>
|
|
|
|
class CalibrateCompass {
|
|
public:
|
|
enum State {
|
|
Ready,
|
|
Calibrating,
|
|
Finished
|
|
};
|
|
|
|
struct CallibrationData {
|
|
int data[3][2];
|
|
};
|
|
|
|
CalibrateCompass(QMC5883LCompass* compass);
|
|
|
|
void loop();
|
|
void start();
|
|
void useData();
|
|
void removeCalibration();
|
|
void reset();
|
|
void saveData();
|
|
void loadData();
|
|
|
|
State getState() const { return this->state; }
|
|
CallibrationData getCallibrationData() const { return this->data; }
|
|
|
|
friend std::ostream& operator<<(std::ostream& os, const CalibrateCompass& caliComp);
|
|
|
|
private:
|
|
void checkDataValidity();
|
|
|
|
QMC5883LCompass* compass;
|
|
State state;
|
|
CallibrationData data;
|
|
|
|
void clearData();
|
|
|
|
bool dataValid = false;
|
|
const uint16_t maxTimeWithoutChange = 5000;
|
|
uint32_t lastChange = 0;
|
|
};
|