/** * @file sensorData.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains the SensorData class * @version 0.1 * @date 2023-09-02 * * @copyright Copyright (c) 2023 * */ #ifndef SENSOR_DATA_H #define SENSOR_DATA_H #include #include #include "component.h" #include "calibrateCompass.h" #include #include #include "point.h" /** * @brief A class to manage all sensors * * Each sensor have separately to be enabled */ class SensorData : public Component { public: SensorData(); ~SensorData(); /** * @brief Enable the gnss module over spi * * @param spiPort * @param csPin */ void enableGnss(SPIClass *spiPort, uint8_t csPin); /** * @brief Enable the gnss module over i2c */ void enableGnss(); void enableRealCompass(); void enableCalcCompass(); // Interface Const /** * @brief Get the azimuth measured by the compass module * * @return int16_t */ int16_t getRealAzimuth() const { return this->realAzimuth; } Point getCurrentPos() const { return this->currentPosition; } const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; }; /** * @brief Get the RealCompass object * @return QMC5883LCompass* */ QMC5883LCompass *getRealCompass() const { return this->realCompass; } // static /** * @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(); void updateUbxData(); QMC5883LCompass *realCompass = nullptr; SFE_UBLOX_GNSS *gnss = nullptr; UBX_NAV_PVT_data_t *gnssData = nullptr; Point currentPosition; int16_t realAzimuth = INT16_MAX; uint32_t lastUbxUpdate = 0; // static 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 constexpr uint8_t loopDelay = 50; }; #endif // SENSOR_DATA_H