refactore
This commit is contained in:
+15
-11
@@ -11,17 +11,8 @@
|
||||
|
||||
#include "sensors.h"
|
||||
|
||||
void Sensors::run() {
|
||||
this->compass->read();
|
||||
this->realAzimuth = this->compass->getAzimuth();
|
||||
}
|
||||
|
||||
void Sensors::runAsChild() {
|
||||
this->gnss->checkUblox();
|
||||
this->gnss->checkCallbacks();
|
||||
|
||||
if (Sensors::newData)
|
||||
Sensors::newData = false;
|
||||
Sensors::Sensors() {
|
||||
this->sensorData = new SensorData(this);
|
||||
}
|
||||
|
||||
void Sensors::enableGnss(SPIClass* spiPort, uint8_t csPin) {
|
||||
@@ -59,6 +50,19 @@ void Sensors::setOutputStatusPrintPVTdata(bool status) {
|
||||
Sensors::outputStatusPrintPVTdata = status;
|
||||
}
|
||||
|
||||
void Sensors::run() {
|
||||
this->compass->read();
|
||||
this->realAzimuth = this->compass->getAzimuth();
|
||||
}
|
||||
|
||||
void Sensors::runAsChild() {
|
||||
this->gnss->checkUblox();
|
||||
this->gnss->checkCallbacks();
|
||||
|
||||
if (Sensors::newData)
|
||||
Sensors::newData = false;
|
||||
}
|
||||
|
||||
void Sensors::initGnss() {
|
||||
uint8_t versionHigh = this->gnss->getProtocolVersionHigh();
|
||||
uint8_t versionLow = this->gnss->getProtocolVersionLow();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file sensorData.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-02
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SENSOR_DATA_H
|
||||
#define SENSOR_DATA_H
|
||||
|
||||
#include "sensors.h"
|
||||
|
||||
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
|
||||
#include <QMC5883LCompass.h>
|
||||
// Gyroskop
|
||||
#include "calcAzimuth.h"
|
||||
|
||||
class SensorData {
|
||||
public:
|
||||
SensorData(Sensors *senors);
|
||||
|
||||
int16_t getRealAzimuth() const { return 0; }
|
||||
int16_t getCalcAzimuth() const { return 0; }
|
||||
CalcAzimuth::CalcAzimuthState getCalcAzimuthState() const { return CalcAzimuth::CalcAzimuthState::Invalid; }
|
||||
const UBX_NAV_PVT_data_t* const getGnssData() const;
|
||||
const void* const getGyroData() const;
|
||||
|
||||
private:
|
||||
Sensors* sensors;
|
||||
};
|
||||
|
||||
SensorData::SensorData(Sensors* senors) {
|
||||
this->sensors = sensors;
|
||||
}
|
||||
|
||||
#endif //SENSOR_DATA_H
|
||||
|
||||
+5
-11
@@ -25,24 +25,15 @@
|
||||
|
||||
class Sensors : public Component {
|
||||
public:
|
||||
enum CalcAzimuthState {
|
||||
Invalid,
|
||||
Bad,
|
||||
Ok,
|
||||
Good,
|
||||
Super
|
||||
};
|
||||
|
||||
Sensors();
|
||||
|
||||
void run() override;
|
||||
void runAsChild() override;
|
||||
|
||||
void enableGnss(SPIClass* spiPort, uint8_t csPin);
|
||||
void enableGnss();
|
||||
void enableCompass();
|
||||
void enableGyroskop();
|
||||
|
||||
const SensorData const getSensorData() const { return this->sensorData; }
|
||||
|
||||
/**
|
||||
* @brief Set the output status for PVTdata.
|
||||
*
|
||||
@@ -54,10 +45,13 @@ class Sensors : public Component {
|
||||
static void setOutputStatusPrintPVTdata(bool status);
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
void runAsChild() override;
|
||||
void initGnss();
|
||||
|
||||
QMC5883LCompass* compass = nullptr;
|
||||
SFE_UBLOX_GNSS* gnss = nullptr;
|
||||
SensorData* sensorData;
|
||||
|
||||
CalcAzimuthState calcAzimuthState = CalcAzimuthState::Invalid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user