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() {
|
||||
|
||||
Reference in New Issue
Block a user