cleaning
refactore all components now have a base class compnent for loop functions
This commit is contained in:
@@ -39,11 +39,6 @@ void Navigation::init(Route* route) {
|
||||
uint8_t versionLow = this->gps->getProtocolVersionLow();
|
||||
std::cout << "u-blox protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl;
|
||||
|
||||
// std::cout << "Set GNSS Module to factory settings... ";
|
||||
// this->gps->factoryReset();
|
||||
// delay(5000);
|
||||
// std::cout << "Complete" << std::endl;
|
||||
|
||||
this->gps->setSPIOutput(COM_TYPE_UBX);
|
||||
this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10);
|
||||
this->gps->setUSBOutput(COM_TYPE_UBX | COM_TYPE_NMEA);
|
||||
@@ -67,14 +62,16 @@ void Navigation::init(Route* route) {
|
||||
CalibrateCompass caliCompass(this->compass);
|
||||
caliCompass.loadData();
|
||||
caliCompass.useData();
|
||||
// std::cout << "Navigation::init compass correction data: " << caliCompass << std::endl;
|
||||
|
||||
this->loopDelay =AZIMUTH_UPDATE_DELAY;
|
||||
}
|
||||
|
||||
Navigation::~Navigation() {
|
||||
delete this->gps;
|
||||
delete this->compass;
|
||||
delete this->ntripClient;
|
||||
delete this->route;
|
||||
if (this->ntripClient)
|
||||
delete this->ntripClient;
|
||||
}
|
||||
|
||||
void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) {
|
||||
@@ -83,9 +80,17 @@ void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String
|
||||
this->ntripClient->loop();
|
||||
this->ntripClient->setActivated(false);
|
||||
this->isNtripInit = true;
|
||||
this->addChildComponent(this->ntripClient);
|
||||
}
|
||||
|
||||
void Navigation::loop() {
|
||||
void Navigation::run() {
|
||||
this->compass->read();
|
||||
this->realAzimuth = this->compass->getAzimuth();
|
||||
|
||||
this->updateMagneticDeclination();
|
||||
}
|
||||
|
||||
void Navigation::runAsChild() {
|
||||
this->gps->checkUblox();
|
||||
this->gps->checkCallbacks();
|
||||
|
||||
@@ -93,18 +98,6 @@ void Navigation::loop() {
|
||||
this->updateCurrentLocation();
|
||||
Navigation::newData = false;
|
||||
}
|
||||
|
||||
if (this->ntripClient)
|
||||
this->ntripClient->loop();
|
||||
|
||||
if (millis() - this->lastMillis > AZIMUTH_UPDATE_DELAY) {
|
||||
this->compass->read();
|
||||
this->realAzimuth = this->compass->getAzimuth();
|
||||
|
||||
this->updateMagneticDeclination();
|
||||
|
||||
this->lastMillis = millis();
|
||||
}
|
||||
}
|
||||
|
||||
void Navigation::newRoute() {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "route.h"
|
||||
#include "NTRIPClient.h"
|
||||
#include "calibrateCompass.h"
|
||||
#include "component.h"
|
||||
|
||||
/**
|
||||
* @brief The minimal distance between Points
|
||||
@@ -54,7 +55,7 @@ struct CourseCorrection {
|
||||
* be drive and the distance to the next checkpoint.
|
||||
*
|
||||
*/
|
||||
class Navigation {
|
||||
class Navigation : public Component {
|
||||
public:
|
||||
enum Status {
|
||||
InsufficientAccuracy,
|
||||
@@ -103,13 +104,6 @@ class Navigation {
|
||||
*/
|
||||
void initNtrip(String host, uint16_t port, String mountPoint, String user, String password);
|
||||
|
||||
/**
|
||||
* @brief Decodes new GPS information
|
||||
*
|
||||
* Should be called ever main loop.
|
||||
*/
|
||||
void loop();
|
||||
|
||||
/**
|
||||
* @brief creates a new empty route
|
||||
*
|
||||
@@ -218,6 +212,8 @@ class Navigation {
|
||||
static int16_t fixDegree(int16_t degree);
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
void runAsChild() override;
|
||||
void updateCurrentLocation();
|
||||
void updateMagneticDeclination();
|
||||
void init(Route* route);
|
||||
|
||||
Reference in New Issue
Block a user