72 lines
1.7 KiB
C++
72 lines
1.7 KiB
C++
/**
|
|
* @file sensors.h
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2023-09-02
|
|
*
|
|
* @copyright Copyright (c) 2023
|
|
*
|
|
*/
|
|
|
|
#ifndef SENSORS_H
|
|
#define SENSORS_H
|
|
|
|
#include <SPI.h>
|
|
#include <iostream>
|
|
//Sensors
|
|
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
|
|
#include <QMC5883LCompass.h>
|
|
// Gyroskop
|
|
|
|
#include "component.h"
|
|
#include "sensorData.h"
|
|
#include "calibrateCompass.h"
|
|
|
|
class Sensors : public Component {
|
|
public:
|
|
Sensors();
|
|
|
|
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.
|
|
*
|
|
* If this is true, a lot of information from the gnss module will be printed in
|
|
* the interval of navigation frequency.
|
|
*
|
|
* @param status
|
|
*/
|
|
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;
|
|
|
|
int16_t realAzimuth = INT16_MAX;
|
|
|
|
static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct);
|
|
static void savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct);
|
|
|
|
static UBX_NAV_PVT_data_t* ubxDataStatic;
|
|
|
|
static uint32_t ubxUpdateTimeStatic;
|
|
|
|
static bool outputStatusPrintPVTdata;
|
|
static bool newData;
|
|
};
|
|
|
|
#endif // SENSORS_H
|