clangtidy corrections part 2

This commit is contained in:
2023-10-12 00:44:27 +02:00
parent 23d854a826
commit a43e2db92b
41 changed files with 2274 additions and 2485 deletions
@@ -4,31 +4,38 @@
* @brief Contains an implementation of the class MenuAutopilot
* @version 0.1
* @date 2022-02-03
*
*
* @copyright Copyright (c) 2022
*
*
*/
#include "menuAutopilot.h"
void MenuAutopilot::printPage() const {
CourseCorrection correction = this->autopilot->getCourseCorrection();
const UBX_NAV_PVT_data_t* gpsData = this->autopilot->getSensorData()->getGnssData();
bool navigationStarted = this->autopilot->getState() >= Autopilot::State::NavigationStarted;
void MenuAutopilot::printPage() const
{
const CourseCorrection correction = this->autopilot->getCourseCorrection();
const UBX_NAV_PVT_data_t *gpsData = this->autopilot->getSensorData()->getGnssData();
const bool navigationStarted = this->autopilot->getState() >= Autopilot::State::NavigationStarted;
String distanceString = "";
if (navigationStarted) {
if (navigationStarted)
{
uint16_t distance = 0;
if (correction.distance < 1) {
distance = (uint16_t) (correction.distance * 100);
if (correction.distance < 1)
{
distance = static_cast<uint16_t>(correction.distance * 100);
distanceString.concat(distance);
distanceString.concat("cm");
} else if (correction.distance < 1000) {
distance = (uint16_t) correction.distance;
}
else if (correction.distance < 1000)
{
distance = static_cast<uint16_t>(correction.distance);
distanceString.concat(distance);
distanceString.concat("m");
} else {
distance = (uint16_t) (correction.distance / 1000);
}
else
{
distance = static_cast<uint16_t>(correction.distance / 1000);
distanceString.concat(distance);
distanceString.concat("km");
}
@@ -37,221 +44,263 @@ void MenuAutopilot::printPage() const {
String lineOne = "No information";
String lineTwo = "available";
switch (this->getCurrentPage()) {
case 0: {
lineOne = "Status: ";
lineTwo = "";
switch (this->autopilot->getState()) {
case Autopilot::State::InsufficientAccuracy :
lineTwo = "Err: LowAccuracy";
break;
case Autopilot::State::NoRoute :
lineTwo = "Err: No route";
break;
case Autopilot::State::NavigationStarted :
lineTwo = "Nav started";
break;
case Autopilot::State::GetToStartPoint :
lineTwo = "Drive to start";
break;
case Autopilot::State::SelfDrivingAvailable :
lineTwo = "Autopilot ready";
break;
case Autopilot::State::SelfDriving :
lineTwo = "Autopilot active";
break;
case Autopilot::State::SelfDrivingRotate :
lineTwo = "Rotating";
break;
case Autopilot::State::TargetReached :
lineTwo = "Target reached";
break;
default:
lineTwo = "UNKOWN - ";
lineTwo.concat(static_cast<int>(this->autopilot->getState()));
break;
}
break;
}
case 1:
if (!navigationStarted) {
lineOne = "Navigation is";
lineTwo = "not started";
break;
}
lineOne = "Distance: ";
lineOne.concat(distanceString);
lineTwo = "Turn: ";
lineTwo.concat(correction.correction);
switch (this->getCurrentPage())
{
case 0:
{
lineOne = "Status: ";
lineTwo = "";
switch (this->autopilot->getState())
{
case Autopilot::State::InsufficientAccuracy:
lineTwo = "Err: LowAccuracy";
break;
case 2:
lineOne = "Target waypoint";
lineTwo = "";
lineTwo.concat(this->autopilot->getRouteInfo().currentPoint);
lineTwo.concat(" from ");
lineTwo.concat(this->autopilot->getRouteInfo().totalPoints);
case Autopilot::State::NoRoute:
lineTwo = "Err: No route";
break;
case 3: {
NTRIPClientStates status = this->autopilot->getSensorData()->getNtripClient()->getClientState();
uint8_t carrSoln = gpsData->flags.bits.carrSoln;
lineOne = "GNSS: ";
if (status == NTRIPClientStates::pushData)
if (carrSoln == 0)
lineOne.concat("None");
else if (carrSoln == 1)
lineOne.concat("Floating");
else if (carrSoln == 2)
lineOne.concat("Fixed");
else
lineOne.concat("UNKNOWN");
else if (status == NTRIPClientStates::notAvailable)
lineOne.concat("No WiFi");
else
lineOne.concat("Offline");
lineTwo = "hAcc: ";
if (gpsData->fixType)
lineTwo.concat(gpsData->hAcc);
else
lineTwo.concat("0");
break;
}
case 4:
if (this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Good
||this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Super)
{
lineOne = "Calc Azi: ";
lineTwo = "State: ";
lineOne.concat(this->autopilot->getSensorData()->getCalcAzimuth());
switch (this->autopilot->getSensorData()->getCalcAzimuthState()) {
case CalcAzimuth::State::Bad :
lineTwo.concat("Bad");
break;
case CalcAzimuth::State::Good :
lineTwo.concat("Good");
break;
case CalcAzimuth::State::Invalid :
lineTwo.concat("Invalid");
break;
case CalcAzimuth::State::Ok :
lineTwo.concat("Ok");
break;
case CalcAzimuth::State::Super :
lineTwo.concat("Super");
break;
default:
lineTwo.concat("Unkown");
break;
}
} else {
lineOne = "Real Azi: ";
lineTwo = "";
lineOne.concat(this->autopilot->getSensorData()->getRealAzimuth());
}
case Autopilot::State::NavigationStarted:
lineTwo = "Nav started";
break;
case 5:
lineOne = "Loop mode is";
if (this->autopilot->getLoopMode())
lineTwo = "enabled";
else
lineTwo = "disabled";
case Autopilot::State::GetToStartPoint:
lineTwo = "Drive to start";
break;
case 6:
lineOne = "Freeze target is";
if (this->targetFreezed)
lineTwo = "activated";
else
lineTwo = "deactivated";
case Autopilot::State::SelfDrivingAvailable:
lineTwo = "Autopilot ready";
break;
case 7:
lineOne = "MinDisToPoint:";
lineTwo = "<- ";
lineTwo.concat(this->minDistance);
lineTwo.concat(" ->");
case Autopilot::State::SelfDriving:
lineTwo = "Autopilot active";
break;
case Autopilot::State::SelfDrivingRotate:
lineTwo = "Rotating";
break;
case Autopilot::State::TargetReached:
lineTwo = "Target reached";
break;
default:
this->printDefault();
return;
lineTwo = "UNKOWN - ";
lineTwo.concat(static_cast<int>(this->autopilot->getState()));
break;
}
break;
}
case 1:
if (!navigationStarted)
{
lineOne = "Navigation is";
lineTwo = "not started";
break;
}
lineOne = "Distance: ";
lineOne.concat(distanceString);
lineTwo = "Turn: ";
lineTwo.concat(correction.correction);
break;
case 2:
lineOne = "Target waypoint";
lineTwo = "";
lineTwo.concat(this->autopilot->getRouteInfo().currentPoint);
lineTwo.concat(" from ");
lineTwo.concat(this->autopilot->getRouteInfo().totalPoints);
break;
case 3:
{
NTRIPClientStates status = this->autopilot->getSensorData()->getNtripClient()->getClientState();
const uint8_t carrSoln = gpsData->flags.bits.carrSoln;
lineOne = "GNSS: ";
if (status == NTRIPClientStates::pushData)
{
if (carrSoln == 0)
{
lineOne.concat("None");
}
else if (carrSoln == 1)
{
lineOne.concat("Floating");
}
else if (carrSoln == 2)
{
lineOne.concat("Fixed");
}
else
{
lineOne.concat("UNKNOWN");
}
}
else if (status == NTRIPClientStates::notAvailable)
lineOne.concat("No WiFi");
else
{
lineOne.concat("Offline");
}
lineTwo = "hAcc: ";
if (static_cast<bool>(gpsData->fixType))
{
lineTwo.concat(gpsData->hAcc);
}
else
{
lineTwo.concat("0");
}
break;
}
case 4:
if (this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Good || this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Super)
{
lineOne = "Calc Azi: ";
lineTwo = "State: ";
lineOne.concat(this->autopilot->getSensorData()->getCalcAzimuth());
switch (this->autopilot->getSensorData()->getCalcAzimuthState())
{
case CalcAzimuth::State::Bad:
lineTwo.concat("Bad");
break;
case CalcAzimuth::State::Good:
lineTwo.concat("Good");
break;
case CalcAzimuth::State::Invalid:
lineTwo.concat("Invalid");
break;
case CalcAzimuth::State::Ok:
lineTwo.concat("Ok");
break;
case CalcAzimuth::State::Super:
lineTwo.concat("Super");
break;
default:
lineTwo.concat("Unkown");
break;
}
}
else
{
lineOne = "Real Azi: ";
lineTwo = "";
lineOne.concat(this->autopilot->getSensorData()->getRealAzimuth());
}
break;
case 5:
lineOne = "Loop mode is";
if (this->autopilot->getLoopMode())
{
lineTwo = "enabled";
}
else
{
lineTwo = "disabled";
}
break;
case 6:
lineOne = "Freeze target is";
if (this->targetFreezed)
{
lineTwo = "activated";
}
else
{
lineTwo = "deactivated";
}
break;
case 7:
lineOne = "MinDisToPoint:";
lineTwo = "<- ";
lineTwo.concat(this->minDistance);
lineTwo.concat(" ->");
break;
default:
this->printDefault();
return;
}
this->print(lineOne, lineTwo);
}
void MenuAutopilot::runCommand() {
switch (this->getCurrentPage()) {
case 5:
this->autopilot->switchLoopMode();
break;
case 6:
if (this->targetFreezed) {
this->targetFreezed = false;
this->autopilot->getNavigation()->freezeTargetPoint(false);
} else {
this->targetFreezed = true;
this->autopilot->getNavigation()->freezeTargetPoint();
}
break;
case 7:
this->minDistance = this->autopilot->getNavigation()->increaseMinDistanceToReachPoint();
break;
default:
break;
}
}
void MenuAutopilot::runCommandNo() {
switch (this->getCurrentPage()) {
case 7:
this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint();
void MenuAutopilot::runCommand()
{
switch (this->getCurrentPage())
{
case 5:
this->autopilot->switchLoopMode();
break;
case 6:
if (this->targetFreezed)
{
this->targetFreezed = false;
this->autopilot->getNavigation()->freezeTargetPoint(false);
}
else
{
this->targetFreezed = true;
this->autopilot->getNavigation()->freezeTargetPoint();
}
break;
case 7:
this->minDistance = this->autopilot->getNavigation()->increaseMinDistanceToReachPoint();
break;
default:
break;
}
}
void MenuAutopilot::update() {
void MenuAutopilot::runCommandNo()
{
switch (this->getCurrentPage())
{
case 7:
this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint();
break;
default:
break;
}
}
void MenuAutopilot::update()
{
if (!this->autopilot->shouldUpdate())
{
return;
}
this->routeInfo = this->autopilot->getRouteInfo();
this->printMenu();
}
void MenuAutopilot::init() {
void MenuAutopilot::init()
{
this->setCountPages(8);
this->autopilot = new Autopilot();
this->autopilot = new Autopilot();
this->driveManager->changeModus(this->autopilot);
this->routeInfo = this->autopilot->getRouteInfo();
//dirty hack to get the val, can be better!!! TODO
// dirty hack to get the val, can be better!!! TODO
this->autopilot->getNavigation()->increaseMinDistanceToReachPoint();
this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint();
@@ -114,7 +114,7 @@ void MenuCalibrateCompass::init() {
this->driveManager->changeModus(this->caliCompassMode);
this->caliCompass = new CalibrateCompass(this->caliCompassMode->getSensorData()->getRealCompass());
this->setCountPages(11);
this->updateDelay = 500;
MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay;
}
void MenuCalibrateCompass::runCommand() {
@@ -45,8 +45,10 @@ class MenuCalibrateCompass : public MenuDriveMode {
void runCommand() override;
private:
CalibrateCompassM* caliCompassMode;
CalibrateCompass* caliCompass;
CalibrateCompassM* caliCompassMode = nullptr;
CalibrateCompass* caliCompass = nullptr;
static constexpr uint16_t updateDelay = 500;
};
#endif // MENU_CALIBRATE_COMPASS_H
@@ -4,134 +4,170 @@
* @brief Contains an implementation of the class MenuCaptureRoute
* @version 0.1
* @date 2022-01-31
*
*
* @copyright Copyright (c) 2022
*
*
*/
#include "menuCaptureRoute.h"
void MenuCaptureRoute::printPage() const {
RouteInfo routeInfo = this->captureRoute->getRouteInfo();
const UBX_NAV_PVT_data_t* gpsData = this->captureRoute->getSensorData()->getGnssData();
void MenuCaptureRoute::printPage() const
{
const RouteInfo routeInfo = this->captureRoute->getRouteInfo();
const UBX_NAV_PVT_data_t *gpsData = this->captureRoute->getSensorData()->getGnssData();
String lineOne = "";
String lineTwo = "";
switch (this->getCurrentPage()) {
case 0:
lineOne = "Capture Route";
lineTwo = "You can drive";
switch (this->getCurrentPage())
{
case 0:
lineOne = "Capture Route";
lineTwo = "You can drive";
break;
case 1:
lineOne = "Saved waypoints";
lineTwo.concat(routeInfo.totalPoints);
break;
case 2:
lineOne = "Last status:";
switch (this->captureRoute->getLastStatus())
{
case Navigation::Status::InsufficientAccuracy:
lineTwo = "Poor Accuracy";
break;
case 1:
lineOne = "Saved waypoints";
lineTwo.concat(routeInfo.totalPoints);
case Navigation::Status::Updated:
lineTwo = "Point added";
break;
case 2:
lineOne = "Last status:";
switch (this->captureRoute->getLastStatus()) {
case Navigation::Status::InsufficientAccuracy:
lineTwo = "Poor Accuracy";
break;
case Navigation::Status::Updated:
lineTwo = "Point added";
break;
case Navigation::Status::Unchanged:
lineTwo = "Point too close";
break;
default:
lineTwo = "---";
break;
}
case Navigation::Status::Unchanged:
lineTwo = "Point too close";
break;
case 3:
lineOne = "Distance to last";
lineTwo = "point: ";
lineTwo.concat(this->captureRoute->getDistanceToLastPoint());
break;
case 4: {
NTRIPClientStates status = this->captureRoute->getSensorData()->getNtripClient()->getClientState();
lineOne = "NTRIP Client is";
if (status == NTRIPClientStates::pushData)
lineTwo = "enabled";
else if (status == NTRIPClientStates::notAvailable)
lineTwo = "not available";
else
lineTwo = "disabled";
break;
}
case 5: {
lineOne = "Carrier Solution";
uint8_t carrSoln = gpsData->flags.bits.carrSoln;
if (carrSoln == 0)
lineTwo = "None";
else if (carrSoln == 1)
lineTwo = "Floating";
else if (carrSoln == 2)
lineTwo = "Fixed";
else
lineTwo = "UNKNOWN";
break;
}
case 6:
lineOne = "hAccuracy: ";
lineTwo = "Azimuth: ";
lineTwo.concat(this->captureRoute->getSensorData()->getRealAzimuth());
if (gpsData->fixType)
lineOne.concat(gpsData->hAcc);
else
lineOne.concat("0");
break;
case 7:
lineOne = "Current minimal";
if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM)
lineTwo = "accuracy is high";
else
lineTwo = "accuracy is low";
break;
default:
this->printDefault();
return;
lineTwo = "---";
break;
}
break;
case 3:
lineOne = "Distance to last";
lineTwo = "point: ";
lineTwo.concat(this->captureRoute->getDistanceToLastPoint());
break;
case 4:
{
NTRIPClientStates status = this->captureRoute->getSensorData()->getNtripClient()->getClientState();
lineOne = "NTRIP Client is";
if (status == NTRIPClientStates::pushData)
{
lineTwo = "enabled";
}
else if (status == NTRIPClientStates::notAvailable)
{
lineTwo = "not available";
}
else
{
lineTwo = "disabled";
}
break;
}
case 5:
{
lineOne = "Carrier Solution";
uint8_t carrSoln = gpsData->flags.bits.carrSoln;
if (carrSoln == 0)
{
lineTwo = "None";
}
else if (carrSoln == 1)
{
lineTwo = "Floating";
}
else if (carrSoln == 2)
{
lineTwo = "Fixed";
}
else
{
lineTwo = "UNKNOWN";
}
break;
}
case 6:
lineOne = "hAccuracy: ";
lineTwo = "Azimuth: ";
lineTwo.concat(this->captureRoute->getSensorData()->getRealAzimuth());
if (gpsData->fixType)
{
lineOne.concat(gpsData->hAcc);
}
else
{
lineOne.concat("0");
}
break;
case 7:
lineOne = "Current minimal";
if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM)
{
lineTwo = "accuracy is high";
}
else
{
lineTwo = "accuracy is low";
}
break;
default:
this->printDefault();
return;
}
this->print(lineOne, lineTwo);
}
void MenuCaptureRoute::update() {
void MenuCaptureRoute::update()
{
if (!this->captureRoute->shouldUpdate())
{
return;
}
this->printMenu();
}
void MenuCaptureRoute::runCommand() {
void MenuCaptureRoute::runCommand()
{
switch (this->getCurrentPage())
{
case 7:
if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM)
{
this->captureRoute->getNavigation()->setMinAccuracy(Point::Accuracy::none);
else
}
else
{
this->captureRoute->getNavigation()->setMinAccuracy(Point::Accuracy::twoDigOfCM);
}
break;
default:
break;
}
}
void MenuCaptureRoute::init() {
void MenuCaptureRoute::init()
{
this->setCountPages(8);
this->updateDelay = 500;
MenuDriveMode::updateDelay = MenuCaptureRoute::updateDelay;
this->captureRoute = new CaptureRoute();
this->driveManager->changeModus(this->captureRoute);
MenuDriveMode::init();
@@ -48,7 +48,9 @@ class MenuCaptureRoute : public MenuDriveMode {
private:
void init() override;
CaptureRoute* captureRoute;
CaptureRoute* captureRoute = nullptr;
static constexpr uint16_t updateDelay = 500;
};
#endif // MENU_MANUAL_DRIVE_H
@@ -14,8 +14,6 @@ MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode
this->noEqualLeft = true;
}
MenuManualControl::~MenuManualControl() {
}
void MenuManualControl::printPage() const {
String lineOne = "";
@@ -28,10 +26,12 @@ void MenuManualControl::printPage() const {
case 1:
lineOne = "Input mode:";
if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog)
if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) {
lineTwo = "Analog";
else
}
else {
lineTwo = "Digital";
}
break;
case 2:
@@ -55,7 +55,7 @@ void MenuManualControl::init() {
this->manualControl = new ManualControl();
this->driveManager->changeModus(this->manualControl);
this->setCountPages(4);
this->updateDelay = 500;
MenuDriveMode::updateDelay = MenuManualControl::updateDelay;
this->activateSpeedMenu();
MenuDriveMode::init();
}
@@ -27,7 +27,6 @@ class MenuManualControl : public MenuDriveMode {
* @param driveManager
*/
MenuManualControl(DriveManager* driveManager);
~MenuManualControl();
/**
* @brief Prints the Information to display and console
@@ -44,8 +43,10 @@ class MenuManualControl : public MenuDriveMode {
void runCommand() override;
private:
ManualControl* manualControl;
CalibrateCompass* caliCompass;
ManualControl* manualControl = nullptr;
CalibrateCompass* caliCompass = nullptr;
static constexpr uint16_t updateDelay = 500;
};
#endif // MENU_MANUAL_DRIVE_H
@@ -118,7 +118,7 @@ void MenuTestMode::init() {
// Other menu config
static constexpr uint8_t percentMax = 100;
static constexpr uint8_t degreeMax = 360;
static constexpr uint16_t degreeMax = 360;
static constexpr uint8_t secondsMax = 120;
static constexpr uint8_t steps = 5;