added a class to calibrate the compass

This commit is contained in:
2023-05-23 23:24:38 +02:00
parent 7418adb027
commit 8199b47089
2 changed files with 146 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
/**
* @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>
class CalibrateCompass {
public:
enum State {
None,
Ready,
Calibrating,
Finished
};
struct CallibrationData {
int data[3][2];
};
CalibrateCompass(QMC5883LCompass* compass);
void loop();
void start();
void useData();
void reset();
State getState() const { return this->state; }
CallibrationData getCallibrationData() const { return this->data; }
private:
QMC5883LCompass* compass;
State state = State::None;
CallibrationData data;
void clearData();
const uint16_t maxTimeWithoutChange = 5000;
uint32_t lastChange = 0;
};