added a class to calibrate the compass
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user