From befbd898cc1377c86f41a12c415cf58d250841c2 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Mon, 4 Sep 2023 15:25:56 +0200 Subject: [PATCH 01/26] driveManager gets now the object --- .../driveModi/Autopilot/menuAutopilot.cpp | 18 ++++---- .../driveModi/Autopilot/menuAutopilot.h | 1 + .../CalibrateCompass/menuCalibrateCompass.cpp | 4 +- .../CaptureRoute/menuCaptureRoute.cpp | 12 ++--- .../driveModi/CaptureRoute/menuCaptureRoute.h | 1 + .../driveModi/ManualDrive/menuManualDrive.cpp | 4 +- .../driveModi/ManualDrive/menuManualDrive.h | 2 +- .../driveModi/TestMode/menuTestMode.cpp | 4 +- src/SpecialMenus/driveModi/menuDriveMode.cpp | 2 +- src/driveModi/Modi/Autopilot/autopilot.cpp | 5 +- src/driveModi/Modi/Autopilot/autopilot.h | 3 +- .../CalibrateCompass/calibrateCompassM.cpp | 1 - .../Modi/CalibrateCompass/calibrateCompassM.h | 2 - .../Modi/CaptureRoute/captureRoute.cpp | 5 +- .../Modi/CaptureRoute/captureRoute.h | 9 +--- .../Modi/ManualControl/manualControl.h | 2 - src/driveModi/Modi/TestMode/testMode.cpp | 9 ---- src/driveModi/Modi/TestMode/testMode.h | 9 ---- src/driveModi/driveManager.cpp | 46 ++----------------- src/driveModi/driveManager.h | 43 ++--------------- src/driveModi/driveModi.cpp | 28 ++++++----- src/driveModi/driveModi.h | 6 ++- src/main.cpp | 3 +- 23 files changed, 63 insertions(+), 156 deletions(-) diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index f146790..9496435 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -210,15 +210,15 @@ void MenuAutopilot::runCommand() const { case 6: if (this->targetFreezed) { this->targetFreezed = false; - this->driveManager->getNavigation()->freezeTargetPoint(false); + this->autopilot->getNavigation()->freezeTargetPoint(false); } else { this->targetFreezed = true; - this->driveManager->getNavigation()->freezeTargetPoint(); + this->autopilot->getNavigation()->freezeTargetPoint(); } break; case 7: - this->minDistance = this->driveManager->getNavigation()->increaseMinDistanceToReachPoint(); + this->minDistance = this->autopilot->getNavigation()->increaseMinDistanceToReachPoint(); break; default: @@ -229,7 +229,7 @@ void MenuAutopilot::runCommand() const { void MenuAutopilot::runCommandNo() const { switch (this->getCurrentPage()) { case 7: - this->minDistance = this->driveManager->getNavigation()->decreaseMinDistanceToReachPoint(); + this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint(); break; default: @@ -247,9 +247,11 @@ void MenuAutopilot::update() { void MenuAutopilot::init() { this->setCountPages(8); - this->driveManager->changeModus(Modi::Autopilot); - this->autopilot = (Autopilot*) this->driveManager->getDriveModiPtr(); + this->autopilot = new Autopilot(); + this->driveManager->changeModus(this->autopilot); this->routeInfo = this->autopilot->getRouteInfo(); - this->driveManager->getNavigation()->increaseMinDistanceToReachPoint(); - this->minDistance = this->driveManager->getNavigation()->decreaseMinDistanceToReachPoint(); + + //dirty hack to get the val, can be better!!! TODO + this->autopilot->getNavigation()->increaseMinDistanceToReachPoint(); + this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint(); } diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h index f662459..c83669d 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h @@ -13,6 +13,7 @@ #define MENU_AUTOPILOT_DRIVE_H #include "SpecialMenus/driveModi/menuDriveMode.h" +#include "driveModi/Modi/Autopilot/autopilot.h" /** * @brief A class to print informations about the Autopilot diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp index 9069641..3b9ac35 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp @@ -110,8 +110,8 @@ void MenuCalibrateCompass::printPage() const { void MenuCalibrateCompass::init() { this->firstPrint = false; - this->driveManager->changeModus(Modi::CalibrateCompass); - this->caliCompassMode = (CalibrateCompassM*) this->driveManager->getDriveModiPtr(); + this->caliCompassMode = new CalibrateCompassM(); + this->driveManager->changeModus(this->caliCompassMode); this->caliCompass = new CalibrateCompass(this->caliCompassMode->getSensorData()->getRealCompass()); this->setCountPages(11); this->updateDelay = 500; diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp index 5a81821..ff7508d 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp @@ -94,7 +94,7 @@ void MenuCaptureRoute::printPage() const { case 7: lineOne = "Current minimal"; - if (this->driveManager->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) + if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) lineTwo = "accuracy is high"; else lineTwo = "accuracy is low"; @@ -118,10 +118,10 @@ void MenuCaptureRoute::runCommand() const { switch (this->getCurrentPage()) { case 7: - if (this->driveManager->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) - this->driveManager->getNavigation()->setMinAccuracy(Point::Accuracy::none); + if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) + this->captureRoute->getNavigation()->setMinAccuracy(Point::Accuracy::none); else - this->driveManager->getNavigation()->setMinAccuracy(Point::Accuracy::twoDigOfCM); + this->captureRoute->getNavigation()->setMinAccuracy(Point::Accuracy::twoDigOfCM); break; default: @@ -132,7 +132,7 @@ void MenuCaptureRoute::runCommand() const { void MenuCaptureRoute::init() { this->setCountPages(8); this->updateDelay = 500; - this->driveManager->changeModus(Modi::CaptureRoute); - this->captureRoute = (CaptureRoute*) this->driveManager->getDriveModiPtr(); + this->captureRoute = new CaptureRoute(); + this->driveManager->changeModus(this->captureRoute); } diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h index 3f321ea..04136c7 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h @@ -12,6 +12,7 @@ #define MENU_MANUAL_DRIVE_H #include "SpecialMenus/driveModi/menuDriveMode.h" +#include "driveModi/Modi/CaptureRoute/captureRoute.h" /** * @brief A class to print informations about the Autopilot diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index f77d6c3..b704d9b 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -56,8 +56,8 @@ void MenuManualControl::printPage() const { void MenuManualControl::init() { this->firstPrint = false; - this->driveManager->changeModus(Modi::ManualControl); - this->manualControl = (ManualControl*) this->driveManager->getDriveModiPtr(); + this->manualControl = new ManualControl(); + this->driveManager->changeModus(this->manualControl); this->setCountPages(4); this->updateDelay = 500; } diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h index 2b1c3d8..7ad8449 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h @@ -13,7 +13,7 @@ #define MENU_MANUAL_DRIVE_H #include "SpecialMenus/driveModi/menuDriveMode.h" -#include "calibrateCompass.h" +#include "driveModi/Modi/ManualControl/manualControl.h" /** * @brief A class to print informations about the class ManualControl diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 18a40d1..6b268cb 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -74,8 +74,8 @@ void MenuTestMode::no() { } void MenuTestMode::init() { - this->driveManager->changeModus(Modi::TestMode); - this->testMode = (TestMode*) this->driveManager->getDriveModiPtr(); + this->testMode = new TestMode(); + this->driveManager->changeModus(this->testMode); testMode->setMaxSpeed(1); testMode->setMaxRotation(8); diff --git a/src/SpecialMenus/driveModi/menuDriveMode.cpp b/src/SpecialMenus/driveModi/menuDriveMode.cpp index 76b0bf3..ab42129 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.cpp +++ b/src/SpecialMenus/driveModi/menuDriveMode.cpp @@ -18,7 +18,7 @@ MenuDriveMode::MenuDriveMode(DriveManager* driveManager) { void MenuDriveMode::left() { this->firstPrint = true; this->configureOnLeave(); - this->driveManager->changeModus(Modi::Off); + this->driveManager->changeModus(); if (parentMenu) { this->parentMenu->printMenu(); this->leaved = true; diff --git a/src/driveModi/Modi/Autopilot/autopilot.cpp b/src/driveModi/Modi/Autopilot/autopilot.cpp index 41b454f..7671518 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.cpp +++ b/src/driveModi/Modi/Autopilot/autopilot.cpp @@ -26,12 +26,11 @@ void DirectionChangeSignal::action() { } -Autopilot::Autopilot(DriveModiParams params, Navigation* navigation) - : ManualControl(params) { +Autopilot::Autopilot() { this->setInputMode(ManualControl::InputMode::Digital); this->directionChangeSignal = new DirectionChangeSignal(this); this->setDirectionChangeCallback(this->directionChangeSignal); - this->navigation = navigation; + this->navigation = new Navigation(this->sensorData); this->init(); } diff --git a/src/driveModi/Modi/Autopilot/autopilot.h b/src/driveModi/Modi/Autopilot/autopilot.h index ea64ac1..3a709be 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.h +++ b/src/driveModi/Modi/Autopilot/autopilot.h @@ -47,7 +47,7 @@ class Autopilot : public ManualControl { * @param moveControl for ManualControl * @param navigation for route instructions */ - Autopilot(DriveModiParams params, Navigation* navigation); + Autopilot(); /** * @brief Destroy the Autopilot object @@ -78,6 +78,7 @@ class Autopilot : public ManualControl { * @return State */ State getState() const { return this->state; } + Navigation* getNavigation() const { return this->navigation; } /** * @brief Tells if there are new informations to display diff --git a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp index d2e195b..5dcdadd 100644 --- a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp +++ b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp @@ -11,7 +11,6 @@ #include "calibrateCompassM.h" -CalibrateCompassM::CalibrateCompassM(DriveModiParams params) : ManualControl(params) {} void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) { if (caliCompass) { diff --git a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h index b101721..753bbc1 100644 --- a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h +++ b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h @@ -18,8 +18,6 @@ class CalibrateCompassM : public ManualControl { public: - CalibrateCompassM(DriveModiParams params); - void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr); private: diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp index 4ab4864..703b201 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp @@ -11,9 +11,8 @@ #include "driveModi/Modi/CaptureRoute/captureRoute.h" -CaptureRoute::CaptureRoute(DriveModiParams params, Navigation* navigation) - : ManualControl(params) { - this->navigation = navigation; +CaptureRoute::CaptureRoute() { + this->navigation = new Navigation(this->sensorData); this->navigation->getRoute()->clear(); this->sensorData->getNtripClient()->setAutoReconnect(true); this->routeInfo = navigation->getRouteInfo(); diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.h b/src/driveModi/Modi/CaptureRoute/captureRoute.h index 0916cee..44b3a4e 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.h +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.h @@ -27,13 +27,7 @@ */ class CaptureRoute : public ManualControl { public: - /** - * @brief Construct a new Capture Route object - * - * @param moveControl for ManualControl - * @param navigation to add Points - */ - CaptureRoute(DriveModiParams params, Navigation* navigation); + CaptureRoute(); /** * @brief Destroy the Capture Route object @@ -56,6 +50,7 @@ class CaptureRoute : public ManualControl { */ RouteInfo getRouteInfo() const { return this->routeInfo; } Navigation::Status getLastStatus() const { return this->status; } + Navigation* getNavigation() const { return this->navigation; } /** * @brief Get the distance to the last saved oint diff --git a/src/driveModi/Modi/ManualControl/manualControl.h b/src/driveModi/Modi/ManualControl/manualControl.h index 138c573..bcda7df 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.h +++ b/src/driveModi/Modi/ManualControl/manualControl.h @@ -33,8 +33,6 @@ class ManualControl : public DriveModi { Digital }; - ManualControl(DriveModiParams params) : DriveModi(params){}; - void switchInputMode(); void setInputMode(InputMode mode) { this->inputMode = mode; } InputMode getInputMode() const { return this->inputMode; } diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index 921e45e..5f5cada 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -10,15 +10,6 @@ */ #include "testMode.h" -TestMode::TestMode(DriveModiParams params, Navigation* navigation) - : DriveModi(params) { - this->navigation = navigation; -} - -TestMode::~TestMode() { - this->moveControl->setDrivingStatus(MoveControl::Status::Stop); -} - void TestMode::run() { if (this->maneuver == Maneuver::Turn) { uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth()); diff --git a/src/driveModi/Modi/TestMode/testMode.h b/src/driveModi/Modi/TestMode/testMode.h index abfe21f..bae19de 100644 --- a/src/driveModi/Modi/TestMode/testMode.h +++ b/src/driveModi/Modi/TestMode/testMode.h @@ -38,15 +38,6 @@ class TestMode : public DriveModi { Drive }; - /** - * @brief Construct a new Test Mode object - * - * @param moveControl - * @param navigation - */ - TestMode(DriveModiParams params, Navigation* navigation); - ~TestMode(); - bool drive(int16_t cm = 0, int16_t degree = 0); /** diff --git a/src/driveModi/driveManager.cpp b/src/driveModi/driveManager.cpp index 5d7dc0f..1631264 100644 --- a/src/driveModi/driveManager.cpp +++ b/src/driveModi/driveManager.cpp @@ -25,59 +25,21 @@ DriveManager::DriveManager(DriveModiParams params){ this->init(); } -DriveManager::~DriveManager() { - delete this->navigation; -} - -void DriveManager::changeModus(Modi modus) { - this->currentModus = modus; - +void DriveManager::changeModus(DriveModi* modus) { if (this->currentModusPtr) { this->removeChildComponent(this->currentModusPtr); delete this->currentModusPtr; + this->currentModusPtr = nullptr; } - //Reset Route to first point - this->navigation->startNavigation(); - switch (modus) { - case Modi::Off: - this->currentModusPtr = nullptr; - break; - - case Modi::ManualControl: { - this->currentModusPtr = new ManualControl(this->driveModiParams); - } - break; - - case Modi::CaptureRoute: { - this->currentModusPtr = new CaptureRoute(this->driveModiParams, this->navigation); - } - break; - - case Modi::Autopilot: { - this->currentModusPtr = new Autopilot(this->driveModiParams, this->navigation); - } - break; - - case Modi::TestMode: { - this->currentModusPtr = new TestMode(driveModiParams, this->navigation); - } - break; - - default: - this->currentModusPtr = nullptr; - break; - } + this->currentModusPtr = modus; if (this->currentModusPtr) + this->currentModusPtr->activate(this->driveModiParams); this->addChildComponent(this->currentModusPtr); } void DriveManager::init() { - this->navigation = new Navigation(this->driveModiParams.sensorData); - this->addChildComponent(this->driveModiParams.moveControl); - this->addChildComponent(this->navigation); this->activateOnlyChilds(); } - diff --git a/src/driveModi/driveManager.h b/src/driveModi/driveManager.h index b0e3215..f62c4e2 100644 --- a/src/driveModi/driveManager.h +++ b/src/driveModi/driveManager.h @@ -12,38 +12,14 @@ #ifndef DRIVE_MANAGER_H #define DRIVE_MANAGER_H -#include -#include - #include "moveControl.h" #include "driveModi/driveModi.h" #include "navigation.h" #include "config.h" -#include "networkConfig.h" -#include "debugTimes.h" #include "controlPadInput.h" #include "component.h" #include "sensorData.h" -// All Drive Modi -#include "driveModi/Modi/ManualControl/manualControl.h" -#include "driveModi/Modi/CaptureRoute/captureRoute.h" -#include "driveModi/Modi/Autopilot/autopilot.h" -#include "driveModi/Modi/TestMode/testMode.h" - -/** - * @brief An enum to choose the DriveMode - * - */ -enum class Modi { - Off, - ManualControl, - CalibrateCompass, - CaptureRoute, - Autopilot, - TestMode -}; - class DriveManager : public Component { public: /** @@ -70,14 +46,7 @@ class DriveManager : public Component { * * @param modus */ - void changeModus(Modi modus); - - /** - * @brief Get the Navigation object - * - * @return Navigation* - */ - Navigation* getNavigation() const {return this->navigation;} + void changeModus(DriveModi* modus = nullptr); /** * @brief Get the DriveModi Ptr object @@ -91,20 +60,14 @@ class DriveManager : public Component { */ DriveModi* getDriveModiPtr() const { return this->currentModusPtr; } - /** - * @brief Get the DriveModi enum - * - * @return Modi - */ - Modi getDriveModi() const { return this->currentModus; } + + bool isActive() const { return this->currentModusPtr; } private: void run() override {}; void init(); - Modi currentModus = Modi::Off; DriveModi *currentModusPtr = nullptr; - Navigation* navigation; DriveModiParams driveModiParams; }; diff --git a/src/driveModi/driveModi.cpp b/src/driveModi/driveModi.cpp index f07e6fe..fb0aa25 100644 --- a/src/driveModi/driveModi.cpp +++ b/src/driveModi/driveModi.cpp @@ -1,17 +1,7 @@ #include "driveModi.h" -DriveModi::DriveModi(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData) { - this->moveControl = moveControl; - this->input = input; - this->sensorData = sensorData; - this->init(); -} - -DriveModi::DriveModi(DriveModiParams params){ - this->moveControl = params.moveControl; - this->input = params.input; - this->sensorData = params.sensorData; - this->init(); +DriveModi::DriveModi() { + this->loopDelay = 0; } DriveModi::~DriveModi() { @@ -20,6 +10,20 @@ DriveModi::~DriveModi() { this->moveControl->setDrivingStatus(MoveControl::Status::Stop); } +void DriveModi::activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData) { + this->moveControl = moveControl; + this->input = input; + this->sensorData = sensorData; + this->init(); +} + +void DriveModi::activate(DriveModiParams params){ + this->moveControl = params.moveControl; + this->input = params.input; + this->sensorData = params.sensorData; + this->init(); +} + void DriveModi::init() { this->moveControl->setDrivingStatus(MoveControl::Status::Drive); this->loopDelay = 40; diff --git a/src/driveModi/driveModi.h b/src/driveModi/driveModi.h index b2267c3..46bbb5a 100644 --- a/src/driveModi/driveModi.h +++ b/src/driveModi/driveModi.h @@ -31,12 +31,14 @@ struct DriveModiParams { */ class DriveModi : public Component { public: - DriveModi(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData); - DriveModi(DriveModiParams); + DriveModi(); virtual ~DriveModi(); const SensorData* getSensorData() const { return this->sensorData; } + void activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData); + void activate(DriveModiParams params); + /** * @brief Set the max speed * diff --git a/src/main.cpp b/src/main.cpp index 0044b6f..09b1ec8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -224,7 +224,8 @@ void makeMenu() { MenuCalibrateCompass* comp_m = new MenuCalibrateCompass(driveManager); MenuGPS* gps_m = new MenuGPS(sensorData); MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery); - MenuRoute* rout_m = new MenuRoute(driveManager->getNavigation()->getRoute()); + //TODO: Wie bekommt jeder die dumme Route? + MenuRoute* rout_m = new MenuRoute(new Route()); auto_m->setUpdateDelay(1000); gps_m->setUpdateDelay(1000); From 1d56a2a36d5fea94574615fa6104a9f15341ac8d Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Mon, 4 Sep 2023 15:52:34 +0200 Subject: [PATCH 02/26] - battery calc now more efficent - new battery values now every 0.5s --- doc/TODO allgemein.txt | 21 +++++++++++++++------ lib/Battery/battery.cpp | 3 ++- lib/Battery/battery.h | 3 ++- src/main.cpp | 1 + 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 0719e08..ae1a25d 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -17,22 +17,31 @@ Do later: -> Menu Display from parent as run() to make Menu as Component -> Racing Mode -> ConsolControl + -> Menü für Sensordaten (kann in jedem Betriebsmodus aufgerufen werden) + - GNSS + - Ntrip + - CalcCompass + - RealCompass + - Gyroskop + - Geschwindigkeiten (vielleicht) + -> Menü für Einstellungen + - PID + - Geschwindigkeiten + -> Battery + - tabelle mit eigenen Werten übergeben und nicht in header (wiederverwendbarkeit) + - kalibrierungsmethode mit Menü + - Daten in flash speichern können + Do now: Code: Doxygen Kommentare aktualisieren - Geschwindigkeiten außerhalb von Modi einstellen, Manager kann die Werte einstellen da Interface Automat in MoveControl weil jetzt in Arbeit beschrieben Liste mit Betriebsmodi, automatisch in Menü einfügen - Betriebmodi dem Drivemanger ohne switchCase geben, aus Liste oder so - bettery managment checken, buffer in battery und in Main - battery tabelle mit eigenen Werten übergeben und nicht in header (wiederverwendbarkeit) - battery methode für daten erzeugen und in eeporm speichern battery bruch mit R werten nur einmal berechnen lange kein daten von fernbedienung dann? Input pointer von fernbedienung nicht veränderbar doppel const trennen funktion und ui route menü - DriveManager Mode als Template übergeben Latex: Genaue Beschreibung von PulseCounter HardwareUnit wenn möglich diff --git a/lib/Battery/battery.cpp b/lib/Battery/battery.cpp index d13e496..5a7bd96 100644 --- a/lib/Battery/battery.cpp +++ b/lib/Battery/battery.cpp @@ -15,6 +15,7 @@ Battery::Battery(uint8_t pin, uint32_t r1, uint32_t r2) { this->pin = pin; this->r1 = r1; this->r2 = r2; + this->batteryVoltageFactor = (double) (this->r1 + this->r2)) / (double) this->r2 this->initBuffer(); this->loopDelay = 100; } @@ -71,7 +72,7 @@ double Battery::calculateInputVoltage() { void Battery::calculateBatteryVoltage() { if (this->r1 && this->r2) { - this->batteryVoltage = (this->calculateInputVoltage() * (double) (this->r1 + this->r2)) / (double) this->r2; + this->batteryVoltage = (this->calculateInputVoltage() * this->batteryVoltageFactor; return; } diff --git a/lib/Battery/battery.h b/lib/Battery/battery.h index f6837be..e0b9f38 100644 --- a/lib/Battery/battery.h +++ b/lib/Battery/battery.h @@ -88,13 +88,14 @@ class Battery : public Component { uint8_t batteryPercent = 0; uint8_t batteryLowPercent = 10; uint8_t bufferPos = 0; - uint8_t calulationDelayMultiplier = 10; + uint8_t calulationDelayMultiplier = 5; uint8_t loopCounter = 0; uint16_t adcBuffer[bufferSize]; uint32_t r1 = 0; uint32_t r2 = 0; bool calculatetNewValues = false; double batteryVoltage = 0; + double batteryVoltageFactor; const float capacityVoltages[21] = {9.82, 10.83, 11.06, 11.12, // 0 5 10 15 11.18, 11.24, 11.3, 11.36, // 20 25 30 35 diff --git a/src/main.cpp b/src/main.cpp index 09b1ec8..15a814c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -154,6 +154,7 @@ void loop() { lcdWrapper->loop(); mainBattery->loop(); + // new Value ervery 0.5s if (mainBattery->isNewValue()) { static uint8_t batteryLowCounter = 0; if (mainBattery->isBatteryLow(10)) From 7c94c8cc56472df8eea5aaac3f1079d01aa840b9 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Mon, 4 Sep 2023 19:42:11 +0200 Subject: [PATCH 03/26] implement gyroskop --- doc/TODO allgemein.txt | 13 +++--- lib/Battery/battery.cpp | 4 +- lib/Sensors/sensorData.cpp | 31 +++++++++++++ lib/Sensors/sensorData.h | 14 ++++-- platformio.ini | 5 +-- .../SensorData/menuSensorData.cpp | 45 +++++++++++++++++++ src/SpecialMenus/SensorData/menuSensorData.h | 28 ++++++++++++ .../Modi/ManualControl/manualControl.cpp | 2 +- src/main.cpp | 4 ++ 9 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 src/SpecialMenus/SensorData/menuSensorData.cpp create mode 100644 src/SpecialMenus/SensorData/menuSensorData.h diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index ae1a25d..cfe6422 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -10,7 +10,9 @@ Do later: -> Engine slow down without curve in motorControl -> Network clean up (Mqtt remove?) -> Extra class for maneuver, autopilot should inherit from int16_t - -> Better remote Control with Leds for gnss rtk etc + -> Remote Control + - Leds for gnss rtk etc + - what happens exactly when no data is arriving -> Test Menu for big curve driving -> Api with Names and show on Maps in Browser -> Menu structure mit add functions for each menu mit pointer return to config (additional not replace) @@ -27,21 +29,18 @@ Do later: -> Menü für Einstellungen - PID - Geschwindigkeiten + - WiFi (save in Flash) -> Battery - tabelle mit eigenen Werten übergeben und nicht in header (wiederverwendbarkeit) - kalibrierungsmethode mit Menü - Daten in flash speichern können + -> Check speration between Ui and Route (RouteMenu) Do now: Code: Doxygen Kommentare aktualisieren - Automat in MoveControl weil jetzt in Arbeit beschrieben - Liste mit Betriebsmodi, automatisch in Menü einfügen - battery bruch mit R werten nur einmal berechnen - lange kein daten von fernbedienung dann? - Input pointer von fernbedienung nicht veränderbar doppel const - trennen funktion und ui route menü + Add Gyroskop Sensor Latex: Genaue Beschreibung von PulseCounter HardwareUnit wenn möglich diff --git a/lib/Battery/battery.cpp b/lib/Battery/battery.cpp index 5a7bd96..1038698 100644 --- a/lib/Battery/battery.cpp +++ b/lib/Battery/battery.cpp @@ -15,7 +15,7 @@ Battery::Battery(uint8_t pin, uint32_t r1, uint32_t r2) { this->pin = pin; this->r1 = r1; this->r2 = r2; - this->batteryVoltageFactor = (double) (this->r1 + this->r2)) / (double) this->r2 + this->batteryVoltageFactor = (double) (this->r1 + this->r2) / (double) this->r2; this->initBuffer(); this->loopDelay = 100; } @@ -72,7 +72,7 @@ double Battery::calculateInputVoltage() { void Battery::calculateBatteryVoltage() { if (this->r1 && this->r2) { - this->batteryVoltage = (this->calculateInputVoltage() * this->batteryVoltageFactor; + this->batteryVoltage = this->calculateInputVoltage() * this->batteryVoltageFactor; return; } diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 5ca4809..22ddd58 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -70,7 +70,32 @@ void SensorData::enableCalcCompass() { } void SensorData::enableGyroskop() { + this->gyroskop->initialize(); + if (!this->gyroskop->testConnection()) { + std::cout << "SensorData::enableGyroskop: Gyroskop is not conntected. Freeze!" << std::endl; + while (true); + } + + uint8_t deviceStatus = this->gyroskop->dmpInitialize(); + + this->gyroskop->setXGyroOffset(220); + this->gyroskop->setYGyroOffset(76); + this->gyroskop->setZGyroOffset(-85); + this->gyroskop->setZAccelOffset(1788); + if (deviceStatus == 0) { + this->gyroskop->CalibrateAccel(6); + this->gyroskop->CalibrateGyro(6); + this->gyroskop->PrintActiveOffsets(); + this->gyroskop->setDMPEnabled(true); + } else { + // ERROR! + // 1 = initial memory load failed + // 2 = DMP configuration updates failed + // (if it's going to break, usually the code will be 1) + std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << (int) deviceStatus <<"). Freeze!" << std::endl; + while (true); + } } CalcAzimuth::State SensorData::getCalcAzimuthState() const { @@ -141,6 +166,12 @@ void SensorData::setOutputStatusPrintPVTdata(bool status) { void SensorData::run() { this->realCompass->read(); this->realAzimuth = this->realCompass->getAzimuth(); + + if (this->gyroskop->dmpGetCurrentFIFOPacket(this->gyroBuffer)) { + this->gyroskop->dmpGetQuaternion(&this->quaternion, this->gyroBuffer); + this->gyroskop->dmpGetGravity(&this->gravity, &this->quaternion); + this->gyroskop->dmpGetYawPitchRoll(this->yawPitchRoll, &this->quaternion, &this->gravity); + } } void SensorData::runAsChild() { diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index fb4abe1..15add06 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -13,6 +13,7 @@ #define SENSOR_DATA_H #include +#include #include #include "component.h" @@ -20,7 +21,7 @@ #include #include -// Gyroskop +#include #include "calcAzimuth.h" #include "ntripClient.h" @@ -46,11 +47,12 @@ class SensorData : public Component { Point getCurrentPos() const { return this->currentPosition; } const UBX_NAV_PVT_data_t* getGnssData() const { return this->gnssData; }; - const void* const getGyroData() const; + const float* getGyroData() const { return this->yawPitchRoll; } CalcAzimuth* getCalcCompass() const { return this->calcCompass; } QMC5883LCompass* getRealCompass() const { return this->realCompass; } NTRIPClient* getNtripClient() const { return this->ntripClient; } + MPU6050* getGyroskop() const { return this->gyroskop; } // static /** @@ -72,9 +74,12 @@ class SensorData : public Component { CalcAzimuth* calcCompass = nullptr; SFE_UBLOX_GNSS* gnss = nullptr; NTRIPClient* ntripClient = nullptr; + MPU6050* gyroskop = nullptr; UBX_NAV_PVT_data_t* gnssData; Point currentPosition; + Quaternion quaternion; + VectorFloat gravity; char* host; char* mountPoint; @@ -83,18 +88,19 @@ class SensorData : public Component { bool isNtripInit = false; + uint8_t gyroBuffer[64]; uint16_t port; int16_t realAzimuth = INT16_MAX; int16_t calcAzimuth = INT16_MAX; + float yawPitchRoll[3]; + // 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 bool newData; }; diff --git a/platformio.ini b/platformio.ini index da001b9..8009a02 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,10 +25,8 @@ lib_deps = mprograms/QMC5883LCompass@^1.2.0 https://git.kleiax.de/PlatformIO-Libs/Menu.git nrf24/RF24@^1.4.5 + jrowberg/I2Cdevlib-MPU6050@^1.0.0 upload_port = COM6 -; extra_scripts = -; pre:autoVersionIncrement/version_increment_pre.py -; post:autoVersionIncrement/version_increment_post.py test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder @@ -37,6 +35,7 @@ check_tool = clangtidy [env:native] platform = native test_ignore = test_embedded +lib_deps = jrowberg/I2Cdevlib-MPU6050@^1.0.0 [platformio] description = A Rover who should be drive a route by gps. diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp new file mode 100644 index 0000000..8198e4c --- /dev/null +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -0,0 +1,45 @@ +/** + * @file menuSensorData.cpp + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-04 + * + * @copyright Copyright (c) 2023 + * + */ + +#include "menuSensorData.h" + +MenuSensorData::MenuSensorData(SensorData* sensorData) : + MenuInformationSites(4) { + this->sensorData = sensorData; +} + +void MenuSensorData::printPage() const { + String lineOne = ""; + String lineTwo = ""; + + switch (this->getCurrentPage()) { + case 0: + lineOne = "Yaw:"; + lineTwo.concat(this->sensorData->getGyroData()[0]); + break; + + case 1: + lineOne = "Pitch:"; + lineTwo.concat(this->sensorData->getGyroData()[1]); + break; + + case 2: + lineOne = "Roll:"; + lineTwo.concat(this->sensorData->getGyroData()[2]); + break; + + default: + this->printDefault(); + return; + } + + this->print(lineOne, lineTwo); +} diff --git a/src/SpecialMenus/SensorData/menuSensorData.h b/src/SpecialMenus/SensorData/menuSensorData.h new file mode 100644 index 0000000..9f0883b --- /dev/null +++ b/src/SpecialMenus/SensorData/menuSensorData.h @@ -0,0 +1,28 @@ +/** + * @file menuSensorData.h + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-04 + * + * @copyright Copyright (c) 2023 + * + */ + +#ifndef MENU_SENSOR_DATA_H +#define MENU_SENSOR_DATA_H + +#include "menuInformationSites.h" +#include "sensorData.h" + +class MenuSensorData : public MenuInformationSites { + public: + MenuSensorData(SensorData* SensorData); + + private: + void printPage() const override; + + SensorData* sensorData; +}; + +#endif //MENU_SENSOR_DATA_H diff --git a/src/driveModi/Modi/ManualControl/manualControl.cpp b/src/driveModi/Modi/ManualControl/manualControl.cpp index a6891ab..a59fa3f 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.cpp +++ b/src/driveModi/Modi/ManualControl/manualControl.cpp @@ -32,7 +32,7 @@ void ManualControl::switchInputMode() { void ManualControl::analogControl() { // Have to be int16_t to avoid overflow (int8_t = 255 - 127 = -128) int16_t x = this->input->x - 127; - int16_t y = this-> input->y - 127; + int16_t y = this->input->y - 127; // static int counter = 0; // if (counter % 60 == 0) { diff --git a/src/main.cpp b/src/main.cpp index 15a814c..3f85073 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,6 +46,7 @@ #include "SpecialMenus/PID/menuPidSettings.h" #include "SpecialMenus/Route/menuRoute.h" #include "SpecialMenus/GPS/menuGPS.h" +#include "SpecialMenus/SensorData/menuSensorData.h" MoveControl moveController; DriveManager* driveManager; @@ -225,15 +226,18 @@ void makeMenu() { MenuCalibrateCompass* comp_m = new MenuCalibrateCompass(driveManager); MenuGPS* gps_m = new MenuGPS(sensorData); MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery); + MenuSensorData* sen_m = new MenuSensorData(sensorData); //TODO: Wie bekommt jeder die dumme Route? MenuRoute* rout_m = new MenuRoute(new Route()); auto_m->setUpdateDelay(1000); gps_m->setUpdateDelay(1000); sys_m->setUpdateDelay(1500); + sen_m->setUpdateDelay(500); // Entry for the main menu main_m->addEntry(new MenuAction("Mode", mode_m)); + main_m->addEntry(new MenuAction("Sensor", sen_m)); main_m->addEntry(new MenuAction("GPS", gps_m)); main_m->addEntry(new MenuAction("Route", rout_m)); main_m->addEntry(new MenuAction("PID", pid_m)); From 7c8406f4382976f35dcc0a2277fd16f9832519c4 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Mon, 4 Sep 2023 20:01:40 +0200 Subject: [PATCH 04/26] fix bugs in gyro implematation --- lib/Sensors/sensorData.cpp | 1 + src/main.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 22ddd58..e7d4159 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -70,6 +70,7 @@ void SensorData::enableCalcCompass() { } void SensorData::enableGyroskop() { + this->gyroskop = new MPU6050(); this->gyroskop->initialize(); if (!this->gyroskop->testConnection()) { std::cout << "SensorData::enableGyroskop: Gyroskop is not conntected. Freeze!" << std::endl; diff --git a/src/main.cpp b/src/main.cpp index 3f85073..6f9b80a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -121,6 +121,7 @@ void setup() { sensorData = new SensorData(); sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs); sensorData->enableRealCompass(); + sensorData->enableGyroskop(); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); outputBuf->activateMqtt(true); From ad560e7d16d84049d7bdd9a73973851a8f723eba Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Sun, 10 Sep 2023 13:00:12 +0200 Subject: [PATCH 05/26] more sensorData menu --- doc/TODO allgemein.txt | 1 - lib/CalcAzimuth/calcAzimuth.cpp | 22 +++ lib/CalcAzimuth/calcAzimuth.h | 2 + lib/Sensors/sensorData.cpp | 6 + lib/Sensors/sensorData.h | 1 + src/SpecialMenus/GPS/menuGPS.cpp | 159 ------------------ src/SpecialMenus/GPS/menuGPS.h | 42 ----- .../SensorData/menuSensorData.cpp | 86 +++++++++- src/main.cpp | 12 +- 9 files changed, 119 insertions(+), 212 deletions(-) delete mode 100644 src/SpecialMenus/GPS/menuGPS.cpp delete mode 100644 src/SpecialMenus/GPS/menuGPS.h diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index cfe6422..070ef63 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -40,7 +40,6 @@ Do later: Do now: Code: Doxygen Kommentare aktualisieren - Add Gyroskop Sensor Latex: Genaue Beschreibung von PulseCounter HardwareUnit wenn möglich diff --git a/lib/CalcAzimuth/calcAzimuth.cpp b/lib/CalcAzimuth/calcAzimuth.cpp index 8db7a5d..889155c 100644 --- a/lib/CalcAzimuth/calcAzimuth.cpp +++ b/lib/CalcAzimuth/calcAzimuth.cpp @@ -30,6 +30,28 @@ void CalcAzimuth::updateCurrentPosition(Point point) { this->positionChanged = true; } +String CalcAzimuth::stateToString(State state) { + switch (state) { + case State::Invalid: + return "Invalid"; + + case State::Bad: + return "Bad"; + + case State::Ok: + return "Ok"; + + case State::Good: + return "Good"; + + case State::Super: + return "Super"; + + default: + return "UNKOWN"; + } +} + void CalcAzimuth::run() { if (!this->positionChanged) return; diff --git a/lib/CalcAzimuth/calcAzimuth.h b/lib/CalcAzimuth/calcAzimuth.h index b44cf8f..03a9a21 100644 --- a/lib/CalcAzimuth/calcAzimuth.h +++ b/lib/CalcAzimuth/calcAzimuth.h @@ -34,6 +34,8 @@ class CalcAzimuth : public Component { int16_t getAzimuth() const { return this->calcAzimuth; } State getState() const { return this->state; } + static String stateToString(State state); + private: void run() override; void updateAzimuth(); diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index e7d4159..5e7a4d7 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -105,6 +105,12 @@ CalcAzimuth::State SensorData::getCalcAzimuthState() const { return CalcAzimuth::State::Invalid; } +NTRIPClientStates SensorData::getNtripState() const { + if (this->ntripClient) + return this->ntripClient->getClientState(); + return NTRIPClientStates::notAvailable; +} + void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { if (!SensorData::outputStatusPrintPVTdata) return; diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index 15add06..71fcf54 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -47,6 +47,7 @@ class SensorData : public Component { Point getCurrentPos() const { return this->currentPosition; } const UBX_NAV_PVT_data_t* getGnssData() const { return this->gnssData; }; + NTRIPClientStates getNtripState() const; const float* getGyroData() const { return this->yawPitchRoll; } CalcAzimuth* getCalcCompass() const { return this->calcCompass; } diff --git a/src/SpecialMenus/GPS/menuGPS.cpp b/src/SpecialMenus/GPS/menuGPS.cpp deleted file mode 100644 index 878fd13..0000000 --- a/src/SpecialMenus/GPS/menuGPS.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @file menuGPS.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains an implementation of the class MenuGPS - * @version 0.1 - * @date 2022-01-29 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "menuGPS.h" - -MenuGPS::MenuGPS(SensorData* sensorData) : - MenuInformationSites(10) { - this->sensorData = sensorData; - // this->ntripClient = this->navigation->getNTRIPClient(); -} - -void MenuGPS::printPage() const { - const UBX_NAV_PVT_data_t* gpsData = this->sensorData->getGnssData(); - uint8_t fixType = 0; - if (gpsData) - fixType = gpsData->fixType; - - String lineOne = "Data isn't valid"; - String lineTwo = "or no GPS signal"; - - switch (this->getCurrentPage()) { - case 0: - if (fixType) { - lineOne = "Sats: "; - lineOne.concat(gpsData->numSV); - lineTwo = "PDOP: "; - lineTwo.concat(gpsData->pDOP); - } - break; - - case 1: - if (fixType) { - lineOne = "Lat: "; - lineOne.concat(gpsData->lat); - lineTwo = "Lon: "; - lineTwo.concat(gpsData->lon); - } - break; - - case 2: - lineOne = "Time: "; - lineTwo = ""; - if (fixType) { - if (gpsData->hour < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->hour); - lineTwo.concat(":"); - if (gpsData->min < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->min); - lineTwo.concat(":"); - if (gpsData->sec < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->sec); - } else - lineTwo = "00:00:00"; - - break; - - case 3: { - // NTRIPClientStates status = this->ntripClient->getClientState(); - // lineOne = "NTRIP Client is"; - - // if (status == NTRIPClientStates::pushData) - // lineTwo = "enabled"; - // else if (status == NTRIPClientStates::notAvailable) - // lineTwo = "not available"; - // else - // lineTwo = "disabled"; - } - break; - - case 4: - lineOne = "Fix type:"; - if (fixType == 0) - lineTwo = "None"; - else if (fixType == 1) - lineTwo = "Dead Reckoning"; - else if (fixType == 2) - lineTwo = "2D"; - else if (fixType == 3) - lineTwo = "3D"; - else if (fixType == 3) - lineTwo = "GNSS + Dead Reck"; - else if (fixType == 5) - lineTwo = "Time Only"; - else - lineTwo = "UNKNOWN"; - 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 = "Hrizntl Accuracy"; - if (fixType) { - lineTwo = ""; - lineTwo.concat(gpsData->hAcc); - } else - lineTwo = "0"; - break; - - case 7: - lineOne = "magDec: "; - lineTwo = "magAcc: "; - if (fixType) { - lineOne.concat(gpsData->magDec); - lineTwo.concat(gpsData->magAcc); - } else { - lineOne.concat("---"); - lineTwo.concat("---"); - } - break; - - case 8: - lineOne = "Azimuth: "; - lineTwo = ""; - lineTwo.concat(this->sensorData->getRealAzimuth()); - break; - - default: - this->printDefault(); - return; - } - - this->print(lineOne, lineTwo); -} - -void MenuGPS::runCommand() const { - switch (this->getCurrentPage()) { - case 3: { - // // std::cout << "MenuGPS::runCommand " << this->ntripClient->getClientState() << std::endl; - // if (this->ntripClient->getClientState() == NTRIPClientStates::pushData) - // this->ntripClient->setActivated(false); - // else if (this->ntripClient->getClientState() != NTRIPClientStates::notAvailable) - // this->ntripClient->setActivated(true); - } - break; - } -} diff --git a/src/SpecialMenus/GPS/menuGPS.h b/src/SpecialMenus/GPS/menuGPS.h deleted file mode 100644 index e88f6fe..0000000 --- a/src/SpecialMenus/GPS/menuGPS.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file menuGPS.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class to print informations about the GPS object - * @version 0.1 - * @date 2022-01-29 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef MENU_GPS_H -#define MENU_GPS_H - -#include - -#include "menuInformationSites.h" -#include "sensorData.h" -#include "ntripClient.h" - -/** - * @brief A class to print informations about the GPS object - * - */ -class MenuGPS : public MenuInformationSites { - public: - /** - * @brief Construct a new Menu GPS object - * - * @param gps - */ - MenuGPS(SensorData* sensorData); - - private: - void printPage() const override; - void runCommand() const override; - - // NTRIPClient* ntripClient; - SensorData* sensorData; -}; - -#endif // MENU_GPS_H diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp index 8198e4c..56b9545 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.cpp +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -12,28 +12,102 @@ #include "menuSensorData.h" MenuSensorData::MenuSensorData(SensorData* sensorData) : - MenuInformationSites(4) { + MenuInformationSites(7) { this->sensorData = sensorData; } void MenuSensorData::printPage() const { + const UBX_NAV_PVT_data_t* gpsData = this->sensorData->getGnssData(); + uint8_t fixType = 0; + if (gpsData) + fixType = gpsData->fixType; + String lineOne = ""; String lineTwo = ""; switch (this->getCurrentPage()) { case 0: - lineOne = "Yaw:"; + lineOne = " Y P R :"; lineTwo.concat(this->sensorData->getGyroData()[0]); + lineTwo.concat(" "); + lineTwo.concat(this->sensorData->getGyroData()[1]); + lineTwo.concat(" "); + lineTwo.concat(this->sensorData->getGyroData()[2]); break; case 1: - lineOne = "Pitch:"; - lineTwo.concat(this->sensorData->getGyroData()[1]); + lineOne = "Real Azimuth:"; + lineTwo.concat(this->sensorData->getRealAzimuth()); break; case 2: - lineOne = "Roll:"; - lineTwo.concat(this->sensorData->getGyroData()[2]); + lineOne = "Calc Azimuth:"; + lineTwo.concat(this->sensorData->getCalcAzimuth()); + lineTwo.concat(" "); + lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState)); + break; + + case 3: { + lineOne = "Lat:"; + lineTwo = "Lon:"; + Point pos = this->sensorData->getCurrentPos(); + lineOne.concat(pos.getLatitude()); + lineTwo.concat(pos.getLongitude()); + } + break; + + case 4: + lineOne = "Time: "; + lineTwo = ""; + if (fixType) { + if (gpsData->hour < 10) + lineTwo.concat("0"); + lineTwo.concat(gpsData->hour); + lineTwo.concat(":"); + if (gpsData->min < 10) + lineTwo.concat("0"); + lineTwo.concat(gpsData->min); + lineTwo.concat(":"); + if (gpsData->sec < 10) + lineTwo.concat("0"); + lineTwo.concat(gpsData->sec); + } else + lineTwo = "00:00:00"; + + break; + + case 5: { + lineOne = "CarSol: "; + lineTwo = "Ntrip: "; + uint8_t carrSoln = gpsData->flags.bits.carrSoln; + if (carrSoln == 0) + lineOne = "None"; + else if (carrSoln == 1) + lineOne = "Floating"; + else if (carrSoln == 2) + lineOne = "Fixed"; + else + lineOne = "UNKNOWN"; + NTRIPClientStates status = this->sensorData->getNtripState(); + if (status == NTRIPClientStates::pushData) + lineTwo = "enabled"; + else if (status == NTRIPClientStates::notAvailable) + lineTwo = " N/A"; + else + lineTwo = "disabled"; + } + break; + + case 6: + lineOne = "HAcc: "; + lineTwo = "Sats: "; + if (fixType) { + lineOne.concat(gpsData->hAcc); + lineTwo.concat(gpsData->numSV); + } else { + lineOne = "-/-"; + lineTwo = "-/-"; + } break; default: diff --git a/src/main.cpp b/src/main.cpp index 6f9b80a..97bbcd4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -217,6 +217,7 @@ void makeMenu() { main_m = new Menu(); main_m->setLcd(lcdWrapper); Menu* mode_m = new Menu(); + Menu* set_m = new Menu(); Menu* pid_m = new Menu(); MenuIntInput* pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0))); MenuIntInput* pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); @@ -225,23 +226,20 @@ void makeMenu() { MenuAutopilot* auto_m = new MenuAutopilot(driveManager); MenuTestMode* testM_m = new MenuTestMode(driveManager); MenuCalibrateCompass* comp_m = new MenuCalibrateCompass(driveManager); - MenuGPS* gps_m = new MenuGPS(sensorData); MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery); MenuSensorData* sen_m = new MenuSensorData(sensorData); //TODO: Wie bekommt jeder die dumme Route? MenuRoute* rout_m = new MenuRoute(new Route()); auto_m->setUpdateDelay(1000); - gps_m->setUpdateDelay(1000); sys_m->setUpdateDelay(1500); sen_m->setUpdateDelay(500); // Entry for the main menu main_m->addEntry(new MenuAction("Mode", mode_m)); main_m->addEntry(new MenuAction("Sensor", sen_m)); - main_m->addEntry(new MenuAction("GPS", gps_m)); main_m->addEntry(new MenuAction("Route", rout_m)); - main_m->addEntry(new MenuAction("PID", pid_m)); + main_m->addEntry(new MenuAction("Settings", set_m)); main_m->addEntry(new MenuAction("Systeminfo", sys_m)); main_m->addEntry(new MenuAction("Restart", restart)); @@ -253,6 +251,12 @@ void makeMenu() { mode_m->addEntry(new MenuAction("Test Mode", testM_m)); mode_m->addEntry(new MenuAction("Consol Control", dummy)); + // Entry for the setting menu + set_m->addEntry(new MenuAction("PID", pid_m)); + set_m->addEntry(new MenuAction("Speed", dummy)); + set_m->addEntry(new MenuAction("Distance", dummy)); + set_m->addEntry(new MenuAction("WiFi", dummy)); + // Entry for the PID Menu pid_m->addEntry(new MenuAction("Left", pidl_m)); pid_m->addEntry(new MenuAction("Right", pidr_m)); From 6c82b9bc6cc9eaa51b5fac264c070bca42159b8c Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Tue, 12 Sep 2023 20:51:41 +0200 Subject: [PATCH 06/26] update todo --- doc/TODO allgemein.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 070ef63..824b11e 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -42,7 +42,6 @@ Code: Doxygen Kommentare aktualisieren Latex: - Genaue Beschreibung von PulseCounter HardwareUnit wenn möglich Anhang: Liste mit allen Komponenten und Kurzbeschreibung 3D: From ae6e74507db961fbb2c0270111c7b4cc94be1112 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 14 Sep 2023 21:54:52 +0200 Subject: [PATCH 07/26] todos --- doc/TODO allgemein.txt | 2 ++ platformio.ini | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 824b11e..87f465a 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -40,6 +40,8 @@ Do later: Do now: Code: Doxygen Kommentare aktualisieren + update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung + wifi als Komponente Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung diff --git a/platformio.ini b/platformio.ini index 8009a02..c5bc22d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -35,7 +35,6 @@ check_tool = clangtidy [env:native] platform = native test_ignore = test_embedded -lib_deps = jrowberg/I2Cdevlib-MPU6050@^1.0.0 [platformio] description = A Rover who should be drive a route by gps. From 936d2b96475d8a5b62ce604aa1fb3d61373c81c0 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Sun, 17 Sep 2023 11:27:23 +0200 Subject: [PATCH 08/26] todos --- doc/TODO allgemein.txt | 12 ++++++++++++ .../Systeminformation/menuSysteminformatio.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 87f465a..74b2cdb 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -45,6 +45,18 @@ Code: Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung + Ausgangssituation, langweilig. Begründung wiesow was nicht benutzt wurde. + Anführungszeichen werden nicht richtig gesetzt, 2.1.1 / 2.2.1 / Oberrahmen "A" / Antennenhalterung "T." + Quellen mal mit und mal ohne leerzeichen hinterm Satz + Alle Aufzählungen am Anfang klein. Und EIN Punkt beim letzten Punkt / Vielleicht komme nach jedem Punkt + Kompass soft und hardware winkel auslesen norden = 0° + Anforderungsanalyse Beschreibung des Pattern, keine Unterstriche sichtbar + Unterschied funktionale und nicht funktionale Anforderungen + Haupträger zweite Abbildung von oben mit benannten Aussparungen + + + + 3D: Oberrahmen soll nur aussehen wie ein A diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp index fd2e5ab..743dc74 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp +++ b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp @@ -26,7 +26,7 @@ void MenuSysteminformation::printPage() const { break; case 1: - lineOne = "Max alloc heap:"; + lineOne = "Max alloc Heap:"; lineTwo.concat(ESP.getMaxAllocHeap()); break; From baf1936824e8a09041fc593fe66edaafcd8eec11 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 20 Sep 2023 08:51:31 +0200 Subject: [PATCH 09/26] network is now a component --- doc/TODO allgemein.txt | 26 ++- include/network.h | 107 ----------- include/networkConfig.h | 113 ++++-------- lib/Network/network.cpp | 164 +++++++++++++++++ lib/Network/network.h | 85 +++++++++ lib/Sensors/sensorData.cpp | 20 +- .../SensorData/menuSensorData.cpp | 2 +- src/main.cpp | 63 ++++--- src/network.cpp | 174 ------------------ 9 files changed, 340 insertions(+), 414 deletions(-) delete mode 100644 include/network.h create mode 100644 lib/Network/network.cpp create mode 100644 lib/Network/network.h delete mode 100644 src/network.cpp diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 74b2cdb..b704681 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -35,30 +35,28 @@ Do later: - kalibrierungsmethode mit Menü - Daten in flash speichern können -> Check speration between Ui and Route (RouteMenu) + -> update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung + -> Rover Objekt mit Error zustand freeze, damit das wenn möglich auch auf dem Display angezeigt wird. Do now: Code: Doxygen Kommentare aktualisieren - update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung - wifi als Komponente + sensor data gnss daten aktualisieren + Menübaum korrigieren, Verlinkung Sensor in Mode etc. + esp und sensoren in den deepsleep Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung - Ausgangssituation, langweilig. Begründung wiesow was nicht benutzt wurde. - Anführungszeichen werden nicht richtig gesetzt, 2.1.1 / 2.2.1 / Oberrahmen "A" / Antennenhalterung "T." - Quellen mal mit und mal ohne leerzeichen hinterm Satz - Alle Aufzählungen am Anfang klein. Und EIN Punkt beim letzten Punkt / Vielleicht komme nach jedem Punkt - Kompass soft und hardware winkel auslesen norden = 0° - Anforderungsanalyse Beschreibung des Pattern, keine Unterstriche sichtbar Unterschied funktionale und nicht funktionale Anforderungen - Haupträger zweite Abbildung von oben mit benannten Aussparungen - - - - + Weniger / Keine Füllwörter + Strom nicht über Zeit sondern Rampe + ESP Pulsecounter Name Richtig? + Zittern? Besseres Wort Signal kann Springen + Rad Umfang gerundet + Trick Debugging mit dem Stream + Gyroskop für Bachelor aufheben 3D: - Oberrahmen soll nur aussehen wie ein A diff --git a/include/network.h b/include/network.h deleted file mode 100644 index cf2cd9b..0000000 --- a/include/network.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file network.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the Network class. - * @version 0.1 - * @date 2021-12-14 - * - * @copyright Copyright (c) 2021 - * - */ - -#ifndef NETWORK_H -#define NETWORK_H - -#include -#include -#include -#include -#include - -#include "networkConfig.h" - -typedef void (*recieveCallbackPtr) (const uint8_t * mac, const uint8_t *incomingData, int len); -typedef void (*sendCallbackPtr) (const uint8_t *mac_addr, esp_now_send_status_t status); - -/** - * @brief This class handles all network stuff - * - * This class only inherits static functions and members and use - * only the configuration data is given by networkConfig.h - * - */ -class Network { - public: - /** - * @brief Set the all IPs needed by this class - */ - static void setIps(); - - /** - * @brief Establish a connection to the WiFi. - * - * @return true Wifi is connected - * @return false Timeout - */ - static bool connectWifi(); - static bool connectEspNow(recieveCallbackPtr reci, sendCallbackPtr send); - static uint8_t getCurrentChannel(); - - /** - * @brief Set all general settings to connect to a broker. - */ - static void setupMQTT(); - - /** - * @brief Checks if mqtt is still connected - * - * If mqtt is not connect, this function try a reconnect - * with the function connectMQTT. This function should be - * called every mainloop. - * - * @return true if connected - * @return false if not connected - */ - static bool checkMQTT(); - static bool initMQTT(); - - /** - * @brief Checks if WiFi is still connected - * - * If WiFi is not connected, this function try a reconnect. - * This function should be called every mainloop. - */ - static void checkWiFi(); - - /** - * @brief Get the Mqtt Client object - * - * @return PubSubClient* - */ - static PubSubClient* getMqttClient(); - static const uint8_t * getBroadcastAddress() { return broadcastAddress; } - - private: - /** - * @brief Tries a connect to the broker - * - * @return true if the connect attemp was successful - * @return false if the connect attemp was unsuccessful - */ - static bool connectMQTT(); - static int32_t getWiFiChannel(const char *ssid); - - static esp_now_peer_info_t peerInfo; - static uint8_t broadcastAddress[6]; - - static IPAddress local_IP; - static IPAddress gateway; - static IPAddress subnet; - static IPAddress mqtt_server; - static IPAddress dnsServer; - - static WiFiClient wifi_client; - static PubSubClient* mqtt_client; -}; - -#endif // NETWORK_H diff --git a/include/networkConfig.h b/include/networkConfig.h index d62b70b..ebb265b 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -12,94 +12,47 @@ * */ -// General config -#define MQTT_TIME_RECONNECT 2500 - -/** - * @brief Wlan connect timeout - * - * This number multiplied by WLAN_CONNECT_LOOP_TIME is the - * timeout in milliseconds. - */ -#define WLAN_CONNECT_TIMEOUT 20 - -/** - * @brief Wlan connect loop time - * - * The time in milliseconds until the next connection attempt. - */ -#define WLAN_CONNECT_LOOP_TIME 500 -#define WLAN_DNS_SERVER "8.8.8.8" -#define ESP_NOW_CONTROLER_MAC {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10} - -#define NTRIP_RTK2GO - -// NTRIP config NRW -#ifdef NTRIP_NRW -#define NTRIP_HOST "www.sapos-nw-ntrip.de" -#define NTRIP_PORT 2101 -#define NTRIP_MOUNT_POINT "VRS_3_3G_NW" -#define NTRIP_USER "nw-916771" -#define NTRIP_PASSWORD "Schalke#246" -#endif // NTRIP_NRW - -// NTRIP config NS -#ifdef NTRIP_NS -#define NTRIP_HOST "openservice-sapos.niedersachsen.de" -#define NTRIP_PORT 2101 -#define NTRIP_MOUNT_POINT "VRS_3_2G_NI" -#define NTRIP_USER "ni_FHDo01" -#define NTRIP_PASSWORD "ALdx-1-3e49" -#endif // NTRIP_NS - -// NTRIP config RTK2Go -#ifdef NTRIP_RTK2GO -#define NTRIP_HOST "rtk2go.com" -#define NTRIP_PORT 2101 -#define NTRIP_MOUNT_POINT "GER-Dortmund" -#define NTRIP_USER "alklein1@gmx.de" -#define NTRIP_PASSWORD "none" -#endif // NTRIP_RTK2GO - +#include #define HOTSPOT -//Network config Hotspot #ifdef HOTSPOT -#define WLAN_SSID "Kleiax Handy" -#define WLAN_PASSWORD "12345677" -#define WLAN_IP "192.168.43.4" -#define WLAN_SUBNETMASK "255.255.128.0" -#define WLAN_GATEWAY "192.168.43.1" -// Only for defines reasons - #define MQTT_SERVER "172.22.64.216" - #define MQTT_PORT 1883 +namespace NetworkConfig { + const char ssid[] = "Kleiax Handy"; + const char password[] = "12345677"; + const char ip[] = "192.168.43.4"; + const char subnet[] = "255.255.255.0"; + const char gateway[] = "192.168.43.1"; + const char dns[] = "8.8.8.8"; + const bool mqtt = false; +} #endif //HOTSPOT //Network config Rhede #ifdef RHEDE -#define WLAN_SSID "LebennigHuus" -#define WLAN_PASSWORD "Punica-699" -#define WLAN_IP "192.168.11.4" -#define WLAN_SUBNETMASK "255.255.128.0" -#define WLAN_GATEWAY "192.168.0.1" -#define MQTT -#define MQTT_SERVER "192.168.1.7" -#define MQTT_PORT 1883 -#define MQTT_AUTH -#define MQTT_USER "kleiax" -#define MQTT_PASSWORD "p?{$_~5%hBM7wrcFkr55KWr#" +namespace NetworkConfig { + const char ssid[] = "LebennigHuus"; + const char password[] = "Punica-699"; + const char ip[] = "192.168.11.4"; + const char subnet[] = "255.255.128.0"; + const char gateway[] = "192.168.0.1"; + const char dns[] = "8.8.8.8"; + const bool mqtt = true; +} #endif //RHEDE -//Network config Doro -#ifdef DORO -#define WLAN_SSID "Tuedelkram" -#define WLAN_PASSWORD "3Kaesehoch!" -#define WLAN_IP "192.168.178.4" -#define WLAN_SUBNETMASK "255.255.255.0" -#define WLAN_GATEWAY "192.168.178.1" - // Only for defines reasons - #define MQTT_SERVER "172.22.64.216" - #define MQTT_PORT 1883 -#endif //DORO +namespace MqttConfig { + const char server[] = "192.168.1.7"; + const uint16_t port = 1883; + const char user[] = "kleiax"; + const char password[] = "p?{$_~5%hBM7wrcFkr55KWr#"; +} +namespace NtripConfig { + const char host[] = "rtk2go.com"; + const uint16_t port = 2101; + const char mountPoint[] = "GER-Dortmund"; + // const char mountPoint[] = "GER-Papenburg"; + const char user[] = "alklein1@gmx.de"; + const char password[] = "none"; +} diff --git a/lib/Network/network.cpp b/lib/Network/network.cpp new file mode 100644 index 0000000..8e668da --- /dev/null +++ b/lib/Network/network.cpp @@ -0,0 +1,164 @@ +/** + * @file network.cpp + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-18 + * + * @copyright Copyright (c) 2023 + * + */ + +#include "network.h" + +Network::Network(const char *ssid, const char *passphrase) { + if (!WiFi.mode(WIFI_AP_STA)) + std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; + + this->init(ssid, passphrase); +} + +Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) { + if (!WiFi.mode(WIFI_AP_STA)) + std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; + + if (!WiFi.config(this->adresses.localIP, + this->adresses.gateway, + this->adresses.subnet, + this->adresses.dnsServer)) + { + std::cout << "STA Failed to configure" << std::endl; + } + + this->init(ssid, passphrase); +} + +Network::~Network() { + if (this->mqttClient) + delete mqttClient; +} + +bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { + if (esp_now_init() != ESP_OK) { + std::cout << "Network::activateEspNow - Error initializing ESP-NOW" << std::endl; + return false; + } + + esp_now_register_send_cb(send); + + memcpy(this->peerInfo.peer_addr, this->broadcastAddress, 6); + this->peerInfo.channel = 0; + this->peerInfo.encrypt = false; + + if (esp_now_add_peer(&peerInfo) != ESP_OK) { + std::cout << "Network::connectEspNow - Failed to add peer" << std::endl; + return false; + } + + esp_now_register_recv_cb(reci); + return true; +} + +bool Network::activateMqtt(const char *user, const char *passphrase) { + this->mqttUser = user; + this->mqttPassphrase = passphrase; + + this->mqttClient = new PubSubClient(this->wifiClient); + this->mqttClient->setServer(this->adresses.mqttServer, this->adresses.mqttPort); + this->mqttClient->setSocketTimeout(1); + + if (this->wifiConnected) + return this->connectMqtt(); + return false; +} + +void Network::printIPs() { + std::cout << std::endl; + if (!this->wifiConnected) { + std::cout << "WiFi is not connected." << std::endl; + return; + } + std::cout << "WiFi is connected to" << std::endl; + std::cout << "IP address: " << std::endl; + std::cout << this->adresses.localIP << std::endl; + std::cout << "WiFi MAC Address: " << WiFi.macAddress() << std::endl << std::endl; +} + +uint8_t Network::getCurrentChannel() { + uint8_t channel; + wifi_second_chan_t secondChannel; + if (esp_wifi_get_channel(&channel, &secondChannel) != ESP_OK) { + std::cout << "Network::getCurrentChannel - Error!" << std::endl; + return -1; + } + + return channel; +} + +void Network::runAsChild() { + if (!this->initSucessful) + return; + + this->checkWifi(); + + if (this->wifiConnected && this->mqttClient) + this->checkMqtt(); +} + +void Network::init(const char *ssid, const char *passphrase) { + // Connect to Wi-Fi network with SSID and password + std::cout << "Connecting to " << ssid << std::endl; + WiFi.begin(ssid, passphrase); + uint8_t timeout = Network::wifiConnectTimeout; + while (WiFi.status() != WL_CONNECTED) { + delay(Network::wifiConnectLoopTime); + std::cout << "." << std::flush; + timeout--; + if (timeout == 0) { + std::cout << std::endl; + std::cout << "WiFi NOT connected." << std::endl; + return; + } + } + + this->wifiConnected = true; + this->printIPs(); +} + +void Network::checkWifi() { + if ((WiFi.status() != WL_CONNECTED) + && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay)) + { + std::cout << "Reconnecting to WiFi..." << std::endl; + WiFi.disconnect(); + this->wifiConnected = WiFi.reconnect(); + this->lastWifiRecoonectAttemp = millis(); + } +} + +void Network::checkMqtt() { + if (!this->mqttClient->connected() + && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay) + { + this->mqttConnected = this->connectMqtt(); + this->lastMqttReconnectAttemp = millis(); + } + + if (this->mqttConnected) + this->mqttClient->loop(); +} + +bool Network::connectMqtt() { + String clientId = "ESP32Rover-"; + clientId += String(random(0xffff), HEX); + + if (this->mqttUser) { + if (this->mqttClient->connect(clientId.c_str(), this->mqttUser, this->mqttPassphrase)) + this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); + } else { + if (this->mqttClient->connect(clientId.c_str())) + this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); + } + + return this->mqttClient->connected(); +} diff --git a/lib/Network/network.h b/lib/Network/network.h new file mode 100644 index 0000000..56f71d5 --- /dev/null +++ b/lib/Network/network.h @@ -0,0 +1,85 @@ +/** + * @file network.h + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-18 + * + * @copyright Copyright (c) 2023 + * + */ + +#ifndef NETWORK_H +#define NETWORK_H + +#include "component.h" + +#include +#include +#include +#include +#include + +typedef void (*recieveCallbackPtr) (const uint8_t * mac, const uint8_t *incomingData, int len); +typedef void (*sendCallbackPtr) (const uint8_t *mac_addr, esp_now_send_status_t status); + +struct NetworkAdresses { + IPAddress localIP; + IPAddress gateway; + IPAddress subnet; + IPAddress dnsServer; + IPAddress mqttServer; + uint16_t mqttPort = 1883; +}; + +class Network : public Component { + public: + Network(const char *ssid, const char *passphrase); + Network(const char *ssid, const char *passphrase, NetworkAdresses adresses); + + ~Network(); + + bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send); + bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr); + + void printIPs(); + + bool isWifiConnected() const { return this->wifiConnected; } + bool isMqttConnected() const { return this->mqttConnected; } + const uint8_t* getBroadcastAddress() const { return this->broadcastAddress; } + PubSubClient* getMqttClient() const { return this->mqttClient; } + + static uint8_t getCurrentChannel(); + + private: + void run() override {}; + void runAsChild() override; + void init(const char *ssid, const char *passphrase); + void checkWifi(); + void checkMqtt(); + bool connectMqtt(); + + NetworkAdresses adresses; + WiFiClient wifiClient; + PubSubClient* mqttClient = nullptr; + esp_now_peer_info_t peerInfo; + + bool initSucessful = false; + bool wifiConnected = false; + bool mqttConnected = false; + + const char *mqttUser; + const char *mqttPassphrase; + + uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10}; + uint32_t lastWifiRecoonectAttemp = 0; + uint32_t lastMqttReconnectAttemp = 0; + + static constexpr uint8_t wifiConnectTimeout = 20; + static constexpr uint16_t wifiConnectLoopTime = 500; + static constexpr uint16_t wifiReconnectDelay = 5000; + static constexpr uint16_t mqttReconnectDelay = 2500; + +}; + +#endif //NETWORK_H diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 5e7a4d7..a3de617 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -171,10 +171,14 @@ void SensorData::setOutputStatusPrintPVTdata(bool status) { } void SensorData::run() { - this->realCompass->read(); - this->realAzimuth = this->realCompass->getAzimuth(); + if (this->realCompass) { + this->realCompass->read(); + this->realAzimuth = this->realCompass->getAzimuth(); + } - if (this->gyroskop->dmpGetCurrentFIFOPacket(this->gyroBuffer)) { + if (this->gyroskop + && this->gyroskop->dmpGetCurrentFIFOPacket(this->gyroBuffer)) + { this->gyroskop->dmpGetQuaternion(&this->quaternion, this->gyroBuffer); this->gyroskop->dmpGetGravity(&this->gravity, &this->quaternion); this->gyroskop->dmpGetYawPitchRoll(this->yawPitchRoll, &this->quaternion, &this->gravity); @@ -182,11 +186,15 @@ void SensorData::run() { } void SensorData::runAsChild() { - this->gnss->checkUblox(); - this->gnss->checkCallbacks(); + if (this->gnss) { + this->gnss->checkUblox(); + this->gnss->checkCallbacks(); + } - if (SensorData::newData) + if (SensorData::newData) { SensorData::newData = false; + // TODO: Update data + } } void SensorData::initGnss() { diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp index 56b9545..13e74f2 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.cpp +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -44,7 +44,7 @@ void MenuSensorData::printPage() const { lineOne = "Calc Azimuth:"; lineTwo.concat(this->sensorData->getCalcAzimuth()); lineTwo.concat(" "); - lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState)); + lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState())); break; case 3: { diff --git a/src/main.cpp b/src/main.cpp index 97bbcd4..6646e51 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,6 +29,7 @@ #include "LcdWrapper.h" #include "moveControl.h" #include "network.h" +#include "networkConfig.h" #include "debugMqtt.h" #include "battery.h" #include "sensorData.h" @@ -45,10 +46,10 @@ #include "SpecialMenus/Systeminformation/menuSysteminformation.h" #include "SpecialMenus/PID/menuPidSettings.h" #include "SpecialMenus/Route/menuRoute.h" -#include "SpecialMenus/GPS/menuGPS.h" #include "SpecialMenus/SensorData/menuSensorData.h" MoveControl moveController; +Network* network; DriveManager* driveManager; Menu* main_m; LiquidCrystal_I2C* lcd; @@ -68,17 +69,13 @@ void restart(void); void receiveCallback (const uint8_t * mac, const uint8_t *incomingData, int len); void sendCallback (const uint8_t *mac_addr, esp_now_send_status_t status); void lcdWrapperCallback (const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows); +NetworkAdresses setIPs(void); void setup() { Serial.begin(115200); // DebugTimes::setConsolOutput(true); DebugTimes setupTime; - char wifiIndicator = 'X'; - - WiFi.mode(WIFI_MODE_STA); - Serial.print("MAC Address: "); - Serial.println(WiFi.macAddress()); spiPort = new SPIClass(HSPI); spiPort->begin(PinNumbers::spiSck, PinNumbers::spiCipo, PinNumbers::spiCopi, PinNumbers::gnssSpiCs); @@ -94,25 +91,21 @@ void setup() { lcd->clear(); lcd->noBacklight(); - Network::setIps(); - Network::setupMQTT(); - wifiIsActive = Network::connectWifi(); - if (wifiIsActive) { - Network::initMQTT(); - if (Network::checkMQTT()) { - DebugMqtt::init(Network::getMqttClient(), Loglevel::debug); - std::cout << "Activate additional output via MQTT..." << std::endl; + network = new Network(NetworkConfig::ssid, NetworkConfig::password, setIPs()); + network->activateEspNow(receiveCallback, sendCallback); + if (NetworkConfig::mqtt) { + if (network->activateMqtt(MqttConfig::user, MqttConfig::password)) { + DebugMqtt::init(network->getMqttClient(), Loglevel::debug); debugMqtt = new DebugMqtt("Console"); outputBuf = new OutputBuf(debugMqtt); - } else + outputBuf->activateMqtt(true); + } else { outputBuf = new OutputBuf(); - wifiIndicator = '-'; + } } else outputBuf = new OutputBuf(); std::cout.rdbuf(outputBuf); - Network::connectEspNow(receiveCallback, sendCallback); - std::cout << "Welcome to Kleiax-Rover" << std::endl; std::cout << "Project verion: " << VERSION << std::endl; std::cout << "Build timestamp: " << BUILD_TIMESTAMP << std::endl; @@ -121,11 +114,12 @@ void setup() { sensorData = new SensorData(); sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs); sensorData->enableRealCompass(); - sensorData->enableGyroskop(); + // sensorData->enableGyroskop(); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); - outputBuf->activateMqtt(true); - + char wifiIndicator = 'X'; + if (network->isWifiConnected()) + wifiIndicator = '-'; lcd->backlight(); lcd->printf("%c Kleiax-Rover %c", wifiIndicator, wifiIndicator); lcd->setCursor(0, 1); @@ -139,16 +133,7 @@ void setup() { } void loop() { - if (wifiIsActive) { - DebugTimes wifiTime; - Network::checkWiFi(); - #ifdef MQTT - bool err = Network::checkMQTT(); - if (!err) - std::cout << "loop(): checkMQTT returns false" << std::endl; - #endif //MQTT - wifiTime.stopConsol("WiFi-Time", 10); - } + network->loop(); sensorData->loop(); driveManager->loop(); controlPad->loop(); @@ -297,8 +282,22 @@ void lcdWrapperCallback (const char data[][LcdWrapper::totalRows], uint8_t lines if (!controlPad->isControlPadConnected()) return; - esp_err_t result = esp_now_send(Network::getBroadcastAddress(), (uint8_t *) data, lines * rows); + esp_err_t result = esp_now_send(network->getBroadcastAddress(), (uint8_t *) data, lines * rows); if (result != ESP_OK) Serial.println("Error sending the data"); } + +NetworkAdresses setIPs() { + NetworkAdresses adresses; + adresses.localIP.fromString(NetworkConfig::ip); + adresses.subnet.fromString(NetworkConfig::subnet); + adresses.gateway.fromString(NetworkConfig::gateway); + adresses.dnsServer.fromString(NetworkConfig::dns); + if (NetworkConfig::mqtt) { + adresses.mqttServer.fromString(MqttConfig::server); + adresses.mqttPort = MqttConfig::port; + } + + return adresses; +} diff --git a/src/network.cpp b/src/network.cpp deleted file mode 100644 index baaa932..0000000 --- a/src/network.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @file network.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the ststic class Network - * @version 0.1 - * @date 2021-12-14 - * - * @copyright Copyright (c) 2021 - * - */ - -#include "network.h" - -IPAddress Network::local_IP; -IPAddress Network::gateway; -IPAddress Network::subnet; -IPAddress Network::mqtt_server; -IPAddress Network::dnsServer; - -WiFiClient Network::wifi_client; -PubSubClient* Network::mqtt_client; - -esp_now_peer_info_t Network::peerInfo; -uint8_t Network::broadcastAddress[6] = ESP_NOW_CONTROLER_MAC; - -void Network::setIps() { - local_IP.fromString(WLAN_IP); - gateway.fromString(WLAN_GATEWAY); - subnet.fromString(WLAN_SUBNETMASK); - mqtt_server.fromString(MQTT_SERVER); - dnsServer.fromString(WLAN_DNS_SERVER); -} - -void Network::setupMQTT() { - Network::mqtt_client = new PubSubClient(wifi_client); - Network::mqtt_client->setServer(MQTT_SERVER, MQTT_PORT); - Network::mqtt_client->setSocketTimeout(1); -} - -bool Network::connectMQTT() { - #ifndef MQTT - return false; - #endif - - // Create a random client ID - String clientId = "ESP32Rover-"; - clientId += String(random(0xffff), HEX); - - #ifdef MQTT_AUTH - if (mqtt_client->connect(clientId.c_str(), MQTT_USER, MQTT_PASSWORD)) { - #endif //MQTT_AUTH - - #ifndef MQTT_AUTH - if (mqtt_client->connect(clientId.c_str())) { - #endif //MQTT_AUTH - - // Once connected, publish an announcement... - mqtt_client->publish("Rover/Info", "Connected to Mqtt-Broker"); - } - return mqtt_client->connected(); -} -bool Network::connectWifi() { - // Configures static IP address - - if (!WiFi.mode(WIFI_AP_STA)) - std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; - - if (!WiFi.config(local_IP, gateway, subnet, dnsServer)) - std::cout << "STA Failed to configure" << std::endl; - - // Connect to Wi-Fi network with SSID and password - std::cout << "Connecting to " << WLAN_SSID << std::endl; - WiFi.begin(WLAN_SSID, WLAN_PASSWORD); - uint8_t timeout = WLAN_CONNECT_TIMEOUT; - while (WiFi.status() != WL_CONNECTED) { - delay(WLAN_CONNECT_LOOP_TIME); - std::cout << "." << std::flush; - timeout--; - if (timeout == 0) { - std::cout << std::endl; - std::cout << "WiFi NOT connected." << std::endl; - return false; - } - } - - // Print local IP address and start web server - std::cout << std::endl; - std::cout << "WiFi connected." << std::endl; - std::cout << "IP address: " << std::endl; - std::cout << WLAN_IP << std::endl; - // std::cout << "WiFi MAC Address: " << WiFi.macAddress() << std::endl << std::endl; - return true; -} - -bool Network::connectEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { - if (esp_now_init() != ESP_OK) { - std::cout << "Network::connectEspNow - Error initializing ESP-NOW" << std::endl; - return false; - } - - esp_now_register_send_cb(send); - - memcpy(peerInfo.peer_addr, broadcastAddress, 6); - peerInfo.channel = 0; - peerInfo.encrypt = false; - - if (esp_now_add_peer(&peerInfo) != ESP_OK) { - std::cout << "Network::connectEspNow - Failed to add peer" << std::endl; - return false; - } - - esp_now_register_recv_cb(reci); - return true; -} - -uint8_t Network::getCurrentChannel() { - uint8_t channel; - wifi_second_chan_t secondChannel; - if (esp_wifi_get_channel(&channel, &secondChannel) != ESP_OK) { - std::cout << "Network::getCurrentChannel - Error!" << std::endl; - return -1; - } - // std::cout << "Network::getCurrentChannel - Current WiFi channel: " - // << (int) channel << " second channel: " << (int) secondChannel - // << std::endl; - return channel; -} - -bool Network::checkMQTT() { - static uint64_t lastReconnectAttempt = 0; - if (!mqtt_client->connected()) { - long now = millis(); - if (now - lastReconnectAttempt > MQTT_TIME_RECONNECT) { - lastReconnectAttempt = now; - // Attempt to reconnect - if (connectMQTT()) - return true; - } - return false; - } - mqtt_client->loop(); - return true; -} - -bool Network::initMQTT() { - if (connectMQTT()) - return true; - return false; -} - -int32_t Network::getWiFiChannel(const char *ssid) { - if (int32_t n = WiFi.scanNetworks()) - for (uint8_t i=0; i= delay)) { - std::cout << "Reconnecting to WiFi..." << std::endl; - WiFi.disconnect(); - WiFi.reconnect(); - previousMillis = currentMillis; - } - -} - -PubSubClient* Network::getMqttClient() { - return mqtt_client; -} From cebd44d79372f3c0c815e6cf2107f71aa64b768a Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Sat, 23 Sep 2023 16:37:40 +0200 Subject: [PATCH 10/26] fix esp now --- lib/Network/network.cpp | 7 ++++--- lib/Network/network.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Network/network.cpp b/lib/Network/network.cpp index 8e668da..d67f65a 100644 --- a/lib/Network/network.cpp +++ b/lib/Network/network.cpp @@ -46,9 +46,10 @@ bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { esp_now_register_send_cb(send); - memcpy(this->peerInfo.peer_addr, this->broadcastAddress, 6); - this->peerInfo.channel = 0; - this->peerInfo.encrypt = false; + esp_now_peer_info_t peerInfo = {}; + memcpy(peerInfo.peer_addr, this->broadcastAddress, 6); + peerInfo.channel = 0; + peerInfo.encrypt = false; if (esp_now_add_peer(&peerInfo) != ESP_OK) { std::cout << "Network::connectEspNow - Failed to add peer" << std::endl; diff --git a/lib/Network/network.h b/lib/Network/network.h index 56f71d5..355ebd9 100644 --- a/lib/Network/network.h +++ b/lib/Network/network.h @@ -62,7 +62,6 @@ class Network : public Component { NetworkAdresses adresses; WiFiClient wifiClient; PubSubClient* mqttClient = nullptr; - esp_now_peer_info_t peerInfo; bool initSucessful = false; bool wifiConnected = false; From d0c5421ad9239132e9ff6ba8761937d45e74e6d8 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Sat, 23 Sep 2023 16:38:34 +0200 Subject: [PATCH 11/26] - fix driveManager quit mode - change com port - edit todos --- doc/TODO allgemein.txt | 6 ------ platformio.ini | 4 ++-- src/driveModi/driveManager.cpp | 3 ++- src/driveModi/driveManager.h | 6 ------ 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index b704681..cd314ed 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -49,13 +49,7 @@ Code: Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung Unterschied funktionale und nicht funktionale Anforderungen - Weniger / Keine Füllwörter Strom nicht über Zeit sondern Rampe - ESP Pulsecounter Name Richtig? - Zittern? Besseres Wort Signal kann Springen - Rad Umfang gerundet - Trick Debugging mit dem Stream - Gyroskop für Bachelor aufheben 3D: diff --git a/platformio.ini b/platformio.ini index c5bc22d..802f7b1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,7 +15,7 @@ board_build.partitions = no_ota.csv framework = arduino monitor_speed = 115200 upload_speed = 921600 -monitor_port = COM6 +monitor_port = COM3 lib_deps = https://git.kleiax.de/PlatformIO-Libs/SparkFunGNSS.git knolleary/PubSubClient@^2.8 @@ -26,7 +26,7 @@ lib_deps = https://git.kleiax.de/PlatformIO-Libs/Menu.git nrf24/RF24@^1.4.5 jrowberg/I2Cdevlib-MPU6050@^1.0.0 -upload_port = COM6 +upload_port = COM3 test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder diff --git a/src/driveModi/driveManager.cpp b/src/driveModi/driveManager.cpp index 1631264..dc948ee 100644 --- a/src/driveModi/driveManager.cpp +++ b/src/driveModi/driveManager.cpp @@ -34,9 +34,10 @@ void DriveManager::changeModus(DriveModi* modus) { this->currentModusPtr = modus; - if (this->currentModusPtr) + if (this->currentModusPtr) { this->currentModusPtr->activate(this->driveModiParams); this->addChildComponent(this->currentModusPtr); + } } void DriveManager::init() { diff --git a/src/driveModi/driveManager.h b/src/driveModi/driveManager.h index f62c4e2..ab70f61 100644 --- a/src/driveModi/driveManager.h +++ b/src/driveModi/driveManager.h @@ -32,12 +32,6 @@ class DriveManager : public Component { DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input); DriveManager(DriveModiParams params); - /** - * @brief Destroy the Drive Manager object - * - */ - ~DriveManager(); - /** * @brief Change the DriveModi to a specific value * From e48f680fecbf4887386f5964bbd5a08cae634c3a Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Sat, 23 Sep 2023 22:47:07 +0200 Subject: [PATCH 12/26] quite some fixes --- include/networkConfig.h | 5 +++-- lib/Network/network.cpp | 6 +++-- lib/Sensors/sensorData.cpp | 22 ++++++++++++------- lib/Sensors/sensorData.h | 6 +++-- .../SensorData/menuSensorData.cpp | 17 +++++++------- src/SpecialMenus/driveModi/menuDriveMode.cpp | 4 ---- src/SpecialMenus/driveModi/menuDriveMode.h | 5 ----- src/driveModi/Modi/Autopilot/autopilot.cpp | 22 +++++++++++++------ src/driveModi/Modi/Autopilot/autopilot.h | 1 + .../Modi/CaptureRoute/captureRoute.cpp | 21 +++++++++++------- .../Modi/CaptureRoute/captureRoute.h | 5 ++--- src/driveModi/driveModi.cpp | 1 + src/driveModi/driveModi.h | 2 ++ src/main.cpp | 1 + 14 files changed, 69 insertions(+), 49 deletions(-) diff --git a/include/networkConfig.h b/include/networkConfig.h index ebb265b..4dafd0e 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -14,7 +14,7 @@ #include -#define HOTSPOT +#define RHEDE #ifdef HOTSPOT namespace NetworkConfig { @@ -51,8 +51,9 @@ namespace MqttConfig { namespace NtripConfig { const char host[] = "rtk2go.com"; const uint16_t port = 2101; - const char mountPoint[] = "GER-Dortmund"; + // const char mountPoint[] = "GER-Dortmund"; // const char mountPoint[] = "GER-Papenburg"; + const char mountPoint[] = "Rtkramerntrip"; const char user[] = "alklein1@gmx.de"; const char password[] = "none"; } diff --git a/lib/Network/network.cpp b/lib/Network/network.cpp index d67f65a..40456e0 100644 --- a/lib/Network/network.cpp +++ b/lib/Network/network.cpp @@ -19,6 +19,8 @@ Network::Network(const char *ssid, const char *passphrase) { } Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) { + this->adresses = adresses; + if (!WiFi.mode(WIFI_AP_STA)) std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; @@ -81,8 +83,8 @@ void Network::printIPs() { } std::cout << "WiFi is connected to" << std::endl; std::cout << "IP address: " << std::endl; - std::cout << this->adresses.localIP << std::endl; - std::cout << "WiFi MAC Address: " << WiFi.macAddress() << std::endl << std::endl; + std::cout << WiFi.localIP().toString().c_str() << std::endl; + std::cout << "WiFi MAC Address: " << WiFi.macAddress().c_str() << std::endl << std::endl; } uint8_t Network::getCurrentChannel() { diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index a3de617..7c62193 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -12,7 +12,6 @@ #include "sensorData.h" bool SensorData::outputStatusPrintPVTdata = false; -bool SensorData::newData = false; uint32_t SensorData::ubxUpdateTimeStatic = 0; UBX_NAV_PVT_data_t* SensorData::ubxDataStatic = nullptr; @@ -161,7 +160,6 @@ void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { void SensorData::savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { SensorData::printPVTdata(ubxDataStruct); - SensorData::newData = true; SensorData::ubxDataStatic = ubxDataStruct; SensorData::ubxUpdateTimeStatic = millis(); } @@ -189,12 +187,9 @@ void SensorData::runAsChild() { if (this->gnss) { this->gnss->checkUblox(); this->gnss->checkCallbacks(); - } - - if (SensorData::newData) { - SensorData::newData = false; - // TODO: Update data - } + if (SensorData::ubxUpdateTimeStatic != this->lastUbxUpdate) + this->updateUbxData(); + } } void SensorData::initGnss() { @@ -210,3 +205,14 @@ void SensorData::initGnss() { this->gnss->setNavigationFrequency(1); this->gnss->setAutoPVT(true); } + +void SensorData::updateUbxData() { + this->gnssData = SensorData::ubxDataStatic; + this->lastUbxUpdate = SensorData::ubxUpdateTimeStatic; + + Point::Coordinates coords; + coords.lat = this->gnssData->lat / 10000000.0; + coords.lon = this->gnssData->lon / 10000000.0; + + this->currentPosition = Point(coords, this->gnssData->hAcc); +} diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index 71fcf54..29656e1 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -70,6 +70,8 @@ class SensorData : public Component { void run() override; void runAsChild() override; void initGnss(); + void updateUbxData(); + QMC5883LCompass* realCompass = nullptr; CalcAzimuth* calcCompass = nullptr; @@ -93,8 +95,9 @@ class SensorData : public Component { uint16_t port; int16_t realAzimuth = INT16_MAX; int16_t calcAzimuth = INT16_MAX; + uint32_t lastUbxUpdate = 0; - float yawPitchRoll[3]; + float yawPitchRoll[3] {0, 0, 0}; // static static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); @@ -103,7 +106,6 @@ class SensorData : public Component { static UBX_NAV_PVT_data_t* ubxDataStatic; static uint32_t ubxUpdateTimeStatic; static bool outputStatusPrintPVTdata; - static bool newData; }; #endif //SENSOR_DATA_H diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp index 13e74f2..2a6f86e 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.cpp +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -14,6 +14,7 @@ MenuSensorData::MenuSensorData(SensorData* sensorData) : MenuInformationSites(7) { this->sensorData = sensorData; + this->noEqualLeft = true; } void MenuSensorData::printPage() const { @@ -81,20 +82,20 @@ void MenuSensorData::printPage() const { lineTwo = "Ntrip: "; uint8_t carrSoln = gpsData->flags.bits.carrSoln; if (carrSoln == 0) - lineOne = "None"; + lineOne.concat("None"); else if (carrSoln == 1) - lineOne = "Floating"; + lineOne.concat("Floating"); else if (carrSoln == 2) - lineOne = "Fixed"; + lineOne.concat("Fixed"); else lineOne = "UNKNOWN"; NTRIPClientStates status = this->sensorData->getNtripState(); if (status == NTRIPClientStates::pushData) - lineTwo = "enabled"; + lineTwo.concat("enabled"); else if (status == NTRIPClientStates::notAvailable) - lineTwo = " N/A"; + lineTwo.concat(" N/A"); else - lineTwo = "disabled"; + lineTwo.concat("disabled"); } break; @@ -105,8 +106,8 @@ void MenuSensorData::printPage() const { lineOne.concat(gpsData->hAcc); lineTwo.concat(gpsData->numSV); } else { - lineOne = "-/-"; - lineTwo = "-/-"; + lineOne.concat("-/-"); + lineTwo.concat("-/-"); } break; diff --git a/src/SpecialMenus/driveModi/menuDriveMode.cpp b/src/SpecialMenus/driveModi/menuDriveMode.cpp index ab42129..0fa91ba 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.cpp +++ b/src/SpecialMenus/driveModi/menuDriveMode.cpp @@ -24,7 +24,3 @@ void MenuDriveMode::left() { this->leaved = true; } } - -void MenuDriveMode::no() { - this->left(); -} diff --git a/src/SpecialMenus/driveModi/menuDriveMode.h b/src/SpecialMenus/driveModi/menuDriveMode.h index 7e4ad87..ae94233 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.h +++ b/src/SpecialMenus/driveModi/menuDriveMode.h @@ -32,11 +32,6 @@ class MenuDriveMode : public MenuInformationSites { */ void left() override; - /** - * @brief Calls left. - */ - void no() override; - protected: void configureOnLeave() {} diff --git a/src/driveModi/Modi/Autopilot/autopilot.cpp b/src/driveModi/Modi/Autopilot/autopilot.cpp index 7671518..9a1da0c 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.cpp +++ b/src/driveModi/Modi/Autopilot/autopilot.cpp @@ -18,20 +18,20 @@ DirectionChangeSignal::DirectionChangeSignal(Autopilot* pilot) { } DirectionChangeSignal::~DirectionChangeSignal() { - pilot->getSensorData()->getCalcCompass()->disableCalcAzimuth(); + CalcAzimuth* calcAzimuth = pilot->getSensorData()->getCalcCompass(); + if (calcAzimuth) + calcAzimuth->disableCalcAzimuth(); } void DirectionChangeSignal::action() { - pilot->getSensorData()->getCalcCompass()->drivingDirectionChange(pilot->getSensorData()->getCurrentPos()); + CalcAzimuth* calcAzimuth = pilot->getSensorData()->getCalcCompass(); + if (calcAzimuth) + calcAzimuth->drivingDirectionChange(pilot->getSensorData()->getCurrentPos()); } Autopilot::Autopilot() { - this->setInputMode(ManualControl::InputMode::Digital); - this->directionChangeSignal = new DirectionChangeSignal(this); - this->setDirectionChangeCallback(this->directionChangeSignal); - this->navigation = new Navigation(this->sensorData); - this->init(); + } Autopilot::~Autopilot() { @@ -247,3 +247,11 @@ void Autopilot::restartLoop() { this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection, true); this->updateDisplay = true; } + +void Autopilot::afterActivate() { + this->setInputMode(ManualControl::InputMode::Digital); + this->directionChangeSignal = new DirectionChangeSignal(this); + this->setDirectionChangeCallback(this->directionChangeSignal); + this->navigation = new Navigation(this->sensorData); + this->init(); +} diff --git a/src/driveModi/Modi/Autopilot/autopilot.h b/src/driveModi/Modi/Autopilot/autopilot.h index 3a709be..c6a81e4 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.h +++ b/src/driveModi/Modi/Autopilot/autopilot.h @@ -102,6 +102,7 @@ class Autopilot : public ManualControl { void askNavigationForOrder(); void selfDriving(); void restartLoop(); + void afterActivate() override; Navigation* navigation; CourseCorrection courseCorrection; diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp index 703b201..cb58e4e 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp @@ -10,16 +10,14 @@ */ #include "driveModi/Modi/CaptureRoute/captureRoute.h" - -CaptureRoute::CaptureRoute() { - this->navigation = new Navigation(this->sensorData); - this->navigation->getRoute()->clear(); - this->sensorData->getNtripClient()->setAutoReconnect(true); - this->routeInfo = navigation->getRouteInfo(); -} +#include "captureRoute.h" CaptureRoute::~CaptureRoute() { - // this->navigation->getNTRIPClient()->setActivated(false); + if (this->navigation) + delete this->navigation; + + if (this->sensorData->getNtripClient()) + this->sensorData->getNtripClient()->setActivated(false); } void CaptureRoute::run() { @@ -34,6 +32,13 @@ void CaptureRoute::run() { } } +void CaptureRoute::afterActivate() { + this->navigation = new Navigation(this->sensorData); + this->navigation->getRoute()->clear(); + this->sensorData->getNtripClient()->setAutoReconnect(true); + this->routeInfo = navigation->getRouteInfo(); +} + double CaptureRoute::getDistanceToLastPoint() const { if (!this->lastSavedPoint.isInit()) return 0; diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.h b/src/driveModi/Modi/CaptureRoute/captureRoute.h index 44b3a4e..48caa1a 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.h +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.h @@ -27,8 +27,6 @@ */ class CaptureRoute : public ManualControl { public: - CaptureRoute(); - /** * @brief Destroy the Capture Route object * @@ -68,8 +66,9 @@ class CaptureRoute : public ManualControl { bool shouldUpdate(); private: void run() override; + void afterActivate() override; - Navigation* navigation; + Navigation* navigation = nullptr; RouteInfo routeInfo; Point lastSavedPoint; Navigation::Status status = Navigation::Status::Complete; diff --git a/src/driveModi/driveModi.cpp b/src/driveModi/driveModi.cpp index fb0aa25..1cbed00 100644 --- a/src/driveModi/driveModi.cpp +++ b/src/driveModi/driveModi.cpp @@ -27,4 +27,5 @@ void DriveModi::activate(DriveModiParams params){ void DriveModi::init() { this->moveControl->setDrivingStatus(MoveControl::Status::Drive); this->loopDelay = 40; + this->afterActivate(); } diff --git a/src/driveModi/driveModi.h b/src/driveModi/driveModi.h index 46bbb5a..33d9f70 100644 --- a/src/driveModi/driveModi.h +++ b/src/driveModi/driveModi.h @@ -60,6 +60,8 @@ class DriveModi : public Component { double getMaxRotation() const { return this->maxRotationSpeed; } protected: + virtual void afterActivate() {} + MoveControl *moveControl; const ControlPadInput* input; const SensorData* sensorData; diff --git a/src/main.cpp b/src/main.cpp index 6646e51..9f7f5ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,6 +114,7 @@ void setup() { sensorData = new SensorData(); sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs); sensorData->enableRealCompass(); + sensorData->enableNtrip(NtripConfig::host, NtripConfig::port, NtripConfig::mountPoint, NtripConfig::user, NtripConfig::password); // sensorData->enableGyroskop(); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); From 38e7db7deea939ac582739adc4a0cfa233b1bd13 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 27 Sep 2023 11:11:39 +0200 Subject: [PATCH 13/26] - added batteryCalibration - start with default Menus for DriveModes --- doc/TODO allgemein.txt | 6 +- include/config.h | 2 +- include/networkConfig.h | 2 +- lib/Battery/battery.cpp | 52 +++++++++++++++- lib/Battery/battery.h | 31 ++++++++-- platformio.ini | 4 +- .../CalibrateBattery/menuCalibrateBattery.cpp | 59 +++++++++++++++++++ .../CalibrateBattery/menuCalibrateBattery.h | 33 +++++++++++ src/SpecialMenus/Speed/menuSpeed.cpp | 13 ++++ src/SpecialMenus/Speed/menuSpeed.h | 21 +++++++ .../menuSysteminformatio.cpp | 1 + src/SpecialMenus/driveModi/menuDriveMode.h | 5 ++ src/main.cpp | 5 +- 13 files changed, 221 insertions(+), 13 deletions(-) create mode 100644 src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp create mode 100644 src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h create mode 100644 src/SpecialMenus/Speed/menuSpeed.cpp create mode 100644 src/SpecialMenus/Speed/menuSpeed.h diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index cd314ed..89e0b07 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -45,12 +45,16 @@ Code: sensor data gnss daten aktualisieren Menübaum korrigieren, Verlinkung Sensor in Mode etc. esp und sensoren in den deepsleep + battery Prozent ausgabe wirkt komisch Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung Unterschied funktionale und nicht funktionale Anforderungen Strom nicht über Zeit sondern Rampe + Formel für Zeit anfahrrampe Einheiten + Überall den Durchmesser der Räder auf 12cm und Pulse auf 384 / 3 = 128 3D: - +Rover: + Spannungsteiler neu kalibrieren. diff --git a/include/config.h b/include/config.h index 0a205f9..d8e60c1 100644 --- a/include/config.h +++ b/include/config.h @@ -21,7 +21,7 @@ namespace PinNumbers { constexpr uint8_t dir1 = 27; constexpr uint8_t dir2 = 12; constexpr uint8_t pwm = 13; - constexpr uint8_t encoder = 26; + constexpr uint8_t encoder = 32; constexpr uint8_t pmwChannel = 0; } diff --git a/include/networkConfig.h b/include/networkConfig.h index 4dafd0e..e5b0bc3 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -14,7 +14,7 @@ #include -#define RHEDE +#define HOTSPOT #ifdef HOTSPOT namespace NetworkConfig { diff --git a/lib/Battery/battery.cpp b/lib/Battery/battery.cpp index 1038698..054d5ae 100644 --- a/lib/Battery/battery.cpp +++ b/lib/Battery/battery.cpp @@ -27,10 +27,15 @@ Battery::Battery(uint8_t pin) { } void Battery::run() { + if (this->calibrationState != CalibrationState::None) { + this->runCalibration(); + return; + } + this->readAdcToBuf(); this->loopCounter++; - if (this->loopCounter == this->calulationDelayMultiplier) { + if (this->loopCounter >= this->calulationDelayMultiplier) { this->calculateBatteryVoltage(); this->calculateBatteryPercent(); this->loopCounter = 0; @@ -40,6 +45,28 @@ void Battery::run() { return; } +void Battery::runCalibration() { + if (this->calibrationState != CalibrationState::Reading) + return; + + this->readAdcToBuf(); + if (this->bufferPos == 0) { + uint16_t res = this->getBufAvg(); + this->newRawAdcVoltages[this->currentCalibrationVoltage] = res; + std::cout << "Index: " + << (int) this->currentCalibrationVoltage + << " Value: " + << (int) res + << std::endl; + this->currentCalibrationVoltage++; + this->calibrationState = CalibrationState::Waiting; + + if (this->currentCalibrationVoltage == 60) { + this->calibrationState = CalibrationState::Finished; + } + } +} + double Battery::getBatteryVoltage() const { double res = this->batteryVoltage; return (int)(res*100+0.5)/100.0; @@ -59,6 +86,29 @@ bool Battery::isNewValue() { return true; } +void Battery::nextVoltageIsReady() { + if (this->calibrationState == CalibrationState::Waiting) { + this->calibrationState = CalibrationState::Reading; + } +} + +void Battery::startCalibration() { + this->calibrationState = CalibrationState::Waiting; + this->currentCalibrationVoltage = 0; + this->bufferPos = 0; + this->loopDelay = 50; + this->newRawAdcVoltages = new uint16_t[60]; +} + +void Battery::finishCalibration() { + if (this->calibrationState != CalibrationState::None) + return; + + delete[] this->newRawAdcVoltages; + this->calibrationState = CalibrationState::None; + this->loopDelay = 100; +} + double Battery::calculateInputVoltage() { // Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095 double reading = this->getBufAvg(); diff --git a/lib/Battery/battery.h b/lib/Battery/battery.h index e0b9f38..f6707ba 100644 --- a/lib/Battery/battery.h +++ b/lib/Battery/battery.h @@ -29,6 +29,13 @@ */ class Battery : public Component { public: + enum CalibrationState { + None, + Reading, + Waiting, + Finished + }; + /** * @brief Construct a new Battery object * @@ -72,8 +79,16 @@ class Battery : public Component { bool isNewValue(); + //Calibration + CalibrationState getCalibrationState() const { return this->calibrationState; } + uint8_t getCurrentCalibrationVoltage() const { return this->currentCalibrationVoltage; } + void nextVoltageIsReady(); + void startCalibration(); + void finishCalibration(); + private: void run() override; + void runCalibration(); double calculateInputVoltage(); void calculateBatteryVoltage(); void calculateBatteryPercent(); @@ -83,6 +98,8 @@ class Battery : public Component { static const uint8_t bufferSize = 30; + CalibrationState calibrationState = CalibrationState::None; + uint8_t absurdLowVoltage = 5; uint8_t pin; uint8_t batteryPercent = 0; @@ -90,7 +107,9 @@ class Battery : public Component { uint8_t bufferPos = 0; uint8_t calulationDelayMultiplier = 5; uint8_t loopCounter = 0; + uint8_t currentCalibrationVoltage = 0; // *0.1 + 7 uint16_t adcBuffer[bufferSize]; + uint16_t* newRawAdcVoltages; uint32_t r1 = 0; uint32_t r2 = 0; bool calculatetNewValues = false; @@ -108,12 +127,12 @@ class Battery : public Component { const double startVoltage = 7; const double stepVoltage = 0.1; const uint16_t rawAdcVoltages[60] = // from 7.0V to 12.9V in 0.1V steps - {1820, 1851, 1880, 1910, 1937, 1967, 1992, 2020, 2048, 2080, - 2109, 2136, 2163, 2189, 2218, 2244, 2273, 2302, 2334, 2363, - 2391, 2415, 2441, 2471, 2499, 2531, 2557, 2587, 2617, 2646, - 2674, 2699, 2730, 2761, 2791, 2816, 2843, 2872, 2900, 2930, - 2958, 2991, 3017, 3049, 3080, 3115, 3144, 3178, 3208, 3242, - 3276, 3313, 3346, 3389, 3433, 3470, 3509, 3548, 3590, 3636}; + {1992, 2021, 2056, 2090, 2118, 2145, 2177, 2208, 2241, 2272, + 2298, 2331, 2362, 2387, 2420, 2453, 2482, 2514, 2543, 2577, + 2607, 2640, 2670, 2703, 2736, 2763, 2794, 2826, 2858, 2890, + 2920, 2956, 2983, 3019, 3054, 3088, 3121, 3158, 3189, 3226, + 3264, 3300, 3339, 3379, 3414, 3453, 3500, 3544, 3598, 3636, + 3682, 3730, 3781, 3837, 3887, 3943, 3997, 4054, 4093, 4095}; }; #endif // BATTERY_H diff --git a/platformio.ini b/platformio.ini index 802f7b1..c5bc22d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,7 +15,7 @@ board_build.partitions = no_ota.csv framework = arduino monitor_speed = 115200 upload_speed = 921600 -monitor_port = COM3 +monitor_port = COM6 lib_deps = https://git.kleiax.de/PlatformIO-Libs/SparkFunGNSS.git knolleary/PubSubClient@^2.8 @@ -26,7 +26,7 @@ lib_deps = https://git.kleiax.de/PlatformIO-Libs/Menu.git nrf24/RF24@^1.4.5 jrowberg/I2Cdevlib-MPU6050@^1.0.0 -upload_port = COM3 +upload_port = COM6 test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder diff --git a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp new file mode 100644 index 0000000..b9ded0a --- /dev/null +++ b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp @@ -0,0 +1,59 @@ +/** + * @file menuCalibrateBattery.cpp + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-26 + * + * @copyright Copyright (c) 2023 + * + */ + +#include "menuCalibrateBattery.h" + +MenuCalibrateBattery::MenuCalibrateBattery(Battery* battery) { + this->setUpdateDelay(400); + this->battery = battery; +} + +void MenuCalibrateBattery::printMenu() { + if (this->battery->getCalibrationState() == Battery::CalibrationState::None) + this->battery->startCalibration(); + + String lineOne = ""; + String lineTwo = ""; + + switch (this->battery->getCalibrationState()) { + case Battery::CalibrationState::Waiting: + lineOne = "Target Voltage:"; + lineTwo = "7 + "; + lineTwo.concat(this->battery->getCurrentCalibrationVoltage()); + lineTwo.concat(" / 10"); + break; + + case Battery::CalibrationState::Reading: + lineOne = "Reading..."; + break; + + case Battery::CalibrationState::Finished: + lineOne = "Finished!"; + break; + + default: + break; + } + + this->print(lineOne, lineTwo); +} + +void MenuCalibrateBattery::left() { + this->battery->finishCalibration(); + + if (parentMenu) + this->parentMenu->printMenu(); +} + +void MenuCalibrateBattery::right() { + if (this->battery->getCalibrationState() == Battery::CalibrationState::Waiting) + this->battery->nextVoltageIsReady(); +} diff --git a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h new file mode 100644 index 0000000..89758eb --- /dev/null +++ b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h @@ -0,0 +1,33 @@ +/** + * @file menuCalibrateBattery.h + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-26 + * + * @copyright Copyright (c) 2023 + * + */ + +#ifndef MENU_CALIBRATE_BATTERY_H +#define MENU_CALIBRATE_BATTERY_H + +#include "menuControl.h" +#include "battery.h" + +class MenuCalibrateBattery : public MenuControl { + public: + MenuCalibrateBattery(Battery* battery); + + void printMenu() override; + + void left() override; + void no() override { this->left(); } + void right() override; + void yes() override { this->right(); } + + private: + Battery* battery; +}; + +#endif //MENU_CALIBRATE_BATTERY_H diff --git a/src/SpecialMenus/Speed/menuSpeed.cpp b/src/SpecialMenus/Speed/menuSpeed.cpp new file mode 100644 index 0000000..e267bc2 --- /dev/null +++ b/src/SpecialMenus/Speed/menuSpeed.cpp @@ -0,0 +1,13 @@ +/** + * @file menuSpeed.cpp + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-26 + * + * @copyright Copyright (c) 2023 + * + */ + +#include "menuSpeed.h" + diff --git a/src/SpecialMenus/Speed/menuSpeed.h b/src/SpecialMenus/Speed/menuSpeed.h new file mode 100644 index 0000000..9acba68 --- /dev/null +++ b/src/SpecialMenus/Speed/menuSpeed.h @@ -0,0 +1,21 @@ +/** + * @file menuSpeed.h + * @author Alexander Klein (alex@kleiax.de) + * @brief + * @version 0.1 + * @date 2023-09-26 + * + * @copyright Copyright (c) 2023 + * + */ + +#ifndef MENU_SPEED_H +#define MENU_SPEED_H + +#include + +class MenuSpeed : MenuIntInput { + +}; + +#endif // MENU_SPEED_H diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp index 743dc74..6706ae7 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp +++ b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp @@ -14,6 +14,7 @@ MenuSysteminformation::MenuSysteminformation(Battery* mainBattery) : MenuInformationSites(8) { this->mainBattery = mainBattery; + this->noEqualLeft = true; } void MenuSysteminformation::printPage() const { diff --git a/src/SpecialMenus/driveModi/menuDriveMode.h b/src/SpecialMenus/driveModi/menuDriveMode.h index ae94233..cff4ea3 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.h +++ b/src/SpecialMenus/driveModi/menuDriveMode.h @@ -13,6 +13,8 @@ #include "menuInformationSites.h" #include "driveModi/driveManager.h" +#include "SpecialMenus/SensorData/menuSensorData.h" +#include "SpecialMenus/Speed/menuSpeed.h" /** * @brief A base class for Menus about DriveModi @@ -36,6 +38,9 @@ class MenuDriveMode : public MenuInformationSites { void configureOnLeave() {} DriveManager* driveManager; + MenuSensorData* menuSensor; + MenuSpeed* menuSpeed; + bool firstPrint = true; }; diff --git a/src/main.cpp b/src/main.cpp index 9f7f5ab..25ec03d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,7 @@ #include "SpecialMenus/PID/menuPidSettings.h" #include "SpecialMenus/Route/menuRoute.h" #include "SpecialMenus/SensorData/menuSensorData.h" +#include "SpecialMenus/CalibrateBattery/menuCalibrateBattery.h" MoveControl moveController; Network* network; @@ -142,7 +143,7 @@ void loop() { lcdWrapper->loop(); mainBattery->loop(); - // new Value ervery 0.5s + // new Value ervery 0.5s if (mainBattery->isNewValue()) { static uint8_t batteryLowCounter = 0; if (mainBattery->isBatteryLow(10)) @@ -216,6 +217,7 @@ void makeMenu() { MenuSensorData* sen_m = new MenuSensorData(sensorData); //TODO: Wie bekommt jeder die dumme Route? MenuRoute* rout_m = new MenuRoute(new Route()); + MenuCalibrateBattery* bat_m = new MenuCalibrateBattery(mainBattery); auto_m->setUpdateDelay(1000); sys_m->setUpdateDelay(1500); @@ -242,6 +244,7 @@ void makeMenu() { set_m->addEntry(new MenuAction("Speed", dummy)); set_m->addEntry(new MenuAction("Distance", dummy)); set_m->addEntry(new MenuAction("WiFi", dummy)); + set_m->addEntry(new MenuAction("Battery", bat_m)); // Entry for the PID Menu pid_m->addEntry(new MenuAction("Left", pidl_m)); From d7357d4f95013c4b838e369dbb30d20ed04c7cab Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 27 Sep 2023 15:32:30 +0200 Subject: [PATCH 14/26] try to make menus accessable from driveMode --- src/SpecialMenus/Speed/menuSpeed.h | 2 +- .../driveModi/Autopilot/menuAutopilot.cpp | 6 +- .../driveModi/Autopilot/menuAutopilot.h | 4 +- .../CalibrateCompass/menuCalibrateCompass.cpp | 2 +- .../CalibrateCompass/menuCalibrateCompass.h | 2 +- .../CaptureRoute/menuCaptureRoute.cpp | 4 +- .../driveModi/CaptureRoute/menuCaptureRoute.h | 2 +- .../driveModi/ManualDrive/menuManualDrive.cpp | 33 ++----- .../driveModi/ManualDrive/menuManualDrive.h | 3 +- .../driveModi/TestMode/menuTestMode.cpp | 2 +- src/SpecialMenus/driveModi/menuDriveMode.cpp | 87 ++++++++++++++++++- src/SpecialMenus/driveModi/menuDriveMode.h | 26 +++++- src/main.cpp | 2 + 13 files changed, 128 insertions(+), 47 deletions(-) diff --git a/src/SpecialMenus/Speed/menuSpeed.h b/src/SpecialMenus/Speed/menuSpeed.h index 9acba68..65b3ccd 100644 --- a/src/SpecialMenus/Speed/menuSpeed.h +++ b/src/SpecialMenus/Speed/menuSpeed.h @@ -14,7 +14,7 @@ #include -class MenuSpeed : MenuIntInput { +class MenuSpeed : public MenuIntInput { }; diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index 9496435..8447325 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -201,7 +201,7 @@ void MenuAutopilot::printPage() const { this->print(lineOne, lineTwo); } -void MenuAutopilot::runCommand() const { +void MenuAutopilot::runCommand() { switch (this->getCurrentPage()) { case 5: this->autopilot->switchLoopMode(); @@ -226,7 +226,7 @@ void MenuAutopilot::runCommand() const { } } -void MenuAutopilot::runCommandNo() const { +void MenuAutopilot::runCommandNo() { switch (this->getCurrentPage()) { case 7: this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint(); @@ -254,4 +254,6 @@ void MenuAutopilot::init() { //dirty hack to get the val, can be better!!! TODO this->autopilot->getNavigation()->increaseMinDistanceToReachPoint(); this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint(); + + MenuDriveMode::init(); } diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h index c83669d..206ffab 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h @@ -47,8 +47,8 @@ class MenuAutopilot : public MenuDriveMode { private: void init() override; - void runCommand() const override; - void runCommandNo() const override; + void runCommand() override; + void runCommandNo() override; bool mutable targetFreezed = false; double mutable minDistance; diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp index 3b9ac35..f709559 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp @@ -117,7 +117,7 @@ void MenuCalibrateCompass::init() { this->updateDelay = 500; } -void MenuCalibrateCompass::runCommand() const { +void MenuCalibrateCompass::runCommand() { switch (this->getCurrentPage()) { case 2: switch (this->caliCompass->getState()) { diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h index 284e200..010bbaf 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h @@ -42,7 +42,7 @@ class MenuCalibrateCompass : public MenuDriveMode { protected: void init() override; - void runCommand() const override; + void runCommand() override; private: CalibrateCompassM* caliCompassMode; diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp index ff7508d..f90f3a5 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp @@ -114,7 +114,7 @@ void MenuCaptureRoute::update() { this->printMenu(); } -void MenuCaptureRoute::runCommand() const { +void MenuCaptureRoute::runCommand() { switch (this->getCurrentPage()) { case 7: @@ -134,5 +134,5 @@ void MenuCaptureRoute::init() { this->updateDelay = 500; this->captureRoute = new CaptureRoute(); this->driveManager->changeModus(this->captureRoute); - + MenuDriveMode::init(); } diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h index 04136c7..9c3ba8a 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h @@ -43,7 +43,7 @@ class MenuCaptureRoute : public MenuDriveMode { */ void update() override; - void runCommand() const override; + void runCommand() override; private: void init() override; diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index b704d9b..72bdeef 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -11,7 +11,7 @@ #include "menuManualDrive.h" MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) { - + this->noEqualLeft = true; } MenuManualControl::~MenuManualControl() { @@ -35,15 +35,11 @@ void MenuManualControl::printPage() const { break; case 2: - lineOne = "Speed: "; - lineOne.concat(this->manualControl->getMaxSpeed()); - lineTwo = "- dec 0.1 inc +"; + lineOne = "Speed Menu"; break; case 3: - lineOne = "RotSpeed: "; - lineOne.concat(this->manualControl->getMaxRotation()); - lineTwo = "- dec 0.1 inc +"; + lineOne = "Sensor Menu"; break; default: @@ -60,39 +56,24 @@ void MenuManualControl::init() { this->driveManager->changeModus(this->manualControl); this->setCountPages(4); this->updateDelay = 500; + MenuDriveMode::init(); } -void MenuManualControl::runCommand() const { +void MenuManualControl::runCommand() { switch (this->getCurrentPage()) { case 1: this->manualControl->switchInputMode(); break; case 2: - this->manualControl->increaseMaxSpeed(); + this->enterSpeedMenu(); break; case 3: - this->manualControl->increaseMaxRotation(); + this->enterSensorMenu(); break; default: break; } } - -void MenuManualControl::runCommandNo() const { - switch (this->getCurrentPage()) - { - case 2: - this->manualControl->decreaseMaxSpeed(); - break; - - case 3: - this->manualControl->decreaseMaxRotation(); - break; - - default: - break; - } -} diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h index 7ad8449..9f2f6d8 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h @@ -41,8 +41,7 @@ class MenuManualControl : public MenuDriveMode { protected: void init() override; - void runCommand() const override; - void runCommandNo() const override; + void runCommand() override; private: ManualControl* manualControl; diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 6b268cb..4d5d76c 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -173,7 +173,7 @@ void MenuTestMode::init() { lightMenu->addEntry(lightRedAction); lightMenu->addEntry(lightGreenAction); lightMenu->addEntry(lightBlueAction); - lightMenu->addEntry(lightOffAction); + lightMenu->addEntry(lightOffAction); } void MenuTestMode::update() { diff --git a/src/SpecialMenus/driveModi/menuDriveMode.cpp b/src/SpecialMenus/driveModi/menuDriveMode.cpp index 0fa91ba..5daacab 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.cpp +++ b/src/SpecialMenus/driveModi/menuDriveMode.cpp @@ -16,11 +16,90 @@ MenuDriveMode::MenuDriveMode(DriveManager* driveManager) { } void MenuDriveMode::left() { + if (this->activeMenu) { + if (this->activeMenu) + this->activeMenu->left(); + return; + } + this->firstPrint = true; this->configureOnLeave(); this->driveManager->changeModus(); - if (parentMenu) { - this->parentMenu->printMenu(); - this->leaved = true; - } + MenuInformationSites::left(); +} + +void MenuDriveMode::right() { + if (this->activeMenu) { + this->activeMenu->right(); + return; + } + MenuInformationSites::right(); +} + +void MenuDriveMode::up() { + if (this->activeMenu) { + this->activeMenu->up(); + return; + } + MenuInformationSites::up(); +} + +void MenuDriveMode::down() { + if (this->activeMenu) { + this->activeMenu->down(); + return; + } + MenuInformationSites::down(); +} + +void MenuDriveMode::yes() { + if (this->activeMenu) { + this->activeMenu->yes(); + return; + } + MenuInformationSites::yes(); +} + +void MenuDriveMode::no() { + if (this->activeMenu) { + this->activeMenu->no(); + return; + } + MenuInformationSites::no(); +} + +void MenuDriveMode::prepareReenterMenu() { + this->activeMenu = nullptr; +} + +void MenuDriveMode::printMenu() { + if (this->activeMenu) { + this->activeMenu->printMenu(); + return; + } + + MenuInformationSites::printMenu(); +} + +void MenuDriveMode::init() { + this->activeMenu = nullptr; +} + +void MenuDriveMode::enterSpeedMenu() { + this->activeMenu = this->menuSpeed; + this->enterMenu(); +} + +void MenuDriveMode::enterSensorMenu() { + this->activeMenu = this->menuSensor; + this->enterMenu(); +} + +void MenuDriveMode::enterMenu() { + if (!this->activeMenu) + return + + this->activeMenu->printMenu(); + std::cout << "Sensor Menu was theretically printed" << std::endl; + this->activeMenu->setParentMenu(this); } diff --git a/src/SpecialMenus/driveModi/menuDriveMode.h b/src/SpecialMenus/driveModi/menuDriveMode.h index cff4ea3..82a67e1 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.h +++ b/src/SpecialMenus/driveModi/menuDriveMode.h @@ -29,19 +29,37 @@ class MenuDriveMode : public MenuInformationSites { */ MenuDriveMode(DriveManager* driveManager); + void addSensorMenu(MenuSensorData* menuSensor) { this->menuSensor = menuSensor; } + void addSpeedMenu(MenuSpeed* menuSpeed) { this->menuSpeed = menuSpeed; } + /** * @brief Goes back to the parentMenu. */ void left() override; + void right() override; + void up() override; + void down() override; + void yes() override; + void no() override; + + void prepareReenterMenu() override; + void printMenu() override; protected: - void configureOnLeave() {} + void init() override; + virtual void configureOnLeave() {} + void enterSpeedMenu(); + void enterSensorMenu(); DriveManager* driveManager; - MenuSensorData* menuSensor; - MenuSpeed* menuSpeed; bool firstPrint = true; -}; + private: + void enterMenu(); + + MenuControl* activeMenu = nullptr; + MenuSensorData* menuSensor = nullptr; + MenuSpeed* menuSpeed = nullptr; +}; #endif // MENU_DRIVE_MODI_H diff --git a/src/main.cpp b/src/main.cpp index 25ec03d..997da5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -223,6 +223,8 @@ void makeMenu() { sys_m->setUpdateDelay(1500); sen_m->setUpdateDelay(500); + man_m->addSensorMenu(sen_m); + // Entry for the main menu main_m->addEntry(new MenuAction("Mode", mode_m)); main_m->addEntry(new MenuAction("Sensor", sen_m)); From 45264c6481fd8bba88d2b9ea96e6801ef375e846 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Fri, 29 Sep 2023 11:30:13 +0200 Subject: [PATCH 15/26] finished speed and sensor menu in modes --- doc/TODO allgemein.txt | 5 +--- include/moveControl.h | 10 +++++--- src/SpecialMenus/PID/menuPidSettings.h | 2 +- src/SpecialMenus/Speed/menuSpeed.cpp | 6 +++++ src/SpecialMenus/Speed/menuSpeed.h | 12 +++++++-- .../driveModi/ManualDrive/menuManualDrive.cpp | 1 + .../driveModi/TestMode/menuTestMode.cpp | 3 +-- src/SpecialMenus/driveModi/menuDriveMode.cpp | 19 ++++++++++++-- src/SpecialMenus/driveModi/menuDriveMode.h | 5 ++-- src/driveModi/Modi/Autopilot/autopilot.cpp | 20 +++++++-------- .../Modi/ManualControl/manualControl.cpp | 18 +++++-------- src/driveModi/Modi/TestMode/testMode.cpp | 16 ++++++------ src/driveModi/driveManager.cpp | 1 + src/driveModi/driveManager.h | 3 ++- src/driveModi/driveModi.h | 25 +++---------------- src/main.cpp | 11 +++++--- src/moveControl.cpp | 17 ++++++++----- 17 files changed, 96 insertions(+), 78 deletions(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 89e0b07..b1d53b8 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -42,10 +42,8 @@ Do later: Do now: Code: Doxygen Kommentare aktualisieren - sensor data gnss daten aktualisieren - Menübaum korrigieren, Verlinkung Sensor in Mode etc. esp und sensoren in den deepsleep - battery Prozent ausgabe wirkt komisch + magic numbers etc Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung @@ -57,4 +55,3 @@ Latex: 3D: Rover: - Spannungsteiler neu kalibrieren. diff --git a/include/moveControl.h b/include/moveControl.h index 8c6d7b8..9fa948c 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -22,6 +22,10 @@ #include "debugTimes.h" #include "component.h" +struct DrivingSpeeds { + double x; + double rot; +}; /** * @brief This class manages the motors and the encoders @@ -91,6 +95,8 @@ class MoveControl : public Component { */ void setRotationSpeed(double speed); + void setSpeeds(DrivingSpeeds drivingSpeeds); + /** * @brief Set Raw Power Left * @@ -159,9 +165,7 @@ class MoveControl : public Component { PID *right_pid; Status driving_status = Status::Stop; - - double x_speed = 0; - double rotation_speed = 0; + DrivingSpeeds drivingSpeeds = {0, 0}; double wheelspeed_left_target = 0; double wheelspeed_right_target = 0; diff --git a/src/SpecialMenus/PID/menuPidSettings.h b/src/SpecialMenus/PID/menuPidSettings.h index 61d5c08..b8fbb44 100644 --- a/src/SpecialMenus/PID/menuPidSettings.h +++ b/src/SpecialMenus/PID/menuPidSettings.h @@ -29,7 +29,7 @@ class MenuPidSettings : public MenuIntInputWrapper { */ MenuPidSettings(PID* pid); - void action(int16_t* values, uint8_t length); + void action(int16_t* values, uint8_t length) override; private: PID* pid; diff --git a/src/SpecialMenus/Speed/menuSpeed.cpp b/src/SpecialMenus/Speed/menuSpeed.cpp index e267bc2..1cb1736 100644 --- a/src/SpecialMenus/Speed/menuSpeed.cpp +++ b/src/SpecialMenus/Speed/menuSpeed.cpp @@ -11,3 +11,9 @@ #include "menuSpeed.h" +void MenuSpeed::action(int16_t* values, uint8_t length) { + if (length != 2) + return; + this->speeds.x = (double) values[0] / 10.0; + this->speeds.rot = (double) values[1] / 10.0; +} diff --git a/src/SpecialMenus/Speed/menuSpeed.h b/src/SpecialMenus/Speed/menuSpeed.h index 65b3ccd..2bdf127 100644 --- a/src/SpecialMenus/Speed/menuSpeed.h +++ b/src/SpecialMenus/Speed/menuSpeed.h @@ -13,9 +13,17 @@ #define MENU_SPEED_H #include +#include "moveControl.h" + +class MenuSpeed : public MenuIntInputWrapper { + public: + MenuSpeed(DrivingSpeeds& speeds) : speeds(speeds){}; + + void action(int16_t* values, uint8_t length) override; + + private: + DrivingSpeeds& speeds; -class MenuSpeed : public MenuIntInput { - }; #endif // MENU_SPEED_H diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index 72bdeef..7f3cb5c 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -56,6 +56,7 @@ void MenuManualControl::init() { this->driveManager->changeModus(this->manualControl); this->setCountPages(4); this->updateDelay = 500; + this->activateSpeedMenu(); MenuDriveMode::init(); } diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 4d5d76c..f5157df 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -77,8 +77,7 @@ void MenuTestMode::init() { this->testMode = new TestMode(); this->driveManager->changeModus(this->testMode); - testMode->setMaxSpeed(1); - testMode->setMaxRotation(8); + this->testMode->setSpeeds(DrivingSpeeds{1, 8}); auto dummy = []() { std::cout << "Dummy in Action" <firstPrint = true; this->configureOnLeave(); + if (this->menuSpeed) + delete this->menuSpeed; this->driveManager->changeModus(); MenuInformationSites::left(); } @@ -85,6 +87,20 @@ void MenuDriveMode::init() { this->activeMenu = nullptr; } +void MenuDriveMode::activateSpeedMenu() { + if (!this->driveManager->isActive()) + return; + + DrivingSpeeds& speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef(); + MenuIntInput* menu = new MenuIntInput(2, new MenuSpeed(speeds)); + + menu->setMinMax(5, UINT8_MAX); + menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10); + menu->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10); + + this->addSpeedMenu(menu); +} + void MenuDriveMode::enterSpeedMenu() { this->activeMenu = this->menuSpeed; this->enterMenu(); @@ -97,9 +113,8 @@ void MenuDriveMode::enterSensorMenu() { void MenuDriveMode::enterMenu() { if (!this->activeMenu) - return + return; this->activeMenu->printMenu(); - std::cout << "Sensor Menu was theretically printed" << std::endl; this->activeMenu->setParentMenu(this); } diff --git a/src/SpecialMenus/driveModi/menuDriveMode.h b/src/SpecialMenus/driveModi/menuDriveMode.h index 82a67e1..c74861e 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.h +++ b/src/SpecialMenus/driveModi/menuDriveMode.h @@ -30,7 +30,7 @@ class MenuDriveMode : public MenuInformationSites { MenuDriveMode(DriveManager* driveManager); void addSensorMenu(MenuSensorData* menuSensor) { this->menuSensor = menuSensor; } - void addSpeedMenu(MenuSpeed* menuSpeed) { this->menuSpeed = menuSpeed; } + void addSpeedMenu(MenuIntInput* menuSpeed) { this->menuSpeed = menuSpeed; } /** * @brief Goes back to the parentMenu. @@ -48,6 +48,7 @@ class MenuDriveMode : public MenuInformationSites { protected: void init() override; virtual void configureOnLeave() {} + void activateSpeedMenu(); void enterSpeedMenu(); void enterSensorMenu(); @@ -60,6 +61,6 @@ class MenuDriveMode : public MenuInformationSites { MenuControl* activeMenu = nullptr; MenuSensorData* menuSensor = nullptr; - MenuSpeed* menuSpeed = nullptr; + MenuIntInput* menuSpeed = nullptr; }; #endif // MENU_DRIVE_MODI_H diff --git a/src/driveModi/Modi/Autopilot/autopilot.cpp b/src/driveModi/Modi/Autopilot/autopilot.cpp index 9a1da0c..49b0cf2 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.cpp +++ b/src/driveModi/Modi/Autopilot/autopilot.cpp @@ -125,17 +125,13 @@ void Autopilot::init() { this->courseCorrection.correction = 0; this->courseCorrection.distance = 0; this->updateDisplay = true; - - this->maxRotationSpeed = 7; - this->maxForwardSpeed = 1.5; } void Autopilot::drive() { - this->moveControl->setRotationSpeed(0); - if (this->courseCorrection.distance >= this->minRemainingDistance) - this->moveControl->setSpeed(this->maxForwardSpeed); - else - this,moveControl->setSpeed(0); + DrivingSpeeds speeds = {0, 0}; + if (this->courseCorrection.distance >= this->minRemainingDistance) + speeds.x = this->maxSpeeds.x; + this->moveControl->setSpeeds(speeds); } void Autopilot::beginRotate() { @@ -145,11 +141,13 @@ void Autopilot::beginRotate() { this->rotationAimAzimuth = this->getSensorData()->getRealAzimuth() + this->courseCorrection.correction; this->rotationAimAzimuth = Navigation::fixDegree(this->rotationAimAzimuth); - this->moveControl->setSpeed(0); + DrivingSpeeds speeds = {0, 0}; if (this->courseCorrection.correction > 0) - this->moveControl->setRotationSpeed(-this->maxRotationSpeed); + speeds.rot = -this->maxSpeeds.rot; else - this->moveControl->setRotationSpeed(this->maxRotationSpeed); + speeds.rot = this->maxSpeeds.rot; + + this->moveControl->setSpeeds(speeds); } } diff --git a/src/driveModi/Modi/ManualControl/manualControl.cpp b/src/driveModi/Modi/ManualControl/manualControl.cpp index a59fa3f..8a81978 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.cpp +++ b/src/driveModi/Modi/ManualControl/manualControl.cpp @@ -34,17 +34,11 @@ void ManualControl::analogControl() { int16_t x = this->input->x - 127; int16_t y = this->input->y - 127; - // static int counter = 0; - // if (counter % 60 == 0) { - // std::cout << "Input: x: " << (int) this->input->x << " y: " << (int) this->input->y << std::endl; - // std::cout << "Output: x: " << (int) x << " y: " << (int) y << std::endl; - // } - // counter++; - double value_per_step = this->maxForwardSpeed * 2 / UINT8_MAX; + double value_per_step = this->maxSpeeds.x * 2 / UINT8_MAX; this->moveControl->setSpeed(-x * value_per_step); - value_per_step = this->maxRotationSpeed * 2 / UINT8_MAX; + value_per_step = this->maxSpeeds.rot * 2 / UINT8_MAX; this->moveControl->setRotationSpeed(y * value_per_step); } @@ -53,16 +47,16 @@ void ManualControl::digitalControl() { int16_t x = this->input->y - 127; if (y > 120) - this->moveControl->setSpeed(-this->maxForwardSpeed); + this->moveControl->setSpeed(-this->maxSpeeds.x); else if (y < -120) - this->moveControl->setSpeed(this->maxForwardSpeed); + this->moveControl->setSpeed(this->maxSpeeds.rot); else this->moveControl->setSpeed(0); if (x > 120) - this->moveControl->setRotationSpeed(this->maxRotationSpeed); + this->moveControl->setRotationSpeed(this->maxSpeeds.rot); else if (x < -120) - this->moveControl->setRotationSpeed(-this->maxRotationSpeed); + this->moveControl->setRotationSpeed(-this->maxSpeeds.rot); else this->moveControl->setRotationSpeed(0); diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index 5f5cada..cb067d1 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -37,9 +37,9 @@ bool TestMode::drive(int16_t cm, int16_t degree) { this->moveControl->setSpeed(0); if (degree < 0) - this->moveControl->setRotationSpeed(-this->maxRotationSpeed); + this->moveControl->setRotationSpeed(-this->maxSpeeds.rot); else if (degree > 0) - this->moveControl->setRotationSpeed(this->maxRotationSpeed); + this->moveControl->setRotationSpeed(this->maxSpeeds.rot); this->azimuth = this->getSensorData()->getRealAzimuth(); this->degree = degree; @@ -53,11 +53,11 @@ bool TestMode::drive(int16_t cm, int16_t degree) { this->moveControl->setRotationSpeed(0); if (cm < 0) - this->moveControl->setSpeed(-this->maxForwardSpeed); + this->moveControl->setSpeed(-this->maxSpeeds.x); else if (cm > 0) - this->moveControl->setSpeed(this->maxForwardSpeed); + this->moveControl->setSpeed(this->maxSpeeds.x); - this->maneuverTime = (uint32_t) (((double) abs(cm) / 100.0) / this->maxForwardSpeed) * 1000; + this->maneuverTime = (uint32_t) (((double) abs(cm) / 100.0) / this->maxSpeeds.x) * 1000; this->busy = true; this->maneuver = Maneuver::Drive; return true; @@ -65,11 +65,11 @@ bool TestMode::drive(int16_t cm, int16_t degree) { //forward or backward and left or right // TODO: Calculate roationspeed if (cm < 0) - this->moveControl->setSpeed(-this->maxForwardSpeed); + this->moveControl->setSpeed(-this->maxSpeeds.x); else if (cm > 0) - this->moveControl->setSpeed(this->maxForwardSpeed); + this->moveControl->setSpeed(this->maxSpeeds.x); - this->maneuverTime = (uint32_t) (((double) cm / 100.0) / this->maxForwardSpeed) * 1000; + this->maneuverTime = (uint32_t) (((double) cm / 100.0) / this->maxSpeeds.x) * 1000; this->busy = true; this->maneuver = Maneuver::Drive; return true; diff --git a/src/driveModi/driveManager.cpp b/src/driveModi/driveManager.cpp index dc948ee..aa371b4 100644 --- a/src/driveModi/driveManager.cpp +++ b/src/driveModi/driveManager.cpp @@ -36,6 +36,7 @@ void DriveManager::changeModus(DriveModi* modus) { if (this->currentModusPtr) { this->currentModusPtr->activate(this->driveModiParams); + this->currentModusPtr->setSpeeds(this->drivingSpeeds); this->addChildComponent(this->currentModusPtr); } } diff --git a/src/driveModi/driveManager.h b/src/driveModi/driveManager.h index ab70f61..8c7f5f9 100644 --- a/src/driveModi/driveManager.h +++ b/src/driveModi/driveManager.h @@ -53,7 +53,7 @@ class DriveManager : public Component { * @return DriveModi* */ DriveModi* getDriveModiPtr() const { return this->currentModusPtr; } - + DrivingSpeeds& getDrivingSpeedsRef() { return this->drivingSpeeds; } bool isActive() const { return this->currentModusPtr; } @@ -63,6 +63,7 @@ class DriveManager : public Component { DriveModi *currentModusPtr = nullptr; DriveModiParams driveModiParams; + DrivingSpeeds drivingSpeeds = {1, 7}; }; diff --git a/src/driveModi/driveModi.h b/src/driveModi/driveModi.h index 33d9f70..adc9db5 100644 --- a/src/driveModi/driveModi.h +++ b/src/driveModi/driveModi.h @@ -39,34 +39,17 @@ class DriveModi : public Component { void activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData); void activate(DriveModiParams params); - /** - * @brief Set the max speed - * - * @param maxSpeed in m/s - */ - void setMaxSpeed(double maxForwardSpeed) { maxForwardSpeed = maxForwardSpeed; } - void increaseMaxSpeed(double increase = 0.1) { maxForwardSpeed += increase; } - void decreaseMaxSpeed(double increase = 0.1) { maxForwardSpeed -= increase; } - double getMaxSpeed() const { return this->maxForwardSpeed; } - - /** - * @brief Set the max rotation - * - * @param maxRotation in rad/s (maybe) - */ - void setMaxRotation(double maxRotation) { maxRotationSpeed = maxRotation; } - void increaseMaxRotation(double increase = 0.1) { maxRotationSpeed += increase; } - void decreaseMaxRotation(double increase = 0.1) { maxRotationSpeed -= increase; } - double getMaxRotation() const { return this->maxRotationSpeed; } + void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; } + DrivingSpeeds getSpeeds() const { return this->maxSpeeds; } + DrivingSpeeds& getSpeedsRef() { return this->maxSpeeds; } protected: virtual void afterActivate() {} MoveControl *moveControl; + DrivingSpeeds maxSpeeds = {1, 7}; const ControlPadInput* input; const SensorData* sensorData; - double maxForwardSpeed = 1; - double maxRotationSpeed = 7; private: void init(); diff --git a/src/main.cpp b/src/main.cpp index 997da5c..161f8f4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -208,6 +208,7 @@ void makeMenu() { Menu* pid_m = new Menu(); MenuIntInput* pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0))); MenuIntInput* pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); + MenuIntInput* speed_m = new MenuIntInput(2, new MenuSpeed(driveManager->getDrivingSpeedsRef())); MenuManualControl* man_m = new MenuManualControl(driveManager); MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager); MenuAutopilot* auto_m = new MenuAutopilot(driveManager); @@ -223,8 +224,6 @@ void makeMenu() { sys_m->setUpdateDelay(1500); sen_m->setUpdateDelay(500); - man_m->addSensorMenu(sen_m); - // Entry for the main menu main_m->addEntry(new MenuAction("Mode", mode_m)); main_m->addEntry(new MenuAction("Sensor", sen_m)); @@ -243,7 +242,7 @@ void makeMenu() { // Entry for the setting menu set_m->addEntry(new MenuAction("PID", pid_m)); - set_m->addEntry(new MenuAction("Speed", dummy)); + set_m->addEntry(new MenuAction("Speed", speed_m)); set_m->addEntry(new MenuAction("Distance", dummy)); set_m->addEntry(new MenuAction("WiFi", dummy)); set_m->addEntry(new MenuAction("Battery", bat_m)); @@ -263,6 +262,12 @@ void makeMenu() { pidr_m->setEntry(1, "I-Part", (uint8_t) moveController.getPID(1)->GetKi()); pidr_m->setEntry(2, "D-Part", (uint8_t) moveController.getPID(1)->GetKd()); + speed_m->setMinMax(5, UINT8_MAX); + speed_m->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10); + speed_m->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10); + + man_m->addSensorMenu(sen_m); + controlPad->setMenuControl(main_m); } diff --git a/src/moveControl.cpp b/src/moveControl.cpp index eb87aa2..20c9248 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -105,20 +105,25 @@ void MoveControl::emergencyStop() { void MoveControl::setSpeed(double speed) { if (speed < 0.2 && speed > -0.2) { - this->x_speed = 0; + this->drivingSpeeds.x = 0; return; } - this->x_speed = speed; + this->drivingSpeeds.x = speed; } void MoveControl::setRotationSpeed(double speed) { if (speed < 0.1 && speed > -0.1){ - this->rotation_speed = 0; + this->drivingSpeeds.rot = 0; return; } - this->rotation_speed = speed; + this->drivingSpeeds.rot = speed; +} + +void MoveControl::setSpeeds(DrivingSpeeds drivingSpeeds) { + this->setSpeed(drivingSpeeds.x); + this->setRotationSpeed(drivingSpeeds.rot); } void MoveControl::setRawPowerLeft(int16_t power) { @@ -169,8 +174,8 @@ void MoveControl::calcTargetWheelSpeed() { // (1 / r) * b constexpr double B = 2.096518987; - this->wheelspeed_right_target = (A * this->x_speed + B * this->rotation_speed) * (Settings::wheelDiameter / 2); - this->wheelspeed_left_target = (A * this->x_speed + (-B) * this->rotation_speed) * (Settings::wheelDiameter / 2); + this->wheelspeed_right_target = (A * this->drivingSpeeds.x + B * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2); + this->wheelspeed_left_target = (A * this->drivingSpeeds.x + (-B) * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2); } void MoveControl::regulateMotors() { From fd3155f49d1e607ca7edeedc26153a0630a74e91 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 4 Oct 2023 09:22:54 +0200 Subject: [PATCH 16/26] added cppcheck --- .gitignore | 3 +-- rover.cppcheck | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 rover.cppcheck diff --git a/.gitignore b/.gitignore index 72abbae..c8ced1f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,11 +3,10 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +rover-cppcheck-build-dir doc/Doxygen/html* doc/Doxygen/generated* - - workspace.code-workspace projektarbeit.code-workspace diff --git a/rover.cppcheck b/rover.cppcheck new file mode 100644 index 0000000..d853181 --- /dev/null +++ b/rover.cppcheck @@ -0,0 +1,16 @@ + + + rover-cppcheck-build-dir + false + true + true + 2 + 100 + + + + + + + rover + From 692adf7e16b5450ebfa244d60268a3c8fa9865d5 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Tue, 10 Oct 2023 17:06:30 +0200 Subject: [PATCH 17/26] - todos - test driving --- doc/TODO allgemein.txt | 12 ++++++++---- include/config.h | 9 +++++---- lib/Speedometer/speedometer.cpp | 13 +++++++++++-- lib/Speedometer/speedometer.h | 10 ++-------- platformio.ini | 5 ++--- src/driveModi/Modi/TestMode/testMode.cpp | 4 ++-- src/driveModi/Modi/TestMode/testMode.h | 2 -- src/moveControl.cpp | 14 ++++++++------ 8 files changed, 38 insertions(+), 31 deletions(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index b1d53b8..5be3695 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -37,20 +37,24 @@ Do later: -> Check speration between Ui and Route (RouteMenu) -> update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung -> Rover Objekt mit Error zustand freeze, damit das wenn möglich auch auf dem Display angezeigt wird. + -> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz Do now: Code: Doxygen Kommentare aktualisieren - esp und sensoren in den deepsleep magic numbers etc + speedometer geschwindigkeit auch als rad/s + Menu in Lib Folder packen + testMode einzelner Motor testen klappt nicht + Fernbedienung! Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung Unterschied funktionale und nicht funktionale Anforderungen - Strom nicht über Zeit sondern Rampe - Formel für Zeit anfahrrampe Einheiten - Überall den Durchmesser der Räder auf 12cm und Pulse auf 384 / 3 = 128 + Overfull H-Boxen + Test Motor, Zeiten kontrolieren. Wenn einfach so dann bezug auf fehler bei Timing und freeRtos + Bild mit RPY einbinden 3D: diff --git a/include/config.h b/include/config.h index d8e60c1..cf8e055 100644 --- a/include/config.h +++ b/include/config.h @@ -35,18 +35,19 @@ namespace PinNumbers { } namespace Settings { - constexpr float wheelDiameter = 0.1263; - constexpr uint16_t encoderSteps = 360; + constexpr float wheelDiameter = 0.105; + constexpr float wheelDistance = 0.255; + constexpr uint16_t encoderSteps = 384; namespace Pid { namespace Left { - constexpr uint8_t P = 75; + constexpr uint8_t P = 5; constexpr uint8_t I = 0; constexpr uint8_t D = 0; } namespace Right { - constexpr uint8_t P = 75; + constexpr uint8_t P = 5; constexpr uint8_t I = 0; constexpr uint8_t D = 0; } diff --git a/lib/Speedometer/speedometer.cpp b/lib/Speedometer/speedometer.cpp index 8313efa..7132b56 100644 --- a/lib/Speedometer/speedometer.cpp +++ b/lib/Speedometer/speedometer.cpp @@ -16,14 +16,14 @@ Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) { this->steps = steps; this->pulseCounter = new Counter(pin); - this->pulseCounter->setFilterValue(1000); // ignore pulses less than 1000 x 2.5ns + this->pulseCounter->setFilterValue(1023); // ignore pulses less than 1000 x 2.5ns this->pulseCounter->clear(); this->pulseCounter->resume(); Component::loopDelay = Speedometer::loopDelay; - clearAvgBuf(); + this->clearAvgBuf(); } Speedometer::~Speedometer() { @@ -47,18 +47,27 @@ void Speedometer::run() { double n = (double)pulse / this->steps; // Wheel revolutions in absolute time double u = n / ((double)elapsedTime / 1000); // Wheel revolutions per second double ms = u * (diameter * PI); // Speed in m/s + double rad = u * 2 * PI; + + if (speed < 0.1) { + speed = 0; + rad = 0; + } switch (this->currentDirection) { case Direction::Forward : this->speed = ms; + this->rad = rad; break; case Direction::Backward : this->speed = -ms; + this->rad = -rad; break; case Direction::None : this->speed = 0; + this->rad = 0; break; } diff --git a/lib/Speedometer/speedometer.h b/lib/Speedometer/speedometer.h index ae78366..a1635fb 100644 --- a/lib/Speedometer/speedometer.h +++ b/lib/Speedometer/speedometer.h @@ -59,13 +59,6 @@ class Speedometer : public Component { */ void setDirection(Direction dir); - /** - * @brief Set the number of last values ​​to be taken into account for the average. - * - * @param val length of the array - */ - void setNumOfValForAvg(uint8_t val); - /** * @brief Set the Enc Filter to prevent bouncing * @@ -88,6 +81,7 @@ class Speedometer : public Component { * @return double speed in m/s */ double getSpeed() const { return this->speed; } + double getSpeedRad() const { return this->rad; }; double getAvgSpeed() const; /** @@ -111,7 +105,6 @@ class Speedometer : public Component { private: void run() override; - void init(uint8_t pin, double diameter, uint16_t steps); void clearAvgBuf(); void addValToBuf(int16_t val); int16_t calcAverage() const; @@ -126,6 +119,7 @@ class Speedometer : public Component { bool calibrationRunning = false; double speed = 0; + double rad = 0; double diameter; uint8_t printCounter = 0; diff --git a/platformio.ini b/platformio.ini index c5bc22d..36de8e2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,7 +15,7 @@ board_build.partitions = no_ota.csv framework = arduino monitor_speed = 115200 upload_speed = 921600 -monitor_port = COM6 +monitor_port = COM3 lib_deps = https://git.kleiax.de/PlatformIO-Libs/SparkFunGNSS.git knolleary/PubSubClient@^2.8 @@ -24,9 +24,8 @@ lib_deps = bblanchon/ArduinoJson@^6.20.0 mprograms/QMC5883LCompass@^1.2.0 https://git.kleiax.de/PlatformIO-Libs/Menu.git - nrf24/RF24@^1.4.5 jrowberg/I2Cdevlib-MPU6050@^1.0.0 -upload_port = COM6 +upload_port = COM3 test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index cb067d1..b937a34 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -112,7 +112,7 @@ void TestMode::abortManeuver() { } uint8_t TestMode::getRemainingManeuverTime() const { - if (busy) + if (this->busy) return (uint8_t) ((this->maneuverTime - (millis() - this->actionStart)) / 1000); return 0; } @@ -120,7 +120,7 @@ uint8_t TestMode::getRemainingManeuverTime() const { bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds) { if (this->busy) return false; - if (powerPercentage >= 100 || powerPercentage <= -100) + if (powerPercentage > 100 || powerPercentage < -100) return false; if (seconds < 0) return false; diff --git a/src/driveModi/Modi/TestMode/testMode.h b/src/driveModi/Modi/TestMode/testMode.h index bae19de..1480e36 100644 --- a/src/driveModi/Modi/TestMode/testMode.h +++ b/src/driveModi/Modi/TestMode/testMode.h @@ -14,7 +14,6 @@ #include #include "moveControl.h" -#include "navigation.h" #include "driveModi/driveModi.h" @@ -97,7 +96,6 @@ class TestMode : public DriveModi { void run() override; bool engineInit(int16_t powerPercentage, int16_t seconds); - Navigation* navigation; Maneuver maneuver = Maneuver::None; int16_t maneuverValueOne = 0; int16_t maneuverValueTwo = 0; diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 20c9248..d7614a4 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -170,12 +170,12 @@ void MoveControl::calcTargetWheelSpeed() { \ 1 -b / \ T / \ Xr / */ // (1 / r) * 1 - constexpr double A = 15.82278481; + constexpr double A = 1.0 / (Settings::wheelDiameter / 2); // (1 / r) * b - constexpr double B = 2.096518987; + constexpr double B = (1.0 / (Settings::wheelDiameter / 2)) * (Settings::wheelDistance / 2); - this->wheelspeed_right_target = (A * this->drivingSpeeds.x + B * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2); - this->wheelspeed_left_target = (A * this->drivingSpeeds.x + (-B) * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2); + this->wheelspeed_right_target = (A * this->drivingSpeeds.x + B * this->drivingSpeeds.rot); + this->wheelspeed_left_target = (A * this->drivingSpeeds.x + (-B) * this->drivingSpeeds.rot); } void MoveControl::regulateMotors() { @@ -208,6 +208,8 @@ void MoveControl::regulateMotors() { } void MoveControl::updateCurrentWheelSpeed() { - this->wheelspeed_left = this->left_speedometer->getSpeed(); - this->wheelspeed_right = this->right_speedometer->getSpeed(); + this->wheelspeed_left = this->left_speedometer->getSpeedRad(); + this->wheelspeed_right = this->right_speedometer->getSpeedRad(); + // this->wheelspeed_left = this->left_speedometer->getSpeed(); + // this->wheelspeed_right = this->right_speedometer->getSpeed(); } From f41cf5c6ebe0e0f631821f66e1a8919a4e064c7a Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Tue, 10 Oct 2023 18:11:46 +0200 Subject: [PATCH 18/26] an update --- doc/TODO allgemein.txt | 1 - src/moveControl.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 5be3695..6a0ff6a 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -44,7 +44,6 @@ Do now: Code: Doxygen Kommentare aktualisieren magic numbers etc - speedometer geschwindigkeit auch als rad/s Menu in Lib Folder packen testMode einzelner Motor testen klappt nicht Fernbedienung! diff --git a/src/moveControl.cpp b/src/moveControl.cpp index d7614a4..0f741c5 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -210,6 +210,4 @@ void MoveControl::regulateMotors() { void MoveControl::updateCurrentWheelSpeed() { this->wheelspeed_left = this->left_speedometer->getSpeedRad(); this->wheelspeed_right = this->right_speedometer->getSpeedRad(); - // this->wheelspeed_left = this->left_speedometer->getSpeed(); - // this->wheelspeed_right = this->right_speedometer->getSpeed(); } From a00e8d6d03bde25db11293999fa4203214ee6c6e Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 11 Oct 2023 11:38:17 +0200 Subject: [PATCH 19/26] fix pwm channel --- doc/TODO allgemein.txt | 18 ++---------------- include/config.h | 2 +- include/networkConfig.h | 14 +++++++++++++- platformio.ini | 5 ++--- src/driveModi/Modi/TestMode/testMode.cpp | 3 ++- src/moveControl.cpp | 10 +++++++--- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 6a0ff6a..d89abe9 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -6,7 +6,6 @@ Do later: -> Program underfloorLighting -> Add an beeper -> Program the beeper - -> Update GNSS Lib to v3 -> Engine slow down without curve in motorControl -> Network clean up (Mqtt remove?) -> Extra class for maneuver, autopilot should inherit from int16_t @@ -19,16 +18,7 @@ Do later: -> Menu Display from parent as run() to make Menu as Component -> Racing Mode -> ConsolControl - -> Menü für Sensordaten (kann in jedem Betriebsmodus aufgerufen werden) - - GNSS - - Ntrip - - CalcCompass - - RealCompass - - Gyroskop - - Geschwindigkeiten (vielleicht) -> Menü für Einstellungen - - PID - - Geschwindigkeiten - WiFi (save in Flash) -> Battery - tabelle mit eigenen Werten übergeben und nicht in header (wiederverwendbarkeit) @@ -44,8 +34,6 @@ Do now: Code: Doxygen Kommentare aktualisieren magic numbers etc - Menu in Lib Folder packen - testMode einzelner Motor testen klappt nicht Fernbedienung! Latex: @@ -53,8 +41,6 @@ Latex: Unterschied funktionale und nicht funktionale Anforderungen Overfull H-Boxen Test Motor, Zeiten kontrolieren. Wenn einfach so dann bezug auf fehler bei Timing und freeRtos - Bild mit RPY einbinden + Was mit den nicht erfüllten Anforderungen machen? + Hardware doppelt erklärt -3D: - -Rover: diff --git a/include/config.h b/include/config.h index cf8e055..5b86d4a 100644 --- a/include/config.h +++ b/include/config.h @@ -30,7 +30,7 @@ namespace PinNumbers { constexpr uint8_t dir2 = 23; constexpr uint8_t pwm = 22; constexpr uint8_t encoder = 33; - constexpr uint8_t pmwChannel = 0; + constexpr uint8_t pmwChannel = 1; } } diff --git a/include/networkConfig.h b/include/networkConfig.h index e5b0bc3..8e28c90 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -14,7 +14,7 @@ #include -#define HOTSPOT +#define HW1 #ifdef HOTSPOT namespace NetworkConfig { @@ -28,6 +28,18 @@ namespace NetworkConfig { } #endif //HOTSPOT +#ifdef HW1 +namespace NetworkConfig { + const char ssid[] = "hw1_gast"; + const char password[] = "KeineAhnung"; + const char ip[] = "192.168.0.4"; + const char subnet[] = "255.255.255.0"; + const char gateway[] = "192.168.0.1"; + const char dns[] = "8.8.8.8"; + const bool mqtt = false; +} +#endif //HW1 + //Network config Rhede #ifdef RHEDE namespace NetworkConfig { diff --git a/platformio.ini b/platformio.ini index 36de8e2..df2e73e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,7 +15,7 @@ board_build.partitions = no_ota.csv framework = arduino monitor_speed = 115200 upload_speed = 921600 -monitor_port = COM3 +monitor_port = COM6 lib_deps = https://git.kleiax.de/PlatformIO-Libs/SparkFunGNSS.git knolleary/PubSubClient@^2.8 @@ -23,9 +23,8 @@ lib_deps = marcoschwartz/LiquidCrystal_I2C@^1.1.4 bblanchon/ArduinoJson@^6.20.0 mprograms/QMC5883LCompass@^1.2.0 - https://git.kleiax.de/PlatformIO-Libs/Menu.git jrowberg/I2Cdevlib-MPU6050@^1.0.0 -upload_port = COM3 +upload_port = COM6 test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index b937a34..2c03b0a 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -17,7 +17,7 @@ void TestMode::run() { this->abort = true; } - if (millis() - this->actionStart > this->maneuverTime || this->abort) { + if (this->busy && millis() - this->actionStart > this->maneuverTime || this->abort) { this->busy = false; this->abort = false; this->moveControl->setDrivingStatus(MoveControl::Status::Stop); @@ -83,6 +83,7 @@ bool TestMode::leftEngine(int16_t powerPercentage, int16_t seconds) { if (this->engineInit(powerPercentage, seconds)) { this->moveControl->setRawPowerLeft(powerPercentage); this->maneuver = Maneuver::LeftEngine; + std::cout << "TestMode::leftEngine" << std::endl; return true; } return false; diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 0f741c5..aee387e 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -44,7 +44,7 @@ MoveControl::MoveControl() { this->right_motor->init(PinNumbers::RightMotor::pwm, PinNumbers::RightMotor::pmwChannel, PinNumbers::RightMotor::dir1, PinNumbers::RightMotor::dir2); this->addChildComponent(this->left_motor); - this->addChildComponent(this->right_motor); + this->addChildComponent(this->right_motor); this->addChildComponent(this->left_speedometer); this->addChildComponent(this->right_speedometer); } @@ -80,11 +80,15 @@ void MoveControl::setDrivingStatus(Status status) { this->driving_status = status; // switch (this->driving_status) { // case Status::Stop : - // Serial.println("New drivingState = Stop in MoveControl::setDrivingStatus"); + // std::cout << "New drivingState = Stop in MoveControl::setDrivingStatus" << std::endl; // break; // case Status::Drive : - // Serial.println("New drivingState = Drive in MoveControl::setDrivingStatus"); + // std::cout << "New drivingState = Drive in MoveControl::setDrivingStatus" << std::endl; + // break; + + // case Status::Raw : + // std::cout << "New drivingState = Raw in MoveControl::setDrivingStatus" << std::endl; // break; // default: From d9d3f6316052d59fee99f4fce8f12414b9271be2 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 11 Oct 2023 11:41:21 +0200 Subject: [PATCH 20/26] pointer as auto declaration --- platformio.ini | 6 ++-- src/SpecialMenus/Route/menuRoute.cpp | 8 ++--- .../driveModi/TestMode/menuTestMode.cpp | 18 +++++------ src/main.cpp | 32 +++++++++---------- src/moveControl.cpp | 3 +- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/platformio.ini b/platformio.ini index c5bc22d..14b3e2d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,7 +15,7 @@ board_build.partitions = no_ota.csv framework = arduino monitor_speed = 115200 upload_speed = 921600 -monitor_port = COM6 +; monitor_port = COM6 lib_deps = https://git.kleiax.de/PlatformIO-Libs/SparkFunGNSS.git knolleary/PubSubClient@^2.8 @@ -26,11 +26,13 @@ lib_deps = https://git.kleiax.de/PlatformIO-Libs/Menu.git nrf24/RF24@^1.4.5 jrowberg/I2Cdevlib-MPU6050@^1.0.0 -upload_port = COM6 +; upload_port = COM6 test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder check_tool = clangtidy +check_flags = + clangtidy: --checks=*,-llvmlibc [env:native] platform = native diff --git a/src/SpecialMenus/Route/menuRoute.cpp b/src/SpecialMenus/Route/menuRoute.cpp index 772c23a..cc66531 100644 --- a/src/SpecialMenus/Route/menuRoute.cpp +++ b/src/SpecialMenus/Route/menuRoute.cpp @@ -87,10 +87,10 @@ void MenuRoute::init() { this->mainMenu->setLcd(this->lcd); pointsMenu->setLcd(this->lcd); - MenuIntInput* importWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::importRoute)); - MenuIntInput* exportWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::exportRoute)); - MenuIntInput* deleteWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::deleteRoute)); - MenuActionRoute* clearWrapper = new MenuActionRoute(this, &MenuRoute::clearRoute); + auto importWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::importRoute)); + auto exportWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::exportRoute)); + auto deleteWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::deleteRoute)); + auto clearWrapper = new MenuActionRoute(this, &MenuRoute::clearRoute); importWrapper->setLcd(this->lcd); importWrapper->setMinMax(0, 100); diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index f5157df..17363cb 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -85,18 +85,18 @@ void MenuTestMode::init() { // Create menu this->mainMenu = new Menu; - Menu* engineMenu = new Menu; - Menu* lightMenu = new Menu; - Menu* encoderMenu = new Menu; + auto engineMenu = new Menu; + auto lightMenu = new Menu; + auto encoderMenu = new Menu; // Sound // Ping google - MenuIntInput* drivingMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::drive)); - MenuIntInput* engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine)); - MenuIntInput* engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine)); - MenuIntInput* engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine)); - SpeedometerTest* encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft()); - SpeedometerTest* encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight()); + auto drivingMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::drive)); + auto engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine)); + auto engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine)); + auto engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine)); + auto encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft()); + auto encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight()); // Set menus on LCD diff --git a/src/main.cpp b/src/main.cpp index 161f8f4..e819e63 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -203,22 +203,22 @@ void makeMenu() { // Create Menu main_m = new Menu(); main_m->setLcd(lcdWrapper); - Menu* mode_m = new Menu(); - Menu* set_m = new Menu(); - Menu* pid_m = new Menu(); - MenuIntInput* pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0))); - MenuIntInput* pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); - MenuIntInput* speed_m = new MenuIntInput(2, new MenuSpeed(driveManager->getDrivingSpeedsRef())); - MenuManualControl* man_m = new MenuManualControl(driveManager); - MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager); - MenuAutopilot* auto_m = new MenuAutopilot(driveManager); - MenuTestMode* testM_m = new MenuTestMode(driveManager); - MenuCalibrateCompass* comp_m = new MenuCalibrateCompass(driveManager); - MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery); - MenuSensorData* sen_m = new MenuSensorData(sensorData); + auto mode_m = new Menu(); + auto set_m = new Menu(); + auto pid_m = new Menu(); + auto pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0))); + auto pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); + auto speed_m = new MenuIntInput(2, new MenuSpeed(driveManager->getDrivingSpeedsRef())); + auto man_m = new MenuManualControl(driveManager); + auto cap_m = new MenuCaptureRoute(driveManager); + auto auto_m = new MenuAutopilot(driveManager); + auto testM_m = new MenuTestMode(driveManager); + auto comp_m = new MenuCalibrateCompass(driveManager); + auto sys_m = new MenuSysteminformation(mainBattery); + auto sen_m = new MenuSensorData(sensorData); //TODO: Wie bekommt jeder die dumme Route? - MenuRoute* rout_m = new MenuRoute(new Route()); - MenuCalibrateBattery* bat_m = new MenuCalibrateBattery(mainBattery); + auto rout_m = new MenuRoute(new Route()); + auto bat_m = new MenuCalibrateBattery(mainBattery); auto_m->setUpdateDelay(1000); sys_m->setUpdateDelay(1500); @@ -271,7 +271,7 @@ void makeMenu() { controlPad->setMenuControl(main_m); } -void restart(void) { +void restart() { lcdWrapper->clear(); lcdWrapper->setCursor(0, 0); lcdWrapper->print("Rebooting ..."); diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 20c9248..b8661c5 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -151,8 +151,7 @@ PID* MoveControl::getPID(uint8_t side) const { return this->left_pid; else if (side == 1) return this->right_pid; - else - return nullptr; + return nullptr; } void MoveControl::setSpeedometerDirection(Speedometer *speedometer, double value) { From 23d854a8260a9f31e0da602fe341d96e4cbb3de3 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 11 Oct 2023 17:35:40 +0200 Subject: [PATCH 21/26] clangtidy corrections part 1 --- clangtidy.txt | 739 ++++++++++++++++++ include/config.h | 6 + include/moveControl.h | 13 +- lib/Battery/battery.cpp | 196 +++-- lib/Battery/battery.h | 203 ++--- lib/CalcAzimuth/calcAzimuth.cpp | 115 +-- lib/CalcAzimuth/calcAzimuth.h | 63 +- lib/Component/component.cpp | 30 +- lib/Component/component.h | 59 +- lib/ControllPad/controlPad.cpp | 60 +- lib/ControllPad/controlPad.h | 45 +- lib/ControllPad/controlPadInput.h | 91 ++- lib/Counter/counter.cpp | 35 +- lib/Counter/counter.h | 37 +- lib/LcdWrapper/LcdWrapper.cpp | 54 +- lib/LcdWrapper/LcdWrapper.h | 89 +-- lib/calibrateCompass/calibrateCompass.cpp | 115 +-- platformio.ini | 24 +- src/SpecialMenus/Route/menuRoute.cpp | 183 +++-- src/SpecialMenus/Route/menuRoute.h | 6 + .../driveModi/TestMode/menuTestMode.cpp | 139 ++-- .../driveModi/TestMode/menuTestMode.h | 4 +- .../driveModi/TestMode/speedometerTest.cpp | 8 +- src/SpecialMenus/driveModi/menuDriveMode.cpp | 31 +- src/driveModi/Modi/Autopilot/autopilot.cpp | 285 ++++--- src/driveModi/Modi/Autopilot/autopilot.h | 18 +- .../CalibrateCompass/calibrateCompassM.cpp | 4 +- .../Modi/CaptureRoute/captureRoute.cpp | 43 +- .../Modi/ManualControl/manualControl.cpp | 84 +- src/driveModi/Modi/TestMode/testMode.cpp | 113 ++- src/driveModi/Modi/TestMode/testMode.h | 163 ++-- src/driveModi/driveManager.cpp | 32 +- src/driveModi/driveModi.cpp | 6 +- src/driveModi/driveModi.h | 11 +- src/main.cpp | 256 +++--- src/moveControl.cpp | 188 +++-- 36 files changed, 2383 insertions(+), 1165 deletions(-) create mode 100644 clangtidy.txt diff --git a/clangtidy.txt b/clangtidy.txt new file mode 100644 index 0000000..06f3caa --- /dev/null +++ b/clangtidy.txt @@ -0,0 +1,739 @@ + +lib/MQTT/debugMqtt.cpp:22: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/MQTT/debugMqtt.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/MQTT/debugMqtt.cpp:32: [medium:warning] 2 adjacent parameters of 'sendMsg' of similar type ('String') are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/MQTT/debugMqtt.cpp:32: [medium:warning] the parameter 'msg' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:33: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/MQTT/debugMqtt.cpp:33: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:34: [medium:warning] parameter 'topic' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:34: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:38: [medium:warning] parameter 'msg' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:41: [medium:warning] method 'sendData' can be made static [readability-convert-member-functions-to-static] +lib/MQTT/debugMqtt.cpp:41: [medium:warning] the parameter 'topic' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:41: [medium:warning] the parameter 'data' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:47: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/MQTT/debugMqtt.cpp:47: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:48: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/MQTT/debugMqtt.cpp:48: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:49: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:49: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:54: [medium:warning] parameter 'data' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:57: [medium:warning] the parameter 'measurement_name' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:57: [medium:warning] the parameter 'field_set' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/MQTT/debugMqtt.cpp:60: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/MQTT/debugMqtt.cpp:60: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:61: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MQTT/debugMqtt.cpp:64: [medium:warning] parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length] +lib/Menu/src/menu.cpp:13: [medium:warning] constructor does not initialize these fields: entrys, selectedEntry [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Menu/src/menu.cpp:18: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] +lib/Menu/src/menu.cpp:18: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menu.cpp:25: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menu.cpp:29: [medium:warning] method 'isInSubmenu' can be made const [readability-make-member-function-const] +lib/Menu/src/menu.cpp:34: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] +lib/Menu/src/menu.cpp:43: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menu.cpp:63: [medium:warning] missing username/bug in TODO [google-readability-todo] +lib/Menu/src/menu.cpp:64: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] +lib/Menu/src/menu.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menu.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menu.cpp:78: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] +lib/Menu/src/menu.cpp:108: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menu.cpp:108: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:13: [medium:warning] 2 adjacent parameters of 'MenuAction' of similar type ('void (*)()') are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Menu/src/menuAction.cpp:14: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:15: [medium:warning] 'function' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:16: [medium:warning] 'callback' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:20: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:21: [medium:warning] 'menu' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:22: [medium:warning] 'isMenu' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:26: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:27: [medium:warning] 'action' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuAction.cpp:31: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] +lib/Menu/src/menuAction.cpp:31: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuAction.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:34: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] +lib/Menu/src/menuAction.cpp:34: [medium:warning] implicit conversion 'MenuActionWrapper *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuAction.cpp:34: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:39: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:42: [medium:warning] implicit conversion 'void (*)()' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuAction.cpp:42: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:44: [medium:warning] implicit conversion 'MenuActionWrapper *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuAction.cpp:44: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:46: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:50: [medium:warning] implicit conversion 'void (*)()' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuAction.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:58: [medium:warning] method 'getIsMenu' can be made const [readability-make-member-function-const] +lib/Menu/src/menuAction.cpp:63: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuAction.cpp:65: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] +lib/Menu/src/menuAction.cpp:65: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuControl.cpp:14: [medium:warning] the parameter 'lineOne' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/Menu/src/menuControl.cpp:14: [medium:warning] the parameter 'lineTwo' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/Menu/src/menuControl.cpp:15: [medium:warning] implicit conversion 'DisplayWrapper *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuControl.cpp:27: [medium:warning] implicit conversion 'DisplayWrapper *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuControl.cpp:27: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuInformationSites.cpp:15: [medium:warning] 'countPages' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuInformationSites.cpp:16: [medium:warning] 'currentPage' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuInformationSites.cpp:17: [medium:warning] 'lastMillis' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuInformationSites.cpp:21: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuInformationSites.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuInformationSites.cpp:29: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuInformationSites.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuInformationSites.cpp:41: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuInformationSites.cpp:92: [medium:warning] variable 'lineOne' of type 'String' can be declared 'const' [misc-const-correctness] +lib/Menu/src/menuInformationSites.cpp:93: [medium:warning] variable 'lineTwo' of type 'String' can be declared 'const' [misc-const-correctness] +lib/Menu/src/menuIntInput.cpp:15: [medium:warning] 'values' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:16: [medium:warning] 'names' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:17: [medium:warning] 'length' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:18: [medium:warning] 'wrapper' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:20: [medium:warning] 'min' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:21: [medium:warning] 'max' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:22: [medium:warning] 'originalValues' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:23: [medium:warning] 'stepsPerInput' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:34: [medium:warning] 'length' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:35: [medium:warning] 'wrapper' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:37: [medium:warning] 'values' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:38: [medium:warning] 'names' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:38: [medium:warning] do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] +lib/Menu/src/menuIntInput.cpp:38: [medium:warning] C-style casts are discouraged; use reinterpret_cast [google-readability-casting] +lib/Menu/src/menuIntInput.cpp:39: [medium:warning] 'min' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:40: [medium:warning] 'max' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:41: [medium:warning] 'originalValues' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:42: [medium:warning] 'stepsPerInput' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Menu/src/menuIntInput.cpp:50: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] +lib/Menu/src/menuIntInput.cpp:65: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:72: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] +lib/Menu/src/menuIntInput.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:85: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:91: [medium:warning] 2 adjacent parameters of 'setMinMax' of similar type ('int16_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Menu/src/menuIntInput.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:106: [medium:warning] 2 adjacent parameters of 'setMinMax' of similar type ('int16_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Menu/src/menuIntInput.cpp:111: [medium:warning] 3 adjacent parameters of 'setMinMaxSteps' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Menu/src/menuIntInput.cpp:117: [medium:warning] 3 adjacent parameters of 'setMinMaxSteps' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Menu/src/menuIntInput.cpp:124: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:131: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:162: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:164: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:171: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:173: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:180: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:184: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuIntInput.cpp:192: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuIntInput.cpp:199: [medium:warning] 17 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Menu/src/menuIntInput.cpp:203: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/Menu/src/menuIntInput.cpp:203: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Menu/src/menuIntInput.cpp:203: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] +lib/Menu/src/menuIntInput.cpp:206: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/Menu/src/menuIntInput.cpp:206: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Menu/src/menuIntInput.cpp:206: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] +lib/Menu/src/menuIntInput.cpp:209: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/Menu/src/menuIntInput.cpp:209: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Menu/src/menuIntInput.cpp:209: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] +lib/Menu/src/menuIntInput.cpp:212: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/Menu/src/menuIntInput.cpp:212: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Menu/src/menuIntInput.cpp:212: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] +lib/Menu/src/menuIntInput.cpp:215: [medium:warning] 17 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Menu/src/menuIntInput.cpp:216: [medium:warning] implicit conversion 'int16_t' (aka 'short') -> bool [readability-implicit-bool-conversion] +lib/Menu/src/menuIntInput.cpp:216: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:217: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/Menu/src/menuIntInput.cpp:217: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Menu/src/menuIntInput.cpp:218: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Menu/src/menuIntInput.cpp:219: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/Menu/src/menuIntInput.cpp:219: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Menu/src/menuIntInput.cpp:221: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Menu/src/menuIntInput.cpp:221: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/MotorControl/motorControl.cpp:15: [medium:warning] constructor does not initialize these fields: pwmPin, pwmChannel, dutycycleMin, dutycycleMax, dir_1, dir_2 [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/MotorControl/motorControl.cpp:21: [medium:warning] 3 adjacent parameters of 'init' of similar type ('uint8_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/MotorControl/motorControl.cpp:40: [medium:warning] variable 'abs_difference' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/MotorControl/motorControl.cpp:43: [medium:warning] variable 'difference' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] +lib/MotorControl/motorControl.cpp:84: [medium:warning] 80 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:84: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] +lib/MotorControl/motorControl.cpp:84: [medium:warning] 80 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:86: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/MotorControl/motorControl.cpp:86: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/MotorControl/motorControl.cpp:91: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:91: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] +lib/MotorControl/motorControl.cpp:91: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:93: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/MotorControl/motorControl.cpp:93: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/MotorControl/motorControl.cpp:98: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:98: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:98: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/MotorControl/motorControl.cpp:100: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/MotorControl/motorControl.cpp:113: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/MotorControl/motorControl.cpp:114: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] +lib/MotorControl/motorControl.cpp:119: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/MotorControl/motorControl.cpp:120: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] +lib/MotorControl/motorControl.cpp:125: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/MotorControl/motorControl.cpp:126: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] +lib/MotorControl/motorControl.cpp:131: [medium:warning] missing username/bug in TODO [google-readability-todo] +lib/MotorControl/motorControl.cpp:132: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:132: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:147: [medium:warning] variable 'pwm_val' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/MotorControl/motorControl.cpp:147: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/MotorControl/motorControl.cpp:164: [medium:warning] missing username/bug in TODO [google-readability-todo] +lib/MotorControl/motorControl.cpp:165: [medium:warning] missing username/bug in TODO [google-readability-todo] +lib/Navigation/navigation.cpp:15: [medium:warning] 'sensorData' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Navigation/navigation.cpp:20: [medium:warning] implicit conversion 'Route *' -> bool [readability-implicit-bool-conversion] +lib/Navigation/navigation.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:35: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] +lib/Navigation/navigation.cpp:35: [medium:warning] implicit conversion 'Route *' -> bool [readability-implicit-bool-conversion] +lib/Navigation/navigation.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:41: [medium:warning] variable 'newTargetPoint' of type 'Point' can be declared 'const' [misc-const-correctness] +lib/Navigation/navigation.cpp:43: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:49: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:55: [medium:warning] 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Navigation/navigation.cpp:65: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] +lib/Navigation/navigation.cpp:81: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:92: [medium:warning] variable 'distance' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Navigation/navigation.cpp:117: [medium:warning] variable 'targetCourse' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] +lib/Navigation/navigation.cpp:118: [medium:warning] variable 'correctionCourse' is not initialized [cppcoreguidelines-init-variables] +lib/Navigation/navigation.cpp:134: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:148: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Navigation/navigation.cpp:148: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Navigation/navigation.cpp:149: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Navigation/navigation.cpp:149: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:150: [medium:warning] 360 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Navigation/navigation.cpp:151: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Navigation/navigation.cpp:151: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Navigation/navigation.cpp:152: [medium:warning] 360 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Navigation/navigation.h:86: [medium:warning] missing username/bug in TODO [google-readability-todo] +lib/Navigation/navigation.h:99: [medium:warning] missing username/bug in TODO [google-readability-todo] +lib/Network/network.cpp:14: [medium:warning] constructor does not initialize these fields: mqttUser, mqttPassphrase [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Network/network.cpp:15: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +lib/Network/network.cpp:15: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:21: [medium:warning] constructor does not initialize these fields: mqttUser, mqttPassphrase [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Network/network.cpp:22: [medium:warning] 'adresses' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Network/network.cpp:22: [medium:warning] parameter 'adresses' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] +lib/Network/network.cpp:24: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +lib/Network/network.cpp:24: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:39: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] +lib/Network/network.cpp:39: [medium:warning] implicit conversion 'PubSubClient *' -> bool [readability-implicit-bool-conversion] +lib/Network/network.cpp:39: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:52: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Network/network.cpp:52: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Network/network.cpp:52: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Network/network.cpp:65: [medium:warning] 2 adjacent parameters of 'activateMqtt' of similar type ('const char *') are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Network/network.cpp:73: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:78: [medium:warning] method 'printIPs' can be made const [readability-make-member-function-const] +lib/Network/network.cpp:91: [medium:warning] variable 'channel' is not initialized [cppcoreguidelines-init-variables] +lib/Network/network.cpp:92: [medium:warning] variable 'secondChannel' is not initialized [cppcoreguidelines-init-variables] +lib/Network/network.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:107: [medium:warning] implicit conversion 'PubSubClient *' -> bool [readability-implicit-bool-conversion] +lib/Network/network.cpp:107: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:116: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +lib/Network/network.cpp:132: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +lib/Network/network.cpp:150: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:156: [medium:warning] 0xffff is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Network/network.cpp:158: [medium:warning] implicit conversion 'const char *' -> bool [readability-implicit-bool-conversion] +lib/Network/network.cpp:159: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Network/network.cpp:162: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:15: [medium:warning] constructor does not initialize these fields: host, mountPoint, user, password [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/NtripClient/ntripClient.cpp:16: [medium:warning] 'gps' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/NtripClient/ntripClient.cpp:17: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:18: [medium:warning] 'port' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/NtripClient/ntripClient.cpp:19: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:20: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:21: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:23: [medium:warning] 'ntripClient' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/NtripClient/ntripClient.cpp:24: [medium:warning] 'state' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/NtripClient/ntripClient.cpp:26: [medium:warning] 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:53: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:86: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/NtripClient/ntripClient.cpp:90: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:95: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:122: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] +lib/NtripClient/ntripClient.cpp:122: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:125: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] +lib/NtripClient/ntripClient.cpp:130: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/NtripClient/ntripClient.cpp:130: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:133: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:136: [medium:warning] variable 'userCredentialsLength' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/NtripClient/ntripClient.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:138: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/NtripClient/ntripClient.cpp:138: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:138: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:143: [medium:warning] variable 'b' of type 'base64' can be declared 'const' [misc-const-correctness] +lib/NtripClient/ntripClient.cpp:143: [medium:warning] variable name 'b' is too short, expected at least 3 characters [readability-identifier-length] +lib/NtripClient/ntripClient.cpp:144: [medium:warning] variable 'strEncodedCredentials' of type 'String' can be declared 'const' [misc-const-correctness] +lib/NtripClient/ntripClient.cpp:144: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +lib/NtripClient/ntripClient.cpp:147: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:149: [medium:warning] the value returned by this function should be used [cert-err33-c] +lib/NtripClient/ntripClient.cpp:149: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:149: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:153: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:153: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:154: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:157: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:165: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:168: [medium:warning] variable 'lastMillis' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] +lib/NtripClient/ntripClient.cpp:169: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] +lib/NtripClient/ntripClient.cpp:175: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:182: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] +lib/NtripClient/ntripClient.cpp:183: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:189: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:189: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:190: [medium:warning] 200 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:191: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:191: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:192: [medium:warning] 401 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:199: [medium:warning] 200 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:200: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/NtripClient/ntripClient.cpp:203: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:205: [medium:warning] 401 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:205: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:216: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +lib/NtripClient/ntripClient.cpp:216: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:223: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +lib/NtripClient/ntripClient.cpp:224: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/NtripClient/ntripClient.cpp:227: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] +lib/NtripClient/ntripClient.cpp:229: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:235: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/NtripClient/ntripClient.cpp:252: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:255: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:269: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:272: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:276: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +lib/NtripClient/ntripClient.cpp:276: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:279: [medium:warning] use auto when initializing with new to avoid duplicating the type name [hicpp-use-auto,modernize-use-auto] +lib/NtripClient/ntripClient.cpp:280: [medium:warning] variable 'res' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/NtripClient/ntripClient.cpp:281: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:282: [medium:warning] do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] +lib/NtripClient/ntripClient.cpp:282: [medium:warning] C-style casts are discouraged; use reinterpret_cast [google-readability-casting] +lib/NtripClient/ntripClient.cpp:287: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/NtripClient/ntripClient.cpp:288: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] +lib/Point/point.cpp:14: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Point/point.cpp:14: [medium:warning] 3 adjacent parameters of 'Point' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Point/point.cpp:20: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Point/point.cpp:20: [medium:warning] 3 adjacent parameters of 'Point' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Point/point.cpp:21: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Point/point.cpp:22: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Point/point.cpp:26: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Point/point.cpp:27: [medium:warning] 'coordinates' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Point/point.cpp:31: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Point/point.cpp:32: [medium:warning] 'coordinates' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Point/point.cpp:33: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Point/point.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Point/point.cpp:39: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Point/point.cpp:56: [medium:warning] variable 'begin' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:57: [medium:warning] variable 'end' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:59: [medium:warning] variable 'lat' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:60: [medium:warning] variable 'dy' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:60: [medium:warning] variable name 'dy' is too short, expected at least 3 characters [readability-identifier-length] +lib/Point/point.cpp:61: [medium:warning] variable 'dx' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:61: [medium:warning] variable name 'dx' is too short, expected at least 3 characters [readability-identifier-length] +lib/Point/point.cpp:71: [medium:warning] variable 'begin' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:72: [medium:warning] variable 'end' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:74: [medium:warning] variable 'phi' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:75: [medium:warning] variable 'lon' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:77: [medium:warning] variable 'res' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] +lib/Point/point.cpp:89: [medium:warning] 2 adjacent parameters of 'init' of similar type ('uint32_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Point/point.cpp:92: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Point/point.cpp:94: [medium:warning] 9999 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Point/point.cpp:94: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Point/point.cpp:96: [medium:warning] 999 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Point/point.cpp:96: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Point/point.cpp:98: [medium:warning] 99 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Point/point.cpp:98: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Point/point.cpp:100: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Point/point.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Route/route.cpp:14: [medium:warning] use '= default' to define a trivial default constructor [hicpp-use-equals-default,modernize-use-equals-default] +lib/Route/route.cpp:29: [medium:warning] the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] +lib/Route/route.cpp:31: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] +lib/Route/route.cpp:41: [medium:warning] the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] +lib/Route/route.cpp:43: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] +lib/Route/route.cpp:47: [medium:warning] missing username/bug in TODO [google-readability-todo] +lib/Route/route.cpp:55: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Route/route.cpp:56: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] +lib/Route/route.cpp:67: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] +lib/Route/route.cpp:71: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Route/route.cpp:72: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] +lib/Route/route.cpp:78: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] +lib/Route/route.cpp:79: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] +lib/Route/route.cpp:84: [medium:warning] uninitialized record type: 'info' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Sensors/sensorData.cpp:18: [medium:warning] constructor does not initialize these fields: gnssData, host, mountPoint, user, password, gyroBuffer, port [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Sensors/sensorData.cpp:19: [medium:warning] 50 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:23: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] +lib/Sensors/sensorData.cpp:23: [medium:warning] implicit conversion 'NTRIPClient *' -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'host' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'mountPoint' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'user' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'password' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] +lib/Sensors/sensorData.cpp:38: [medium:warning] 4000000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:38: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] +lib/Sensors/sensorData.cpp:40: [medium:warning] converting integer literal to bool, use bool literal instead [modernize-use-bool-literals] +lib/Sensors/sensorData.cpp:40: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:40: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:47: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] +lib/Sensors/sensorData.cpp:49: [medium:warning] converting integer literal to bool, use bool literal instead [modernize-use-bool-literals] +lib/Sensors/sensorData.cpp:49: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:49: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:57: [medium:warning] 0x0d is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:58: [medium:warning] 0x0b is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:61: [medium:warning] 0x0C is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:61: [medium:warning] 0x10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:76: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:79: [medium:warning] variable 'deviceStatus' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:81: [medium:warning] 220 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:82: [medium:warning] 76 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:83: [medium:warning] 85 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:84: [medium:warning] 1788 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:87: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:88: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:96: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Sensors/sensorData.cpp:97: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:102: [medium:warning] implicit conversion 'CalcAzimuth *' -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:108: [medium:warning] implicit conversion 'NTRIPClient *' -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:108: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:114: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:117: [medium:warning] variable 'latitude' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:117: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Sensors/sensorData.cpp:117: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:118: [medium:warning] variable 'longitude' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:118: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Sensors/sensorData.cpp:118: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:119: [medium:warning] variable 'altitude' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:119: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Sensors/sensorData.cpp:119: [medium:warning] 1000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:121: [medium:warning] variable 'fixType' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:122: [medium:warning] 32 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:123: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:124: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:125: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:126: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:127: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:128: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:129: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:130: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:131: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:132: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:133: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:133: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:134: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:135: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:138: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:138: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] +lib/Sensors/sensorData.cpp:139: [medium:warning] 16 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:140: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:141: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:142: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:143: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:144: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:145: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:146: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:147: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:149: [medium:warning] variable 'hAcc' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:172: [medium:warning] implicit conversion 'QMC5883LCompass *' -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:177: [medium:warning] implicit conversion 'MPU6050 *' (aka 'MPU6050_6Axis_MotionApps20 *') -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:178: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:178: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:180: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:182: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +lib/Sensors/sensorData.cpp:187: [medium:warning] implicit conversion 'SFE_UBLOX_GNSS *' -> bool [readability-implicit-bool-conversion] +lib/Sensors/sensorData.cpp:190: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Sensors/sensorData.cpp:196: [medium:warning] variable 'versionHigh' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:197: [medium:warning] variable 'versionLow' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +lib/Sensors/sensorData.cpp:198: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Sensors/sensorData.cpp:198: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Sensors/sensorData.cpp:201: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:213: [medium:warning] uninitialized record type: 'coords' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Sensors/sensorData.cpp:214: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Sensors/sensorData.cpp:215: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Speedometer/speedometer.cpp:14: [medium:warning] constructor does not initialize these fields: buf [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/Speedometer/speedometer.cpp:14: [medium:warning] 3 adjacent parameters of 'Speedometer' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] +lib/Speedometer/speedometer.cpp:15: [medium:warning] 'diameter' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Speedometer/speedometer.cpp:16: [medium:warning] 'steps' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Speedometer/speedometer.cpp:18: [medium:warning] 'pulseCounter' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Speedometer/speedometer.cpp:19: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Speedometer/speedometer.cpp:34: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Speedometer/speedometer.cpp:37: [medium:warning] variable 'time' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:39: [medium:warning] variable 'elapsedTime' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:42: [medium:warning] variable 'pulse' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:47: [medium:warning] variable 'n' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:47: [medium:warning] variable name 'n' is too short, expected at least 3 characters [readability-identifier-length] +lib/Speedometer/speedometer.cpp:47: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Speedometer/speedometer.cpp:48: [medium:warning] variable 'u' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:48: [medium:warning] variable name 'u' is too short, expected at least 3 characters [readability-identifier-length] +lib/Speedometer/speedometer.cpp:48: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Speedometer/speedometer.cpp:48: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Speedometer/speedometer.cpp:49: [medium:warning] variable 'ms' of type 'double' can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:49: [medium:warning] variable name 'ms' is too short, expected at least 3 characters [readability-identifier-length] +lib/Speedometer/speedometer.cpp:52: [medium:warning] 0.1 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Speedometer/speedometer.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Speedometer/speedometer.cpp:85: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Speedometer/speedometer.cpp:85: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Speedometer/speedometer.cpp:86: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +lib/Speedometer/speedometer.cpp:91: [medium:warning] variable 'avg' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:92: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +lib/Speedometer/speedometer.cpp:105: [medium:warning] variable 'res' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] +lib/Speedometer/speedometer.cpp:113: [medium:warning] use range-based for loop instead [modernize-loop-convert] +lib/Speedometer/speedometer.cpp:113: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Speedometer/speedometer.cpp:121: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Speedometer/speedometer.cpp:127: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +lib/Speedometer/speedometer.cpp:127: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Speedometer/speedometer.cpp:129: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +lib/Times/debugTimes.cpp:17: [medium:warning] 'startTime' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/Times/debugTimes.cpp:29: [medium:warning] method 'stop' can be made const [readability-make-member-function-const] +lib/Times/debugTimes.cpp:33: [medium:warning] method 'stopConsol' can be made const [readability-make-member-function-const] +lib/Times/debugTimes.cpp:34: [medium:warning] variable 'time' of type 'uint64_t' (aka 'unsigned long long') can be declared 'const' [misc-const-correctness] +lib/Times/debugTimes.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/Times/debugTimes.cpp:41: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/calibrateCompass/calibrateCompass.cpp:14: [medium:warning] constructor does not initialize these fields: data [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +lib/calibrateCompass/calibrateCompass.cpp:16: [medium:warning] 'compass' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/calibrateCompass/calibrateCompass.cpp:17: [medium:warning] 'state' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +lib/calibrateCompass/calibrateCompass.cpp:32: [medium:warning] variable 'xAxis' of type 'int' can be declared 'const' [misc-const-correctness] +lib/calibrateCompass/calibrateCompass.cpp:33: [medium:warning] variable 'yAxis' of type 'int' can be declared 'const' [misc-const-correctness] +lib/calibrateCompass/calibrateCompass.cpp:34: [medium:warning] variable 'zAxis' of type 'int' can be declared 'const' [misc-const-correctness] +lib/calibrateCompass/calibrateCompass.cpp:72: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +lib/calibrateCompass/calibrateCompass.cpp:164: [medium:warning] use range-based for loop instead [modernize-loop-convert] +lib/calibrateCompass/calibrateCompass.cpp:175: [medium:warning] use range-based for loop instead [modernize-loop-convert] +lib/calibrateCompass/calibrateCompass.cpp:185: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] +lib/calibrateCompass/calibrateCompass.cpp:188: [medium:warning] parameter name 'os' is too short, expected at least 3 characters [readability-identifier-length] +lib/calibrateCompass/calibrateCompass.cpp:191: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/calibrateCompass/calibrateCompass.cpp:193: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/calibrateCompass/calibrateCompass.cpp:195: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/calibrateCompass/calibrateCompass.cpp:197: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/calibrateCompass/calibrateCompass.cpp:199: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +lib/calibrateCompass/calibrateCompass.cpp:201: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] +src/OutputBuf/outputBuf.cpp:15: [medium:warning] initializer for base class 'std::streambuf' (aka 'basic_streambuf') is redundant [readability-redundant-member-init] +src/OutputBuf/outputBuf.cpp:16: [medium:warning] 'debugMqtt' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/OutputBuf/outputBuf.cpp:17: [medium:warning] 'serialBT' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/OutputBuf/outputBuf.cpp:19: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] +src/OutputBuf/outputBuf.cpp:19: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/OutputBuf/outputBuf.cpp:22: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] +src/OutputBuf/outputBuf.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/OutputBuf/outputBuf.cpp:27: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] +src/OutputBuf/outputBuf.cpp:27: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/OutputBuf/outputBuf.cpp:32: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] +src/OutputBuf/outputBuf.cpp:32: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/OutputBuf/outputBuf.cpp:46: [medium:warning] parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length] +src/OutputBuf/outputBuf.cpp:50: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] +src/OutputBuf/outputBuf.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/OutputBuf/outputBuf.cpp:51: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/OutputBuf/outputBuf.cpp:53: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] +src/OutputBuf/outputBuf.cpp:53: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/OutputBuf/outputBuf.cpp:54: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/OutputBuf/outputBuf.cpp:56: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:15: [medium:warning] 400 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:16: [medium:warning] 'battery' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:52: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] +src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:57: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/PID/menuPidSettings.cpp:15: [medium:warning] 'pid' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/PID/menuPidSettings.cpp:19: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoute.cpp:16: [medium:warning] 'menuRoute' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/Route/menuRoute.cpp:17: [medium:warning] 'dataFunction' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/Route/menuRoute.cpp:25: [medium:warning] constructor does not initialize these fields: mainMenu [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +src/SpecialMenus/Route/menuRoute.cpp:27: [medium:warning] 'route' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/Route/menuRoute.cpp:163: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +src/SpecialMenus/Route/menuRoute.cpp:188: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/Route/menuRoute.cpp:193: [medium:warning] 202 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoute.cpp:216: [medium:warning] uninitialized record type: 'coords' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +src/SpecialMenus/Route/menuRoute.cpp:229: [medium:warning] variable 'totalPoints' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] +src/SpecialMenus/Route/menuRoute.cpp:234: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +src/SpecialMenus/Route/menuRoute.cpp:273: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/Route/menuRoute.cpp:275: [medium:warning] 201 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoute.cpp:298: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] +src/SpecialMenus/Route/menuRoute.cpp:323: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/Route/menuRoute.cpp:328: [medium:warning] 202 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoutePoints.cpp:14: [medium:warning] initializer for base class 'MenuInformationSites' is redundant [readability-redundant-member-init] +src/SpecialMenus/Route/menuRoutePoints.cpp:15: [medium:warning] 'route' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/Route/menuRoutePoints.cpp:19: [medium:warning] variable 'amountPoints' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] +src/SpecialMenus/Route/menuRoutePoints.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:27: [medium:warning] variable 'currentPage' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +src/SpecialMenus/Route/menuRoutePoints.cpp:28: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:49: [medium:warning] variable name 'p' is too short, expected at least 3 characters [readability-identifier-length] +src/SpecialMenus/Route/menuRoutePoints.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:54: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:56: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:58: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Route/menuRoutePoints.cpp:61: [medium:warning] 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoutePoints.cpp:62: [medium:warning] variable 'string' is not initialized [cppcoreguidelines-init-variables] +src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] +src/SpecialMenus/SensorData/menuSensorData.cpp:15: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/SensorData/menuSensorData.cpp:16: [medium:warning] 'sensorData' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/SensorData/menuSensorData.cpp:20: [medium:warning] function 'printPage' has cognitive complexity of 26 (threshold 25) [readability-function-cognitive-complexity] +src/SpecialMenus/SensorData/menuSensorData.cpp:23: [medium:warning] implicit conversion 'const UBX_NAV_PVT_data_t *' -> bool [readability-implicit-bool-conversion] +src/SpecialMenus/SensorData/menuSensorData.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:54: [medium:warning] variable 'pos' of type 'Point' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/SensorData/menuSensorData.cpp:63: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +src/SpecialMenus/SensorData/menuSensorData.cpp:64: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/SensorData/menuSensorData.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:68: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/SensorData/menuSensorData.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:72: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/SensorData/menuSensorData.cpp:72: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:75: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:80: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/SensorData/menuSensorData.cpp:83: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +src/SpecialMenus/SensorData/menuSensorData.cpp:83: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] +src/SpecialMenus/SensorData/menuSensorData.cpp:84: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:86: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:88: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:90: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:92: [medium:warning] variable 'status' of type 'NTRIPClientStates' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/SensorData/menuSensorData.cpp:93: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:95: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/SensorData/menuSensorData.cpp:102: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/SensorData/menuSensorData.cpp:105: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +src/SpecialMenus/Speed/menuSpeed.cpp:15: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/Speed/menuSpeed.cpp:17: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/SpecialMenus/Speed/menuSpeed.cpp:17: [medium:warning] 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Speed/menuSpeed.cpp:18: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/SpecialMenus/Speed/menuSpeed.cpp:18: [medium:warning] 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:15: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:16: [medium:warning] 'mainBattery' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] +src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:36: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:53: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:58: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:60: [medium:warning] 16 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:63: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:14: [medium:warning] function 'printPage' has cognitive complexity of 36 (threshold 25) [readability-function-cognitive-complexity] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:15: [medium:warning] variable 'correction' of type 'CourseCorrection' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:17: [medium:warning] variable 'navigationStarted' of type 'bool' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:23: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:23: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:26: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:27: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:31: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:31: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:108: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:108: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:111: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:112: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:114: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:116: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:118: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:120: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:122: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:126: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:126: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:128: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:173: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:175: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:177: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:181: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:183: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:185: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:189: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:206: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:210: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:220: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:231: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:241: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:249: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:13: [medium:warning] constructor does not initialize these fields: caliCompassMode, caliCompass [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:67: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:72: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:77: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:82: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:89: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:96: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:116: [medium:warning] 11 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:117: [medium:warning] 500 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:147: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:151: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:155: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:14: [medium:warning] variable 'routeInfo' of type 'RouteInfo' can be declared 'const' [misc-const-correctness] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:62: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:71: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:73: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:73: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:74: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:76: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:80: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:85: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:89: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:89: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:91: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:95: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:99: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:112: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:120: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:121: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:123: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:133: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:134: [medium:warning] 500 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] +src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:13: [medium:warning] constructor does not initialize these fields: manualControl, caliCompass [cppcoreguidelines-pro-type-member-init,hicpp-member-init] +src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:17: [medium:warning] use '= default' to define a trivial destructor [hicpp-use-equals-default,modernize-use-equals-default] +src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:33: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] +src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:58: [medium:warning] 500 is a magic number; consider replacing it with a named constant + + + + + +========================= [PASSED] Took 541.63 seconds ========================= + +Component HIGH MEDIUM LOW +------------------------------------------- ------ -------- ----- +include 0 4 0 +lib/Battery 0 85 0 +lib/CalcAzimuth 0 9 0 +lib/Component 0 10 0 +lib/ControllPad 0 27 0 +lib/Counter 0 9 0 +lib/LcdWrapper 0 23 0 +lib/MQTT 0 42 0 +lib/Menu/include 0 13 0 +lib/Menu/src 0 188 0 +lib/MotorControl 0 38 0 +lib/Navigation 0 41 0 +lib/Network 0 36 0 +lib/NtripClient 0 98 0 +lib/Point 0 42 0 +lib/Route 0 20 0 +lib/Sensors 0 108 0 +lib/Speedometer 0 44 0 +lib/Times 0 11 0 +lib/calibrateCompass 0 28 0 +src 0 129 0 +src/OutputBuf 0 22 0 +src/SpecialMenus/CalibrateBattery 0 8 0 +src/SpecialMenus/PID 0 7 0 +src/SpecialMenus/Route 0 62 0 +src/SpecialMenus/SensorData 0 32 0 +src/SpecialMenus/Speed 0 9 0 +src/SpecialMenus/Systeminformation 0 9 0 +src/SpecialMenus/driveModi 0 26 0 +src/SpecialMenus/driveModi/Autopilot 0 37 0 +src/SpecialMenus/driveModi/CalibrateCompass 0 16 0 +src/SpecialMenus/driveModi/CaptureRoute 0 27 0 +src/SpecialMenus/driveModi/ManualDrive 0 8 0 +src/SpecialMenus/driveModi/TestMode 0 108 0 +src/driveModi 0 6 0 +src/driveModi/Modi/Autopilot 0 20 0 +src/driveModi/Modi/CalibrateCompass 0 2 0 +src/driveModi/Modi/CaptureRoute 0 7 0 +src/driveModi/Modi/ManualControl 0 9 0 +src/driveModi/Modi/TestMode 0 31 0 + +Total 0 1451 0 + +Environment Tool Status Duration +------------- --------- -------- ------------ +embedded clangtidy PASSED 00:09:01.626 +========================= 1 succeeded in 00:09:01.626 ========================= diff --git a/include/config.h b/include/config.h index 5b86d4a..d3828d3 100644 --- a/include/config.h +++ b/include/config.h @@ -16,6 +16,9 @@ namespace PinNumbers { constexpr uint8_t spiCipo = 4; constexpr uint8_t spiSck = 5; constexpr uint8_t gnssSpiCs = 17; + constexpr uint8_t sda = 21; + constexpr uint8_t scl = 19; + constexpr uint8_t battery = 35; namespace LeftMotor { constexpr uint8_t dir1 = 27; @@ -35,6 +38,9 @@ namespace PinNumbers { } namespace Settings { + constexpr uint32_t baudRate = 115200; + constexpr uint32_t i2cSpeed = 400000; + constexpr float wheelDiameter = 0.105; constexpr float wheelDistance = 0.255; constexpr uint16_t encoderSteps = 384; diff --git a/include/moveControl.h b/include/moveControl.h index 9fa948c..e274e9b 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -123,7 +123,7 @@ class MoveControl : public Component { * @param i * @param d */ - void setPidTunings(uint8_t side, double p, double i, double d); + void setPidTunings(uint8_t side, double pPart, double iPart, double dPart); /** * @brief Returns the PID object of the choosen side. @@ -152,7 +152,7 @@ class MoveControl : public Component { private: void run() override; - void setSpeedometerDirection(Speedometer *speedometer, double value); + static void setSpeedometerDirection(Speedometer *speedometer, double value); void calcTargetWheelSpeed(); void regulateMotors(); void updateCurrentWheelSpeed(); @@ -171,12 +171,17 @@ class MoveControl : public Component { double wheelspeed_right_target = 0; double wheelspeed_left = 0; double wheelspeed_right = 0; - double left_pid_out; - double right_pid_out; + double left_pid_out = 0; + double right_pid_out = 0; uint8_t overTimeCounter = 0; uint8_t overTimeMax = 100; int8_t rawPowerLeft = 0; int8_t rawPowerRight = 0; + + static constexpr int8_t maxPercentage = 100; + static constexpr float minSpeed = 0.2; + static constexpr uint8_t loopDelay = 20; + }; #endif // MOVE_CONTROL_H diff --git a/lib/Battery/battery.cpp b/lib/Battery/battery.cpp index 054d5ae..8aedcb2 100644 --- a/lib/Battery/battery.cpp +++ b/lib/Battery/battery.cpp @@ -4,30 +4,32 @@ * @brief Contains the implementation of the class Battery * @version 0.1 * @date 2022-02-05 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "battery.h" -Battery::Battery(uint8_t pin, uint32_t r1, uint32_t r2) { - this->pin = pin; - this->r1 = r1; - this->r2 = r2; - this->batteryVoltageFactor = (double) (this->r1 + this->r2) / (double) this->r2; +Battery::Battery(uint8_t pin, uint32_t firstResistor, uint32_t secondResistor) + : pin{pin}, firstResistor{firstResistor}, secondResistor{secondResistor}, + batteryVoltageFactor{firstResistor + secondResistor / static_cast(secondResistor)} +{ this->initBuffer(); - this->loopDelay = 100; + Component::loopDelay = Battery::loopDelay; } -Battery::Battery(uint8_t pin) { - this->pin = pin; +Battery::Battery(uint8_t pin) + : pin{pin} +{ this->initBuffer(); - this->loopDelay = 100; + Component::loopDelay = Battery::loopDelay; } -void Battery::run() { - if (this->calibrationState != CalibrationState::None) { +void Battery::run() +{ + if (this->calibrationState != CalibrationState::None) + { this->runCalibration(); return; } @@ -35,164 +37,202 @@ void Battery::run() { this->readAdcToBuf(); this->loopCounter++; - if (this->loopCounter >= this->calulationDelayMultiplier) { + if (this->loopCounter >= this->calulationDelayMultiplier) + { this->calculateBatteryVoltage(); this->calculateBatteryPercent(); this->loopCounter = 0; this->calculatetNewValues = true; } - - return; } -void Battery::runCalibration() { +void Battery::runCalibration() +{ if (this->calibrationState != CalibrationState::Reading) + { return; + } - this->readAdcToBuf(); - if (this->bufferPos == 0) { - uint16_t res = this->getBufAvg(); + this->readAdcToBuf(); + if (this->bufferPos == 0) + { + const uint16_t res = this->getBufAvg(); this->newRawAdcVoltages[this->currentCalibrationVoltage] = res; - std::cout << "Index: " - << (int) this->currentCalibrationVoltage + std::cout << "Index: " + << (int)this->currentCalibrationVoltage << " Value: " - << (int) res + << (int)res << std::endl; this->currentCalibrationVoltage++; this->calibrationState = CalibrationState::Waiting; - if (this->currentCalibrationVoltage == 60) { + if (this->currentCalibrationVoltage == Battery::rawAdcVoltagesCount) + { this->calibrationState = CalibrationState::Finished; } } } -double Battery::getBatteryVoltage() const { - double res = this->batteryVoltage; - return (int)(res*100+0.5)/100.0; +double Battery::getBatteryVoltage() const +{ + return static_cast((this->batteryVoltage * 100 + 0.5)) / 100.0; } -bool Battery::isBatteryLow(double voltage) const { +bool Battery::isBatteryLow(double voltage) const +{ if (this->getBatteryVoltage() <= voltage && this->batteryVoltage > this->absurdLowVoltage) + { return true; + } return false; } -bool Battery::isNewValue() { +bool Battery::isNewValue() +{ if (!this->calculatetNewValues) + { return false; - + } + this->calculatetNewValues = false; return true; } -void Battery::nextVoltageIsReady() { - if (this->calibrationState == CalibrationState::Waiting) { +void Battery::nextVoltageIsReady() +{ + if (this->calibrationState == CalibrationState::Waiting) + { this->calibrationState = CalibrationState::Reading; } } -void Battery::startCalibration() { +void Battery::startCalibration() +{ this->calibrationState = CalibrationState::Waiting; this->currentCalibrationVoltage = 0; this->bufferPos = 0; - this->loopDelay = 50; - this->newRawAdcVoltages = new uint16_t[60]; + Component::loopDelay = Battery::loopDelay / 2; + this->newRawAdcVoltages = new uint16_t[Battery::rawAdcVoltagesCount]; } -void Battery::finishCalibration() { +void Battery::finishCalibration() +{ if (this->calibrationState != CalibrationState::None) + { return; + } delete[] this->newRawAdcVoltages; this->calibrationState = CalibrationState::None; - this->loopDelay = 100; + Component::loopDelay = Battery::loopDelay; } -double Battery::calculateInputVoltage() { +double Battery::calculateInputVoltage() +{ // Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095 double reading = this->getBufAvg(); - if(reading < 1 || reading > 4095) return 0; - return - 0.000000000000016 * pow(reading,4) - + 0.000000000118171 * pow(reading,3) - - 0.000000301211691 * pow(reading,2) - + 0.001109019271794 * reading - + 0.034143524634089; + if (reading < 1 || reading > Battery::adcMaxValue) + { + return 0; + } + + return -this->adcCurveCoeficient[0] * pow(reading, 4) + this->adcCurveCoeficient[1] * pow(reading, 3) - this->adcCurveCoeficient[2] * pow(reading, 2) + this->adcCurveCoeficient[3] * reading + this->adcCurveCoeficient[4]; } -void Battery::calculateBatteryVoltage() { - if (this->r1 && this->r2) { +void Battery::calculateBatteryVoltage() +{ + if (this->firstResistor && this->secondResistor) + { this->batteryVoltage = this->calculateInputVoltage() * this->batteryVoltageFactor; return; } - uint16_t adcValue = this->getBufAvg(); - if (adcValue < this->rawAdcVoltages[0]) { + const uint16_t adcValue = this->getBufAvg(); + if (adcValue < this->rawAdcVoltages[0]) + { this->batteryVoltage = -1; return; } - if (adcValue > this->rawAdcVoltages[this->rawAdcVoltagesCount] + 50) { - this->batteryVoltage = -2; - return; - } - - uint8_t index; - for (index = 1; index < this->rawAdcVoltagesCount; index++) { + uint8_t index = 1; + for (; index < this->rawAdcVoltagesCount; index++) + { if (adcValue < this->rawAdcVoltages[index]) + { break; + } } - double indexDelta = this->rawAdcVoltages[index] - this->rawAdcVoltages[index - 1]; - double valueDelta = this->rawAdcVoltages[index] - adcValue; + const double indexDelta = this->rawAdcVoltages[index] - this->rawAdcVoltages[index - 1]; + const double valueDelta = this->rawAdcVoltages[index] - adcValue; double voltage = this->startVoltage + (index - 1) * this->stepVoltage; voltage += valueDelta / indexDelta * this->stepVoltage; this->batteryVoltage = voltage; - - // std::cout << "Battery::calculateBatteryVoltage() - Voltage: " << voltage << " Index: " <<(int) index << " adcValue: " << (int) adcValue <<" iD: " << indexDelta << " vD: " << valueDelta << std::endl; } -void Battery::calculateBatteryPercent() { +void Battery::calculateBatteryPercent() +{ int8_t size = sizeof(this->capacityVoltages) / sizeof(*this->capacityVoltages); - uint8_t i; - for (i = 0; i < size; i++) { - if (this->batteryVoltage <= this->capacityVoltages[i]) + uint8_t index = 0; + for (; index < size; index++) + { + if (this->batteryVoltage <= this->capacityVoltages[index]) + { break; + } } - - if (i == 0) { - if (this->batteryVoltage > 6) - std::cout << "Critical low battery!" << std::endl; - } else if (i == size - 1) { - } else { - double diffToLowerVal = this->batteryVoltage - this->capacityVoltages[i - 1]; - double diffToHigherVal = this->capacityVoltages[i] - this->batteryVoltage; - if (diffToLowerVal > diffToHigherVal) - i--; + if (index == 0) + { + if (this->batteryVoltage > this->absurdLowVoltage) + { + std::cout << "Critical low battery!" << std::endl; + } } - this->batteryPercent = i * (100 / (size - 1)); + else if (index == size - 1) + { + } + else + { + const double diffToLowerVal = this->batteryVoltage - this->capacityVoltages[index - 1]; + const double diffToHigherVal = this->capacityVoltages[index] - this->batteryVoltage; + if (diffToLowerVal > diffToHigherVal) + { + index--; + } + } + this->batteryPercent = index * (100 / (size - 1)); } -void Battery::readAdcToBuf() { +void Battery::readAdcToBuf() +{ this->adcBuffer[this->bufferPos] = analogRead(this->pin); this->bufferPos++; if (this->bufferPos == Battery::bufferSize) + { this->bufferPos = 0; + } // std::cout << "Battery::readAdcToBuf added Value: " << this->adcBuffer[this->bufferPos] << std::endl; } -void Battery::initBuffer() { +void Battery::initBuffer() +{ for (uint8_t i = 0; i < Battery::bufferSize; i++) + { this->adcBuffer[i] = 0; + } } -uint16_t Battery::getBufAvg() const { +uint16_t Battery::getBufAvg() const +{ uint32_t res = 0; uint8_t emptyPos = 0; - for (uint8_t i = 0; i < Battery::bufferSize; i++) { + for (uint8_t i = 0; i < Battery::bufferSize; i++) + { if (this->adcBuffer[i] == 0) + { emptyPos++; + } res += this->adcBuffer[i]; } return res / (Battery::bufferSize - emptyPos); diff --git a/lib/Battery/battery.h b/lib/Battery/battery.h index f6707ba..2afc17d 100644 --- a/lib/Battery/battery.h +++ b/lib/Battery/battery.h @@ -4,9 +4,9 @@ * @brief Contains a class for battery monitoring * @version 0.1 * @date 2022-02-05 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef BATTERY_H @@ -21,118 +21,127 @@ /** * @brief A class for battery monitoring - * + * * This class reads the voltage from an analog pin to calculate the * charge level of a 3 Cell Li-Poly battery pack. The battery pack have * to be after a voltage diveder, so that maximum voltage for the * microcontroller is 3.3 Volt. */ -class Battery : public Component { - public: - enum CalibrationState { - None, - Reading, - Waiting, - Finished - }; +class Battery : public Component +{ +public: + enum CalibrationState + { + None, + Reading, + Waiting, + Finished + }; - /** - * @brief Construct a new Battery object - * - * The voltage devider have to be calculated, so that the input - * voltage from 3.3 Volt is never exceeded. It is assumed that - * the microcontroller is connected to the second resistor. - * - * @param pin The analog to read from. - * @param r1 First resistor of the voltage devider. - * @param r2 Second resistor of the voltage devider. - */ - Battery(uint8_t pin, uint32_t r1, uint32_t r2); - Battery(uint8_t pin); + /** + * @brief Construct a new Battery object + * + * The voltage devider have to be calculated, so that the input + * voltage from 3.3 Volt is never exceeded. It is assumed that + * the microcontroller is connected to the second resistor. + * + * @param pin The analog to read from. + * @param firstResistor First resistor of the voltage devider. + * @param secondResistor Second resistor of the voltage devider. + */ + Battery(uint8_t pin, uint32_t firstResistor, uint32_t secondResistor); + Battery(uint8_t pin); - /** - * @brief Get the battery voltage - * - * @return double in Volt - */ - double getBatteryVoltage() const; + /** + * @brief Get the battery voltage + * + * @return double in Volt + */ + double getBatteryVoltage() const; - /** - * @brief Get the charge level of the battery - * - * @return uint8_t charge level in percent - */ - uint8_t getBatteryPercent() const { return this->batteryPercent; } + /** + * @brief Get the charge level of the battery + * + * @return uint8_t charge level in percent + */ + uint8_t getBatteryPercent() const { return this->batteryPercent; } - /** - * @brief Checks if the battery is low. - * - * The function will also return false if the battery voltage is - * absurd low. This is for the case that the uController is powered - * by usb and no battery is connected. - * - * @param voltage the limit the battery have to - * @return true if the battery is low - * @return false if the battery is high - */ - bool isBatteryLow(double voltage) const; + /** + * @brief Checks if the battery is low. + * + * The function will also return false if the battery voltage is + * absurd low. This is for the case that the uController is powered + * by usb and no battery is connected. + * + * @param voltage the limit the battery have to + * @return true if the battery is low + * @return false if the battery is high + */ + bool isBatteryLow(double voltage) const; - bool isNewValue(); + bool isNewValue(); - //Calibration - CalibrationState getCalibrationState() const { return this->calibrationState; } - uint8_t getCurrentCalibrationVoltage() const { return this->currentCalibrationVoltage; } - void nextVoltageIsReady(); - void startCalibration(); - void finishCalibration(); + // Calibration + CalibrationState getCalibrationState() const { return this->calibrationState; } + uint8_t getCurrentCalibrationVoltage() const { return this->currentCalibrationVoltage; } + void nextVoltageIsReady(); + void startCalibration(); + void finishCalibration(); - private: - void run() override; - void runCalibration(); - double calculateInputVoltage(); - void calculateBatteryVoltage(); - void calculateBatteryPercent(); - void readAdcToBuf(); - void initBuffer(); - uint16_t getBufAvg() const; +private: + void run() override; + void runCalibration(); + double calculateInputVoltage(); + void calculateBatteryVoltage(); + void calculateBatteryPercent(); + void readAdcToBuf(); + void initBuffer(); + uint16_t getBufAvg() const; - static const uint8_t bufferSize = 30; + static constexpr uint8_t bufferSize = 30; + static constexpr uint8_t loopDelay = 100; + static constexpr uint16_t adcMaxValue = 4095; - CalibrationState calibrationState = CalibrationState::None; + CalibrationState calibrationState = CalibrationState::None; - uint8_t absurdLowVoltage = 5; - uint8_t pin; - uint8_t batteryPercent = 0; - uint8_t batteryLowPercent = 10; - uint8_t bufferPos = 0; - uint8_t calulationDelayMultiplier = 5; - uint8_t loopCounter = 0; - uint8_t currentCalibrationVoltage = 0; // *0.1 + 7 - uint16_t adcBuffer[bufferSize]; - uint16_t* newRawAdcVoltages; - uint32_t r1 = 0; - uint32_t r2 = 0; - bool calculatetNewValues = false; - double batteryVoltage = 0; - double batteryVoltageFactor; + uint8_t absurdLowVoltage = 5; + uint8_t pin; + uint8_t batteryPercent = 0; + uint8_t batteryLowPercent = 10; + uint8_t bufferPos = 0; + uint8_t calulationDelayMultiplier = 5; + uint8_t loopCounter = 0; + uint8_t currentCalibrationVoltage = 0; // *0.1 + 7 + uint16_t adcBuffer[bufferSize]; + uint16_t *newRawAdcVoltages = nullptr; + uint32_t firstResistor = 0; + uint32_t secondResistor = 0; + bool calculatetNewValues = false; + double batteryVoltage = 0; + double batteryVoltageFactor; - const float capacityVoltages[21] = {9.82, 10.83, 11.06, 11.12, // 0 5 10 15 - 11.18, 11.24, 11.3, 11.36, // 20 25 30 35 - 11.39, 11.45, 11.51, 11.56, // 40 45 50 55 - 11.62, 11.74, 11.86, 11.95, // 60 65 70 75 - 12.07, 12.25, 12.33, 12.45, // 80 85 90 95 - 12.6 }; + const float capacityVoltages[21] = {9.82, 10.83, 11.06, 11.12, // 0 5 10 15 + 11.18, 11.24, 11.3, 11.36, // 20 25 30 35 + 11.39, 11.45, 11.51, 11.56, // 40 45 50 55 + 11.62, 11.74, 11.86, 11.95, // 60 65 70 75 + 12.07, 12.25, 12.33, 12.45, // 80 85 90 95 + 12.6}; - const uint8_t rawAdcVoltagesCount = 60; - const double startVoltage = 7; - const double stepVoltage = 0.1; - const uint16_t rawAdcVoltages[60] = // from 7.0V to 12.9V in 0.1V steps - {1992, 2021, 2056, 2090, 2118, 2145, 2177, 2208, 2241, 2272, - 2298, 2331, 2362, 2387, 2420, 2453, 2482, 2514, 2543, 2577, - 2607, 2640, 2670, 2703, 2736, 2763, 2794, 2826, 2858, 2890, - 2920, 2956, 2983, 3019, 3054, 3088, 3121, 3158, 3189, 3226, - 3264, 3300, 3339, 3379, 3414, 3453, 3500, 3544, 3598, 3636, - 3682, 3730, 3781, 3837, 3887, 3943, 3997, 4054, 4093, 4095}; + static constexpr uint8_t rawAdcVoltagesCount = 60; + const double startVoltage = 7; + const double stepVoltage = 0.1; + const uint16_t rawAdcVoltages[rawAdcVoltagesCount] = // from 7.0V to 12.9V in 0.1V steps + {1992, 2021, 2056, 2090, 2118, 2145, 2177, 2208, 2241, 2272, + 2298, 2331, 2362, 2387, 2420, 2453, 2482, 2514, 2543, 2577, + 2607, 2640, 2670, 2703, 2736, 2763, 2794, 2826, 2858, 2890, + 2920, 2956, 2983, 3019, 3054, 3088, 3121, 3158, 3189, 3226, + 3264, 3300, 3339, 3379, 3414, 3453, 3500, 3544, 3598, 3636, + 3682, 3730, 3781, 3837, 3887, 3943, 3997, 4054, 4093, 4095}; + const double adcCurveCoeficient[5] = {0.000000000000016, + 0.000000000118171, + 0.000000301211691, + 0.001109019271794, + 0.034143524634089}; }; #endif // BATTERY_H diff --git a/lib/CalcAzimuth/calcAzimuth.cpp b/lib/CalcAzimuth/calcAzimuth.cpp index 889155c..f7f3c4a 100644 --- a/lib/CalcAzimuth/calcAzimuth.cpp +++ b/lib/CalcAzimuth/calcAzimuth.cpp @@ -1,114 +1,121 @@ /** * @file calcAzimuth.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "calcAzimuth.h" -CalcAzimuth::CalcAzimuth(Point point) { - this->lastChangePoint = point; - this->currentPosition = point; - this->loopDelay = 50; +CalcAzimuth::CalcAzimuth(Point point) + : lastChangePoint{point}, currentPosition{point} +{ + Component::loopDelay = CalcAzimuth::loopDelay; } -void CalcAzimuth::drivingDirectionChange(Point point) { - if (point.isInit() && point.isValid()) { +void CalcAzimuth::drivingDirectionChange(Point point) +{ + if (point.isInit() && point.isValid()) + { this->directionChangeMode = true; this->lastChangePoint = point; this->state = State::Invalid; } } -void CalcAzimuth::updateCurrentPosition(Point point) { +void CalcAzimuth::updateCurrentPosition(Point point) +{ this->currentPosition = point; this->positionChanged = true; } -String CalcAzimuth::stateToString(State state) { - switch (state) { - case State::Invalid: - return "Invalid"; +String CalcAzimuth::stateToString(State state) +{ + switch (state) + { + case State::Invalid: + return "Invalid"; - case State::Bad: - return "Bad"; + case State::Bad: + return "Bad"; - case State::Ok: - return "Ok"; + case State::Ok: + return "Ok"; - case State::Good: - return "Good"; + case State::Good: + return "Good"; - case State::Super: - return "Super"; - - default: - return "UNKOWN"; + case State::Super: + return "Super"; + + default: + return "UNKOWN"; } } -void CalcAzimuth::run() { +void CalcAzimuth::run() +{ if (!this->positionChanged) + { return; + } this->positionChanged = false; this->updateAzimuth(); } -void CalcAzimuth::updateAzimuth() { - if (!this->directionChangeMode - || this->lastChangePoint.distanceTo(this->currentPosition) < 1.0) +void CalcAzimuth::updateAzimuth() +{ + if (!this->directionChangeMode || this->lastChangePoint.distanceTo(this->currentPosition) < 1.0) { this->state = State::Invalid; - this->calcAzimuth = 999; + this->calcAzimuth = INT16_MIN; return; } this->calcAzimuth = this->lastChangePoint.courseTo(this->currentPosition); // Map point accuracy to State - if (this->lastChangePoint.getAccuracy() == Point::Accuracy::oneDigOfCM - || this->currentPosition.getAccuracy() == Point::Accuracy::oneDigOfCM) + if (this->lastChangePoint.getAccuracy() == Point::Accuracy::oneDigOfCM || this->currentPosition.getAccuracy() == Point::Accuracy::oneDigOfCM) { this->state = State::Good; - } - else if (this->lastChangePoint.getAccuracy() == Point::Accuracy::twoDigOfCM - || this->currentPosition.getAccuracy() == Point::Accuracy::twoDigOfCM) + } + else if (this->lastChangePoint.getAccuracy() == Point::Accuracy::twoDigOfCM || this->currentPosition.getAccuracy() == Point::Accuracy::twoDigOfCM) { this->state = State::Ok; - } - else if (this->lastChangePoint.getAccuracy() == Point::Accuracy::threeDigOfCM - || this->currentPosition.getAccuracy() == Point::Accuracy::threeDigOfCM) + } + else if (this->lastChangePoint.getAccuracy() == Point::Accuracy::threeDigOfCM || this->currentPosition.getAccuracy() == Point::Accuracy::threeDigOfCM) { this->state = State::Bad; - } - else + } + else { this->state = State::Invalid; } // Upgrade quality if the range grows up - if (this->lastChangePoint.distanceTo(this->currentPosition) > 2.0) { - switch (this->state) { - case State::Bad : - this->state = State::Ok; - break; - - case State::Ok : - this->state = State::Good; - break; + if (this->lastChangePoint.distanceTo(this->currentPosition) > this->minDistanceForBetterQuality) + { + switch (this->state) + { + case State::Bad: + this->state = State::Ok; + break; - case State::Good : - this->state = State::Super; - break; + case State::Ok: + this->state = State::Good; + break; - default: - break; + case State::Good: + this->state = State::Super; + break; + + default: + break; } } } diff --git a/lib/CalcAzimuth/calcAzimuth.h b/lib/CalcAzimuth/calcAzimuth.h index 03a9a21..c3aa08d 100644 --- a/lib/CalcAzimuth/calcAzimuth.h +++ b/lib/CalcAzimuth/calcAzimuth.h @@ -1,12 +1,12 @@ /** * @file calcAzimuth.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef CALC_AZIMUTH_H @@ -15,38 +15,43 @@ #include "component.h" #include "point.h" -class CalcAzimuth : public Component { - public: - enum State { - Invalid, - Bad, - Ok, - Good, - Super - }; +class CalcAzimuth : public Component +{ +public: + enum State + { + Invalid, + Bad, + Ok, + Good, + Super + }; - CalcAzimuth(Point point); + CalcAzimuth(Point point); - void drivingDirectionChange(Point point); - void updateCurrentPosition(Point point); - void disableCalcAzimuth() { this->directionChangeMode = false; } + void drivingDirectionChange(Point point); + void updateCurrentPosition(Point point); + void disableCalcAzimuth() { this->directionChangeMode = false; } - int16_t getAzimuth() const { return this->calcAzimuth; } - State getState() const { return this->state; } + int16_t getAzimuth() const { return this->calcAzimuth; } + State getState() const { return this->state; } - static String stateToString(State state); + static String stateToString(State state); - private: - void run() override; - void updateAzimuth(); +private: + void run() override; + void updateAzimuth(); - State state = State::Invalid; - Point lastChangePoint; - Point currentPosition; + State state = State::Invalid; + Point lastChangePoint; + Point currentPosition; - bool positionChanged = false; - bool directionChangeMode = false; - int16_t calcAzimuth = INT16_MAX; + bool positionChanged = false; + bool directionChangeMode = false; + int16_t calcAzimuth = INT16_MAX; + double minDistanceForBetterQuality = 2; + + static constexpr uint8_t loopDelay = 50; }; -#endif //CALC_AZIMUTH_H +#endif // CALC_AZIMUTH_H diff --git a/lib/Component/component.cpp b/lib/Component/component.cpp index 05b035e..8bf2ab5 100644 --- a/lib/Component/component.cpp +++ b/lib/Component/component.cpp @@ -1,25 +1,35 @@ #include "component.h" -Component::Component(uint16_t loopDelay) { - this->loopDelay = loopDelay; +Component::Component(uint16_t loopDelay) : loopDelay{loopDelay} +{ } -void Component::loop() { +void Component::loop() +{ if (!this->active) + { return; + } - if (this->childComponents.size()){ - std::list::iterator it; + if (this->childComponents.size()) + { + std::list::iterator it; for (it = this->childComponents.begin(); it != this->childComponents.end(); it++) + { (*it)->loop(); + } } this->runAsChild(); if (this->onlyChilds) + { return; + } - if (this->loopDelay && millis() - this->lastMillis < this->loopDelay) + if (static_cast(this->loopDelay) && millis() - this->lastMillis < this->loopDelay) + { return; + } this->lastMillis = millis(); @@ -28,13 +38,17 @@ void Component::loop() { this->afterRun(); if (this->timeUpdateAfter) + { this->lastMillis = millis(); + } } -void Component::addChildComponent(Component* child) { +void Component::addChildComponent(Component *child) +{ this->childComponents.push_back(child); } -void Component::removeChildComponent(Component* child) { +void Component::removeChildComponent(Component *child) +{ this->childComponents.remove(child); } diff --git a/lib/Component/component.h b/lib/Component/component.h index d8e5542..7e4b93a 100644 --- a/lib/Component/component.h +++ b/lib/Component/component.h @@ -1,12 +1,12 @@ /** * @file component.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-08-16 - * + * * @copyright Copyright (c) 2023 - * + * */ #pragma once @@ -15,37 +15,38 @@ #include -class Component { - public: - Component() {} - Component(uint16_t loopDelay); +class Component +{ +public: + Component() {} + Component(uint16_t loopDelay); - void loop(); - - void deactivate() { this->active = false; } - void activate() { this->active = false; } - - protected: - virtual void runAsChild() {} - virtual void beforeRun() {} - virtual void run() = 0; - virtual void afterRun() {} + void loop(); - void addChildComponent(Component* child); - void removeChildComponent(Component* child); + void deactivate() { this->active = false; } + void activate() { this->active = false; } - void activateOnlyChilds() { this->onlyChilds = true; } - void deactivateOnlyChilds() { this->onlyChilds = false; } +protected: + virtual void runAsChild() {} + virtual void beforeRun() {} + virtual void run() = 0; + virtual void afterRun() {} - void setTimerAfterTask() { this->timeUpdateAfter = true; } + void addChildComponent(Component *child); + void removeChildComponent(Component *child); - uint16_t loopDelay = 0; + void activateOnlyChilds() { this->onlyChilds = true; } + void deactivateOnlyChilds() { this->onlyChilds = false; } - private: - std::list childComponents; + void setTimerAfterTask() { this->timeUpdateAfter = true; } - bool active = true; - bool onlyChilds = false; - bool timeUpdateAfter = false; - uint32_t lastMillis = 0; + uint16_t loopDelay = 0; + +private: + std::list childComponents; + + bool active = true; + bool onlyChilds = false; + bool timeUpdateAfter = false; + uint32_t lastMillis = 0; }; diff --git a/lib/ControllPad/controlPad.cpp b/lib/ControllPad/controlPad.cpp index 187e65c..737ae6c 100644 --- a/lib/ControllPad/controlPad.cpp +++ b/lib/ControllPad/controlPad.cpp @@ -1,37 +1,43 @@ /** * @file controlPad.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-03-30 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "controlPad.h" -ControlPad::ControlPad() { - this->loopDelay = 5; -} +ControlPad::ControlPad() : Component(5), controlInput{0, 0, 0, 0} {} -void ControlPad::run() { - if(!this->connected) +void ControlPad::run() +{ + if (!this->connected) + { return; + } - if (millis() - this->lastMessageReceive > this->disconnectTime) { + if (millis() - this->lastMessageReceive > this->disconnectTime) + { this->connected = false; this->controlInput.buttons = 0; - this->controlInput.x = 127; - this->controlInput.y = 127; + this->controlInput.x = UINT8_MAX / 2; + this->controlInput.y = UINT8_MAX / 2; return; } if (this->lastButtons != controlInput.buttons) + { this->updated = true; + } - if (this->menuControl && this->controlInput.buttons > 0 && this->updated) { - if (this->firstButtonPress) { + if (static_cast(this->menuControl) && this->controlInput.buttons > 0 && this->updated) + { + if (this->firstButtonPress) + { this->menuControl->printMenu(); this->firstButtonPress = false; std::cout << "ControlPad::loop - First menu print" << std::endl; @@ -39,38 +45,48 @@ void ControlPad::run() { } if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Left)) + { this->menuControl->left(); + } else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Right)) + { this->menuControl->right(); + } else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Up)) + { this->menuControl->up(); + } else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Down)) + { this->menuControl->down(); + } else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Yes)) + { this->menuControl->yes(); + } else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::No)) + { this->menuControl->no(); + } this->updated = false; this->lastButtons = controlInput.buttons; } - return; } -void ControlPad::insertData(const uint8_t *data) { +void ControlPad::insertData(const uint8_t *data) +{ this->connected = true; this->lastMessageReceive = millis(); - uint8_t lastCount = this->controlInput.counter + 1; + const uint8_t lastCount = this->controlInput.counter + 1; memcpy(&(this->controlInput), data, sizeof(this->controlInput)); if (lastCount != this->controlInput.counter) std::cout << "ControlPad::insertData counter wrong value" << std::endl; - if (this->controlInput.x > 127 - this->deadZoneX - && this->controlInput.x < 127 + this->deadZoneX) - this->controlInput.x = 127; + if (this->controlInput.x > UINT8_MAX / 2 - this->deadZoneX && this->controlInput.x < UINT8_MAX / 2 + this->deadZoneX) + this->controlInput.x = UINT8_MAX / 2; - if (this->controlInput.y > 127 - this->deadZoneY - && this->controlInput.y < 127 + this->deadZoneY) - this->controlInput.y = 127; + if (this->controlInput.y > UINT8_MAX / 2 - this->deadZoneY && this->controlInput.y < UINT8_MAX / 2 + this->deadZoneY) + this->controlInput.y = UINT8_MAX / 2; } diff --git a/lib/ControllPad/controlPad.h b/lib/ControllPad/controlPad.h index 71412cf..1df2ba2 100644 --- a/lib/ControllPad/controlPad.h +++ b/lib/ControllPad/controlPad.h @@ -1,12 +1,12 @@ /** * @file controlPad.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-03-30 - * + * * @copyright Copyright (c) 2023 - * + * */ #pragma once @@ -16,33 +16,34 @@ #include #include -class ControlPad : public Component { - public: - ControlPad(); +class ControlPad : public Component +{ +public: + ControlPad(); - void insertData(const uint8_t *data); + void insertData(const uint8_t *data); - void setMenuControl(MenuControl* menuControl) { this->menuControl = menuControl; } + void setMenuControl(MenuControl *menuControl) { this->menuControl = menuControl; } - const ControlPadInput* getControlPadDataPtr() const { return &this->controlInput; } + const ControlPadInput *getControlPadDataPtr() const { return &this->controlInput; } - bool isControlPadConnected() const { return this->connected; } + bool isControlPadConnected() const { return this->connected; } - private: - void run() override; +private: + void run() override; - MenuControl* menuControl = nullptr; - ControlPadInput controlInput; + MenuControl *menuControl = nullptr; + ControlPadInput controlInput; - bool connected = false; - bool updated = false; - bool firstButtonPress = true; + bool connected = false; + bool updated = false; + bool firstButtonPress = true; - uint8_t deadZoneX = 20; - uint8_t deadZoneY = 20; - uint8_t lastButtons = 0; + uint8_t deadZoneX = 20; + uint8_t deadZoneY = 20; + uint8_t lastButtons = 0; - uint16_t disconnectTime = 100; + uint16_t disconnectTime = 100; - uint32_t lastMessageReceive = 0; + uint32_t lastMessageReceive = 0; }; diff --git a/lib/ControllPad/controlPadInput.h b/lib/ControllPad/controlPadInput.h index aab44ef..2239744 100644 --- a/lib/ControllPad/controlPadInput.h +++ b/lib/ControllPad/controlPadInput.h @@ -1,12 +1,12 @@ /** * @file controlPadInput.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-03-30 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef CONTROL_PAD_INPUT_H @@ -14,61 +14,66 @@ #include -struct ControlPadInput { +struct ControlPadInput +{ uint8_t buttons; uint8_t x; uint8_t y; uint8_t counter; }; +class ControlPadButton +{ +public: + enum PadButton + { + Left = 4, + Right = 8, + Up = 2, + Down = 1, + Yes = 32, + No = 16, + Action = 64 + }; -class ControlPadButton { - public: - enum PadButton { - Left = 4, - Right = 8, - Up = 2, - Down = 1, - Yes = 32, - No = 16, - Action = 64 - }; + static bool isControlPadButtonPressed(const ControlPadInput *input, PadButton button) + { + uint8_t buttonNum = input->buttons; + switch (button) + { + case PadButton::Left: + return buttonNum & (uint8_t)PadButton::Left; + break; - static bool isControlPadButtonPressed(const ControlPadInput *input, PadButton button) { - uint8_t buttonNum = input->buttons; - switch (button) { - case PadButton::Left : - return buttonNum & (uint8_t) PadButton::Left; - break; + case PadButton::Right: + return buttonNum & (uint8_t)PadButton::Right; + break; - case PadButton::Right : - return buttonNum & (uint8_t) PadButton::Right; - break; + case PadButton::Up: + return buttonNum & (uint8_t)PadButton::Up; + break; - case PadButton::Up : - return buttonNum & (uint8_t) PadButton::Up; - break; + case PadButton::Down: + return buttonNum & (uint8_t)PadButton::Down; + break; - case PadButton::Down : - return buttonNum & (uint8_t) PadButton::Down; - break; + case PadButton::Yes: + return buttonNum & (uint8_t)PadButton::Yes; + break; - case PadButton::Yes : - return buttonNum & (uint8_t) PadButton::Yes; - break; + case PadButton::No: + return buttonNum & (uint8_t)PadButton::No; + break; - case PadButton::No : - return buttonNum & (uint8_t) PadButton::No; - break; + case PadButton::Action: + return buttonNum & (uint8_t)PadButton::Action; + break; - case PadButton::Action : - return buttonNum & (uint8_t) PadButton::Action; - break; - - default: - return false;; - } + default: + return false; + ; } + } }; #endif // CONTROL_PAD_INPUT_H diff --git a/lib/Counter/counter.cpp b/lib/Counter/counter.cpp index ea69173..fa15a30 100644 --- a/lib/Counter/counter.cpp +++ b/lib/Counter/counter.cpp @@ -1,14 +1,14 @@ #include "counter.h" -#include uint8_t Counter::amountOfCounter = 0; -Counter::Counter(uint8_t pin) { - this->pulsePin = pin; - - this->unit = static_cast(Counter::amountOfCounter); - if (Counter::amountOfCounter < 7) +Counter::Counter(uint8_t pin) + : pulsePin{pin}, unit{static_cast(Counter::amountOfCounter)} +{ + if (Counter::amountOfCounter <= Counter::maxCounter) + { Counter::amountOfCounter++; + } pcnt_config_t config; config.unit = this->unit; @@ -24,33 +24,40 @@ Counter::Counter(uint8_t pin) { pcnt_unit_config(&config); } -void Counter::pause() { +void Counter::pause() +{ pcnt_counter_pause(this->unit); } -void Counter::resume() { +void Counter::resume() +{ pcnt_counter_resume(this->unit); } -void Counter::clear() { +void Counter::clear() +{ pcnt_counter_clear(this->unit); } -int16_t Counter::getValue() const { - int16_t res; +int16_t Counter::getValue() const +{ + int16_t res = 0; pcnt_get_counter_value(this->unit, &res); return res; } -void Counter::setFilterValue(uint16_t value) { +void Counter::setFilterValue(uint16_t value) +{ pcnt_set_filter_value(this->unit, value); this->filterEnable(); } -void Counter::filterEnable() { +void Counter::filterEnable() +{ pcnt_filter_enable(this->unit); } -void Counter::filterDisable() { +void Counter::filterDisable() +{ pcnt_filter_disable(this->unit); } diff --git a/lib/Counter/counter.h b/lib/Counter/counter.h index 59c5a56..34579e6 100644 --- a/lib/Counter/counter.h +++ b/lib/Counter/counter.h @@ -2,29 +2,32 @@ #include #include +#include -class Counter { - public: - Counter(uint8_t pin); +class Counter +{ +public: + Counter(uint8_t pin); - void pause(); - void resume(); - void clear(); + void pause(); + void resume(); + void clear(); - int16_t getValue() const; + int16_t getValue() const; - void setFilterValue(uint16_t value); - void filterEnable(); - void filterDisable(); + void setFilterValue(uint16_t value); + void filterEnable(); + void filterDisable(); - private: - static constexpr int16_t highLimit = INT16_MAX; - static constexpr uint8_t lowLimit = 0; +private: + static constexpr int16_t highLimit = INT16_MAX; + static constexpr uint8_t lowLimit = 0; + static constexpr uint8_t maxCounter = 6; - static uint8_t amountOfCounter; + static uint8_t amountOfCounter; - bool initalised = false; + bool initalised = false; - uint8_t pulsePin; - pcnt_unit_t unit; + uint8_t pulsePin; + pcnt_unit_t unit; }; diff --git a/lib/LcdWrapper/LcdWrapper.cpp b/lib/LcdWrapper/LcdWrapper.cpp index 527202f..4d48230 100644 --- a/lib/LcdWrapper/LcdWrapper.cpp +++ b/lib/LcdWrapper/LcdWrapper.cpp @@ -4,62 +4,80 @@ * @brief Contains the implementation of the class LcdWrapper * @version 0.1 * @date 2023-01-08 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "LcdWrapper.h" -LcdWrapper::LcdWrapper(LiquidCrystal_I2C* lcd) { - this->lcd = lcd; +LcdWrapper::LcdWrapper(LiquidCrystal_I2C *lcd) + : lcd{lcd}, changed{false} +{ this->clear(); - this->changed = false; } -void LcdWrapper::run() { +void LcdWrapper::run() +{ if (!this->changed) + { return; + } this->lcd->clear(); - for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) { + for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) + { this->lcd->setCursor(0, i); - this->lcd->print(this->data[i]); + this->lcd->print(static_cast(this->data[i])); } - - if (this->callback) + + if (static_cast(this->callback)) + { this->callback(this->data, LcdWrapper::totalLines, LcdWrapper::totalRows); + } this->changed = false; } -void LcdWrapper::clear() { - for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) { - for (uint8_t j = 0; j < LcdWrapper::totalRows; j++) { +void LcdWrapper::clear() +{ + for (uint8_t i = 0; i < LcdWrapper::totalLines; i++) + { + for (uint8_t j = 0; j < LcdWrapper::totalRows; j++) + { data[i][j] = ' '; } } this->changed = true; } -void LcdWrapper::setCursor(uint8_t row, uint8_t line) { +void LcdWrapper::setCursor(uint8_t row, uint8_t line) +{ if (row > LcdWrapper::totalRows - 1) + { row = LcdWrapper::totalRows - 1; + } if (line > LcdWrapper::totalLines - 1) + { line = LcdWrapper::totalLines - 1; + } this->cursorRow = row; this->cursorLine = line; } -void LcdWrapper::print(const char *str) { +void LcdWrapper::print(const char *str) +{ uint8_t inputStringPosition = 0; - for (uint8_t i = this->cursorRow; i < LcdWrapper::totalRows; i++) { + for (uint8_t i = this->cursorRow; i < LcdWrapper::totalRows; i++) + { if (str[inputStringPosition] == '\0') + { break; - else - this->data[this->cursorLine][i] = str[inputStringPosition]; + } + this->data[this->cursorLine][i] = str[inputStringPosition]; + inputStringPosition++; } this->changed = true; diff --git a/lib/LcdWrapper/LcdWrapper.h b/lib/LcdWrapper/LcdWrapper.h index e78e269..dd19cc5 100644 --- a/lib/LcdWrapper/LcdWrapper.h +++ b/lib/LcdWrapper/LcdWrapper.h @@ -4,9 +4,9 @@ * @brief Contains the LcdWrapper class * @version 0.1 * @date 2023-01-08 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef LCD_WRAPPER_H @@ -17,59 +17,60 @@ #include #include -typedef void (*LcdWrapperCallback) (const char data[][16], uint8_t lines, uint8_t rows); +typedef void (*LcdWrapperCallback)(const char data[][16], uint8_t lines, uint8_t rows); /** - * @brief A class for the Menu class to print information - * + * @brief A class for the Menu class to print information + * * This class inherits the DisplayWrapper class as a interface. - * The class takes the information to print from any thread. The + * The class takes the information to print from any thread. The * loop function has to be called to print the data. */ -class LcdWrapper : public DisplayWrapper, public Component { - public: - /** - * @brief Construct a new Lcd Wrapper object - * - * @param lcd - */ - LcdWrapper(LiquidCrystal_I2C* lcd); +class LcdWrapper : public DisplayWrapper, public Component +{ +public: + /** + * @brief Construct a new Lcd Wrapper object + * + * @param lcd + */ + LcdWrapper(LiquidCrystal_I2C *lcd); - /** - * @brief Empty the buffer - * - */ - void clear() override; + /** + * @brief Empty the buffer + * + */ + void clear() override; - /** - * @brief Set point where data to be saved - * - * @param row - * @param line - */ - void setCursor(uint8_t row, uint8_t line) override; - void setCallback(LcdWrapperCallback callback) { this->callback = callback; } + /** + * @brief Set point where data to be saved + * + * @param row + * @param line + */ + void setCursor(uint8_t row, uint8_t line) override; + void setCallback(LcdWrapperCallback callback) { this->callback = callback; } - /** - * @brief Save the data to be printed - * - * @param str - */ - void print(const char *str) override; + /** + * @brief Save the data to be printed + * + * @param str + */ + void print(const char *str) override; - static constexpr uint8_t totalRows = 16; - static constexpr uint8_t totalLines = 2; - private: - void run() override; + static constexpr uint8_t totalRows = 16; + static constexpr uint8_t totalLines = 2; - - LiquidCrystal_I2C* lcd; - LcdWrapperCallback callback = nullptr; - char data[LcdWrapper::totalLines][LcdWrapper::totalRows]; +private: + void run() override; - uint8_t cursorRow = 0; - uint8_t cursorLine = 0; + LiquidCrystal_I2C *lcd; + LcdWrapperCallback callback = nullptr; + char data[LcdWrapper::totalLines][LcdWrapper::totalRows]; - bool changed = false; + uint8_t cursorRow = 0; + uint8_t cursorLine = 0; + + bool changed = false; }; #endif // DISPLAY_WRAPPER_H diff --git a/lib/calibrateCompass/calibrateCompass.cpp b/lib/calibrateCompass/calibrateCompass.cpp index 90586a2..43e3326 100644 --- a/lib/calibrateCompass/calibrateCompass.cpp +++ b/lib/calibrateCompass/calibrateCompass.cpp @@ -1,68 +1,79 @@ /** * @file calibrateCompass.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-05-23 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "calibrateCompass.h" -CalibrateCompass::CalibrateCompass(QMC5883LCompass* compass) { +CalibrateCompass::CalibrateCompass(QMC5883LCompass *compass) +{ this->compass = compass; this->state = State::Ready; this->clearData(); this->activateOnlyChilds(); } -void CalibrateCompass::runAsChild() { +void CalibrateCompass::runAsChild() +{ if (this->state != State::Calibrating) + { return; + } bool changed = false; this->compass->read(); - int x = this->compass->getX(); - int y = this->compass->getY(); - int z = this->compass->getZ(); + int xAxis = this->compass->getX(); + int yAxis = this->compass->getY(); + int zAxis = this->compass->getZ(); - if(x < this->data.data[0][0]) { - this->data.data[0][0] = x; + if (xAxis < this->data.data[0][0]) + { + this->data.data[0][0] = xAxis; changed = true; } - if(x > this->data.data[0][1]) { - this->data.data[0][1] = x; + if (xAxis > this->data.data[0][1]) + { + this->data.data[0][1] = xAxis; changed = true; } - if(y < this->data.data[1][0]) { - this->data.data[1][0] = y; + if (yAxis < this->data.data[1][0]) + { + this->data.data[1][0] = yAxis; changed = true; } - if(y > this->data.data[1][1]) { - this->data.data[1][1] = y; + if (yAxis > this->data.data[1][1]) + { + this->data.data[1][1] = yAxis; changed = true; } - if(z < this->data.data[2][0]) { - this->data.data[2][0] = z; + if (zAxis < this->data.data[2][0]) + { + this->data.data[2][0] = zAxis; changed = true; } - if(z > this->data.data[2][1]) { - this->data.data[2][1] = z; + if (zAxis > this->data.data[2][1]) + { + this->data.data[2][1] = zAxis; changed = true; } if (changed) this->lastChange = millis(); - if (millis() - this->lastChange > this->maxTimeWithoutChange) { + if (millis() - this->lastChange > this->maxTimeWithoutChange) + { this->state = State::Finished; this->checkDataValidity(); } @@ -70,9 +81,12 @@ void CalibrateCompass::runAsChild() { void CalibrateCompass::run() {} -void CalibrateCompass::start() { +void CalibrateCompass::start() +{ if (this->state != State::Ready) + { return; + } this->clearData(); this->state = State::Calibrating; @@ -80,39 +94,45 @@ void CalibrateCompass::start() { this->lastChange = millis(); } -void CalibrateCompass::useData() { - if (!this->dataValid) { +void CalibrateCompass::useData() +{ + if (!this->dataValid) + { std::cout << "CalibrateCompass::useData - Data not valid" << std::endl; return; } - this->compass->setCalibration( this->data.data[0][0], - this->data.data[0][1], - this->data.data[1][0], - this->data.data[1][1], - this->data.data[2][0], - this->data.data[2][1] - ); + this->compass->setCalibration(this->data.data[0][0], + this->data.data[0][1], + this->data.data[1][0], + this->data.data[1][1], + this->data.data[2][0], + this->data.data[2][1]); - std::cout << "CalibrateCompass::useData " << *this << std::endl; + std::cout << "CalibrateCompass::useData " << *this << std::endl; } -void CalibrateCompass::removeCalibration() { +void CalibrateCompass::removeCalibration() +{ this->compass->clearCalibration(); } -void CalibrateCompass::reset() { +void CalibrateCompass::reset() +{ this->clearData(); this->state = State::Ready; } -void CalibrateCompass::saveData() { +void CalibrateCompass::saveData() +{ if (!this->dataValid) + { return; + } Preferences preferences; preferences.begin("compass", false); - + preferences.putInt("xLow", this->data.data[0][0]); preferences.putInt("xHigh", this->data.data[0][1]); preferences.putInt("yLow", this->data.data[1][0]); @@ -123,7 +143,8 @@ void CalibrateCompass::saveData() { preferences.end(); } -void CalibrateCompass::loadData() { +void CalibrateCompass::loadData() +{ Preferences preferences; preferences.begin("compass", true); @@ -138,20 +159,23 @@ void CalibrateCompass::loadData() { this->checkDataValidity(); } -void CalibrateCompass::clearData() { - for (uint8_t i = 0; i < 3; i++) { +void CalibrateCompass::clearData() +{ + for (uint8_t i = 0; i < 3; i++) + { this->data.data[i][0] = 0; this->data.data[i][1] = 0; } this->dataValid = false; } -void CalibrateCompass::checkDataValidity() { +void CalibrateCompass::checkDataValidity() +{ int sum = 0; - for (uint8_t i = 0; i < 3; i++) { - if (this->data.data[i][0] > INT16_MAX || this->data.data[i][0] < INT16_MIN - || this->data.data[i][1] > INT16_MAX || this->data.data[i][1] < INT16_MIN) - { + for (uint8_t i = 0; i < 3; i++) + { + if (this->data.data[i][0] > INT16_MAX || this->data.data[i][0] < INT16_MIN || this->data.data[i][1] > INT16_MAX || this->data.data[i][1] < INT16_MIN) + { this->dataValid = false; return; } @@ -161,7 +185,8 @@ void CalibrateCompass::checkDataValidity() { this->dataValid = sum; } -std::ostream& operator<<(std::ostream& os, const CalibrateCompass& caliComp) { +std::ostream &operator<<(std::ostream &os, const CalibrateCompass &caliComp) +{ os << "("; os << caliComp.data.data[0][0]; os << ", "; diff --git a/platformio.ini b/platformio.ini index ad4ec3d..9d9aec8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,7 +30,11 @@ build_type = debug monitor_filters = esp32_exception_decoder check_tool = clangtidy check_flags = - clangtidy: --checks=*,-llvmlibc + clangtidy: --checks=-*,cert-*,cppcoreguidelines-*,clang-analyzer-*,google-*,hicpp-*,modernize-*,performance-*,portability-*,readability-*,bugprone-*,misc-*,openmp-*,objc-* --fix +check_src_filters = + + + + + + [env:native] platform = native @@ -38,3 +42,21 @@ test_ignore = test_embedded [platformio] description = A Rover who should be drive a route by gps. + + +; Bei Möglichkeit folgendes aus clang tidy entfernen +; cppcoreguidelines-owning-memory +; +; +; +; +; +; +; +; +; +; +; +; +; +# diff --git a/src/SpecialMenus/Route/menuRoute.cpp b/src/SpecialMenus/Route/menuRoute.cpp index cc66531..875d505 100644 --- a/src/SpecialMenus/Route/menuRoute.cpp +++ b/src/SpecialMenus/Route/menuRoute.cpp @@ -1,36 +1,44 @@ /** * @file menuRoute.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the classes MenuActionRoute, MenuRoute and MenuRouteWrapper. + * @brief Contains the implementation of the classes MenuActionRoute, MenuRoute and MenuRouteWrapper. * @version 0.1 * @date 2022-12-28 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuRoute.h" -MenuActionRoute::MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction) { +MenuActionRoute::MenuActionRoute(MenuRoute *menuRoute, DataFunction dataFunction) +{ this->menuRoute = menuRoute; this->dataFunction = dataFunction; } -void MenuActionRoute::action() { +void MenuActionRoute::action() +{ (this->menuRoute->*this->dataFunction)(0); } -MenuRoute::MenuRoute(Route* route) { +MenuRoute::MenuRoute(Route *route) +{ this->route = route; } -MenuRoute::~MenuRoute() { +MenuRoute::~MenuRoute() +{ if (isInit) + { delete this->mainMenu; + } } -void MenuRoute::printMenu() { - if (!this->isInit) { +void MenuRoute::printMenu() +{ + if (!this->isInit) + { this->isInit = true; this->init(); } @@ -38,72 +46,103 @@ void MenuRoute::printMenu() { this->mainMenu->printMenu(); } - -void MenuRoute::down() { - if (blockInput) return; +void MenuRoute::down() +{ + if (blockInput) + { + return; + } this->mainMenu->down(); } -void MenuRoute::up() { - if (blockInput) return; +void MenuRoute::up() +{ + if (blockInput) + { + return; + } this->mainMenu->up(); } -void MenuRoute::right() { - if (blockInput) return; +void MenuRoute::right() +{ + if (blockInput) + { + return; + } this->mainMenu->right(); } -void MenuRoute::left() { - if (blockInput) return; +void MenuRoute::left() +{ + if (blockInput) + { + return; + } if (this->mainMenu->isInSubmenu()) + { this->mainMenu->left(); + } else + { this->parentMenu->printMenu(); + } } -void MenuRoute::yes() { - if (blockInput) return; +void MenuRoute::yes() +{ + if (blockInput) + { + return; + } this->mainMenu->yes(); } -void MenuRoute::no() { - if (blockInput) return; +void MenuRoute::no() +{ + if (blockInput) + { + return; + } if (this->mainMenu->isInSubmenu()) + { this->mainMenu->no(); + } else + { this->left(); + } } - -void MenuRoute::init() { +void MenuRoute::init() +{ // auto dummy = []() { // std::cout << "Dummy in Action" <mainMenu = new Menu; - MenuRoutePoints* pointsMenu = new MenuRoutePoints(this->route); + auto *pointsMenu = new MenuRoutePoints(this->route); this->mainMenu->setLcd(this->lcd); pointsMenu->setLcd(this->lcd); - auto importWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::importRoute)); - auto exportWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::exportRoute)); - auto deleteWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::deleteRoute)); - auto clearWrapper = new MenuActionRoute(this, &MenuRoute::clearRoute); + auto *importWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::importRoute)); + auto *exportWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::exportRoute)); + auto *deleteWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::deleteRoute)); + auto *clearWrapper = new MenuActionRoute(this, &MenuRoute::clearRoute); importWrapper->setLcd(this->lcd); - importWrapper->setMinMax(0, 100); + importWrapper->setMinMax(0, MenuRoute::maxRouteNumber); importWrapper->setPrintParentMenu(false); importWrapper->setEntry(0, "Import Route"); exportWrapper->setLcd(this->lcd); - exportWrapper->setMinMax(0, 100); + exportWrapper->setMinMax(0, MenuRoute::maxRouteNumber); exportWrapper->setPrintParentMenu(false); exportWrapper->setEntry(0, "Export Route"); deleteWrapper->setLcd(this->lcd); - deleteWrapper->setMinMax(0, 100); + deleteWrapper->setMinMax(0, MenuRoute::maxRouteNumber); deleteWrapper->setPrintParentMenu(false); deleteWrapper->setEntry(0, "Delete Route"); @@ -114,13 +153,15 @@ void MenuRoute::init() { this->mainMenu->addEntry(new MenuAction("Delete", deleteWrapper)); } -void MenuRoute::importRoute(uint8_t routeNumber) { +void MenuRoute::importRoute(uint8_t routeNumber) +{ this->blockInput = true; String lineOne = ""; String lineTwo = ""; - if (WiFi.status() != WL_CONNECTED) { + if (WiFi.status() != WL_CONNECTED) + { lineOne = "Not connected to"; lineTwo = "the WiFi."; this->print(lineOne, lineTwo); @@ -128,7 +169,8 @@ void MenuRoute::importRoute(uint8_t routeNumber) { return; } - if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) { + if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) + { lineOne = "Not enough mem"; lineTwo = "for Json obj"; this->print(lineOne, lineTwo); @@ -139,7 +181,7 @@ void MenuRoute::importRoute(uint8_t routeNumber) { WiFiClient client; HTTPClient http; DynamicJsonDocument doc(JSON_DOCUMENT_SIZE_ROUTE); - + String host = "http://rover.kleiax.de/api/"; host.concat(routeNumber); http.begin(client, host); @@ -149,14 +191,19 @@ void MenuRoute::importRoute(uint8_t routeNumber) { lineTwo = "Code: "; if (httpResponseCode == 202) + { deserializeJson(doc, http.getStream()); + } else + { lineOne = "HTTP Error"; + } lineTwo.concat(httpResponseCode); this->print(lineOne, lineTwo); - if (httpResponseCode <= 0) { + if (httpResponseCode <= 0) + { this->blockInput = false; return; } @@ -164,7 +211,8 @@ void MenuRoute::importRoute(uint8_t routeNumber) { uint16_t totalPoints = doc["amountPoints"]; this->route->clear(); - for (uint16_t i = 0; i < totalPoints; i++) { + for (uint16_t i = 0; i < totalPoints; i++) + { Point::Coordinates coords; coords.lat = doc["points"][i][0].as(); coords.lon = doc["points"][i][1].as(); @@ -175,14 +223,16 @@ void MenuRoute::importRoute(uint8_t routeNumber) { http.end(); } -void MenuRoute::exportRoute(uint8_t routeNumber) { +void MenuRoute::exportRoute(uint8_t routeNumber) +{ this->blockInput = true; uint16_t totalPoints = this->route->getRouteInfo().totalPoints; String lineOne = ""; String lineTwo = ""; - if (WiFi.status() != WL_CONNECTED) { + if (WiFi.status() != WL_CONNECTED) + { lineOne = "Not connected to"; lineTwo = "the WiFi."; this->print(lineOne, lineTwo); @@ -190,7 +240,8 @@ void MenuRoute::exportRoute(uint8_t routeNumber) { return; } - if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) { + if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) + { lineOne = "Not enough mem"; lineTwo = "for Json obj"; this->print(lineOne, lineTwo); @@ -205,7 +256,8 @@ void MenuRoute::exportRoute(uint8_t routeNumber) { Point::Coordinates coords = this->route->startRoute().getCoordinates(); doc["points"][0][0] = coords.lat; doc["points"][0][1] = coords.lon; - for (uint16_t i = 1; i < totalPoints; i++) { + for (uint16_t i = 1; i < totalPoints; i++) + { coords = this->route->getNextPoint().getCoordinates(); doc["points"][i][0] = coords.lat; doc["points"][i][1] = coords.lon; @@ -215,30 +267,36 @@ void MenuRoute::exportRoute(uint8_t routeNumber) { WiFiClient client; HTTPClient http; - + http.begin(client, "http://rover.kleiax.de/api/"); http.addHeader("Content-Type", "application/json"); int httpResponseCode = http.POST(jsonData); if (httpResponseCode == 201) + { lineOne = "Export complete"; + } else + { lineOne = "HTTP Error"; + } lineTwo = "Code: "; lineTwo.concat(httpResponseCode); this->print(lineOne, lineTwo); this->blockInput = false; - + http.end(); } -void MenuRoute::deleteRoute(uint8_t routeNumber) { +void MenuRoute::deleteRoute(uint8_t routeNumber) +{ this->blockInput = true; String lineOne = ""; String lineTwo = ""; - if (WiFi.status() != WL_CONNECTED) { + if (WiFi.status() != WL_CONNECTED) + { lineOne = "Not connected to"; lineTwo = "the WiFi."; this->print(lineOne, lineTwo); @@ -246,7 +304,8 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) { return; } - if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) { + if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) + { lineOne = "Not enough mem"; lineTwo = "for Json obj"; this->print(lineOne, lineTwo); @@ -257,7 +316,7 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) { WiFiClient client; HTTPClient http; DynamicJsonDocument doc(JSON_DOCUMENT_SIZE_ROUTE); - + String host = "http://rover.kleiax.de/api/"; host.concat(routeNumber); http.begin(client, host); @@ -267,9 +326,13 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) { lineTwo = "Code: "; if (httpResponseCode == 202) + { deserializeJson(doc, http.getStream()); + } else + { lineOne = "HTTP Error"; + } lineTwo.concat(httpResponseCode); this->print(lineOne, lineTwo); @@ -278,29 +341,37 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) { http.end(); } -void MenuRoute::clearRoute(uint8_t none) { +void MenuRoute::clearRoute(uint8_t none) +{ + //The parameter exist only for compability + none; this->route->clear(); this->print("Currente route", "deleted..."); } -MenuRouteWrapper::MenuRouteWrapper(MenuRoute* menuRoute, DataFunction dataFunction) { - this->menuRoute = menuRoute; - this->dataFunction = dataFunction; +MenuRouteWrapper::MenuRouteWrapper(MenuRoute *menuRoute, DataFunction dataFunction) + : menuRoute {menuRoute}, dataFunction {dataFunction} +{ + } -void MenuRouteWrapper::action(int16_t* values, uint8_t length) { - if (length < 1) { +void MenuRouteWrapper::action(int16_t *values, uint8_t length) +{ + if (length < 1) + { std::cout << "Error in MenuRouteWrapper::action" << std::endl; return; } if (values[0] < 0) + { values[0] = 0; + } if (values[0] > UINT8_MAX) + { values[0] = UINT8_MAX; + } (this->menuRoute->*this->dataFunction)(values[0]); } - - diff --git a/src/SpecialMenus/Route/menuRoute.h b/src/SpecialMenus/Route/menuRoute.h index b8cdae8..b53437b 100644 --- a/src/SpecialMenus/Route/menuRoute.h +++ b/src/SpecialMenus/Route/menuRoute.h @@ -126,6 +126,12 @@ class MenuRoute : public MenuControl { bool isInit = false; bool blockInput = false; + + static constexpr uint8_t maxRouteNumber = 100; + static constexpr uint16_t httpValidExport = 201; + static constexpr uint16_t httpValidImport = 202; + static constexpr uint16_t httpValidDelete = 202; + }; /** diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 17363cb..89d224f 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -10,8 +10,9 @@ */ #include "menuTestMode.h" -MenuTestMode::MenuTestMode(DriveManager* driveManager) { - this->driveManager = driveManager; +MenuTestMode::MenuTestMode(DriveManager* driveManager) + : driveManager {driveManager} +{ } MenuTestMode::~MenuTestMode() { @@ -30,73 +31,77 @@ void MenuTestMode::printMenu() { } void MenuTestMode::down() { - if (this->checkInput()) + if (this->checkInput()) { this->mainMenu->down(); + } } void MenuTestMode::up() { - if (this->checkInput()) + if (this->checkInput()) { this->mainMenu->up(); + } } void MenuTestMode::right() { - if (this->checkInput()) + if (this->checkInput()) { this->mainMenu->right(); + } } void MenuTestMode::left() { if (this->mainMenu->isInSubmenu()) - if (this->checkInput()) + if (this->checkInput()) { this->mainMenu->left(); + } else { this->testMode->abortManeuver(); this->mainMenu->left(); } - else + else { this->parentMenu->printMenu(); + } } void MenuTestMode::yes() { - if (this->checkInput()) + if (this->checkInput()) { this->mainMenu->yes(); + } } void MenuTestMode::no() { - if (this->mainMenu->isInSubmenu()) + if (this->mainMenu->isInSubmenu()) { if (this->checkInput()) this->mainMenu->no(); else { this->testMode->abortManeuver(); this->mainMenu->no(); - } - else - this->left(); + }} + else{ + this->left();} } void MenuTestMode::init() { this->testMode = new TestMode(); this->driveManager->changeModus(this->testMode); - this->testMode->setSpeeds(DrivingSpeeds{1, 8}); - auto dummy = []() { std::cout << "Dummy in Action" <mainMenu = new Menu; - auto engineMenu = new Menu; - auto lightMenu = new Menu; - auto encoderMenu = new Menu; + auto *engineMenu = new Menu; + auto *lightMenu = new Menu; + auto *encoderMenu = new Menu; // Sound // Ping google - auto drivingMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::drive)); - auto engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine)); - auto engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine)); - auto engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine)); - auto encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft()); - auto encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight()); + auto *drivingMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::drive)); + auto *engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine)); + auto *engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine)); + auto *engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine)); + auto *encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft()); + auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight()); // Set menus on LCD @@ -112,47 +117,52 @@ void MenuTestMode::init() { encoderRightMenu->setLcd(this->lcd); // Other menu config + static constexpr uint8_t percentMax = 100; + static constexpr uint8_t degreeMax = 360; + static constexpr uint8_t secondsMax = 120; + static constexpr uint8_t steps = 5; + drivingMenu->setEntry(0, "Centimeter", 100); - drivingMenu->setMinMaxSteps(0, -1000, 1000, 25); + drivingMenu->setMinMaxSteps(0, -1000, 1000, steps * 5); drivingMenu->setEntry(1, "Degree"); - drivingMenu->setMinMaxSteps(1, -360, 360, 15); + drivingMenu->setMinMaxSteps(1, -degreeMax, degreeMax, steps * 3); drivingMenu->setPrintParentMenu(false); engineLeftMenu->setEntry(0, "Percentage"); - engineLeftMenu->setMinMaxSteps(0, -100, 100, 5); - engineLeftMenu->setEntry(1, "Seconds", 5); - engineLeftMenu->setMinMaxSteps(1, 0, 120, 1); + engineLeftMenu->setMinMaxSteps(0, -percentMax, percentMax, steps); + engineLeftMenu->setEntry(1, "Seconds", steps); + engineLeftMenu->setMinMaxSteps(1, 0, secondsMax, 1); engineLeftMenu->setPrintParentMenu(false); engineRightMenu->setEntry(0, "Percentage"); - engineRightMenu->setMinMaxSteps(0, -100, 100, 5); - engineRightMenu->setEntry(1, "Seconds", 5); - engineRightMenu->setMinMaxSteps(1, 0, 120, 1); + engineRightMenu->setMinMaxSteps(0, -percentMax, percentMax, steps); + engineRightMenu->setEntry(1, "Seconds", steps); + engineRightMenu->setMinMaxSteps(1, 0, secondsMax, 1); engineRightMenu->setPrintParentMenu(false); engineBothMenu->setEntry(0, "Percentage"); - engineBothMenu->setMinMaxSteps(0, -100, 100, 5); - engineBothMenu->setEntry(1, "Seconds", 5); - engineBothMenu->setMinMaxSteps(1, 0, 120, 1); + engineBothMenu->setMinMaxSteps(0, -percentMax, percentMax, steps); + engineBothMenu->setEntry(1, "Seconds", steps); + engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1); engineBothMenu->setPrintParentMenu(false); // Entrys for the menus - MenuAction* engineAction = new MenuAction("Engine", engineMenu); - MenuAction* engineLeftAction = new MenuAction("Left", engineLeftMenu); - MenuAction* engineRightAction = new MenuAction("Right", engineRightMenu); - MenuAction* engineBothAction = new MenuAction("Both", engineBothMenu); + auto *engineAction = new MenuAction("Engine", engineMenu); + auto *engineLeftAction = new MenuAction("Left", engineLeftMenu); + auto *engineRightAction = new MenuAction("Right", engineRightMenu); + auto *engineBothAction = new MenuAction("Both", engineBothMenu); - MenuAction* drivingAction = new MenuAction("Driving", drivingMenu); + auto *drivingAction = new MenuAction("Driving", drivingMenu); - MenuAction* encoderAction = new MenuAction("Encoder", encoderMenu); - MenuAction* encoderLeftAction = new MenuAction("Left", encoderLeftMenu); - MenuAction* encoderRightAction = new MenuAction("Right", encoderRightMenu); + auto *encoderAction = new MenuAction("Encoder", encoderMenu); + auto *encoderLeftAction = new MenuAction("Left", encoderLeftMenu); + auto *encoderRightAction = new MenuAction("Right", encoderRightMenu); - MenuAction* lightAction = new MenuAction("Light", lightMenu); - MenuAction* lightFlashAction = new MenuAction("Flash", dummy); - MenuAction* lightFadeAction = new MenuAction("Fade", dummy); - MenuAction* lightRedAction = new MenuAction("Red", dummy); - MenuAction* lightGreenAction = new MenuAction("Green", dummy); - MenuAction* lightBlueAction = new MenuAction("Blue", dummy); - MenuAction* lightOffAction = new MenuAction("Off", dummy); + auto *lightAction = new MenuAction("Light", lightMenu); + auto *lightFlashAction = new MenuAction("Flash", dummy); + auto *lightFadeAction = new MenuAction("Fade", dummy); + auto *lightRedAction = new MenuAction("Red", dummy); + auto *lightGreenAction = new MenuAction("Green", dummy); + auto *lightBlueAction = new MenuAction("Blue", dummy); + auto *lightOffAction = new MenuAction("Off", dummy); // Add entrys to the menus this->mainMenu->addEntry(engineAction); @@ -176,11 +186,11 @@ void MenuTestMode::init() { } void MenuTestMode::update() { - if (this->maneuverInAction) + if (this->maneuverInAction) { if (millis() - this->lastUpdateTime > updateDelay) { this->printManeuverTime(); this->lastUpdateTime = millis(); - } + }} } bool MenuTestMode::checkInput() { @@ -190,8 +200,9 @@ bool MenuTestMode::checkInput() { return false; } - if (this->maneuverInAction) + if (this->maneuverInAction) { this->maneuverInAction = false; + } return true; } @@ -209,16 +220,18 @@ void MenuTestMode::printManeuverTime() { } } -MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction) { - this->menu = menu; - this->testMode = this->menu->getTestMode(); - this->testModeFunctionSingle = testModeFunction; +MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction) + : menu {menu}, + testModeFunctionSingle {testModeFunction}, + testMode {menu->getTestMode()} +{ } -MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction) { - this->menu = menu; - this->testMode = this->menu->getTestMode(); - this->testModeFunctionDouble = testModeFunction; +MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction) + : menu {menu}, + testModeFunctionDouble {testModeFunction}, + testMode {menu->getTestMode()} +{ } void MenuTestModeWrapper::action(int16_t* values, uint8_t length) { @@ -228,10 +241,12 @@ void MenuTestModeWrapper::action(int16_t* values, uint8_t length) { bool res = false; - if (length == 2 && this->testModeFunctionDouble) + if (length == 2 && static_cast(this->testModeFunctionDouble)) { res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]); - else if (length == 1 && this->testModeFunctionSingle) + } + else if (length == 1 && static_cast(this->testModeFunctionSingle)) { res = (this->testMode->*this->testModeFunctionSingle)(values[0]); + } if (res) { this->menu->printManeuverTime(); diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.h b/src/SpecialMenus/driveModi/TestMode/menuTestMode.h index cb3c3b5..4022dbc 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.h +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.h @@ -70,8 +70,8 @@ class MenuTestMode : public MenuControl { bool checkInput(); DriveManager* driveManager; - TestMode* testMode; - Menu* mainMenu; + TestMode* testMode = nullptr; + Menu* mainMenu = nullptr; bool isInit = false; bool maneuverInAction = false; diff --git a/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp b/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp index cf06a1b..8d88049 100644 --- a/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp +++ b/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp @@ -11,8 +11,9 @@ #include "speedometerTest.h" -SpeedometerTest::SpeedometerTest(Speedometer* speedometer) { - this->speedometer = speedometer; +SpeedometerTest::SpeedometerTest(Speedometer* speedometer) + : speedometer {speedometer} +{ this->speedometer->setDirection(Speedometer::Forward); } @@ -46,8 +47,9 @@ void SpeedometerTest::left() { } void SpeedometerTest::no() { - if (this->state == State::Running) + if (this->state == State::Running){ speedometer->calibrationMeasurementStop(); + } this->state = State::Off; this->parentMenu->printMenu(); diff --git a/src/SpecialMenus/driveModi/menuDriveMode.cpp b/src/SpecialMenus/driveModi/menuDriveMode.cpp index 7ecea58..2245eee 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.cpp +++ b/src/SpecialMenus/driveModi/menuDriveMode.cpp @@ -11,27 +11,28 @@ #include "menuDriveMode.h" -MenuDriveMode::MenuDriveMode(DriveManager* driveManager) { - this->driveManager = driveManager; +MenuDriveMode::MenuDriveMode(DriveManager* driveManager) + : driveManager {driveManager} +{ } void MenuDriveMode::left() { - if (this->activeMenu) { - if (this->activeMenu) + if (static_cast(this->activeMenu)) { + if (static_cast(this->activeMenu)) { this->activeMenu->left(); + } return; } this->firstPrint = true; this->configureOnLeave(); - if (this->menuSpeed) delete this->menuSpeed; this->driveManager->changeModus(); MenuInformationSites::left(); } void MenuDriveMode::right() { - if (this->activeMenu) { + if (static_cast(this->activeMenu)) { this->activeMenu->right(); return; } @@ -39,7 +40,7 @@ void MenuDriveMode::right() { } void MenuDriveMode::up() { - if (this->activeMenu) { + if (static_cast(this->activeMenu)) { this->activeMenu->up(); return; } @@ -47,7 +48,7 @@ void MenuDriveMode::up() { } void MenuDriveMode::down() { - if (this->activeMenu) { + if (static_cast(this->activeMenu)) { this->activeMenu->down(); return; } @@ -55,7 +56,7 @@ void MenuDriveMode::down() { } void MenuDriveMode::yes() { - if (this->activeMenu) { + if (static_cast(this->activeMenu)) { this->activeMenu->yes(); return; } @@ -63,7 +64,7 @@ void MenuDriveMode::yes() { } void MenuDriveMode::no() { - if (this->activeMenu) { + if (static_cast(this->activeMenu)) { this->activeMenu->no(); return; } @@ -75,7 +76,7 @@ void MenuDriveMode::prepareReenterMenu() { } void MenuDriveMode::printMenu() { - if (this->activeMenu) { + if (static_cast(this->activeMenu)) { this->activeMenu->printMenu(); return; } @@ -88,11 +89,12 @@ void MenuDriveMode::init() { } void MenuDriveMode::activateSpeedMenu() { - if (!this->driveManager->isActive()) + if (!this->driveManager->isActive()) { return; + } DrivingSpeeds& speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef(); - MenuIntInput* menu = new MenuIntInput(2, new MenuSpeed(speeds)); + auto *menu = new MenuIntInput(2, new MenuSpeed(speeds)); menu->setMinMax(5, UINT8_MAX); menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10); @@ -112,8 +114,9 @@ void MenuDriveMode::enterSensorMenu() { } void MenuDriveMode::enterMenu() { - if (!this->activeMenu) + if (!static_cast(this->activeMenu)) { return; + } this->activeMenu->printMenu(); this->activeMenu->setParentMenu(this); diff --git a/src/driveModi/Modi/Autopilot/autopilot.cpp b/src/driveModi/Modi/Autopilot/autopilot.cpp index 49b0cf2..cdfc5eb 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.cpp +++ b/src/driveModi/Modi/Autopilot/autopilot.cpp @@ -4,138 +4,161 @@ * @brief Contains the implementation of the class Autopilot * @version 0.1 * @date 2022-02-02 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "driveModi/Modi/Autopilot/autopilot.h" #include "autopilot.h" -DirectionChangeSignal::DirectionChangeSignal(Autopilot* pilot) { - this->pilot = pilot; +DirectionChangeSignal::DirectionChangeSignal(Autopilot *pilot) + : pilot {pilot} +{ this->action(); } -DirectionChangeSignal::~DirectionChangeSignal() { - CalcAzimuth* calcAzimuth = pilot->getSensorData()->getCalcCompass(); - if (calcAzimuth) +DirectionChangeSignal::~DirectionChangeSignal() +{ + CalcAzimuth *calcAzimuth = pilot->getSensorData()->getCalcCompass(); + if (static_cast(calcAzimuth)) + { calcAzimuth->disableCalcAzimuth(); + } } -void DirectionChangeSignal::action() { - CalcAzimuth* calcAzimuth = pilot->getSensorData()->getCalcCompass(); - if (calcAzimuth) +void DirectionChangeSignal::action() +{ + CalcAzimuth *calcAzimuth = pilot->getSensorData()->getCalcCompass(); + if (static_cast(calcAzimuth)) + { calcAzimuth->drivingDirectionChange(pilot->getSensorData()->getCurrentPos()); + } } - -Autopilot::Autopilot() { - -} - -Autopilot::~Autopilot() { +Autopilot::~Autopilot() +{ delete this->directionChangeSignal; // this->navigation->getNTRIPClient()->setActivated(false); } -void Autopilot::run() { +void Autopilot::run() +{ this->routeInfo = this->navigation->getRouteInfo(); - switch (this->state) { - case State::InsufficientAccuracy: - this->askNavigationForOrder(); - return; + switch (this->state) + { + case State::InsufficientAccuracy: + this->askNavigationForOrder(); + return; - case State::NoRoute: - return; + case State::NoRoute: + return; - case State::None: - return; + case State::None: + return; - case State::NavigationStarted: - this->askNavigationForOrder(); - this->checkButtonInput(); - break; + case State::NavigationStarted: + this->askNavigationForOrder(); + this->checkButtonInput(); + break; - case State::GetToStartPoint: - ManualControl::run(); - this->askNavigationForOrder(); - if (this->routeInfo.currentPoint >= 2) - this->state = State::SelfDrivingAvailable; - break; + case State::GetToStartPoint: + ManualControl::run(); + this->askNavigationForOrder(); + if (this->routeInfo.currentPoint >= 2){ + this->state = State::SelfDrivingAvailable; + } + break; - case State::SelfDrivingAvailable: - ManualControl::run(); - this->askNavigationForOrder(); - this->checkButtonInput(); - break; + case State::SelfDrivingAvailable: + ManualControl::run(); + this->askNavigationForOrder(); + this->checkButtonInput(); + break; - case State::SelfDriving: - this->askNavigationForOrder(); - this->checkButtonInput(); - this->selfDriving(); - break; + case State::SelfDriving: + this->askNavigationForOrder(); + this->checkButtonInput(); + this->selfDriving(); + break; - case SelfDrivingRotate: - this->checkButtonInput(); - this->rotate(); - break; + case SelfDrivingRotate: + this->checkButtonInput(); + this->rotate(); + break; - case State::TargetReached: - if (this->loopMode) - this->restartLoop(); - break; - - default: - break; + case State::TargetReached: + if (this->loopMode){ + this->restartLoop(); + } + break; + + default: + break; } } -void Autopilot::restart() { +void Autopilot::restart() +{ this->init(); } -bool Autopilot::shouldUpdate() { - if (this->updateDisplay) { +bool Autopilot::shouldUpdate() +{ + if (this->updateDisplay) + { this->updateDisplay = false; return true; } return false; } -void Autopilot::testRotate(int16_t degree) { - if (!degree) +void Autopilot::testRotate(int16_t degree) +{ + if (!static_cast(degree)) + { return; + } this->courseCorrection.correction = degree; this->beginRotate(); } -void Autopilot::init() { +void Autopilot::init() +{ if (this->navigation->startNavigation()) - this->state = State::NavigationStarted; - else - this->state = State::NoRoute; - this->routeInfo = this->navigation->getRouteInfo(); - this->sensorData->getNtripClient()->setAutoReconnect(true); + { + this->state = State::NavigationStarted; + } + else + { + this->state = State::NoRoute; + } + this->routeInfo = this->navigation->getRouteInfo(); + this->sensorData->getNtripClient()->setAutoReconnect(true); - this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection, true); + this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection, true); - this->courseCorrection.correction = 0; - this->courseCorrection.distance = 0; - this->updateDisplay = true; + this->courseCorrection.correction = 0; + this->courseCorrection.distance = 0; + this->updateDisplay = true; } -void Autopilot::drive() { +void Autopilot::drive() +{ DrivingSpeeds speeds = {0, 0}; if (this->courseCorrection.distance >= this->minRemainingDistance) + { speeds.x = this->maxSpeeds.x; + } this->moveControl->setSpeeds(speeds); } -void Autopilot::beginRotate() { - if (this->state != State::SelfDrivingRotate) { +void Autopilot::beginRotate() +{ + if (this->state != State::SelfDrivingRotate) + { this->lastState = this->state; this->state = State::SelfDrivingRotate; this->rotationAimAzimuth = this->getSensorData()->getRealAzimuth() + this->courseCorrection.correction; @@ -143,35 +166,40 @@ void Autopilot::beginRotate() { DrivingSpeeds speeds = {0, 0}; if (this->courseCorrection.correction > 0) + { speeds.rot = -this->maxSpeeds.rot; + } else + { speeds.rot = this->maxSpeeds.rot; + } this->moveControl->setSpeeds(speeds); } } -void Autopilot::rotate() { - if (abs(this->getSensorData()->getRealAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct) { +void Autopilot::rotate() +{ + if (abs(this->getSensorData()->getRealAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct) + { this->endRotate(); return; } - if ((abs(this->getSensorData()->getRealAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct * 3) - && - ((this->courseCorrection.correction > 0 - && this->rotationAimAzimuth < this->getSensorData()->getRealAzimuth()) - || (this->courseCorrection.correction < 0 - && this->rotationAimAzimuth > this->getSensorData()->getRealAzimuth()))) + if ((abs(this->getSensorData()->getRealAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct * 3) && + ((this->courseCorrection.correction > 0 && this->rotationAimAzimuth < this->getSensorData()->getRealAzimuth()) || (this->courseCorrection.correction < 0 && this->rotationAimAzimuth > this->getSensorData()->getRealAzimuth()))) { this->endRotate(); std::cout << "Autopilot::rotate: Rover rotated too far" << std::endl; - } + } } -void Autopilot::endRotate() { +void Autopilot::endRotate() +{ if (this->state != State::SelfDrivingRotate) + { return; + } this->state = this->lastState; this->sensorData->getCalcCompass()->drivingDirectionChange(this->sensorData->getCurrentPos()); @@ -180,65 +208,85 @@ void Autopilot::endRotate() { this->moveControl->setDrivingStatus(MoveControl::Status::Drive); } -void Autopilot::checkButtonInput() { - if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action) - && millis() - this->lastAutopilotChangeMillis > this->autopilotChangeDelayMillis) { - - if (this->state == State::SelfDrivingAvailable) +void Autopilot::checkButtonInput() +{ + if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action) && millis() - this->lastAutopilotChangeMillis > this->autopilotChangeDelayMillis) + { + + if (this->state == State::SelfDrivingAvailable) + { this->state = State::SelfDriving; + } else if (this->state == State::SelfDriving || this->state == State::SelfDrivingRotate) + { this->state = State::SelfDrivingAvailable; + } else if (this->state == State::NavigationStarted) + { this->state = State::GetToStartPoint; + } this->updateDisplay = true; this->lastAutopilotChangeMillis = millis(); } } -void Autopilot::askNavigationForOrder() { +void Autopilot::askNavigationForOrder() +{ this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection); - switch (this->lastOrderStatus) { - case Navigation::Status::Complete: - this->state = State::TargetReached; - this->moveControl->setSpeed(0); - this->moveControl->setRotationSpeed(0); - break; - - case Navigation::Status::InsufficientAccuracy: - if (this->state == State::InsufficientAccuracy) - break; - this->lastState = this->state; - this->state = State::InsufficientAccuracy; - this->moveControl->setSpeed(0); - this->moveControl->setRotationSpeed(0); - break; + switch (this->lastOrderStatus) + { + case Navigation::Status::Complete: + this->state = State::TargetReached; + this->moveControl->setSpeed(0); + this->moveControl->setRotationSpeed(0); + break; - case Navigation::Status::Unchanged: - if (this->state == State::InsufficientAccuracy) - this->state = this->lastState; + case Navigation::Status::InsufficientAccuracy: + if (this->state == State::InsufficientAccuracy){ break; + } + this->lastState = this->state; + this->state = State::InsufficientAccuracy; + this->moveControl->setSpeed(0); + this->moveControl->setRotationSpeed(0); + break; - case Navigation::Status::Updated: - if (this->state == State::InsufficientAccuracy) - this->state = this->lastState; - break; - - default: - break; + case Navigation::Status::Unchanged: + if (this->state == State::InsufficientAccuracy){ + this->state = this->lastState; + } + break; + + case Navigation::Status::Updated: + if (this->state == State::InsufficientAccuracy){ + this->state = this->lastState; + } + break; + + default: + break; } } -void Autopilot::selfDriving() { +void Autopilot::selfDriving() +{ if (this->state != State::SelfDriving) + { return; + } if (abs(this->courseCorrection.correction) >= this->maxCourseDeviationBeforeAct) + { this->beginRotate(); + } else + { this->drive(); + } } -void Autopilot::restartLoop() { +void Autopilot::restartLoop() +{ this->navigation->startNavigation(); this->state = State::SelfDriving; this->routeInfo = this->navigation->getRouteInfo(); @@ -246,7 +294,8 @@ void Autopilot::restartLoop() { this->updateDisplay = true; } -void Autopilot::afterActivate() { +void Autopilot::afterActivate() +{ this->setInputMode(ManualControl::InputMode::Digital); this->directionChangeSignal = new DirectionChangeSignal(this); this->setDirectionChangeCallback(this->directionChangeSignal); diff --git a/src/driveModi/Modi/Autopilot/autopilot.h b/src/driveModi/Modi/Autopilot/autopilot.h index c6a81e4..6a5efc3 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.h +++ b/src/driveModi/Modi/Autopilot/autopilot.h @@ -41,14 +41,6 @@ class Autopilot : public ManualControl { TargetReached }; - /** - * @brief Construct a new Autopilot object - * - * @param moveControl for ManualControl - * @param navigation for route instructions - */ - Autopilot(); - /** * @brief Destroy the Autopilot object * @@ -104,13 +96,13 @@ class Autopilot : public ManualControl { void restartLoop(); void afterActivate() override; - Navigation* navigation; - CourseCorrection courseCorrection; - RouteInfo routeInfo; + Navigation* navigation = nullptr; + CourseCorrection courseCorrection{0, 0}; + RouteInfo routeInfo{0, 0}; State state = State::None; State lastState = State::None; Navigation::Status lastOrderStatus; - DirectionChangeSignal* directionChangeSignal; + DirectionChangeSignal* directionChangeSignal = nullptr; bool updateDisplay = false; bool loopMode = false; @@ -119,7 +111,7 @@ class Autopilot : public ManualControl { uint16_t autopilotChangeDelayMillis = 500; uint32_t lastAutopilotChangeMillis = 0; - int16_t rotationAimAzimuth; + int16_t rotationAimAzimuth = 0; double minRemainingDistance = 0.25; }; diff --git a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp index 5dcdadd..81a970e 100644 --- a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp +++ b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp @@ -13,10 +13,10 @@ void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) { - if (caliCompass) { + if (static_cast(caliCompass)) { this->caliCompass = caliCompass; this->addChildComponent(this->caliCompass); - } else if (this->caliCompass) { + } else if (static_cast(this->caliCompass)) { this->removeChildComponent(this->caliCompass); this->caliCompass = caliCompass; } diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp index cb58e4e..13c531a 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp @@ -4,27 +4,32 @@ * @brief Contains the implementation of the class CaptureRoute * @version 0.1 * @date 2022-02-15 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "driveModi/Modi/CaptureRoute/captureRoute.h" #include "captureRoute.h" -CaptureRoute::~CaptureRoute() { - if (this->navigation) - delete this->navigation; +CaptureRoute::~CaptureRoute() +{ + delete this->navigation; - if (this->sensorData->getNtripClient()) + if (static_cast(this->sensorData->getNtripClient())) + { this->sensorData->getNtripClient()->setActivated(false); + } } -void CaptureRoute::run() { +void CaptureRoute::run() +{ ManualControl::run(); - if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) { + if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) + { this->status = this->navigation->addCurrentPosToRoute(); - if (this->status == Navigation::Status::Updated) { + if (this->status == Navigation::Status::Updated) + { this->lastSavedPoint = this->navigation->getCurrentPosition(); this->routeInfo = navigation->getRouteInfo(); this->updateDisplay = true; @@ -32,21 +37,27 @@ void CaptureRoute::run() { } } -void CaptureRoute::afterActivate() { +void CaptureRoute::afterActivate() +{ this->navigation = new Navigation(this->sensorData); - this->navigation->getRoute()->clear(); - this->sensorData->getNtripClient()->setAutoReconnect(true); - this->routeInfo = navigation->getRouteInfo(); + this->navigation->getRoute()->clear(); + this->sensorData->getNtripClient()->setAutoReconnect(true); + this->routeInfo = navigation->getRouteInfo(); } -double CaptureRoute::getDistanceToLastPoint() const { +double CaptureRoute::getDistanceToLastPoint() const +{ if (!this->lastSavedPoint.isInit()) + { return 0; + } return this->lastSavedPoint.distanceTo(this->navigation->getCurrentPosition()); } -bool CaptureRoute::shouldUpdate() { - if (this->updateDisplay) { +bool CaptureRoute::shouldUpdate() +{ + if (this->updateDisplay) + { this->updateDisplay = false; return true; } diff --git a/src/driveModi/Modi/ManualControl/manualControl.cpp b/src/driveModi/Modi/ManualControl/manualControl.cpp index 8a81978..de54097 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.cpp +++ b/src/driveModi/Modi/ManualControl/manualControl.cpp @@ -4,67 +4,89 @@ * @brief Implementation of the class manualControl.h * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "manualControl.h" -void ManualControl::run() { - switch (this->inputMode) { - case InputMode::Analog : - this->analogControl(); - break; +void ManualControl::run() +{ + switch (this->inputMode) + { + case InputMode::Analog: + this->analogControl(); + break; - case InputMode::Digital : - this->digitalControl(); - break; - - default: - break; + case InputMode::Digital: + this->digitalControl(); + break; + + default: + break; } } -void ManualControl::switchInputMode() { +void ManualControl::switchInputMode() +{ this->inputMode = (this->inputMode == InputMode::Analog) ? InputMode::Digital : InputMode::Analog; } -void ManualControl::analogControl() { +void ManualControl::analogControl() +{ // Have to be int16_t to avoid overflow (int8_t = 255 - 127 = -128) - int16_t x = this->input->x - 127; - int16_t y = this->input->y - 127; - + const int16_t xAxis = this->input->x - 127; + const int16_t yAxis = this->input->y - 127; double value_per_step = this->maxSpeeds.x * 2 / UINT8_MAX; - this->moveControl->setSpeed(-x * value_per_step); + this->moveControl->setSpeed(-xAxis * value_per_step); value_per_step = this->maxSpeeds.rot * 2 / UINT8_MAX; - this->moveControl->setRotationSpeed(y * value_per_step); + this->moveControl->setRotationSpeed(yAxis * value_per_step); } -void ManualControl::digitalControl() { - int16_t y = this->input->x - 127; - int16_t x = this->input->y - 127; +void ManualControl::digitalControl() +{ + static constexpr uint8_t deadzone = 120; + const int16_t yAxis = this->input->x - 127; + const int16_t xAxis = this->input->y - 127; - if (y > 120) + if (yAxis > deadzone) + { this->moveControl->setSpeed(-this->maxSpeeds.x); - else if (y < -120) + } + else if (yAxis < -deadzone) + { this->moveControl->setSpeed(this->maxSpeeds.rot); + } else + { this->moveControl->setSpeed(0); + } - if (x > 120) + if (xAxis > deadzone) + { this->moveControl->setRotationSpeed(this->maxSpeeds.rot); - else if (x < -120) + } + else if (xAxis < -deadzone) + { this->moveControl->setRotationSpeed(-this->maxSpeeds.rot); + } else + { this->moveControl->setRotationSpeed(0); + } - if (this->directionChangeWrapper && (x > 120 || x < -120)) + if (static_cast(this->directionChangeWrapper) && (xAxis > deadzone || xAxis < -deadzone)) + { this->lastLoopTurned = true; - else if (this->lastLoopTurned) { - if (this->directionChangeWrapper) + } + else if (this->lastLoopTurned) + { + if (static_cast(this->directionChangeWrapper)) + { this->directionChangeWrapper->action(); + } this->lastLoopTurned = false; - } + } } diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index 2c03b0a..9e26897 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -4,20 +4,24 @@ * @brief Contains the implementation of the class TestMode. * @version 0.1 * @date 2022-09-08 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "testMode.h" -void TestMode::run() { - if (this->maneuver == Maneuver::Turn) { +void TestMode::run() +{ + if (this->maneuver == Maneuver::Turn) + { uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth()); - if (delta > this->degree) + if (delta > this->degree) { this->abort = true; + } } - if (this->busy && millis() - this->actionStart > this->maneuverTime || this->abort) { + if (this->busy && millis() - this->actionStart > this->maneuverTime || this->abort) + { this->busy = false; this->abort = false; this->moveControl->setDrivingStatus(MoveControl::Status::Stop); @@ -25,62 +29,76 @@ void TestMode::run() { } } -bool TestMode::drive(int16_t cm, int16_t degree) { - if (this->busy) +bool TestMode::drive(int16_t cmDistance, int16_t degree) +{ + if (this->busy){ return false; + } this->actionStart = millis(); this->moveControl->setDrivingStatus(MoveControl::Status::Drive); - if (cm == 0) { - //Only left or right + if (cmDistance == 0) + { + // Only left or right this->moveControl->setSpeed(0); - if (degree < 0) + if (degree < 0){ this->moveControl->setRotationSpeed(-this->maxSpeeds.rot); - else if (degree > 0) + } + else if (degree > 0){ this->moveControl->setRotationSpeed(this->maxSpeeds.rot); - + } + this->azimuth = this->getSensorData()->getRealAzimuth(); this->degree = degree; this->maneuverTime = 5 * 1000; this->busy = true; return true; - - } else if (degree == 0) { - //Only forward or backward + } + if (degree == 0) + { + // Only forward or backward this->moveControl->setRotationSpeed(0); - if (cm < 0) + if (cmDistance < 0){ this->moveControl->setSpeed(-this->maxSpeeds.x); - else if (cm > 0) + } + else if (cmDistance > 0){ this->moveControl->setSpeed(this->maxSpeeds.x); - - this->maneuverTime = (uint32_t) (((double) abs(cm) / 100.0) / this->maxSpeeds.x) * 1000; + } + + this->maneuverTime = static_cast(((abs(cmDistance) / 100.0) / this->maxSpeeds.x) * 1000); this->busy = true; this->maneuver = Maneuver::Drive; return true; - } else { - //forward or backward and left or right - // TODO: Calculate roationspeed - if (cm < 0) + } + else + { + // forward or backward and left or right + // TODO: Calculate roationspeed + if (cmDistance < 0){ this->moveControl->setSpeed(-this->maxSpeeds.x); - else if (cm > 0) + } + else if (cmDistance > 0){ this->moveControl->setSpeed(this->maxSpeeds.x); - - this->maneuverTime = (uint32_t) (((double) cm / 100.0) / this->maxSpeeds.x) * 1000; + } + + this->maneuverTime = static_cast(((cmDistance / 100.0) / this->maxSpeeds.x) * 1000); this->busy = true; this->maneuver = Maneuver::Drive; return true; } - this->moveControl->setDrivingStatus(MoveControl::Status::Stop); + this->moveControl->setDrivingStatus(MoveControl::Status::Stop); return false; } -bool TestMode::leftEngine(int16_t powerPercentage, int16_t seconds) { - if (this->engineInit(powerPercentage, seconds)) { +bool TestMode::leftEngine(int16_t powerPercentage, int16_t seconds) +{ + if (this->engineInit(powerPercentage, seconds)) + { this->moveControl->setRawPowerLeft(powerPercentage); this->maneuver = Maneuver::LeftEngine; std::cout << "TestMode::leftEngine" << std::endl; @@ -89,8 +107,10 @@ bool TestMode::leftEngine(int16_t powerPercentage, int16_t seconds) { return false; } -bool TestMode::rightEngine(int16_t powerPercentage, int16_t seconds) { - if (this->engineInit(powerPercentage, seconds)) { +bool TestMode::rightEngine(int16_t powerPercentage, int16_t seconds) +{ + if (this->engineInit(powerPercentage, seconds)) + { this->moveControl->setRawPowerRight(powerPercentage); this->maneuver = Maneuver::RightEngine; return true; @@ -98,8 +118,10 @@ bool TestMode::rightEngine(int16_t powerPercentage, int16_t seconds) { return false; } -bool TestMode::bothEngine(int16_t powerPercentage, int16_t seconds) { - if (this->engineInit(powerPercentage, seconds)) { +bool TestMode::bothEngine(int16_t powerPercentage, int16_t seconds) +{ + if (this->engineInit(powerPercentage, seconds)) + { this->moveControl->setRawPowerLeft(powerPercentage); this->moveControl->setRawPowerRight(powerPercentage); this->maneuver = Maneuver::BothEngine; @@ -108,23 +130,30 @@ bool TestMode::bothEngine(int16_t powerPercentage, int16_t seconds) { return false; } -void TestMode::abortManeuver() { +void TestMode::abortManeuver() +{ this->abort = true; } -uint8_t TestMode::getRemainingManeuverTime() const { - if (this->busy) - return (uint8_t) ((this->maneuverTime - (millis() - this->actionStart)) / 1000); +uint8_t TestMode::getRemainingManeuverTime() const +{ + if (this->busy){ + return static_cast((this->maneuverTime - (millis() - this->actionStart)) / 1000); + } return 0; } -bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds) { - if (this->busy) +bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds) +{ + if (this->busy){ return false; - if (powerPercentage > 100 || powerPercentage < -100) + } + if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage){ return false; - if (seconds < 0) + } + if (seconds < 0){ return false; + } this->actionStart = millis(); this->moveControl->setDrivingStatus(MoveControl::Status::Raw); diff --git a/src/driveModi/Modi/TestMode/testMode.h b/src/driveModi/Modi/TestMode/testMode.h index 1480e36..bb49794 100644 --- a/src/driveModi/Modi/TestMode/testMode.h +++ b/src/driveModi/Modi/TestMode/testMode.h @@ -4,11 +4,11 @@ * @brief Contains a class to test different functions from the rover. * @version 0.1 * @date 2022-09-08 - * + * * @copyright Copyright (c) 2022 - * + * */ -#ifndef TEST_MODE_H +#ifndef TEST_MODE_H #define TEST_MODE_H #include @@ -16,97 +16,100 @@ #include "moveControl.h" #include "driveModi/driveModi.h" - /** * @brief Test different functions from the rover. - * + * * You can test engine, engine controller, light and speed meter. */ -class TestMode : public DriveModi { - public: - /** - * @brief Different states to test the engine - * - */ - enum Maneuver { - None, - LeftEngine, - RightEngine, - BothEngine, - Turn, - Drive - }; +class TestMode : public DriveModi +{ +public: + /** + * @brief Different states to test the engine + * + */ + enum Maneuver + { + None, + LeftEngine, + RightEngine, + BothEngine, + Turn, + Drive + }; - bool drive(int16_t cm = 0, int16_t degree = 0); + bool drive(int16_t cmDistance = 0, int16_t degree = 0); - /** - * @brief Sets the left Engine to a specific power value. - * - * This start a maneuver with the given time. - * - * @param powerPercentage from 0% to 100% - * @param seconds time to run the engine - * @return true success - * @return false failure - */ - bool leftEngine(int16_t powerPercentage, int16_t seconds); + /** + * @brief Sets the left Engine to a specific power value. + * + * This start a maneuver with the given time. + * + * @param powerPercentage from 0% to 100% + * @param seconds time to run the engine + * @return true success + * @return false failure + */ + bool leftEngine(int16_t powerPercentage, int16_t seconds); - /** - * @brief See leftEngine - * - * @param powerPercentage - * @param seconds - * @return true - * @return false - */ - bool rightEngine(int16_t powerPercentage, int16_t seconds); + /** + * @brief See leftEngine + * + * @param powerPercentage + * @param seconds + * @return true + * @return false + */ + bool rightEngine(int16_t powerPercentage, int16_t seconds); - /** - * @brief See leftEngine - * - * @param powerPercentage - * @param seconds - * @return true - * @return false - */ - bool bothEngine(int16_t powerPercentage, int16_t seconds); + /** + * @brief See leftEngine + * + * @param powerPercentage + * @param seconds + * @return true + * @return false + */ + bool bothEngine(int16_t powerPercentage, int16_t seconds); - /** - * @brief Abort the running maneuver. - * - * Stops all movement. This is the only possibility to cancel a maneuver - * before the time is up. - */ - void abortManeuver(); + /** + * @brief Abort the running maneuver. + * + * Stops all movement. This is the only possibility to cancel a maneuver + * before the time is up. + */ + void abortManeuver(); - uint8_t getRemainingManeuverTime() const; + uint8_t getRemainingManeuverTime() const; - /** - * @brief Returns true if a maneuver is running - * - * @return true - * @return false - */ - bool getBusy() const { return this->busy; } - Maneuver getManeuver() const { return this->maneuver; } - Speedometer* getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); } - Speedometer* getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); } + /** + * @brief Returns true if a maneuver is running + * + * @return true + * @return false + */ + bool getBusy() const { return this->busy; } + Maneuver getManeuver() const { return this->maneuver; } + Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); } + Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); } - private: - void run() override; - bool engineInit(int16_t powerPercentage, int16_t seconds); +private: + void run() override; + bool engineInit(int16_t powerPercentage, int16_t seconds); - Maneuver maneuver = Maneuver::None; - int16_t maneuverValueOne = 0; - int16_t maneuverValueTwo = 0; + Maneuver maneuver = Maneuver::None; + int16_t maneuverValueOne = 0; + int16_t maneuverValueTwo = 0; - bool busy = false; - bool abort = false; - - uint16_t azimuth; - int16_t degree; - uint32_t maneuverTime = 0; - uint32_t actionStart = 0; + bool busy = false; + bool abort = false; + + uint16_t azimuth; + int16_t degree; + uint32_t maneuverTime = 0; + uint32_t actionStart = 0; + + static constexpr int8_t maxPercentage = 100; }; #endif // TEST_MODE_H diff --git a/src/driveModi/driveManager.cpp b/src/driveModi/driveManager.cpp index aa371b4..7b62f3c 100644 --- a/src/driveModi/driveManager.cpp +++ b/src/driveModi/driveManager.cpp @@ -4,44 +4,46 @@ * @brief Implementation of the class DriveManager * @version 0.1 * @date 2021-12-14 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "driveModi/driveManager.h" -DriveManager::DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input) { - this->driveModiParams.input = input; - this->driveModiParams.moveControl = moveControl; - this->driveModiParams.sensorData = sensorData; - +DriveManager::DriveManager(MoveControl *moveControl, const SensorData *sensorData, const ControlPadInput *input) + : driveModiParams{moveControl, input, sensorData} +{ this->init(); } -DriveManager::DriveManager(DriveModiParams params){ - this->driveModiParams = params; - +DriveManager::DriveManager(DriveModiParams params) + : driveModiParams{params} +{ this->init(); } -void DriveManager::changeModus(DriveModi* modus) { - if (this->currentModusPtr) { +void DriveManager::changeModus(DriveModi *modus) +{ + if (static_cast(this->currentModusPtr)) + { this->removeChildComponent(this->currentModusPtr); delete this->currentModusPtr; this->currentModusPtr = nullptr; } - + this->currentModusPtr = modus; - if (this->currentModusPtr) { + if (static_cast(this->currentModusPtr)) + { this->currentModusPtr->activate(this->driveModiParams); this->currentModusPtr->setSpeeds(this->drivingSpeeds); this->addChildComponent(this->currentModusPtr); } } -void DriveManager::init() { +void DriveManager::init() +{ this->addChildComponent(this->driveModiParams.moveControl); this->activateOnlyChilds(); } diff --git a/src/driveModi/driveModi.cpp b/src/driveModi/driveModi.cpp index 1cbed00..ef573d3 100644 --- a/src/driveModi/driveModi.cpp +++ b/src/driveModi/driveModi.cpp @@ -1,9 +1,5 @@ #include "driveModi.h" -DriveModi::DriveModi() { - this->loopDelay = 0; -} - DriveModi::~DriveModi() { this->moveControl->setSpeed(0); this->moveControl->setRotationSpeed(0); @@ -26,6 +22,6 @@ void DriveModi::activate(DriveModiParams params){ void DriveModi::init() { this->moveControl->setDrivingStatus(MoveControl::Status::Drive); - this->loopDelay = 40; + this->loopDelay = DriveModi::defaultDelay; this->afterActivate(); } diff --git a/src/driveModi/driveModi.h b/src/driveModi/driveModi.h index adc9db5..daa6749 100644 --- a/src/driveModi/driveModi.h +++ b/src/driveModi/driveModi.h @@ -31,7 +31,6 @@ struct DriveModiParams { */ class DriveModi : public Component { public: - DriveModi(); virtual ~DriveModi(); const SensorData* getSensorData() const { return this->sensorData; } @@ -46,12 +45,14 @@ class DriveModi : public Component { protected: virtual void afterActivate() {} - MoveControl *moveControl; + MoveControl *moveControl = nullptr; DrivingSpeeds maxSpeeds = {1, 7}; - const ControlPadInput* input; - const SensorData* sensorData; + const ControlPadInput* input = nullptr; + const SensorData* sensorData = nullptr; private: - void init(); + void init(); + + static constexpr uint8_t defaultDelay = 40; }; #endif // DRIVEMODI_H diff --git a/src/main.cpp b/src/main.cpp index e819e63..3431a27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,15 +2,15 @@ * @file main.cpp * @author Alexander Klein (alex@kleiax.de) * @brief The main file. - * + * * Sets up Network stuff, PS3-Controller, Menu and Lcd * Handles Controller Input - * + * * @version 0.1 * @date 2022-02-15 - * + * * @copyright Copyright (c) 2022 - * + * */ #include @@ -50,61 +50,71 @@ #include "SpecialMenus/CalibrateBattery/menuCalibrateBattery.h" MoveControl moveController; -Network* network; -DriveManager* driveManager; -Menu* main_m; -LiquidCrystal_I2C* lcd; -LcdWrapper* lcdWrapper; -OutputBuf* outputBuf; -DebugMqtt* debugMqtt = nullptr; -Battery* mainBattery; -SPIClass* spiPort; -SensorData* sensorData; -ControlPad* controlPad; +Network *network; +DriveManager *driveManager; +Menu *main_m; +LiquidCrystal_I2C *lcd; +LcdWrapper *lcdWrapper; +OutputBuf *outputBuf; +DebugMqtt *debugMqtt = nullptr; +Battery *mainBattery; +SPIClass *spiPort; +SensorData *sensorData; +ControlPad *controlPad; -bool wifiIsActive; +constexpr uint16_t displayUpdateDelay = 500; -void i2cScanner(void); -void makeMenu(void); -void restart(void); -void receiveCallback (const uint8_t * mac, const uint8_t *incomingData, int len); -void sendCallback (const uint8_t *mac_addr, esp_now_send_status_t status); -void lcdWrapperCallback (const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows); -NetworkAdresses setIPs(void); +void i2cScanner(); +void makeMenu(); +void restart(); +void receiveCallback(const uint8_t *mac, const uint8_t *incomingData, int len); +void sendCallback(const uint8_t *mac_addr, esp_now_send_status_t status); +void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows); +NetworkAdresses setIPs(); - -void setup() { - Serial.begin(115200); +void setup() +{ + Serial.begin(Settings::baudRate); // DebugTimes::setConsolOutput(true); DebugTimes setupTime; spiPort = new SPIClass(HSPI); spiPort->begin(PinNumbers::spiSck, PinNumbers::spiCipo, PinNumbers::spiCopi, PinNumbers::gnssSpiCs); - mainBattery = new Battery(35); + mainBattery = new Battery(PinNumbers::battery); controlPad = new ControlPad(); - Wire.begin(21, 19); - Wire.setClock(400000); + Wire.begin(PinNumbers::sda, PinNumbers::scl); + Wire.setClock(Settings::i2cSpeed); i2cScanner(); - lcd = new LiquidCrystal_I2C(0x3F,16,2); + lcd = new LiquidCrystal_I2C(0x3F, 16, 2); lcd->init(); lcd->clear(); lcd->noBacklight(); - network = new Network(NetworkConfig::ssid, NetworkConfig::password, setIPs()); + network = new Network(static_cast(NetworkConfig::ssid), + static_cast(NetworkConfig::password), + setIPs()); network->activateEspNow(receiveCallback, sendCallback); - if (NetworkConfig::mqtt) { - if (network->activateMqtt(MqttConfig::user, MqttConfig::password)) { + if (NetworkConfig::mqtt) + { + if (network->activateMqtt(static_cast(MqttConfig::user), + static_cast(MqttConfig::password))) + { DebugMqtt::init(network->getMqttClient(), Loglevel::debug); debugMqtt = new DebugMqtt("Console"); outputBuf = new OutputBuf(debugMqtt); outputBuf->activateMqtt(true); - } else { + } + else + { outputBuf = new OutputBuf(); } - } else + } + else + { outputBuf = new OutputBuf(); + } std::cout.rdbuf(outputBuf); std::cout << "Welcome to Kleiax-Rover" << std::endl; @@ -115,13 +125,19 @@ void setup() { sensorData = new SensorData(); sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs); sensorData->enableRealCompass(); - sensorData->enableNtrip(NtripConfig::host, NtripConfig::port, NtripConfig::mountPoint, NtripConfig::user, NtripConfig::password); + sensorData->enableNtrip(static_cast(NtripConfig::host), + NtripConfig::port, + static_cast(NtripConfig::mountPoint), + static_cast(NtripConfig::user), + static_cast(NtripConfig::password)); // sensorData->enableGyroskop(); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); char wifiIndicator = 'X'; if (network->isWifiConnected()) + { wifiIndicator = '-'; + } lcd->backlight(); lcd->printf("%c Kleiax-Rover %c", wifiIndicator, wifiIndicator); lcd->setCursor(0, 1); @@ -134,7 +150,8 @@ void setup() { setupTime.stopConsol("Setup"); } -void loop() { +void loop() +{ network->loop(); sensorData->loop(); driveManager->loop(); @@ -143,86 +160,113 @@ void loop() { lcdWrapper->loop(); mainBattery->loop(); - // new Value ervery 0.5s - if (mainBattery->isNewValue()) { + // new Value ervery 0.5s + if (mainBattery->isNewValue()) + { static uint8_t batteryLowCounter = 0; - if (mainBattery->isBatteryLow(10)) + static constexpr uint8_t minVoltage = 10; + if (mainBattery->isBatteryLow(minVoltage)) + { batteryLowCounter++; + } else + { batteryLowCounter = 0; + } - if (batteryLowCounter >= 10) { + if (batteryLowCounter >= 10) + { moveController.emergencyStop(); - uint16_t voltage = (uint16_t) (mainBattery->getBatteryVoltage() * 100); + const auto voltage = static_cast(mainBattery->getBatteryVoltage() * 100); lcd->setCursor(0, 0); lcd->printf("Low Battery: %u", voltage); lcd->setCursor(0, 1); lcd->print("Please turn off."); - - while (true); + + while (true) + { + } } } } -void i2cScanner() { +void i2cScanner() +{ + constexpr uint8_t checkForLength = 16; + constexpr uint8_t maxAdresses = UINT8_MAX / 2; std::cout << "\nI2C Scanner" << std::endl; - byte error, address; - int nDevices; + byte error = 0; + byte address = 0; + int nDevices = 0; std::cout << "Scanning..." << std::endl; - nDevices = 0; - for(address = 1; address < 127; address++ ) { + for (address = 1; address < maxAdresses; address++) + { Wire.beginTransmission(address); error = Wire.endTransmission(); - if (error == 0) { + if (error == 0) + { std::cout << "I2C device found at address 0x"; - if (address<16) + if (address < checkForLength) + { std::cout << "0"; - std::cout << std::hex << (int) address << std::dec << std::endl; + } + std::cout << std::hex << static_cast(address) << std::dec << std::endl; // std::cout << (int) address << std::endl; nDevices++; } - else if (error==4) { + else if (error == 4) + { std::cout << "Unknow error at address 0x"; - if (address<16) + if (address < checkForLength) + { std::cout << "0"; - std::cout << std::hex << (int) address << std::dec << std::endl; - } + } + std::cout << std::hex << static_cast(address) << std::dec << std::endl; + } } if (nDevices == 0) - std::cout << "No I2C devices found\n" << std::endl; + { + std::cout << "No I2C devices found\n" + << std::endl; + } else - std::cout << "done\n" << std::endl; + { + std::cout << "done\n" + << std::endl; + } } -void makeMenu() { - auto dummy = []() { - std::cout << "Dummy in Action" <setLcd(lcdWrapper); - auto mode_m = new Menu(); - auto set_m = new Menu(); - auto pid_m = new Menu(); - auto pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0))); - auto pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); - auto speed_m = new MenuIntInput(2, new MenuSpeed(driveManager->getDrivingSpeedsRef())); - auto man_m = new MenuManualControl(driveManager); - auto cap_m = new MenuCaptureRoute(driveManager); - auto auto_m = new MenuAutopilot(driveManager); - auto testM_m = new MenuTestMode(driveManager); - auto comp_m = new MenuCalibrateCompass(driveManager); - auto sys_m = new MenuSysteminformation(mainBattery); - auto sen_m = new MenuSensorData(sensorData); - //TODO: Wie bekommt jeder die dumme Route? - auto rout_m = new MenuRoute(new Route()); - auto bat_m = new MenuCalibrateBattery(mainBattery); + auto *mode_m = new Menu(); + auto *set_m = new Menu(); + auto *pid_m = new Menu(); + auto *pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0))); + auto *pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); + auto *speed_m = new MenuIntInput(2, new MenuSpeed(driveManager->getDrivingSpeedsRef())); + auto *man_m = new MenuManualControl(driveManager); + auto *cap_m = new MenuCaptureRoute(driveManager); + auto *auto_m = new MenuAutopilot(driveManager); + auto *testM_m = new MenuTestMode(driveManager); + auto *comp_m = new MenuCalibrateCompass(driveManager); + auto *sys_m = new MenuSysteminformation(mainBattery); + auto *sen_m = new MenuSensorData(sensorData); + // TODO: Wie bekommt jeder die dumme Route? + auto *rout_m = new MenuRoute(new Route()); + auto *bat_m = new MenuCalibrateBattery(mainBattery); - auto_m->setUpdateDelay(1000); - sys_m->setUpdateDelay(1500); - sen_m->setUpdateDelay(500); + auto_m->setUpdateDelay(displayUpdateDelay); + sys_m->setUpdateDelay(displayUpdateDelay); + sen_m->setUpdateDelay(displayUpdateDelay); // Entry for the main menu main_m->addEntry(new MenuAction("Mode", mode_m)); @@ -253,14 +297,14 @@ void makeMenu() { // Other config pidl_m->setMinMax(0, UINT8_MAX); - pidl_m->setEntry(0, "P-Part", (uint8_t) moveController.getPID(0)->GetKp()); - pidl_m->setEntry(1, "I-Part", (uint8_t) moveController.getPID(0)->GetKi()); - pidl_m->setEntry(2, "D-Part", (uint8_t) moveController.getPID(0)->GetKd()); + pidl_m->setEntry(0, "P-Part", static_cast(moveController.getPID(0)->GetKp())); + pidl_m->setEntry(1, "I-Part", static_cast(moveController.getPID(0)->GetKi())); + pidl_m->setEntry(2, "D-Part", static_cast(moveController.getPID(0)->GetKd())); pidr_m->setMinMax(0, UINT8_MAX); - pidr_m->setEntry(0, "P-Part", (uint8_t) moveController.getPID(1)->GetKp()); - pidr_m->setEntry(1, "I-Part", (uint8_t) moveController.getPID(1)->GetKi()); - pidr_m->setEntry(2, "D-Part", (uint8_t) moveController.getPID(1)->GetKd()); + pidr_m->setEntry(0, "P-Part", static_cast(moveController.getPID(1)->GetKp())); + pidr_m->setEntry(1, "I-Part", static_cast(moveController.getPID(1)->GetKi())); + pidr_m->setEntry(2, "D-Part", static_cast(moveController.getPID(1)->GetKd())); speed_m->setMinMax(5, UINT8_MAX); speed_m->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10); @@ -271,42 +315,56 @@ void makeMenu() { controlPad->setMenuControl(main_m); } -void restart() { +void restart() +{ lcdWrapper->clear(); lcdWrapper->setCursor(0, 0); lcdWrapper->print("Rebooting ..."); ESP.restart(); } -void receiveCallback (const uint8_t * mac, const uint8_t *incomingData, int len) { +void receiveCallback(const uint8_t *mac, const uint8_t *incomingData, int len) +{ if (len != sizeof(ControlPadInput)) + { return; + } controlPad->insertData(incomingData); } -void sendCallback (const uint8_t *mac_addr, esp_now_send_status_t status) { +void sendCallback(const uint8_t *mac_addr, esp_now_send_status_t status) +{ if (status != ESP_NOW_SEND_SUCCESS) + { std::cout << "sendCallback - Delivery Fail" << std::endl; + } } -void lcdWrapperCallback (const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows) { +void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows) +{ if (!controlPad->isControlPadConnected()) + { return; + } + + const esp_err_t result = esp_now_send(network->getBroadcastAddress(), reinterpret_cast(data), lines * rows); - esp_err_t result = esp_now_send(network->getBroadcastAddress(), (uint8_t *) data, lines * rows); - if (result != ESP_OK) + { Serial.println("Error sending the data"); + } } -NetworkAdresses setIPs() { +NetworkAdresses setIPs() +{ NetworkAdresses adresses; - adresses.localIP.fromString(NetworkConfig::ip); - adresses.subnet.fromString(NetworkConfig::subnet); - adresses.gateway.fromString(NetworkConfig::gateway); - adresses.dnsServer.fromString(NetworkConfig::dns); - if (NetworkConfig::mqtt) { - adresses.mqttServer.fromString(MqttConfig::server); + adresses.localIP.fromString(static_cast(NetworkConfig::ip)); + adresses.subnet.fromString(static_cast(NetworkConfig::subnet)); + adresses.gateway.fromString(static_cast(NetworkConfig::gateway)); + adresses.dnsServer.fromString(static_cast(NetworkConfig::dns)); + if (NetworkConfig::mqtt) + { + adresses.mqttServer.fromString(static_cast(MqttConfig::server)); adresses.mqttPort = MqttConfig::port; } diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 7fd06a5..3f9fce5 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -4,41 +4,40 @@ * @brief Contains an implementation of the class MoveControl * @version 0.1 * @date 2022-02-15 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "moveControl.h" -MoveControl::MoveControl() { - this->loopDelay = 20; - this->left_motor = new MotorControl(); - this->right_motor = new MotorControl(); - this->left_speedometer = new Speedometer(PinNumbers::LeftMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps); - this->right_speedometer = new Speedometer(PinNumbers::RightMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps); - - this->left_pid = new PID( &this->wheelspeed_left, - &this->left_pid_out, - &this->wheelspeed_left_target, - Settings::Pid::Left::P, - Settings::Pid::Left::I, - Settings::Pid::Left::D, - DIRECT); - this->right_pid = new PID( &this->wheelspeed_right, - &this->right_pid_out, - &this->wheelspeed_right_target, - Settings::Pid::Right::P, - Settings::Pid::Right::I, - Settings::Pid::Right::D, - DIRECT); - +MoveControl::MoveControl() + : Component(MoveControl::loopDelay), + left_motor{new MotorControl()}, + right_motor{new MotorControl()}, + left_speedometer{new Speedometer(PinNumbers::LeftMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, + right_speedometer{new Speedometer(PinNumbers::RightMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, + left_pid{new PID(&this->wheelspeed_left, + &this->left_pid_out, + &this->wheelspeed_left_target, + Settings::Pid::Left::P, + Settings::Pid::Left::I, + Settings::Pid::Left::D, + DIRECT)}, + right_pid{new PID(&this->wheelspeed_right, + &this->right_pid_out, + &this->wheelspeed_right_target, + Settings::Pid::Right::P, + Settings::Pid::Right::I, + Settings::Pid::Right::D, + DIRECT)} +{ this->left_pid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax); this->left_pid->SetSampleTime(Settings::Pid::sampleTime); this->left_pid->SetMode(AUTOMATIC); this->right_pid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax); this->right_pid->SetSampleTime(Settings::Pid::sampleTime); - this->right_pid->SetMode(AUTOMATIC); + this->right_pid->SetMode(AUTOMATIC); this->left_motor->init(PinNumbers::LeftMotor::pwm, PinNumbers::LeftMotor::pmwChannel, PinNumbers::LeftMotor::dir1, PinNumbers::LeftMotor::dir2); this->right_motor->init(PinNumbers::RightMotor::pwm, PinNumbers::RightMotor::pmwChannel, PinNumbers::RightMotor::dir1, PinNumbers::RightMotor::dir2); @@ -46,10 +45,11 @@ MoveControl::MoveControl() { this->addChildComponent(this->left_motor); this->addChildComponent(this->right_motor); this->addChildComponent(this->left_speedometer); - this->addChildComponent(this->right_speedometer); + this->addChildComponent(this->right_speedometer); } -MoveControl::~MoveControl() { +MoveControl::~MoveControl() +{ this->left_motor->emergencyStop(); this->right_motor->emergencyStop(); @@ -59,10 +59,10 @@ MoveControl::~MoveControl() { delete this->right_speedometer; delete this->left_pid; delete this->right_pid; - } -void MoveControl::run() { +void MoveControl::run() +{ this->updateCurrentWheelSpeed(); this->calcTargetWheelSpeed(); @@ -72,7 +72,8 @@ void MoveControl::run() { this->regulateMotors(); } -void MoveControl::setDrivingStatus(Status status) { +void MoveControl::setDrivingStatus(Status status) +{ this->setSpeed(0); this->setRotationSpeed(0); this->setRawPowerLeft(0); @@ -97,7 +98,8 @@ void MoveControl::setDrivingStatus(Status status) { // } } -void MoveControl::emergencyStop() { +void MoveControl::emergencyStop() +{ this->left_motor->emergencyStop(); this->right_motor->emergencyStop(); this->setSpeed(0); @@ -107,8 +109,10 @@ void MoveControl::emergencyStop() { this->driving_status = Status::Stop; } -void MoveControl::setSpeed(double speed) { - if (speed < 0.2 && speed > -0.2) { +void MoveControl::setSpeed(double speed) +{ + if (speed < MoveControl::minSpeed && speed > -MoveControl::minSpeed) + { this->drivingSpeeds.x = 0; return; } @@ -116,8 +120,10 @@ void MoveControl::setSpeed(double speed) { this->drivingSpeeds.x = speed; } -void MoveControl::setRotationSpeed(double speed) { - if (speed < 0.1 && speed > -0.1){ +void MoveControl::setRotationSpeed(double speed) +{ + if (speed < MoveControl::minSpeed && speed > -MoveControl::minSpeed) + { this->drivingSpeeds.rot = 0; return; } @@ -125,92 +131,120 @@ void MoveControl::setRotationSpeed(double speed) { this->drivingSpeeds.rot = speed; } -void MoveControl::setSpeeds(DrivingSpeeds drivingSpeeds) { +void MoveControl::setSpeeds(DrivingSpeeds drivingSpeeds) +{ this->setSpeed(drivingSpeeds.x); this->setRotationSpeed(drivingSpeeds.rot); } -void MoveControl::setRawPowerLeft(int16_t power) { - if (power <= 100 && power >= -100) - this->rawPowerLeft = power; +void MoveControl::setRawPowerLeft(int16_t power) +{ + if (power <= MoveControl::maxPercentage && power >= -MoveControl::maxPercentage) + { + this->rawPowerLeft = static_cast(power); + } } -void MoveControl::setRawPowerRight(int16_t power) { - if (power <= 100 && power >= -100) - this->rawPowerRight = power; +void MoveControl::setRawPowerRight(int16_t power) +{ + if (power <= MoveControl::maxPercentage && power >= -MoveControl::maxPercentage) + { + this->rawPowerRight = static_cast(power); + } } -void MoveControl::setPidTunings(uint8_t side, double p, double i, double d) { - PID* selectedPID = nullptr; +void MoveControl::setPidTunings(uint8_t side, double pPart, double iPart, double dPart) +{ + PID *selectedPID = nullptr; if (side == 0) + { selectedPID = this->left_pid; + } else if (side == 1) + { selectedPID = this->right_pid; + } - selectedPID->SetTunings(p, i, d); + selectedPID->SetTunings(pPart, iPart, dPart); } -PID* MoveControl::getPID(uint8_t side) const { +PID *MoveControl::getPID(uint8_t side) const +{ if (side == 0) + { return this->left_pid; - else if (side == 1) + } + if (side == 1) + { return this->right_pid; + } return nullptr; } -void MoveControl::setSpeedometerDirection(Speedometer *speedometer, double value) { +void MoveControl::setSpeedometerDirection(Speedometer *speedometer, double value) +{ if (value > 0) + { speedometer->setDirection(Speedometer::Direction::Forward); + } else if (value < 0) + { speedometer->setDirection(Speedometer::Direction::Backward); + } else + { speedometer->setDirection(Speedometer::Direction::None); + } } -void MoveControl::calcTargetWheelSpeed() { +void MoveControl::calcTargetWheelSpeed() +{ /* original formula: (1 / r) / 1 b \ / x \ = / Xl \ \ 1 -b / \ T / \ Xr / */ // (1 / r) * 1 - constexpr double A = 1.0 / (Settings::wheelDiameter / 2); + constexpr double A1r1 = 1.0 / (Settings::wheelDiameter / 2); // (1 / r) * b - constexpr double B = (1.0 / (Settings::wheelDiameter / 2)) * (Settings::wheelDistance / 2); + constexpr double B1rb = (1.0 / (Settings::wheelDiameter / 2)) * (Settings::wheelDistance / 2); - this->wheelspeed_right_target = (A * this->drivingSpeeds.x + B * this->drivingSpeeds.rot); - this->wheelspeed_left_target = (A * this->drivingSpeeds.x + (-B) * this->drivingSpeeds.rot); + this->wheelspeed_right_target = (A1r1 * this->drivingSpeeds.x + B1rb * this->drivingSpeeds.rot); + this->wheelspeed_left_target = (A1r1 * this->drivingSpeeds.x + (-B1rb) * this->drivingSpeeds.rot); } -void MoveControl::regulateMotors() { - switch (this->driving_status) { - case Status::Stop : - this->left_motor->setTargetPower(0); - this->right_motor->setTargetPower(0); - this->setSpeedometerDirection(this->left_speedometer, 0); - this->setSpeedometerDirection(this->right_speedometer, 0); - break; +void MoveControl::regulateMotors() +{ + switch (this->driving_status) + { + case Status::Stop: + this->left_motor->setTargetPower(0); + this->right_motor->setTargetPower(0); + this->setSpeedometerDirection(this->left_speedometer, 0); + this->setSpeedometerDirection(this->right_speedometer, 0); + break; - case Status::Drive : - this->left_motor->setTargetPower( (int8_t) this->left_pid_out); - this->right_motor->setTargetPower( (int8_t) this->right_pid_out); - this->setSpeedometerDirection(this->left_speedometer, this->left_motor->getPower()); - this->setSpeedometerDirection(this->right_speedometer, this->right_motor->getPower()); - break; + case Status::Drive: + this->left_motor->setTargetPower(static_cast(this->left_pid_out)); + this->right_motor->setTargetPower(static_cast(this->right_pid_out)); + this->setSpeedometerDirection(this->left_speedometer, this->left_motor->getPower()); + this->setSpeedometerDirection(this->right_speedometer, this->right_motor->getPower()); + break; - case Status::Raw : - this->left_motor->setTargetPower(this->rawPowerLeft); - this->right_motor->setTargetPower(this->rawPowerRight); - this->setSpeedometerDirection(this->left_speedometer, this->rawPowerLeft); - this->setSpeedometerDirection(this->right_speedometer, this->rawPowerRight); - break; + case Status::Raw: + this->left_motor->setTargetPower(this->rawPowerLeft); + this->right_motor->setTargetPower(this->rawPowerRight); + this->setSpeedometerDirection(this->left_speedometer, this->rawPowerLeft); + this->setSpeedometerDirection(this->right_speedometer, this->rawPowerRight); + break; - default: - Serial.println("Wrong drivingState in MoveControl::regulateMotors"); - break; + default: + Serial.println("Wrong drivingState in MoveControl::regulateMotors"); + break; } } -void MoveControl::updateCurrentWheelSpeed() { +void MoveControl::updateCurrentWheelSpeed() +{ this->wheelspeed_left = this->left_speedometer->getSpeedRad(); this->wheelspeed_right = this->right_speedometer->getSpeedRad(); } From a43e2db92bd0a4f40009f73cfdf4522935c4b8c3 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 00:44:27 +0200 Subject: [PATCH 22/26] clangtidy corrections part 2 --- clangtidy.txt | 687 ------------------ lib/MQTT/debugMqtt.cpp | 30 +- lib/MQTT/debugMqtt.h | 8 +- lib/MotorControl/motorControl.cpp | 153 ++-- lib/MotorControl/motorControl.h | 162 ++--- lib/Navigation/navigation.cpp | 127 ++-- lib/Navigation/navigation.h | 223 +++--- lib/Network/network.cpp | 124 ++-- lib/Network/network.h | 87 +-- lib/NtripClient/ntripClient.cpp | 326 +++++---- lib/NtripClient/ntripClient.h | 176 ++--- lib/Point/point.cpp | 100 +-- lib/Point/point.h | 213 +++--- lib/Route/route.cpp | 68 +- lib/Route/route.h | 5 - lib/Sensors/sensorData.cpp | 209 ++++-- lib/Sensors/sensorData.h | 140 ++-- lib/Speedometer/speedometer.cpp | 128 ++-- lib/Speedometer/speedometer.h | 185 ++--- lib/Times/debugTimes.cpp | 35 +- lib/Times/debugTimes.h | 83 +-- lib/calibrateCompass/calibrateCompass.cpp | 42 +- lib/calibrateCompass/calibrateCompass.h | 71 +- src/OutputBuf/outputBuf.cpp | 61 +- .../CalibrateBattery/menuCalibrateBattery.cpp | 63 +- .../CalibrateBattery/menuCalibrateBattery.h | 31 +- src/SpecialMenus/PID/menuPidSettings.cpp | 15 +- src/SpecialMenus/Route/menuRoute.cpp | 26 +- src/SpecialMenus/Route/menuRoute.h | 210 +++--- src/SpecialMenus/Route/menuRoutePoints.cpp | 63 +- .../SensorData/menuSensorData.cpp | 214 +++--- src/SpecialMenus/Speed/menuSpeed.cpp | 7 +- .../menuSysteminformatio.cpp | 3 +- .../driveModi/Autopilot/menuAutopilot.cpp | 435 ++++++----- .../CalibrateCompass/menuCalibrateCompass.cpp | 2 +- .../CalibrateCompass/menuCalibrateCompass.h | 6 +- .../CaptureRoute/menuCaptureRoute.cpp | 218 +++--- .../driveModi/CaptureRoute/menuCaptureRoute.h | 4 +- .../driveModi/ManualDrive/menuManualDrive.cpp | 10 +- .../driveModi/ManualDrive/menuManualDrive.h | 7 +- .../driveModi/TestMode/menuTestMode.cpp | 2 +- 41 files changed, 2274 insertions(+), 2485 deletions(-) diff --git a/clangtidy.txt b/clangtidy.txt index 06f3caa..d6d4dfe 100644 --- a/clangtidy.txt +++ b/clangtidy.txt @@ -1,691 +1,4 @@ -lib/MQTT/debugMqtt.cpp:22: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/MQTT/debugMqtt.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MQTT/debugMqtt.cpp:32: [medium:warning] 2 adjacent parameters of 'sendMsg' of similar type ('String') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/MQTT/debugMqtt.cpp:32: [medium:warning] the parameter 'msg' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:33: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:33: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:34: [medium:warning] parameter 'topic' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:34: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:38: [medium:warning] parameter 'msg' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:41: [medium:warning] method 'sendData' can be made static [readability-convert-member-functions-to-static] -lib/MQTT/debugMqtt.cpp:41: [medium:warning] the parameter 'topic' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:41: [medium:warning] the parameter 'data' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:47: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:47: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:48: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:48: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:49: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:49: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:54: [medium:warning] parameter 'data' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:57: [medium:warning] the parameter 'measurement_name' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:57: [medium:warning] the parameter 'field_set' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:60: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:60: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:61: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:64: [medium:warning] parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length] -lib/Menu/src/menu.cpp:13: [medium:warning] constructor does not initialize these fields: entrys, selectedEntry [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Menu/src/menu.cpp:18: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:18: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:25: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:29: [medium:warning] method 'isInSubmenu' can be made const [readability-make-member-function-const] -lib/Menu/src/menu.cpp:34: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:43: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:63: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Menu/src/menu.cpp:64: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:78: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:108: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menu.cpp:108: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:13: [medium:warning] 2 adjacent parameters of 'MenuAction' of similar type ('void (*)()') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuAction.cpp:14: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:15: [medium:warning] 'function' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:16: [medium:warning] 'callback' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:20: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:21: [medium:warning] 'menu' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:22: [medium:warning] 'isMenu' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:26: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:27: [medium:warning] 'action' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:31: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Menu/src/menuAction.cpp:31: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:34: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Menu/src/menuAction.cpp:34: [medium:warning] implicit conversion 'MenuActionWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:34: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:39: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:42: [medium:warning] implicit conversion 'void (*)()' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:42: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:44: [medium:warning] implicit conversion 'MenuActionWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:44: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:46: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:50: [medium:warning] implicit conversion 'void (*)()' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:58: [medium:warning] method 'getIsMenu' can be made const [readability-make-member-function-const] -lib/Menu/src/menuAction.cpp:63: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:65: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] -lib/Menu/src/menuAction.cpp:65: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuControl.cpp:14: [medium:warning] the parameter 'lineOne' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Menu/src/menuControl.cpp:14: [medium:warning] the parameter 'lineTwo' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Menu/src/menuControl.cpp:15: [medium:warning] implicit conversion 'DisplayWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuControl.cpp:27: [medium:warning] implicit conversion 'DisplayWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuControl.cpp:27: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:15: [medium:warning] 'countPages' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuInformationSites.cpp:16: [medium:warning] 'currentPage' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuInformationSites.cpp:17: [medium:warning] 'lastMillis' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuInformationSites.cpp:21: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:29: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:41: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuInformationSites.cpp:92: [medium:warning] variable 'lineOne' of type 'String' can be declared 'const' [misc-const-correctness] -lib/Menu/src/menuInformationSites.cpp:93: [medium:warning] variable 'lineTwo' of type 'String' can be declared 'const' [misc-const-correctness] -lib/Menu/src/menuIntInput.cpp:15: [medium:warning] 'values' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:16: [medium:warning] 'names' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:17: [medium:warning] 'length' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:18: [medium:warning] 'wrapper' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:20: [medium:warning] 'min' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:21: [medium:warning] 'max' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:22: [medium:warning] 'originalValues' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:23: [medium:warning] 'stepsPerInput' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:34: [medium:warning] 'length' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:35: [medium:warning] 'wrapper' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:37: [medium:warning] 'values' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:38: [medium:warning] 'names' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:38: [medium:warning] do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] -lib/Menu/src/menuIntInput.cpp:38: [medium:warning] C-style casts are discouraged; use reinterpret_cast [google-readability-casting] -lib/Menu/src/menuIntInput.cpp:39: [medium:warning] 'min' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:40: [medium:warning] 'max' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:41: [medium:warning] 'originalValues' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:42: [medium:warning] 'stepsPerInput' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:50: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:65: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:72: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:85: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:91: [medium:warning] 2 adjacent parameters of 'setMinMax' of similar type ('int16_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:106: [medium:warning] 2 adjacent parameters of 'setMinMax' of similar type ('int16_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:111: [medium:warning] 3 adjacent parameters of 'setMinMaxSteps' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:117: [medium:warning] 3 adjacent parameters of 'setMinMaxSteps' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:124: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:131: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:162: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:164: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:171: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:173: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:180: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:184: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuIntInput.cpp:192: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuIntInput.cpp:199: [medium:warning] 17 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Menu/src/menuIntInput.cpp:203: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:203: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:203: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:206: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:206: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:206: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:209: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:209: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:209: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:212: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:212: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:212: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:215: [medium:warning] 17 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Menu/src/menuIntInput.cpp:216: [medium:warning] implicit conversion 'int16_t' (aka 'short') -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuIntInput.cpp:216: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:217: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:217: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:218: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:219: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:219: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:221: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:221: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MotorControl/motorControl.cpp:15: [medium:warning] constructor does not initialize these fields: pwmPin, pwmChannel, dutycycleMin, dutycycleMax, dir_1, dir_2 [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/MotorControl/motorControl.cpp:21: [medium:warning] 3 adjacent parameters of 'init' of similar type ('uint8_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/MotorControl/motorControl.cpp:40: [medium:warning] variable 'abs_difference' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/MotorControl/motorControl.cpp:43: [medium:warning] variable 'difference' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/MotorControl/motorControl.cpp:84: [medium:warning] 80 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:84: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:84: [medium:warning] 80 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:86: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/MotorControl/motorControl.cpp:86: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/MotorControl/motorControl.cpp:91: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:91: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:91: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:93: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/MotorControl/motorControl.cpp:93: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/MotorControl/motorControl.cpp:98: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:98: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:98: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:100: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:113: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:114: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/MotorControl/motorControl.cpp:119: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:120: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/MotorControl/motorControl.cpp:125: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:126: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/MotorControl/motorControl.cpp:131: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/MotorControl/motorControl.cpp:132: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:132: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:147: [medium:warning] variable 'pwm_val' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/MotorControl/motorControl.cpp:147: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:164: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/MotorControl/motorControl.cpp:165: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Navigation/navigation.cpp:15: [medium:warning] 'sensorData' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Navigation/navigation.cpp:20: [medium:warning] implicit conversion 'Route *' -> bool [readability-implicit-bool-conversion] -lib/Navigation/navigation.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:35: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Navigation/navigation.cpp:35: [medium:warning] implicit conversion 'Route *' -> bool [readability-implicit-bool-conversion] -lib/Navigation/navigation.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:41: [medium:warning] variable 'newTargetPoint' of type 'Point' can be declared 'const' [misc-const-correctness] -lib/Navigation/navigation.cpp:43: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:49: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:55: [medium:warning] 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:65: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] -lib/Navigation/navigation.cpp:81: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:92: [medium:warning] variable 'distance' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Navigation/navigation.cpp:117: [medium:warning] variable 'targetCourse' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Navigation/navigation.cpp:118: [medium:warning] variable 'correctionCourse' is not initialized [cppcoreguidelines-init-variables] -lib/Navigation/navigation.cpp:134: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:148: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:148: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:149: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:149: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:150: [medium:warning] 360 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:151: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:151: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:152: [medium:warning] 360 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.h:86: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Navigation/navigation.h:99: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Network/network.cpp:14: [medium:warning] constructor does not initialize these fields: mqttUser, mqttPassphrase [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Network/network.cpp:15: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:15: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:21: [medium:warning] constructor does not initialize these fields: mqttUser, mqttPassphrase [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Network/network.cpp:22: [medium:warning] 'adresses' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Network/network.cpp:22: [medium:warning] parameter 'adresses' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/Network/network.cpp:24: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:24: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:39: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Network/network.cpp:39: [medium:warning] implicit conversion 'PubSubClient *' -> bool [readability-implicit-bool-conversion] -lib/Network/network.cpp:39: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:52: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Network/network.cpp:52: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Network/network.cpp:52: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Network/network.cpp:65: [medium:warning] 2 adjacent parameters of 'activateMqtt' of similar type ('const char *') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Network/network.cpp:73: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:78: [medium:warning] method 'printIPs' can be made const [readability-make-member-function-const] -lib/Network/network.cpp:91: [medium:warning] variable 'channel' is not initialized [cppcoreguidelines-init-variables] -lib/Network/network.cpp:92: [medium:warning] variable 'secondChannel' is not initialized [cppcoreguidelines-init-variables] -lib/Network/network.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:107: [medium:warning] implicit conversion 'PubSubClient *' -> bool [readability-implicit-bool-conversion] -lib/Network/network.cpp:107: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:116: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:132: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:150: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:156: [medium:warning] 0xffff is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Network/network.cpp:158: [medium:warning] implicit conversion 'const char *' -> bool [readability-implicit-bool-conversion] -lib/Network/network.cpp:159: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:162: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:15: [medium:warning] constructor does not initialize these fields: host, mountPoint, user, password [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/NtripClient/ntripClient.cpp:16: [medium:warning] 'gps' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:17: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:18: [medium:warning] 'port' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:19: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:20: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:21: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:23: [medium:warning] 'ntripClient' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:24: [medium:warning] 'state' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:26: [medium:warning] 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:53: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:86: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/NtripClient/ntripClient.cpp:90: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:95: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:122: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:122: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:125: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] -lib/NtripClient/ntripClient.cpp:130: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/NtripClient/ntripClient.cpp:130: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:133: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:136: [medium:warning] variable 'userCredentialsLength' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:138: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/NtripClient/ntripClient.cpp:138: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:138: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:143: [medium:warning] variable 'b' of type 'base64' can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:143: [medium:warning] variable name 'b' is too short, expected at least 3 characters [readability-identifier-length] -lib/NtripClient/ntripClient.cpp:144: [medium:warning] variable 'strEncodedCredentials' of type 'String' can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:144: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/NtripClient/ntripClient.cpp:147: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:149: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/NtripClient/ntripClient.cpp:149: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:149: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:153: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:153: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:154: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:157: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:165: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:168: [medium:warning] variable 'lastMillis' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:169: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:175: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:182: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:183: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:189: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:189: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:190: [medium:warning] 200 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:191: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:191: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:192: [medium:warning] 401 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:199: [medium:warning] 200 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:200: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/NtripClient/ntripClient.cpp:203: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:205: [medium:warning] 401 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:205: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:216: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:216: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:223: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:224: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:227: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:229: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:235: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:252: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:255: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:269: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:272: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:276: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:276: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:279: [medium:warning] use auto when initializing with new to avoid duplicating the type name [hicpp-use-auto,modernize-use-auto] -lib/NtripClient/ntripClient.cpp:280: [medium:warning] variable 'res' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:281: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:282: [medium:warning] do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] -lib/NtripClient/ntripClient.cpp:282: [medium:warning] C-style casts are discouraged; use reinterpret_cast [google-readability-casting] -lib/NtripClient/ntripClient.cpp:287: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:288: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/Point/point.cpp:14: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:14: [medium:warning] 3 adjacent parameters of 'Point' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Point/point.cpp:20: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:20: [medium:warning] 3 adjacent parameters of 'Point' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Point/point.cpp:21: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:22: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:26: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:27: [medium:warning] 'coordinates' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Point/point.cpp:31: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:32: [medium:warning] 'coordinates' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Point/point.cpp:33: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:39: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:56: [medium:warning] variable 'begin' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:57: [medium:warning] variable 'end' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:59: [medium:warning] variable 'lat' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:60: [medium:warning] variable 'dy' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:60: [medium:warning] variable name 'dy' is too short, expected at least 3 characters [readability-identifier-length] -lib/Point/point.cpp:61: [medium:warning] variable 'dx' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:61: [medium:warning] variable name 'dx' is too short, expected at least 3 characters [readability-identifier-length] -lib/Point/point.cpp:71: [medium:warning] variable 'begin' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:72: [medium:warning] variable 'end' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:74: [medium:warning] variable 'phi' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:75: [medium:warning] variable 'lon' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:77: [medium:warning] variable 'res' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:89: [medium:warning] 2 adjacent parameters of 'init' of similar type ('uint32_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Point/point.cpp:92: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:94: [medium:warning] 9999 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:94: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:96: [medium:warning] 999 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:96: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:98: [medium:warning] 99 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:98: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:100: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Route/route.cpp:14: [medium:warning] use '= default' to define a trivial default constructor [hicpp-use-equals-default,modernize-use-equals-default] -lib/Route/route.cpp:29: [medium:warning] the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] -lib/Route/route.cpp:31: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:41: [medium:warning] the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] -lib/Route/route.cpp:43: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:47: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Route/route.cpp:55: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Route/route.cpp:56: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:67: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:71: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Route/route.cpp:72: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:78: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] -lib/Route/route.cpp:79: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:84: [medium:warning] uninitialized record type: 'info' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Sensors/sensorData.cpp:18: [medium:warning] constructor does not initialize these fields: gnssData, host, mountPoint, user, password, gyroBuffer, port [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Sensors/sensorData.cpp:19: [medium:warning] 50 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:23: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Sensors/sensorData.cpp:23: [medium:warning] implicit conversion 'NTRIPClient *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'host' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'mountPoint' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'user' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'password' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:38: [medium:warning] 4000000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:38: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] -lib/Sensors/sensorData.cpp:40: [medium:warning] converting integer literal to bool, use bool literal instead [modernize-use-bool-literals] -lib/Sensors/sensorData.cpp:40: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:40: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:47: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] -lib/Sensors/sensorData.cpp:49: [medium:warning] converting integer literal to bool, use bool literal instead [modernize-use-bool-literals] -lib/Sensors/sensorData.cpp:49: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:49: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:57: [medium:warning] 0x0d is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:58: [medium:warning] 0x0b is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:61: [medium:warning] 0x0C is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:61: [medium:warning] 0x10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:76: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:79: [medium:warning] variable 'deviceStatus' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:81: [medium:warning] 220 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:82: [medium:warning] 76 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:83: [medium:warning] 85 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:84: [medium:warning] 1788 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:87: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:88: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:96: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:97: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:102: [medium:warning] implicit conversion 'CalcAzimuth *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:108: [medium:warning] implicit conversion 'NTRIPClient *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:108: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:114: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:117: [medium:warning] variable 'latitude' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:117: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:117: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:118: [medium:warning] variable 'longitude' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:118: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:118: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:119: [medium:warning] variable 'altitude' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:119: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:119: [medium:warning] 1000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:121: [medium:warning] variable 'fixType' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:122: [medium:warning] 32 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:123: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:124: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:125: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:126: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:127: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:128: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:129: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:130: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:131: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:132: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:133: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:133: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:134: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:135: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:138: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:138: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -lib/Sensors/sensorData.cpp:139: [medium:warning] 16 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:140: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:141: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:142: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:143: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:144: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:145: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:146: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:147: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:149: [medium:warning] variable 'hAcc' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:172: [medium:warning] implicit conversion 'QMC5883LCompass *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:177: [medium:warning] implicit conversion 'MPU6050 *' (aka 'MPU6050_6Axis_MotionApps20 *') -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:178: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:178: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:180: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:182: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:187: [medium:warning] implicit conversion 'SFE_UBLOX_GNSS *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:190: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:196: [medium:warning] variable 'versionHigh' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:197: [medium:warning] variable 'versionLow' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:198: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:198: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:201: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:213: [medium:warning] uninitialized record type: 'coords' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Sensors/sensorData.cpp:214: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:215: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:14: [medium:warning] constructor does not initialize these fields: buf [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Speedometer/speedometer.cpp:14: [medium:warning] 3 adjacent parameters of 'Speedometer' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Speedometer/speedometer.cpp:15: [medium:warning] 'diameter' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Speedometer/speedometer.cpp:16: [medium:warning] 'steps' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Speedometer/speedometer.cpp:18: [medium:warning] 'pulseCounter' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Speedometer/speedometer.cpp:19: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:34: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:37: [medium:warning] variable 'time' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:39: [medium:warning] variable 'elapsedTime' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:42: [medium:warning] variable 'pulse' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:47: [medium:warning] variable 'n' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:47: [medium:warning] variable name 'n' is too short, expected at least 3 characters [readability-identifier-length] -lib/Speedometer/speedometer.cpp:47: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Speedometer/speedometer.cpp:48: [medium:warning] variable 'u' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:48: [medium:warning] variable name 'u' is too short, expected at least 3 characters [readability-identifier-length] -lib/Speedometer/speedometer.cpp:48: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Speedometer/speedometer.cpp:48: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:49: [medium:warning] variable 'ms' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:49: [medium:warning] variable name 'ms' is too short, expected at least 3 characters [readability-identifier-length] -lib/Speedometer/speedometer.cpp:52: [medium:warning] 0.1 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:85: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:85: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:86: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:91: [medium:warning] variable 'avg' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:92: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Speedometer/speedometer.cpp:105: [medium:warning] variable 'res' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:113: [medium:warning] use range-based for loop instead [modernize-loop-convert] -lib/Speedometer/speedometer.cpp:113: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:121: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:127: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Speedometer/speedometer.cpp:127: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:129: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Times/debugTimes.cpp:17: [medium:warning] 'startTime' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Times/debugTimes.cpp:29: [medium:warning] method 'stop' can be made const [readability-make-member-function-const] -lib/Times/debugTimes.cpp:33: [medium:warning] method 'stopConsol' can be made const [readability-make-member-function-const] -lib/Times/debugTimes.cpp:34: [medium:warning] variable 'time' of type 'uint64_t' (aka 'unsigned long long') can be declared 'const' [misc-const-correctness] -lib/Times/debugTimes.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Times/debugTimes.cpp:41: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/calibrateCompass/calibrateCompass.cpp:14: [medium:warning] constructor does not initialize these fields: data [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/calibrateCompass/calibrateCompass.cpp:16: [medium:warning] 'compass' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/calibrateCompass/calibrateCompass.cpp:17: [medium:warning] 'state' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/calibrateCompass/calibrateCompass.cpp:32: [medium:warning] variable 'xAxis' of type 'int' can be declared 'const' [misc-const-correctness] -lib/calibrateCompass/calibrateCompass.cpp:33: [medium:warning] variable 'yAxis' of type 'int' can be declared 'const' [misc-const-correctness] -lib/calibrateCompass/calibrateCompass.cpp:34: [medium:warning] variable 'zAxis' of type 'int' can be declared 'const' [misc-const-correctness] -lib/calibrateCompass/calibrateCompass.cpp:72: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/calibrateCompass/calibrateCompass.cpp:164: [medium:warning] use range-based for loop instead [modernize-loop-convert] -lib/calibrateCompass/calibrateCompass.cpp:175: [medium:warning] use range-based for loop instead [modernize-loop-convert] -lib/calibrateCompass/calibrateCompass.cpp:185: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/calibrateCompass/calibrateCompass.cpp:188: [medium:warning] parameter name 'os' is too short, expected at least 3 characters [readability-identifier-length] -lib/calibrateCompass/calibrateCompass.cpp:191: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:193: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:195: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:197: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:199: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:201: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -src/OutputBuf/outputBuf.cpp:15: [medium:warning] initializer for base class 'std::streambuf' (aka 'basic_streambuf') is redundant [readability-redundant-member-init] -src/OutputBuf/outputBuf.cpp:16: [medium:warning] 'debugMqtt' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/OutputBuf/outputBuf.cpp:17: [medium:warning] 'serialBT' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/OutputBuf/outputBuf.cpp:19: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:19: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:22: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:27: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:27: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:32: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:32: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:46: [medium:warning] parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length] -src/OutputBuf/outputBuf.cpp:50: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:51: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/OutputBuf/outputBuf.cpp:53: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:53: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:54: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/OutputBuf/outputBuf.cpp:56: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:15: [medium:warning] 400 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:16: [medium:warning] 'battery' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:52: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:57: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/PID/menuPidSettings.cpp:15: [medium:warning] 'pid' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/PID/menuPidSettings.cpp:19: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoute.cpp:16: [medium:warning] 'menuRoute' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoute.cpp:17: [medium:warning] 'dataFunction' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoute.cpp:25: [medium:warning] constructor does not initialize these fields: mainMenu [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/Route/menuRoute.cpp:27: [medium:warning] 'route' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoute.cpp:163: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -src/SpecialMenus/Route/menuRoute.cpp:188: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:193: [medium:warning] 202 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoute.cpp:216: [medium:warning] uninitialized record type: 'coords' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/Route/menuRoute.cpp:229: [medium:warning] variable 'totalPoints' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:234: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -src/SpecialMenus/Route/menuRoute.cpp:273: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:275: [medium:warning] 201 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoute.cpp:298: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -src/SpecialMenus/Route/menuRoute.cpp:323: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:328: [medium:warning] 202 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:14: [medium:warning] initializer for base class 'MenuInformationSites' is redundant [readability-redundant-member-init] -src/SpecialMenus/Route/menuRoutePoints.cpp:15: [medium:warning] 'route' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoutePoints.cpp:19: [medium:warning] variable 'amountPoints' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoutePoints.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:27: [medium:warning] variable 'currentPage' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoutePoints.cpp:28: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:49: [medium:warning] variable name 'p' is too short, expected at least 3 characters [readability-identifier-length] -src/SpecialMenus/Route/menuRoutePoints.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:54: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:56: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:58: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:61: [medium:warning] 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:62: [medium:warning] variable 'string' is not initialized [cppcoreguidelines-init-variables] -src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -src/SpecialMenus/SensorData/menuSensorData.cpp:15: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:16: [medium:warning] 'sensorData' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/SensorData/menuSensorData.cpp:20: [medium:warning] function 'printPage' has cognitive complexity of 26 (threshold 25) [readability-function-cognitive-complexity] -src/SpecialMenus/SensorData/menuSensorData.cpp:23: [medium:warning] implicit conversion 'const UBX_NAV_PVT_data_t *' -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/SensorData/menuSensorData.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:54: [medium:warning] variable 'pos' of type 'Point' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/SensorData/menuSensorData.cpp:63: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/SensorData/menuSensorData.cpp:64: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:68: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:72: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:72: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:75: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:80: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:83: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/SensorData/menuSensorData.cpp:83: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -src/SpecialMenus/SensorData/menuSensorData.cpp:84: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:86: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:88: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:90: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:92: [medium:warning] variable 'status' of type 'NTRIPClientStates' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/SensorData/menuSensorData.cpp:93: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:95: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:102: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:105: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/Speed/menuSpeed.cpp:15: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Speed/menuSpeed.cpp:17: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/Speed/menuSpeed.cpp:17: [medium:warning] 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Speed/menuSpeed.cpp:18: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/Speed/menuSpeed.cpp:18: [medium:warning] 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:15: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:16: [medium:warning] 'mainBattery' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:36: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:53: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:58: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:60: [medium:warning] 16 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:63: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:14: [medium:warning] function 'printPage' has cognitive complexity of 36 (threshold 25) [readability-function-cognitive-complexity] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:15: [medium:warning] variable 'correction' of type 'CourseCorrection' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:17: [medium:warning] variable 'navigationStarted' of type 'bool' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:23: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:23: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:26: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:27: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:31: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:31: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:108: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:108: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:111: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:112: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:114: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:116: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:118: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:120: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:122: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:126: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:126: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:128: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:173: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:175: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:177: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:181: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:183: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:185: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:189: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:206: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:210: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:220: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:231: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:241: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:249: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:13: [medium:warning] constructor does not initialize these fields: caliCompassMode, caliCompass [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:67: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:72: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:77: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:82: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:89: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:96: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:116: [medium:warning] 11 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:117: [medium:warning] 500 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:147: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:151: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:155: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:14: [medium:warning] variable 'routeInfo' of type 'RouteInfo' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:62: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:71: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:73: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:73: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:74: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:76: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:80: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:85: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:89: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:89: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:91: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:95: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:99: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:112: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:120: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:121: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:123: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:133: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:134: [medium:warning] 500 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:13: [medium:warning] constructor does not initialize these fields: manualControl, caliCompass [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:17: [medium:warning] use '= default' to define a trivial destructor [hicpp-use-equals-default,modernize-use-equals-default] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:33: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:58: [medium:warning] 500 is a magic number; consider replacing it with a named constant - - - - - ========================= [PASSED] Took 541.63 seconds ========================= Component HIGH MEDIUM LOW diff --git a/lib/MQTT/debugMqtt.cpp b/lib/MQTT/debugMqtt.cpp index 44a2fe9..3de8e95 100644 --- a/lib/MQTT/debugMqtt.cpp +++ b/lib/MQTT/debugMqtt.cpp @@ -18,10 +18,12 @@ char DebugMqtt::msg[MQTT_BUFFER_SIZE]; char DebugMqtt::topic[MQTT_BUFFER_SIZE]; -DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) { - this->name = name; - if (bufSize != 0) +DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) + : name {name} +{ + if (bufSize != 0) { this->bufSize = bufSize; + } this->buf = new char[this->bufSize]; } @@ -30,8 +32,8 @@ DebugMqtt::~DebugMqtt() { } void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg) { - snprintf (DebugMqtt::msg, MQTT_BUFFER_SIZE, "%s: %s",this->name ,msg.c_str()); - this->sendData(loglevel, topic, DebugMqtt::msg); + snprintf (static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s: %s"),this->name ,msg.c_str()); + this->sendData(loglevel, topic, static_cast(DebugMqtt::msg)); } void DebugMqtt::sendMsg(Loglevel loglevel, String msg) { @@ -44,27 +46,27 @@ void DebugMqtt::sendData(Loglevel loglevel, String topic, String data) { } if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none) { - snprintf (DebugMqtt::topic, MQTT_BUFFER_SIZE, "%s%s", DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str()); - snprintf (DebugMqtt::msg, MQTT_BUFFER_SIZE, "%s", data.c_str()); - client->publish(DebugMqtt::topic, DebugMqtt::msg); + snprintf (static_cast(DebugMqtt::topic), MQTT_BUFFER_SIZE, static_cast("%s%s"), DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str()); + snprintf (static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s"), data.c_str()); + client->publish(DebugMqtt::topic, static_cast(DebugMqtt::msg)); } } void DebugMqtt::sendData(Loglevel loglevel, String data){ - this->sendData(loglevel, "", data); + DebugMqtt::sendData(loglevel, "", data); } void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos) { // Example String: "weather temperature=82 1465839830100400200"; - snprintf(DebugMqtt::msg, MQTT_BUFFER_SIZE, "%s %s=%f %llu", measurement_name.c_str(), field_set.c_str(), measurement, nanos); - this->sendData(Loglevel::influx, DebugMqtt::msg); + snprintf(static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s %s=%f %llu"), measurement_name.c_str(), field_set.c_str(), measurement, nanos); + this->sendData(Loglevel::influx, static_cast(DebugMqtt::msg)); } -void DebugMqtt::addCharacter(char c) { - this->buf[this->bufPos] = c; +void DebugMqtt::addCharacter(char character) { + this->buf[this->bufPos] = character; this->bufPos++; - if (c == '\n' || this->bufPos >= this->bufSize - 1) { + if (character == '\n' || this->bufPos >= this->bufSize - 1) { this->buf[this->bufPos - 1] = '\0'; this->sendMsg(Loglevel::info, buf); this->bufPos = 0; diff --git a/lib/MQTT/debugMqtt.h b/lib/MQTT/debugMqtt.h index a93f783..194fd14 100644 --- a/lib/MQTT/debugMqtt.h +++ b/lib/MQTT/debugMqtt.h @@ -108,8 +108,8 @@ class DebugMqtt { * @param topic Additional topic behind loglevel * @param data The message to send as String */ - void sendData(Loglevel loglevel, String topic, String data); - void sendData(Loglevel loglevel, String data); + static void sendData(Loglevel loglevel, String topic, String data); + static void sendData(Loglevel loglevel, String data); /** * @brief Send a Message via MQTT for InfluxDB @@ -132,9 +132,9 @@ class DebugMqtt { * 1. when the buffer is full * 2. when the character is '\n' * - * @param c + * @param character */ - void addCharacter(char c); + void addCharacter(char character); /** * @brief Initialize debugMQTT for all instances diff --git a/lib/MotorControl/motorControl.cpp b/lib/MotorControl/motorControl.cpp index de366e9..6ff901f 100644 --- a/lib/MotorControl/motorControl.cpp +++ b/lib/MotorControl/motorControl.cpp @@ -5,20 +5,20 @@ * @see motorControl.h * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "motorControl.h" -MotorControl::MotorControl() { - this->setMinPwm(MotorControl::pwmMin); - this->setMaxPwm(MotorControl::pwmMax); +MotorControl::MotorControl() +{ Component::loopDelay = MotorControl::loopDelay; } -void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2) { +void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2) +{ this->pwmPin = pwmPin; this->pwmChannel = pwmChannel; this->dir_1 = dir_1; @@ -35,107 +35,141 @@ void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8 ledcWrite(this->pwmChannel, 0); } -void MotorControl::run() { +void MotorControl::run() +{ // Absolute difference between targetPower and power - uint8_t abs_difference = abs(this->targetPower - this->power); + const uint8_t abs_difference = abs(this->targetPower - this->power); // Difference between targetPower and power - int16_t difference = this->targetPower - this->power; + const int16_t difference = this->targetPower - this->power; // Check that the target speed is close to 0 and that the abs_difference is lower than MotorControl::powerSteps - if (abs(this->targetPower) < MotorControl::powerSteps && abs_difference < MotorControl::powerSteps) { + if (abs(this->targetPower) < MotorControl::powerSteps && abs_difference < MotorControl::powerSteps) + { this->setRealPower(0); return; } // Correct speed - if (abs_difference < MotorControl::powerSteps) { + if (abs_difference < MotorControl::powerSteps) + { return; } // Positive or negative tagret speed - if (this->targetPower >= 0) { + if (this->targetPower >= 0) + { // Positive or negative speed - if (this->power >= 0) { - if (difference > 0) { + if (this->power >= 0) + { + if (difference > 0) + { this->increasePower(MotorControl::powerSteps); - } else { + } + else + { this->increasePower(-MotorControl::powerSteps); } - } else { + } + else + { this->increasePower(MotorControl::powerSteps); } - - } else { + } + else + { // Positive or negative speed - if (this->power >= 0) { + if (this->power >= 0) + { this->increasePower(-MotorControl::powerSteps); - } else { - if (difference > 0) { + } + else + { + if (difference > 0) + { this->increasePower(MotorControl::powerSteps); - } else { + } + else + { this->increasePower(-MotorControl::powerSteps); } } } } -void MotorControl::setMinPwm(uint8_t min) { - if (min > 80) min = 80; - //transform percentage to real pwm value - min = (uint8_t) (((1 << pwmRes) - 1) * (min / 100.0)); +void MotorControl::setMinPwm(uint8_t min) +{ + if (min > MotorControl::maxPwmMin) + { + min = MotorControl::maxPwmMin; + } + // transform percentage to real pwm value + min = static_cast(((static_cast(1) << pwmRes) - 1) * (min / 100.0)); this->dutycycleMin = min; } -void MotorControl::setMaxPwm(uint8_t max) { - if (max > 100) max = 100; - //transform percentage to real pwm value - max = (uint8_t) (((1 << pwmRes) - 1) * (max / 100.0)); +void MotorControl::setMaxPwm(uint8_t max) +{ + if (max > 100) + { + max = 100; + } + // transform percentage to real pwm value + max = static_cast(((static_cast(1) << pwmRes) - 1) * (max / 100.0)); this->dutycycleMax = max; } -void MotorControl::setTargetPower(int8_t power) { +void MotorControl::setTargetPower(int8_t power) +{ if (power <= 100 && power >= -100) + { this->targetPower = power; + } else + { std::cout << " MotorControl::setTargetPower: Invalid Argument - Power: " << power << std::endl; + } } -void MotorControl::stop() { +void MotorControl::stop() +{ this->targetPower = 0; } -void MotorControl::emergencyStop() { +void MotorControl::emergencyStop() +{ setRealPower(0); } -bool MotorControl::isTargetPowerReached() const { - if (this->targetPower == this->power) - return true; - return false; +bool MotorControl::isTargetPowerReached() const +{ + return this->targetPower == this->power; } -bool MotorControl::isAccelerationPositive() const { - if (power < targetPower) - return true; - return false; +bool MotorControl::isAccelerationPositive() const +{ + return power < targetPower; } -bool MotorControl::isAccelerationNegative() const { - if (power > targetPower) - return true; - return false; +bool MotorControl::isAccelerationNegative() const +{ + return power > targetPower; } -void MotorControl::setRealPower(int8_t power) { - //TODO: Exceptionhandling - if (power <= 100 && power >= -100) { +void MotorControl::setRealPower(int8_t power) +{ + // TODO: Exceptionhandling + if (power <= 100 && power >= -100) + { this->power = power; - } else { + } + else + { return; } - if (this->power == 0) { + if (this->power == 0) + { this->direction = 0; digitalWrite(this->dir_1, LOW); digitalWrite(this->dir_2, LOW); @@ -144,13 +178,16 @@ void MotorControl::setRealPower(int8_t power) { return; } - uint8_t pwm_val = map(abs(power), 0, 100, this->dutycycleMin, this->dutycycleMax); + const uint8_t pwm_val = map(abs(power), 0, 100, this->dutycycleMin, this->dutycycleMax); - if ((this->direction == 1 || this->direction == 0) && power < 0){ // new direction backward + if ((this->direction == 1 || this->direction == 0) && power < 0) + { // new direction backward this->direction = 2; digitalWrite(this->dir_1, LOW); digitalWrite(this->dir_2, HIGH); - } else if ((this->direction == 2 || this->direction == 0) && power > 0){ // new direction forward + } + else if ((this->direction == 2 || this->direction == 0) && power > 0) + { // new direction forward this->direction = 1; digitalWrite(this->dir_1, HIGH); digitalWrite(this->dir_2, LOW); @@ -160,10 +197,12 @@ void MotorControl::setRealPower(int8_t power) { this->dutycycle = pwm_val; } -void MotorControl::increasePower(int8_t power) { - //TODO: Exceptionhandling - //TODO: make a stop befor a direction change - if (abs(power) > 2 * MotorControl::powerSteps) { +void MotorControl::increasePower(int8_t power) +{ + // TODO: Exceptionhandling + // TODO: make a stop befor a direction change + if (abs(power) > 2 * MotorControl::powerSteps) + { Serial.println("Invalid Argument in MotorControl::increasePower"); return; } diff --git a/lib/MotorControl/motorControl.h b/lib/MotorControl/motorControl.h index 3294960..fc576cd 100644 --- a/lib/MotorControl/motorControl.h +++ b/lib/MotorControl/motorControl.h @@ -4,9 +4,9 @@ * @brief Inherits a class to control a motor with pwm signal. * @version 0.1 * @date 2021-12-09 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef MOTOR_CONTROL_H #define MOTOR_CONTROL_H @@ -23,98 +23,98 @@ * You can control the acceleration of the motor, for example to * prevent a damage on your H-Bridge. */ -class MotorControl : public Component { - public: - MotorControl(); +class MotorControl : public Component +{ +public: + MotorControl(); - /** - * @brief Initialize the motorController - * - * @param pwmPin The output pin for the signal on the esp. - * @param pwmChannel One of the pwm channels from the esp. - * @param dir_1 First direction pin for the H-Bridge. - * @param dir_2 Second direction pin for the H-Bridge. - */ - void init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2); + /** + * @brief Initialize the motorController + * + * @param pwmPin The output pin for the signal on the esp. + * @param pwmChannel One of the pwm channels from the esp. + * @param dir_1 First direction pin for the H-Bridge. + * @param dir_2 Second direction pin for the H-Bridge. + */ + void init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2); - /** - * @brief Set the minimum duty cycle - * - * @param min duty cycle in percent - */ - void setMinPwm(uint8_t min); + /** + * @brief Set the minimum duty cycle + * + * @param min duty cycle in percent + */ + void setMinPwm(uint8_t min); - /** - * @brief Set the maximum duty cycle - * - * @param max duty cycle in percent - */ - void setMaxPwm(uint8_t max); + /** + * @brief Set the maximum duty cycle + * + * @param max duty cycle in percent + */ + void setMaxPwm(uint8_t max); - /** - * @brief Set the Target Power - * - * If the given power is greater than 100 or smaller than -100, then - * this function only print an error to consol. - * - * @param power power in percent - */ - void setTargetPower(int8_t power); + /** + * @brief Set the Target Power + * + * If the given power is greater than 100 or smaller than -100, then + * this function only print an error to consol. + * + * @param power power in percent + */ + void setTargetPower(int8_t power); - /** - * @brief Stops the motor like setTargetPower() to 0 - * - */ - void stop(); + /** + * @brief Stops the motor like setTargetPower() to 0 + * + */ + void stop(); - /** - * @brief Stops the motor immediately - * - */ - void emergencyStop(); + /** + * @brief Stops the motor immediately + * + */ + void emergencyStop(); - /** - * @brief Get the current power - * - * @return int8_t percent of power (-100 to 100) - */ - int8_t getPower() const { return this->power; }; + /** + * @brief Get the current power + * + * @return int8_t percent of power (-100 to 100) + */ + int8_t getPower() const { return this->power; }; - /** - * @brief Get the target power - * - * @return int8_t percent of power (-100 to 100) - */ - int8_t getTargetPower() const { return this->targetPower; }; + /** + * @brief Get the target power + * + * @return int8_t percent of power (-100 to 100) + */ + int8_t getTargetPower() const { return this->targetPower; }; - uint16_t getDutycycle() const { return this->dutycycle; } - bool isTargetPowerReached() const; - bool isAccelerationPositive() const; - bool isAccelerationNegative() const; + uint16_t getDutycycle() const { return this->dutycycle; } + bool isTargetPowerReached() const; + bool isAccelerationPositive() const; + bool isAccelerationNegative() const; - private: - void run() override; - void setRealPower(int8_t power); - void increasePower(int8_t power); +private: + void run() override; + void setRealPower(int8_t power); + void increasePower(int8_t power); - static constexpr uint8_t loopDelay = 10; - static constexpr uint16_t pwmFreq = 16000; - static constexpr uint8_t pwmRes = 8; - static constexpr uint8_t powerSteps = 2; // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms - static constexpr uint8_t pwmMin = 55; - static constexpr uint8_t pwmMax = 98; // Max 98% of 2^PWM_RES + static constexpr uint8_t loopDelay = 10; + static constexpr uint16_t pwmFreq = 16000; + static constexpr uint8_t pwmRes = 8; + static constexpr uint8_t powerSteps = 2; // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms + static constexpr uint8_t maxPwmMin = 80; - int8_t targetPower = 0; - int8_t power = 0; - uint8_t direction = 0; // 0 = stop, 1 = forward, 2 = backward + int8_t targetPower = 0; + int8_t power = 0; + uint8_t direction = 0; // 0 = stop, 1 = forward, 2 = backward - uint8_t pwmPin; - uint8_t pwmChannel; - uint16_t dutycycle = 0; - uint8_t dutycycleMin; - uint8_t dutycycleMax; - uint8_t dir_1; - uint8_t dir_2; + uint8_t pwmPin = 0; + uint8_t pwmChannel = 0; + uint16_t dutycycle = 0; + uint8_t dutycycleMin = 55; + uint8_t dutycycleMax = 98; // Max 98% of 2^PWM_RES + uint8_t dir_1 = 0; + uint8_t dir_2 = 0; }; #endif // MOTOR_CONTROL_H diff --git a/lib/Navigation/navigation.cpp b/lib/Navigation/navigation.cpp index fec6397..ac48865 100644 --- a/lib/Navigation/navigation.cpp +++ b/lib/Navigation/navigation.cpp @@ -4,56 +4,72 @@ * @brief Contains the implementation of the class Navigation * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "navigation.h" -Navigation::Navigation(const SensorData* sensorData, Route* route) { - this->sensorData = sensorData; +Navigation::Navigation(const SensorData *sensorData, Route *route) + : sensorData{sensorData} +{ this->init(route); } -void Navigation::init(Route* route) { - if (route) +void Navigation::init(Route *route) +{ + if (static_cast(route)) + { this->route = route; + } else + { this->route = new Route(); + } Component::loopDelay = Navigation::loopDelay; } -Navigation::~Navigation() { +Navigation::~Navigation() +{ delete this->route; } void Navigation::run() {} -void Navigation::newRoute() { - if (this->route) - delete this->route; +void Navigation::newRoute() +{ + delete this->route; this->route = new Route(); } -bool Navigation::startNavigation() { - Point newTargetPoint = this->route->startRoute(); +bool Navigation::startNavigation() +{ + const Point newTargetPoint = this->route->startRoute(); this->navigationStarted = this->setTargetPoint(newTargetPoint); if (this->navigationStarted) + { this->navigationFinished = false; + } return this->navigationStarted; } -Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, bool forceUpdate) { +Navigation::Status Navigation::getCourseCorrection(CourseCorrection &correction, bool forceUpdate) +{ if (this->navigationFinished) + { return Status::Complete; + } if (this->currentPosition.getAccuracy() <= this->minAccuracy) + { return Status::InsufficientAccuracy; + } - if (this->currentPosition.distanceTo(this->lastPointCalcCorrection) < (this->minDistanceToReachPoint / 2.0) - && !forceUpdate) { + // Check if the Rover has moved, if the Rover hasnt moved this function will be return. + if (this->currentPosition.distanceTo(this->lastPointCalcCorrection) < (this->minDistanceToReachPoint) / 2 && !forceUpdate) + { correction.correction = this->calculateCourseCorrection(this->lastPointCalcCorrection); correction.distance = this->lastPointCalcCorrection.distanceTo(this->targetPoint); return Status::Unchanged; @@ -62,8 +78,10 @@ Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, double distance = this->currentPosition.distanceTo(this->targetPoint); // Check if I need a new Point - if (distance < this->minDistanceToReachPoint && this->preventNextPoint == false) { - if (!this->nextPoint()) { + if (distance < this->minDistanceToReachPoint && this->preventNextPoint == false) + { + if (!this->nextPoint()) + { this->navigationFinished = true; this->navigationStarted = false; return Status::Complete; // End of navigation @@ -77,21 +95,25 @@ Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, return Status::Updated; } -Navigation::Status Navigation::addCurrentPosToRoute() { +Navigation::Status Navigation::addCurrentPosToRoute() +{ if (this->currentPosition.getAccuracy() <= this->minAccuracy) + { return Status::InsufficientAccuracy; + } // First Point - if (this->route->getRouteInfo().totalPoints == 0) { + if (this->route->getRouteInfo().totalPoints == 0) + { this->route->addPointToRoute(this->currentPosition); this->lastPointRouteInsert = this->currentPosition; return Status::Updated; } // Every Point after the first - double distance = this->currentPosition.distanceTo(this->lastPointRouteInsert); - if (Navigation::minDisBetweenPoints <= distance - && Navigation::maxDisBetweenPoints >= distance){ + const double distance = this->currentPosition.distanceTo(this->lastPointRouteInsert); + if (Navigation::minDisBetweenPoints <= distance && Navigation::maxDisBetweenPoints >= distance) + { this->route->addPointToRoute(this->currentPosition); this->lastPointRouteInsert = this->currentPosition; return Status::Updated; @@ -99,57 +121,58 @@ Navigation::Status Navigation::addCurrentPosToRoute() { return Status::Unchanged; } -// void Navigation::updateCurrentLocation() { -// if (Navigation::ubxUpdateTimeStatic == this->ubxUpdateTime) -// return; +int16_t Navigation::calculateCourseCorrection(Point &point) +{ + const int16_t targetCourse = point.courseTo(this->targetPoint); + int16_t correctionCourse = 0; -// this->ubxData = Navigation::ubxDataStatic; -// this->ubxUpdateTime = Navigation::ubxUpdateTimeStatic; - -// Point::Coordinates coords; -// coords.lat = this->ubxData->lat / 10000000.0; -// coords.lon = this->ubxData->lon / 10000000.0; - -// this->currentPosition = Point(coords, this->ubxData->hAcc); -// } - -int16_t Navigation::calculateCourseCorrection(Point& point) { - int16_t targetCourse = point.courseTo(this->targetPoint); - int16_t correctionCourse; - - if (this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Good - || this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Super) + if (this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Good || this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Super) { correctionCourse = targetCourse - this->sensorData->getCalcAzimuth(); this->lastUsedCalcAzimuth = true; - } else { + } + else + { correctionCourse = targetCourse - this->sensorData->getRealAzimuth(); this->lastUsedCalcAzimuth = false; } - + return Navigation::fixDegree(correctionCourse); } -bool Navigation::nextPoint() { +bool Navigation::nextPoint() +{ if (!this->navigationStarted) + { return false; + } return this->setTargetPoint(this->route->getNextPoint()); } -bool Navigation::setTargetPoint(Point target) { - if (target.isInit()) { +bool Navigation::setTargetPoint(Point target) +{ + if (target.isInit()) + { this->targetPoint = target; return true; } return false; } -int16_t Navigation::fixDegree(int16_t degree) { - while (degree < -180 || degree > 180) { - if (degree > 180) - degree -= 360; - else if (degree < -180) - degree += 360; +int16_t Navigation::fixDegree(int16_t degree) +{ + static constexpr uint16_t fullCircle = 360; + + while (degree < -fullCircle / 2 || degree > fullCircle / 2) + { + if (degree > fullCircle / 2) + { + degree -= fullCircle; + } + else if (degree < -fullCircle / 2) + { + degree += fullCircle; + } } return degree; } diff --git a/lib/Navigation/navigation.h b/lib/Navigation/navigation.h index 55ae3ee..cfe7ed6 100644 --- a/lib/Navigation/navigation.h +++ b/lib/Navigation/navigation.h @@ -4,9 +4,9 @@ * @brief Contains a class which navigate an object by the given route * @version 0.1 * @date 2022-01-10 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef NAVIGATION_H @@ -21,143 +21,144 @@ /** * @brief This struct inherits the result of the navigation - * + * * The drive get objects of this struct and should * correct the direction in dependency on this. - * + * */ -struct CourseCorrection { +struct CourseCorrection +{ int16_t correction; double distance; }; /** * @brief This class navigate an object - * + * * The class use the given Route and the gps device * to tell the driver in which direction he have to * be drive and the distance to the next checkpoint. - * + * */ -class Navigation : public Component { - public: - enum Status { - InsufficientAccuracy, - Unchanged, - Updated, - Complete - }; +class Navigation : public Component +{ +public: + enum Status + { + InsufficientAccuracy, + Unchanged, + Updated, + Complete + }; - /** - * @brief Construct a new Navigation object and using I2C - * - * @param route with which to navigate - */ - Navigation(const SensorData* sensorData, Route* route = nullptr); + /** + * @brief Construct a new Navigation object and using I2C + * + * @param route with which to navigate + */ + Navigation(const SensorData *sensorData, Route *route = nullptr); - /** - * @brief Destroy the Navigation object - * - */ - ~Navigation(); + /** + * @brief Destroy the Navigation object + * + */ + ~Navigation(); - /** - * @brief creates a new empty route - * - */ - void newRoute(); + /** + * @brief creates a new empty route + * + */ + void newRoute(); - /** - * @brief Tries to start the route - * - * For example the route can not be started - * if there are no Points or wrong Points. - * - * @return true route is started - * @return false route can not be started - */ - bool startNavigation(); - void freezeTargetPoint(bool val = true) { this->preventNextPoint = val; }; - - - double increaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint += 0.1; } - double decreaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint -= 0.1; } + /** + * @brief Tries to start the route + * + * For example the route can not be started + * if there are no Points or wrong Points. + * + * @return true route is started + * @return false route can not be started + */ + bool startNavigation(); + void freezeTargetPoint(bool val = true) { this->preventNextPoint = val; }; - // TODO: Dokumentation korrigieren. - /** - * @brief Get the Course Correction object - * - * This should be called by the driver to get new instructions. - * - * @param correction passed as refernce to get the data - * @return true if new correction data provided - * @return false if route is finished - */ - Status getCourseCorrection(CourseCorrection& correction, bool forceUpdate = false); + double increaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint += 0.1; } + double decreaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint -= 0.1; } + // TODO: Dokumentation korrigieren. + /** + * @brief Get the Course Correction object + * + * This should be called by the driver to get new instructions. + * + * @param correction passed as refernce to get the data + * @return true if new correction data provided + * @return false if route is finished + */ + Status getCourseCorrection(CourseCorrection &correction, bool forceUpdate = false); - // TODO: Dokumentation korrigieren. - /** - * @brief Tries to add the current Position to the route - * - * This can be go wrong if there is no valid GPS signal - * - * @return true successful added point - * @return false no point added to route - */ - Status addCurrentPosToRoute(); + // TODO: Dokumentation korrigieren. + /** + * @brief Tries to add the current Position to the route + * + * This can be go wrong if there is no valid GPS signal + * + * @return true successful added point + * @return false no point added to route + */ + Status addCurrentPosToRoute(); - /** - * @brief Get the Route Info object - * - * This object contains information about the route. - * For example the stored points. - * - * @return RouteInfo - */ - RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); } - Route* getRoute() const { return this->route; } - Point getCurrentPosition() const { return this->currentPosition; } + /** + * @brief Get the Route Info object + * + * This object contains information about the route. + * For example the stored points. + * + * @return RouteInfo + */ + RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); } + Route *getRoute() const { return this->route; } + Point getCurrentPosition() const { return this->currentPosition; } - Point::Accuracy getMinAccuracy() const { return this->minAccuracy; } - void setMinAccuracy(Point::Accuracy accuracy) { this->minAccuracy = accuracy; } + Point::Accuracy getMinAccuracy() const { return this->minAccuracy; } + void setMinAccuracy(Point::Accuracy accuracy) { this->minAccuracy = accuracy; } - // map input in range from -180 to 180 degree - static int16_t fixDegree(int16_t degree); + // map input in range from -180 to 180 degree + static int16_t fixDegree(int16_t degree); - private: - void run() override; - void init(Route* route); - bool nextPoint(); - bool setTargetPoint(Point target); - int16_t calculateCourseCorrection(Point& point); +private: + void run() override; + void init(Route *route); + bool nextPoint(); + bool setTargetPoint(Point target); + int16_t calculateCourseCorrection(Point &point); - static constexpr uint8_t loopDelay = 20; - static constexpr uint8_t maxDisBetweenPoints = 10; - static constexpr float minDisBetweenPoints = 0.3; - - const SensorData* sensorData; - Route* route = nullptr; + static constexpr uint8_t loopDelay = 20; + static constexpr uint8_t maxDisBetweenPoints = 10; + static constexpr float minDisBetweenPoints = 0.3; - Point lastPointRouteInsert; - Point lastPointCalcCorrection; - Point lastPointDrivingDirectionChange; - Point targetPoint; - Point currentPosition; - Point::Accuracy minAccuracy = Point::Accuracy::twoDigOfCM; - - bool navigationStarted = false; - bool navigationFinished = false; - bool isNtripInit = false; - bool preventNextPoint = false; - bool directionChangeMode = false; - bool lastUsedCalcAzimuth = false; + const SensorData *sensorData; + Route *route = nullptr; - uint8_t timeToWait = 200; - uint32_t lastMillis = 0; - uint32_t ubxUpdateTime = 0; + Point lastPointRouteInsert; + Point lastPointCalcCorrection; + Point lastPointDrivingDirectionChange; + Point targetPoint; + Point currentPosition; + Point::Accuracy minAccuracy = Point::Accuracy::twoDigOfCM; - double minDistanceToReachPoint = 0.5; + bool navigationStarted = false; + bool navigationFinished = false; + bool isNtripInit = false; + bool preventNextPoint = false; + bool directionChangeMode = false; + bool lastUsedCalcAzimuth = false; + + uint8_t timeToWait = 200; + uint32_t lastMillis = 0; + uint32_t ubxUpdateTime = 0; + + double minDistanceToReachPoint = 0.5; }; #endif // NAVIGATION_H diff --git a/lib/Network/network.cpp b/lib/Network/network.cpp index 40456e0..3479e3e 100644 --- a/lib/Network/network.cpp +++ b/lib/Network/network.cpp @@ -1,33 +1,38 @@ /** * @file network.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-18 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "network.h" -Network::Network(const char *ssid, const char *passphrase) { - if (!WiFi.mode(WIFI_AP_STA)) +Network::Network(const char *ssid, const char *passphrase) +{ + if (!WiFiGenericClass::mode(WIFI_AP_STA)) + { std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; + } this->init(ssid, passphrase); } -Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) { - this->adresses = adresses; - - if (!WiFi.mode(WIFI_AP_STA)) +Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) + : adresses{adresses} +{ + if (!WiFiGenericClass::mode(WIFI_AP_STA)) + { std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; + } if (!WiFi.config(this->adresses.localIP, this->adresses.gateway, this->adresses.subnet, - this->adresses.dnsServer)) + this->adresses.dnsServer)) { std::cout << "STA Failed to configure" << std::endl; } @@ -35,13 +40,15 @@ Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adres this->init(ssid, passphrase); } -Network::~Network() { - if (this->mqttClient) - delete mqttClient; +Network::~Network() +{ + delete mqttClient; } -bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { - if (esp_now_init() != ESP_OK) { +bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) +{ + if (esp_now_init() != ESP_OK) + { std::cout << "Network::activateEspNow - Error initializing ESP-NOW" << std::endl; return false; } @@ -49,11 +56,12 @@ bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { esp_now_register_send_cb(send); esp_now_peer_info_t peerInfo = {}; - memcpy(peerInfo.peer_addr, this->broadcastAddress, 6); - peerInfo.channel = 0; + memcpy(static_cast(peerInfo.peer_addr), static_cast(this->broadcastAddress), 6); + peerInfo.channel = 0; peerInfo.encrypt = false; - if (esp_now_add_peer(&peerInfo) != ESP_OK) { + if (esp_now_add_peer(&peerInfo) != ESP_OK) + { std::cout << "Network::connectEspNow - Failed to add peer" << std::endl; return false; } @@ -62,7 +70,8 @@ bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { return true; } -bool Network::activateMqtt(const char *user, const char *passphrase) { +bool Network::activateMqtt(const char *user, const char *passphrase) +{ this->mqttUser = user; this->mqttPassphrase = passphrase; @@ -71,53 +80,68 @@ bool Network::activateMqtt(const char *user, const char *passphrase) { this->mqttClient->setSocketTimeout(1); if (this->wifiConnected) + { return this->connectMqtt(); + } return false; } -void Network::printIPs() { +const void Network::printIPs() +{ std::cout << std::endl; - if (!this->wifiConnected) { + if (!this->wifiConnected) + { std::cout << "WiFi is not connected." << std::endl; return; } std::cout << "WiFi is connected to" << std::endl; std::cout << "IP address: " << std::endl; std::cout << WiFi.localIP().toString().c_str() << std::endl; - std::cout << "WiFi MAC Address: " << WiFi.macAddress().c_str() << std::endl << std::endl; + std::cout << "WiFi MAC Address: " << WiFi.macAddress().c_str() << std::endl + << std::endl; } -uint8_t Network::getCurrentChannel() { - uint8_t channel; - wifi_second_chan_t secondChannel; - if (esp_wifi_get_channel(&channel, &secondChannel) != ESP_OK) { +uint8_t Network::getCurrentChannel() +{ + uint8_t channel = 0; + wifi_second_chan_t secondChannel = WIFI_SECOND_CHAN_NONE; + if (esp_wifi_get_channel(&channel, &secondChannel) != ESP_OK) + { std::cout << "Network::getCurrentChannel - Error!" << std::endl; return -1; } - + return channel; } -void Network::runAsChild() { +void Network::runAsChild() +{ if (!this->initSucessful) + { return; + } this->checkWifi(); - if (this->wifiConnected && this->mqttClient) + if (this->wifiConnected && static_cast(this->mqttClient)) + { this->checkMqtt(); + } } -void Network::init(const char *ssid, const char *passphrase) { +void Network::init(const char *ssid, const char *passphrase) +{ // Connect to Wi-Fi network with SSID and password std::cout << "Connecting to " << ssid << std::endl; WiFi.begin(ssid, passphrase); uint8_t timeout = Network::wifiConnectTimeout; - while (WiFi.status() != WL_CONNECTED) { + while (WiFiSTAClass::status() != WL_CONNECTED) + { delay(Network::wifiConnectLoopTime); std::cout << "." << std::flush; timeout--; - if (timeout == 0) { + if (timeout == 0) + { std::cout << std::endl; std::cout << "WiFi NOT connected." << std::endl; return; @@ -128,9 +152,9 @@ void Network::init(const char *ssid, const char *passphrase) { this->printIPs(); } -void Network::checkWifi() { - if ((WiFi.status() != WL_CONNECTED) - && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay)) +void Network::checkWifi() +{ + if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay)) { std::cout << "Reconnecting to WiFi..." << std::endl; WiFi.disconnect(); @@ -139,29 +163,39 @@ void Network::checkWifi() { } } -void Network::checkMqtt() { - if (!this->mqttClient->connected() - && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay) +void Network::checkMqtt() +{ + if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay) { this->mqttConnected = this->connectMqtt(); this->lastMqttReconnectAttemp = millis(); } if (this->mqttConnected) + { this->mqttClient->loop(); + } } -bool Network::connectMqtt() { +bool Network::connectMqtt() +{ String clientId = "ESP32Rover-"; - clientId += String(random(0xffff), HEX); + clientId += String(random(), HEX); - if (this->mqttUser) { + if (static_cast(this->mqttUser)) + { if (this->mqttClient->connect(clientId.c_str(), this->mqttUser, this->mqttPassphrase)) + { this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); - } else { - if (this->mqttClient->connect(clientId.c_str())) - this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); + } } - + else + { + if (this->mqttClient->connect(clientId.c_str())) + { + this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); + } + } + return this->mqttClient->connected(); } diff --git a/lib/Network/network.h b/lib/Network/network.h index 355ebd9..acd7841 100644 --- a/lib/Network/network.h +++ b/lib/Network/network.h @@ -1,12 +1,12 @@ /** * @file network.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-18 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef NETWORK_H @@ -20,10 +20,11 @@ #include #include -typedef void (*recieveCallbackPtr) (const uint8_t * mac, const uint8_t *incomingData, int len); -typedef void (*sendCallbackPtr) (const uint8_t *mac_addr, esp_now_send_status_t status); +typedef void (*recieveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len); +typedef void (*sendCallbackPtr)(const uint8_t *mac_addr, esp_now_send_status_t status); -struct NetworkAdresses { +struct NetworkAdresses +{ IPAddress localIP; IPAddress gateway; IPAddress subnet; @@ -32,53 +33,53 @@ struct NetworkAdresses { uint16_t mqttPort = 1883; }; -class Network : public Component { - public: - Network(const char *ssid, const char *passphrase); - Network(const char *ssid, const char *passphrase, NetworkAdresses adresses); +class Network : public Component +{ +public: + Network(const char *ssid, const char *passphrase); + Network(const char *ssid, const char *passphrase, NetworkAdresses adresses); - ~Network(); + ~Network(); - bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send); - bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr); + bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send); + bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr); - void printIPs(); + const void printIPs(); - bool isWifiConnected() const { return this->wifiConnected; } - bool isMqttConnected() const { return this->mqttConnected; } - const uint8_t* getBroadcastAddress() const { return this->broadcastAddress; } - PubSubClient* getMqttClient() const { return this->mqttClient; } + bool isWifiConnected() const { return this->wifiConnected; } + bool isMqttConnected() const { return this->mqttConnected; } + const uint8_t *getBroadcastAddress() const { return this->broadcastAddress; } + PubSubClient *getMqttClient() const { return this->mqttClient; } - static uint8_t getCurrentChannel(); - - private: - void run() override {}; - void runAsChild() override; - void init(const char *ssid, const char *passphrase); - void checkWifi(); - void checkMqtt(); - bool connectMqtt(); + static uint8_t getCurrentChannel(); - NetworkAdresses adresses; - WiFiClient wifiClient; - PubSubClient* mqttClient = nullptr; +private: + void run() override{}; + void runAsChild() override; + void init(const char *ssid, const char *passphrase); + void checkWifi(); + void checkMqtt(); + bool connectMqtt(); - bool initSucessful = false; - bool wifiConnected = false; - bool mqttConnected = false; + NetworkAdresses adresses; + WiFiClient wifiClient; + PubSubClient *mqttClient = nullptr; - const char *mqttUser; - const char *mqttPassphrase; + bool initSucessful = false; + bool wifiConnected = false; + bool mqttConnected = false; - uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10}; - uint32_t lastWifiRecoonectAttemp = 0; - uint32_t lastMqttReconnectAttemp = 0; + const char *mqttUser = nullptr; + const char *mqttPassphrase = nullptr; - static constexpr uint8_t wifiConnectTimeout = 20; - static constexpr uint16_t wifiConnectLoopTime = 500; - static constexpr uint16_t wifiReconnectDelay = 5000; - static constexpr uint16_t mqttReconnectDelay = 2500; + uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10}; + uint32_t lastWifiRecoonectAttemp = 0; + uint32_t lastMqttReconnectAttemp = 0; + static constexpr uint8_t wifiConnectTimeout = 20; + static constexpr uint16_t wifiConnectLoopTime = 500; + static constexpr uint16_t wifiReconnectDelay = 5000; + static constexpr uint16_t mqttReconnectDelay = 2500; }; -#endif //NETWORK_H +#endif // NETWORK_H diff --git a/lib/NtripClient/ntripClient.cpp b/lib/NtripClient/ntripClient.cpp index 847f877..731442c 100644 --- a/lib/NtripClient/ntripClient.cpp +++ b/lib/NtripClient/ntripClient.cpp @@ -4,84 +4,90 @@ * @brief Contains the implementation of the class NTRIPClient. * @version 0.1 * @date 2022-09-18 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "ntripClient.h" - -NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) { - this->gps = gps; - strcpy(this->host, host); - this->port = port; - strcpy(this->mountPoint, mountPoint); - strcpy(this->user, user); - strcpy(this->password, password); - - this->ntripClient = new WiFiClient; - this->state = NTRIPClientStates::closeConnection; - - this->loopDelay = 20; +NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS *gps, const char *host, uint16_t port, const char *mountPoint, const char *user, const char *password) + : gps{gps}, port{port}, host{host}, mountPoint{mountPoint}, user{user}, password{password}, ntripClient{new WiFiClient}, state{NTRIPClientStates::closeConnection} +{ + Component::loopDelay = NTRIPClient::loopDelay; } -NTRIPClient::~NTRIPClient() { +NTRIPClient::~NTRIPClient() +{ delete this->ntripClient; } -void NTRIPClient::run() { - switch (this->state) { - case NTRIPClientStates::openConnection: - if (!this->activated) { - this->state = NTRIPClientStates::closeConnection; - break; - } - - std::cout << "Connecting to the NTRIP caster..." << std::endl; - if (this->beginClient()) { - std::cout << "Connected to the NTRIP caster!" << std::endl; - this->state = NTRIPClientStates::pushData; - } else { - std::cout << "Failed!" << std::endl; - this->state = NTRIPClientStates::wait; - this->activated = false; - } - break; - - case NTRIPClientStates::pushData: - if (!processConnection() || !this->activated) - this->state = NTRIPClientStates::closeConnection; - break; - - case NTRIPClientStates::closeConnection: - std::cout << "Closing the connection to the NTRIP caster..." << std::endl; - this->closeConnection(); - state = NTRIPClientStates::wait; - break; - - case NTRIPClientStates::wait: - if (this->activated) - this->state = NTRIPClientStates::openConnection; - else - this->checkAutoReconnect(); - break; - - case NTRIPClientStates::notAvailable: - break; - - default: - std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl; +void NTRIPClient::run() +{ + switch (this->state) + { + case NTRIPClientStates::openConnection: + if (!this->activated) + { this->state = NTRIPClientStates::closeConnection; break; + } + + std::cout << "Connecting to the NTRIP caster..." << std::endl; + if (this->beginClient()) + { + std::cout << "Connected to the NTRIP caster!" << std::endl; + this->state = NTRIPClientStates::pushData; + } + else + { + std::cout << "Failed!" << std::endl; + this->state = NTRIPClientStates::wait; + this->activated = false; + } + break; + + case NTRIPClientStates::pushData: + if (!processConnection() || !this->activated) + { + this->state = NTRIPClientStates::closeConnection; + } + break; + + case NTRIPClientStates::closeConnection: + std::cout << "Closing the connection to the NTRIP caster..." << std::endl; + this->closeConnection(); + state = NTRIPClientStates::wait; + break; + + case NTRIPClientStates::wait: + if (this->activated) + { + this->state = NTRIPClientStates::openConnection; + } + else + { + this->checkAutoReconnect(); + } + break; + + case NTRIPClientStates::notAvailable: + break; + + default: + std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl; + this->state = NTRIPClientStates::closeConnection; + break; } } -void NTRIPClient::runAsChild() { +void NTRIPClient::runAsChild() +{ this->pushGPGGA(); } -void NTRIPClient::gpsConfiguration() { +void NTRIPClient::gpsConfiguration() +{ this->gps->setSPIOutput(COM_TYPE_UBX | COM_TYPE_NMEA); this->gps->setPortInput(COM_PORT_SPI, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); // Set the differential mode - ambiguities are fixed whenever possible @@ -90,21 +96,28 @@ void NTRIPClient::gpsConfiguration() { this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10); } -bool NTRIPClient::setActivated(bool state) { - // std::cout << "NTRIPClient::setActivated: b - " << b << std::endl; +bool NTRIPClient::setActivated(bool state) +{ if (state && this->state != NTRIPClientStates::notAvailable) + { this->activated = true; + } else if (state) + { return false; - else { + } + else + { this->activated = false; this->autoReconnect = false; } return true; } -void NTRIPClient::setAutoReconnect(bool state) { - if (state) { +void NTRIPClient::setAutoReconnect(bool state) +{ + if (state) + { this->reconnectAttemps = 0; this->autoReconnect = true; return; @@ -113,61 +126,67 @@ void NTRIPClient::setAutoReconnect(bool state) { this->autoReconnect = false; } -bool NTRIPClient::beginClient() { +bool NTRIPClient::beginClient() +{ + static constexpr uint16_t httpError = 401; + static constexpr uint16_t httpCheck = 200; + std::cout << "Opening socket to " << this->host << std::endl; char serverRequest[this->bufferSize]; char credentials[this->bufferSize]; - if (!this->ntripClient->connect(this->host, this->port)) { + if (!static_cast(this->ntripClient->connect(static_cast(this->host), this->port))) + { std::cout << "Connection to caster failed" << std::endl; return false; - } else { - std::cout << "Connected to " << this->host << " : " << this->port << std::endl; - std::cout << "Requesting NTRIP Data from mount point " << this->mountPoint << std::endl; - - // Generate the server request (GET) - snprintf(serverRequest, - this->bufferSize, - "GET /%s HTTP/1.0\r\nUser-Agent: NTRIP SparkFun u-blox Client v1.0\r\n", - this->mountPoint); - - // Credentials - uint8_t userCredentialsLength = strlen(this->user) + strlen(this->password) + 2; - char* userCredentials = new char[userCredentialsLength]; - snprintf(userCredentials, userCredentialsLength, "%s:%s", this->user, this->password); - - std::cout << "Sending credentials: " << userCredentials << std::endl; - - //Encode - base64 b; - String strEncodedCredentials = b.encode(userCredentials); - delete userCredentials; - char encodedCredentials[strEncodedCredentials.length() + 1]; - strEncodedCredentials.toCharArray(encodedCredentials, sizeof(encodedCredentials)); - - snprintf(credentials, sizeof(credentials), "Authorization: Basic %s\r\n", encodedCredentials); } + std::cout << "Connected to " << this->host << " : " << this->port << std::endl; + std::cout << "Requesting NTRIP Data from mount point " << this->mountPoint << std::endl; + + // Generate the server request (GET) + snprintf(static_cast(serverRequest), + this->bufferSize, + static_cast("GET /%s HTTP/1.0\r\nUser-Agent: NTRIP SparkFun u-blox Client v1.0\r\n"), + this->mountPoint); + + // Credentials + const uint8_t userCredentialsLength = strlen(this->user) + strlen(this->password) + 2; + auto *userCredentials = new char[userCredentialsLength]; + snprintf(static_cast(userCredentials), userCredentialsLength, static_cast("%s:%s"), this->user, this->password); + + std::cout << "Sending credentials: " << userCredentials << std::endl; + + // Encode + const base64 base; + const String strEncodedCredentials = base64::encode(userCredentials); + delete userCredentials; + char encodedCredentials[strEncodedCredentials.length() + 1]; + strEncodedCredentials.toCharArray(static_cast(encodedCredentials), sizeof(encodedCredentials)); + + snprintf(credentials, sizeof(credentials), static_cast("Authorization: Basic %s\r\n"), static_cast(encodedCredentials)); // Add the encoded credentials to the server request - strncat(serverRequest, credentials, this->bufferSize); - strncat(serverRequest, "\r\n", this->bufferSize); + strncat(static_cast(serverRequest), static_cast(credentials), this->bufferSize); + strncat(static_cast(serverRequest), static_cast("\r\n"), this->bufferSize); - std::cout << "serverRequest size: " - << strlen(serverRequest) - << " of " - << this->bufferSize - << " bytes available" - << std::endl; + std::cout << static_cast("serverRequest size: ") + << strlen(serverRequest) + << static_cast(" of ") + << this->bufferSize + << static_cast(" bytes available") + << std::endl; // Send the server request std::cout << "Sending server request: " << serverRequest << std::endl; this->ntripClient->write(serverRequest, strlen(serverRequest)); - //Wait up to 5 seconds for response - uint32_t lastMillis = millis(); - while (!ntripClient->available()) { - if (millis() - lastMillis > this->timeOut) { + // Wait up to 5 seconds for response + const uint32_t lastMillis = millis(); + while (static_cast(!ntripClient->available())) + { + if (millis() - lastMillis > this->timeOut) + { std::cout << "Caster timed out!" << std::endl; this->ntripClient->stop(); return false; @@ -175,35 +194,48 @@ bool NTRIPClient::beginClient() { delay(10); } - //Check reply + // Check reply uint16_t httpStatusCode = 0; char response[this->bufferSize]; uint16_t responseIndex = 0; - while (this->ntripClient->available()) { + while (static_cast(this->ntripClient->available())) + { if (responseIndex == sizeof(response)) + { break; + } response[responseIndex++] = ntripClient->read(); - if (httpStatusCode == 0) { - if (strstr(response, "200") != nullptr) - httpStatusCode = 200; - if (strstr(response, "401") != nullptr) - httpStatusCode = 401; + if (httpStatusCode == 0) + { + if (strstr(response, static_cast("200")) != nullptr) + { + httpStatusCode = httpCheck; + } + if (strstr(response, static_cast("401")) != nullptr) + { + httpStatusCode = httpError; + } } } response[responseIndex] = '\0'; // std::cout << "Caster response: " << response << std::endl; - if (httpStatusCode != 200) { - std::cout << "Failed to connect to " << this->host << " - HTTP Code: " << (int) httpStatusCode + if (httpStatusCode != httpCheck) + { + std::cout << "Failed to connect to " << this->host << " - HTTP Code: " << (int)httpStatusCode << " Length of Response: " << responseIndex << std::endl; if (httpStatusCode == 0) + { std::cout << "Response: " << response << std::endl; - else if (httpStatusCode == 401) + } + else if (httpStatusCode == httpError) + { std::cout << "Statuscode 401 - Unauthorized" << std::endl; + } return false; } @@ -212,35 +244,47 @@ bool NTRIPClient::beginClient() { return true; } -void NTRIPClient::closeConnection() { - if (this->ntripClient->connected()) +void NTRIPClient::closeConnection() +{ + if (static_cast(this->ntripClient->connected())) + { this->ntripClient->stop(); + } this->activated = false; std::cout << "NtripClient disconnected from: " << this->host << std::endl; } -bool NTRIPClient::processConnection() { - if (this->ntripClient->connected()) { +bool NTRIPClient::processConnection() +{ + if (static_cast(this->ntripClient->connected())) + { uint8_t rtcmData[this->bufferSize * 8]; uint16_t rtcmCount = 0; - while (this->ntripClient->available()) { + while (static_cast(this->ntripClient->available())) + { rtcmData[rtcmCount++] = ntripClient->read(); if (rtcmCount == sizeof(rtcmData)) + { break; + } } - if (rtcmCount > 0) { + if (rtcmCount > 0) + { this->lastReceivedRtcmTime = millis(); - this->gps->pushRawData(rtcmData, rtcmCount); + this->gps->pushRawData(static_cast(rtcmData), rtcmCount); // std::cout << "Pushed " << rtcmCount << " RTCM bytes to ZED." << std::endl; } - } else { + } + else + { std::cout << "Connection to " << this->host << " dropped!" << std::endl; return false; } - if (millis() - this->lastReceivedRtcmTime > this->timeOut) { + if (millis() - this->lastReceivedRtcmTime > this->timeOut) + { std::cout << "RTCM timeout!" << std::endl; return false; } @@ -248,15 +292,21 @@ bool NTRIPClient::processConnection() { return true; } -void NTRIPClient::checkAutoReconnect() { +void NTRIPClient::checkAutoReconnect() +{ if (!this->autoReconnect) + { return; + } if (millis() - this->lastReconnectTime < this->reconnectDelayTime) + { return; + } this->lastReconnectTime = millis(); - if (this->reconnectAttemps >= this->maxReconnectAttemps) { + if (this->reconnectAttemps >= this->maxReconnectAttemps) + { this->autoReconnect = false; return; } @@ -265,26 +315,34 @@ void NTRIPClient::checkAutoReconnect() { this->reconnectAttemps++; } -void NTRIPClient::pushGPGGA() { +void NTRIPClient::pushGPGGA() +{ if (!this->transmitLocation && !this->activated) + { return; + } if (millis() - this->lastGPGGAPushTime < this->pushGPGGATime) + { return; + } this->lastGPGGAPushTime = millis(); if (!this->ntripClient->connected()) + { std::cout << "Failed to pushing GGA to server: " << std::endl; - - NMEA_GGA_data_t *data = new NMEA_GGA_data_t; - uint8_t res = this->gps->getLatestNMEAGPGGA(data); + } + + auto *data = new NMEA_GGA_data_t; + const uint8_t res = this->gps->getLatestNMEAGPGGA(data); if (res == 2) - this->ntripClient->print((const char *)data); + { + this->ntripClient->print(reinterpret_cast(data)); + } delete data; } -bool NTRIPClient::isConnected() { - if (this->state == NTRIPClientStates::pushData) - return true; - return false; +bool NTRIPClient::isConnected() +{ + return this->state == NTRIPClientStates::pushData; } diff --git a/lib/NtripClient/ntripClient.h b/lib/NtripClient/ntripClient.h index 577bbfa..9c2fded 100644 --- a/lib/NtripClient/ntripClient.h +++ b/lib/NtripClient/ntripClient.h @@ -4,9 +4,9 @@ * @brief Contains the class NTRIPClient * @version 0.1 * @date 2023-02-13 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef NTRIP_CLIENT @@ -22,109 +22,113 @@ #include "component.h" /** - * @brief States for the state machine. - * + * @brief States for the state machine. + * */ -enum NTRIPClientStates { - openConnection, - pushData, - closeConnection, - wait, - notAvailable +enum NTRIPClientStates +{ + openConnection, + pushData, + closeConnection, + wait, + notAvailable }; /** * @brief Ntrip Client - * + * * This class can connect to a ntrip server to pull correction * data and push it to a given gnss module. This module have to be compatible * with the SparkFun u-blox GNSS Arduino Library. */ -class NTRIPClient : public Component { - public: - /** - * @brief Construct a new NTRIPClient object - * - * @param gps The Gnss module - * @param host - * @param port - * @param mountPoint - * @param user - * @param password - */ - NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password); - ~NTRIPClient(); +class NTRIPClient : public Component +{ +public: + /** + * @brief Construct a new NTRIPClient object + * + * @param gps The Gnss module + * @param host + * @param port + * @param mountPoint + * @param user + * @param password + */ + NTRIPClient(SFE_UBLOX_GNSS *gps, const char *host, uint16_t port, const char *mountPoint, const char *user, const char *password); + ~NTRIPClient(); - /** - * @brief Configure the Gnss module to accept correction data - * - */ - void gpsConfiguration(); + /** + * @brief Configure the Gnss module to accept correction data + * + */ + void gpsConfiguration(); - /** - * @brief Activate or deactivate the location transmission - * - * Some server need the position of the Gnss module to send the - * right correction data. - * - * @param b - */ - void setTransmitLocation(bool b) { this->transmitLocation = b; } + /** + * @brief Activate or deactivate the location transmission + * + * Some server need the position of the Gnss module to send the + * right correction data. + * + * @param b + */ + void setTransmitLocation(bool b) { this->transmitLocation = b; } - /** - * @brief Activate or deactivate the connection to the server. - * - * @param state - * @return true success - * @return false failure - */ - bool setActivated(bool state); - void setAutoReconnect(bool state); + /** + * @brief Activate or deactivate the connection to the server. + * + * @param state + * @return true success + * @return false failure + */ + bool setActivated(bool state); + void setAutoReconnect(bool state); - bool isConnected(); + bool isConnected(); - /** - * @brief Get the Client State object - * - * Returns the state of the State machine - * - * @return NTRIPClientStates - */ - NTRIPClientStates getClientState() { return this->state; } + /** + * @brief Get the Client State object + * + * Returns the state of the State machine + * + * @return NTRIPClientStates + */ + NTRIPClientStates getClientState() { return this->state; } - private: - void run() override; - void runAsChild() override; - void pushGPGGA(); - bool beginClient(); - void closeConnection(); - bool processConnection(); - void checkAutoReconnect(); +private: + void run() override; + void runAsChild() override; + void pushGPGGA(); + bool beginClient(); + void closeConnection(); + bool processConnection(); + void checkAutoReconnect(); - SFE_UBLOX_GNSS* gps; - WiFiClient* ntripClient; - NTRIPClientStates state = NTRIPClientStates::notAvailable; + SFE_UBLOX_GNSS *gps; + WiFiClient *ntripClient; + NTRIPClientStates state = NTRIPClientStates::notAvailable; - bool transmitLocation = false; - bool activated = true; - bool autoReconnect = false; + bool transmitLocation = false; + bool activated = true; + bool autoReconnect = false; - uint8_t reconnectAttemps = 0; - uint16_t port; - uint32_t lastReceivedRtcmTime = 0; - // uint32_t lastNtripConnectTime = 0; // can deleted? - uint32_t lastGPGGAPushTime = 0; - uint32_t lastReconnectTime = 0; + uint8_t reconnectAttemps = 0; + uint16_t port; + uint32_t lastReceivedRtcmTime = 0; + // uint32_t lastNtripConnectTime = 0; // can deleted? + uint32_t lastGPGGAPushTime = 0; + uint32_t lastReconnectTime = 0; - char host[128]; - char mountPoint[128]; - char user[128]; - char password[128]; - const uint8_t maxReconnectAttemps = 10; - const uint16_t reconnectDelayTime = 1000; - const uint16_t timeOut = 10000; - const uint16_t bufferSize = 512; - const uint16_t pushGPGGATime = 10000; + const char *host; + const char *mountPoint; + const char *user; + const char *password; + const uint8_t maxReconnectAttemps = 10; + const uint16_t reconnectDelayTime = 1000; + const uint16_t timeOut = 10000; + const uint16_t bufferSize = 512; + const uint16_t pushGPGGATime = 10000; + + static constexpr uint8_t loopDelay = 20; }; #endif diff --git a/lib/Point/point.cpp b/lib/Point/point.cpp index eee438e..a87be22 100644 --- a/lib/Point/point.cpp +++ b/lib/Point/point.cpp @@ -1,104 +1,118 @@ /** * @file point.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "point.h" -Point::Point(double lat, double lon, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates.lat = lat; - this->coordinates.lon = lon; +Point::Point(double lat, double lon, uint32_t horizontalAccuracy, uint32_t creationTime) + : coordinates{lat, lon} +{ this->init(horizontalAccuracy, creationTime); } -Point::Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates.lat = lat / 10000000.0; - this->coordinates.lon = lon / 10000000.0; +Point::Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy, uint32_t creationTime) + : coordinates{lat / 10000000.0, lon / 10000000.0} +{ this->init(horizontalAccuracy, creationTime); } -Point::Point(Coordinates coords, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates = coords; +Point::Point(Coordinates coords, uint32_t horizontalAccuracy, uint32_t creationTime) + : coordinates{coords} +{ this->init(horizontalAccuracy, creationTime); } -Point::Point(Coordinates coords, bool imported) { +Point::Point(Coordinates coords, bool imported) +{ this->coordinates = coords; if (imported) + { this->init(UINT32_MAX, 0); + } else + { this->init(0, 0); + } } -Point::Point() { +Point::Point() +{ this->coordinates.lat = 0; - this->coordinates.lon = 0; + this->coordinates.lon = 0; this->init(0, 0); } -bool Point::operator==(const Point& rhs) const { +bool Point::operator==(const Point &rhs) const +{ return this->coordinates == rhs.getCoordinates(); } - // distance = sqrt(dx * dx + dy * dy) - // mit distance: Entfernung in km - // dx = 111.3 * cos(lat) * (lon1 - lon2) - // lat = (lat1 + lat2) / 2 * 0.01745 - // dy = 111.3 * (lat1 - lat2) - // lat1, lat2, lon1, lon2: Breite, Länge in Grad -double Point::distanceTo(const Coordinates& point) const { - Coordinates begin = this->coordinates; - Coordinates end = point; +double Point::distanceTo(const Coordinates &point) const +{ + const Coordinates begin = this->coordinates; + const Coordinates end = point; - double lat = (begin.lat + end.lat) / 2 * ROUTE_DEGREE_TO_RADIANT; - double dy = ROUTE_DISTANCE_BETWEEN_LATITUDE * (begin.lat - end.lat); - double dx = ROUTE_DISTANCE_BETWEEN_LATITUDE * cos(lat) * (begin.lon - end.lon); + const double lat = (begin.lat + end.lat) / 2 * ROUTE_DEGREE_TO_RADIANT; + const double dy = ROUTE_DISTANCE_BETWEEN_LATITUDE * (begin.lat - end.lat); + const double dx = ROUTE_DISTANCE_BETWEEN_LATITUDE * cos(lat) * (begin.lon - end.lon); return sqrt(dx * dx + dy * dy); } -double Point::distanceTo(const Point &point) const { +double Point::distanceTo(const Point &point) const +{ return this->distanceTo(point.getCoordinates()); } -int16_t Point::courseTo(const Coordinates& point) const { - Coordinates begin = this->coordinates; - Coordinates end = point; +int16_t Point::courseTo(const Coordinates &point) const +{ + const Coordinates begin = this->coordinates; + const Coordinates end = point; - double phi = log( tan(end.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) / tan(begin.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) ); - double lon = (begin.lon * ROUTE_DEGREE_TO_RADIANT - end.lon * ROUTE_DEGREE_TO_RADIANT); + const double phi = log(tan(end.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) / tan(begin.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4)); + const double lon = (begin.lon * ROUTE_DEGREE_TO_RADIANT - end.lon * ROUTE_DEGREE_TO_RADIANT); - int16_t res = static_cast(atan2(lon, phi) / ROUTE_DEGREE_TO_RADIANT) * -1; - - // if (res < 0) - // res += 360; - - return res; + return static_cast(atan2(lon, phi) / ROUTE_DEGREE_TO_RADIANT) * -1; } -int16_t Point::courseTo(const Point &point) const { +int16_t Point::courseTo(const Point &point) const +{ return this->courseTo(point.getCoordinates()); } -void Point::init(uint32_t horizontalAccuracy, uint32_t creationTime) { +void Point::init(uint32_t horizontalAccuracy, uint32_t creationTime) +{ this->creationTime = creationTime; if (horizontalAccuracy == UINT32_MAX) + { this->accuracy = Accuracy::imported; + } else if (horizontalAccuracy > 9999) + { this->accuracy = Accuracy::fourDigOfCM; + } else if (horizontalAccuracy > 999) + { this->accuracy = Accuracy::threeDigOfCM; + } else if (horizontalAccuracy > 99) + { this->accuracy = Accuracy::twoDigOfCM; + } else if (horizontalAccuracy > 1) + { this->accuracy = Accuracy::oneDigOfCM; - else - this->accuracy = Accuracy::none; + } + else + { + this->accuracy = Accuracy::none; + } } diff --git a/lib/Point/point.h b/lib/Point/point.h index 9b7072e..3cc4862 100644 --- a/lib/Point/point.h +++ b/lib/Point/point.h @@ -1,139 +1,142 @@ /** * @file point.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef POINT_H #define POINT_H -#include +#include #define ROUTE_DEGREE_TO_RADIANT 0.01745 #define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300 /** * @brief A to handle points on the earth - * + * * The points inherits latidue and longitude as doubles - * + * */ -class Point{ - public: - /** - * @brief Hold the data longitude and latitude - * - */ - struct Coordinates { - double lon; - double lat; +class Point +{ +public: + /** + * @brief Hold the data longitude and latitude + * + */ + struct Coordinates + { + double lon; + double lat; - bool operator==(const Coordinates rhs) const { - return ( this->lon == rhs.lon ) && ( this->lon == rhs.lon ); - } - }; + bool operator==(const Coordinates rhs) const + { + return (this->lon == rhs.lon) && (this->lon == rhs.lon); + } + }; - /** - * @brief The Accuracy is set by the constructor - * - */ - enum Accuracy { - none, - fourDigOfCM, - threeDigOfCM, - twoDigOfCM, - oneDigOfCM, - imported - }; + /** + * @brief The Accuracy is set by the constructor + * + */ + enum Accuracy + { + none, + fourDigOfCM, + threeDigOfCM, + twoDigOfCM, + oneDigOfCM, + imported + }; + /** + * @brief Construct a new Point object + * + * @param lat latitude + * @param lon longitude + * @param horizontalAccuracy mm + * @param coords Coordinates + * @param imported if true than highest accuracy + */ + Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); + Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); + Point(Coordinates coords, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); + Point(Coordinates coords, bool imported); + Point(); - /** - * @brief Construct a new Point object - * - * @param lat latitude - * @param lon longitude - * @param horizontalAccuracy mm - * @param coords Coordinates - * @param imported if true than highest accuracy - */ - Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(Coordinates coords, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(Coordinates coords, bool imported); - Point(); + /** + * @brief Checks if to points are equal. + * + * @param rhs + * @return true + * @return false + */ + bool operator==(const Point &rhs) const; - /** - * @brief Checks if to points are equal. - * - * @param rhs - * @return true - * @return false - */ - bool operator==(const Point& rhs) const; + /** + * @brief Checks if the point is initalized. + * + * @return true + * @return false + */ + bool isInit() const { return this->coordinates.lat + this->coordinates.lon; } - /** - * @brief Checks if the point is initalized. - * - * @return true - * @return false - */ - bool isInit() const { return this->coordinates.lat + this->coordinates.lon; } + /** + * @brief Checks if the point is valid. + * + * If the accuracy is higher than zero, true will be returned. + * + * @return true + * @return false + */ + bool isValid() const { return (this->accuracy > 0) ? true : false; } - /** - * @brief Checks if the point is valid. - * - * If the accuracy is higher than zero, true will be returned. - * - * @return true - * @return false - */ - bool isValid() const { return (this->accuracy > 0) ? true : false; } + /** + * @brief Calculates the distance between to points. + * + * @param point + * @return double meter + */ + double distanceTo(const Coordinates &point) const; + double distanceTo(const Point &point) const; - /** - * @brief Calculates the distance between to points. - * - * @param point - * @return double meter - */ - double distanceTo(const Coordinates& point) const; - double distanceTo(const Point& point) const; + /** + * @brief Calculates the course to an other point. + * + * @param point + * @return int16_t degree + */ + int16_t courseTo(const Coordinates &point) const; + int16_t courseTo(const Point &point) const; - /** - * @brief Calculates the course to an other point. - * - * @param point - * @return int16_t degree - */ - int16_t courseTo(const Coordinates& point) const; - int16_t courseTo(const Point& point) const; + uint32_t getCreationTime() const { return this->creationTime; } + double getLongitude() const { return this->coordinates.lon; } + double getLatitude() const { return this->coordinates.lat; } + Coordinates getCoordinates() const { return this->coordinates; } - uint32_t getCreationTime() const { return this->creationTime; } - double getLongitude() const { return this->coordinates.lon; } - double getLatitude() const { return this->coordinates.lat; } - Coordinates getCoordinates() const { return this->coordinates; } + /** + * @brief Get the Accuracy object + * + * The higher the value, the greater the accuracy. + * You can check it by Accuracy. + * + * @return Accuracy + */ + Accuracy getAccuracy() const { return this->accuracy; } - /** - * @brief Get the Accuracy object - * - * The higher the value, the greater the accuracy. - * You can check it by Accuracy. - * - * @return Accuracy - */ - Accuracy getAccuracy() const { return this->accuracy; } +private: + void init(uint32_t horizontalAccuracy, uint32_t creationTime); - private: - void init(uint32_t horizontalAccuracy, uint32_t creationTime); + Accuracy accuracy = Accuracy::none; + Coordinates coordinates{0, 0}; - Accuracy accuracy = Accuracy::none; - Coordinates coordinates; - - uint32_t creationTime = 0; + uint32_t creationTime = 0; }; -#endif //POINT_H +#endif // POINT_H diff --git a/lib/Route/route.cpp b/lib/Route/route.cpp index 65d2cf2..d79b5e8 100644 --- a/lib/Route/route.cpp +++ b/lib/Route/route.cpp @@ -4,29 +4,29 @@ * @brief Implements the class Route and Point * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "route.h" -Route::Route() { - -} - -void Route::addPointToRoute(Point point) { +void Route::addPointToRoute(Point point) +{ this->points.push_back(point); } -void Route::clear() { +void Route::clear() +{ this->points.clear(); this->currentPoint = 0; this->started = false; } -Point Route::startRoute() { - if (this->points.size() < 1) { +Point Route::startRoute() +{ + if (this->points.empty()) + { this->started = false; return Point(); } @@ -37,8 +37,10 @@ Point Route::startRoute() { return *this->it; } -Point Route::endRoute() { - if (this->points.size() < 1) { +Point Route::endRoute() +{ + if (this->points.empty()) + { this->started = false; return Point(); } @@ -51,37 +53,47 @@ Point Route::endRoute() { return *this->it; } -Point Route::getNextPoint() { +Point Route::getNextPoint() +{ + Point point; if (!this->started) - return Point(); + { + return point; + } - if (this->it != --this->points.end()) { + if (this->it != --this->points.end()) + { this->it++; this->currentPoint++; return *this->it; - // } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) { - // this->currentPoint++; - // return *this->it; + // } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) { + // this->currentPoint++; + // return *this->it; } - - return Point(); + + return point; } -Point Route::getPreviousPoint() { +Point Route::getPreviousPoint() +{ + Point point; if (!this->started) - return Point(); - - if (this->it != this->points.begin()) { + { + return point; + } + + if (this->it != this->points.begin()) + { this->it--; this->currentPoint--; return *this->it; - } else { - return Point(); } + return point; } -RouteInfo Route::getRouteInfo() { - RouteInfo info; +RouteInfo Route::getRouteInfo() +{ + RouteInfo info{0, 0}; info.totalPoints = this->points.size(); info.currentPoint = this->currentPoint; return info; diff --git a/lib/Route/route.h b/lib/Route/route.h index ab751b7..7b38315 100644 --- a/lib/Route/route.h +++ b/lib/Route/route.h @@ -40,11 +40,6 @@ struct RouteInfo{ */ class Route { public: - /** - * @brief Construct a new Route object. - */ - Route(); - /** * @brief Adds a point to the list. * diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 7c62193..b80c8ac 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -1,30 +1,32 @@ /** * @file senors.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-02 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "sensorData.h" bool SensorData::outputStatusPrintPVTdata = false; uint32_t SensorData::ubxUpdateTimeStatic = 0; -UBX_NAV_PVT_data_t* SensorData::ubxDataStatic = nullptr; +UBX_NAV_PVT_data_t *SensorData::ubxDataStatic = nullptr; -SensorData::SensorData() { - this->loopDelay = 50; +SensorData::SensorData() +{ + Component::loopDelay = SensorData::loopDelay; } -SensorData::~SensorData() { - if (this->ntripClient) - delete this->ntripClient; +SensorData::~SensorData() +{ + delete this->ntripClient; } -void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, String user, String password) { +void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, String user, String password) +{ this->ntripClient = new NTRIPClient(this->gnss, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str()); this->ntripClient->gpsConfiguration(); this->ntripClient->loop(); @@ -33,120 +35,176 @@ void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, Stri this->addChildComponent(this->ntripClient); } -void SensorData::enableGnss(SPIClass* spiPort, uint8_t csPin) { +void SensorData::enableGnss(SPIClass *spiPort, uint8_t csPin) +{ this->gnss = new SFE_UBLOX_GNSS(); - if (this->gnss->begin(*spiPort, csPin, 4000000) == false) { + if (this->gnss->begin(*spiPort, csPin, 4000000) == false) + { std::cout << "u-blox GNSS not detected on SPI bus. Please check wiring. Freezing." << std::endl; - while (1); + while (true) + { + } } this->initGnss(); } -void SensorData::enableGnss() { +void SensorData::enableGnss() +{ this->gnss = new SFE_UBLOX_GNSS(); - if (this->gnss->begin() == false) { + if (this->gnss->begin() == false) + { std::cout << "u-blox GNSS not detected at default I2C address. Please check wiring. Freezing." << std::endl; - while (1); + while (true) + { + } } this->initGnss(); } -void SensorData::enableRealCompass() { +void SensorData::enableRealCompass() +{ + static constexpr byte address = 0x0d; + this->realCompass = new QMC5883LCompass(); // Init Compass - Wire.beginTransmission(0x0d); + Wire.beginTransmission(address); + // TODO: describe Bytes !!! Wire.write(0x0b); Wire.write(0x01); Wire.endTransmission(); - this->realCompass->setMode(0x01,0x0C,0x10,0X00); + this->realCompass->setMode(0x01, 0x0C, 0x10, 0X00); CalibrateCompass caliCompass(this->realCompass); caliCompass.loadData(); caliCompass.useData(); } -void SensorData::enableCalcCompass() { - +void SensorData::enableCalcCompass() +{ + // TODO: !!! implementieren } -void SensorData::enableGyroskop() { +void SensorData::enableGyroskop() +{ this->gyroskop = new MPU6050(); this->gyroskop->initialize(); - if (!this->gyroskop->testConnection()) { + if (!this->gyroskop->testConnection()) + { std::cout << "SensorData::enableGyroskop: Gyroskop is not conntected. Freeze!" << std::endl; - while (true); + while (true) + { + } } - uint8_t deviceStatus = this->gyroskop->dmpInitialize(); + const uint8_t deviceStatus = this->gyroskop->dmpInitialize(); + // TODO: !!! MagicNumer 6x this->gyroskop->setXGyroOffset(220); this->gyroskop->setYGyroOffset(76); this->gyroskop->setZGyroOffset(-85); this->gyroskop->setZAccelOffset(1788); - - if (deviceStatus == 0) { + + if (deviceStatus == 0) + { this->gyroskop->CalibrateAccel(6); this->gyroskop->CalibrateGyro(6); this->gyroskop->PrintActiveOffsets(); this->gyroskop->setDMPEnabled(true); - } else { + } + else + { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) - std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << (int) deviceStatus <<"). Freeze!" << std::endl; - while (true); + std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << static_cast(deviceStatus) << "). Freeze!" << std::endl; + while (true) + { + } } } -CalcAzimuth::State SensorData::getCalcAzimuthState() const { - if (this->calcCompass) +CalcAzimuth::State SensorData::getCalcAzimuthState() const +{ + if (static_cast(this->calcCompass)) + { return this->calcCompass->getState(); + } return CalcAzimuth::State::Invalid; } -NTRIPClientStates SensorData::getNtripState() const { - if (this->ntripClient) +NTRIPClientStates SensorData::getNtripState() const +{ + if (static_cast(this->ntripClient)) + { return this->ntripClient->getClientState(); + } return NTRIPClientStates::notAvailable; } -void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { +void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) +{ + static constexpr uint8_t stringSize = 32; + if (!SensorData::outputStatusPrintPVTdata) + { return; + } - double latitude = (double) ubxDataStruct->lat / 10000000.0; - double longitude = (double) ubxDataStruct->lon / 10000000.0; - double altitude = (double) ubxDataStruct->hMSL / 1000.0; + const double latitude = ubxDataStruct->lat / 10000000.0; + const double longitude = ubxDataStruct->lon / 10000000.0; + const double altitude = ubxDataStruct->hMSL / 1000.0; - uint8_t fixType = ubxDataStruct->fixType; - char fixTypeString[32]; + const uint8_t fixType = ubxDataStruct->fixType; + char fixTypeString[stringSize]; if (fixType == 0) - strcpy(fixTypeString, "None"); + { + strcpy(fixTypeString, static_cast("None")); + } else if (fixType == 1) - strcpy(fixTypeString, "Dead Reckoning"); + { + strcpy(fixTypeString, static_cast("Dead Reckoning")); + } else if (fixType == 2) - strcpy(fixTypeString, "2D"); + { + strcpy(fixTypeString, static_cast("2D")); + } else if (fixType == 3) - strcpy(fixTypeString, "3D"); + { + strcpy(fixTypeString, static_cast("3D")); + } else if (fixType == 3) - strcpy(fixTypeString, "GNSS + Dead Reckoning"); + { + strcpy(fixTypeString, static_cast("GNSS + Dead Reckoning")); + } else if (fixType == 5) - strcpy(fixTypeString, "Time Only"); + { + strcpy(fixTypeString, static_cast("Time Only")); + } else - strcpy(fixTypeString, "UNKNOWN"); + { + strcpy(fixTypeString, static_cast("UNKNOWN")); + } - uint8_t carrSoln = ubxDataStruct->flags.bits.carrSoln; - char carrSolnString[16]; + const uint8_t carrSoln = ubxDataStruct->flags.bits.carrSoln; + char carrSolnString[stringSize]; if (carrSoln == 0) - strcpy(carrSolnString, "None"); + { + strcpy(carrSolnString, static_cast("None")); + } else if (carrSoln == 1) - strcpy(carrSolnString, "Floating"); + { + strcpy(carrSolnString, static_cast("Floating")); + } else if (carrSoln == 2) - strcpy(carrSolnString, "Fixed"); + { + strcpy(carrSolnString, static_cast("Fixed")); + } else - strcpy(carrSolnString, "UNKNOWN"); + { + strcpy(carrSolnString, static_cast("UNKNOWN")); + } - uint32_t hAcc = ubxDataStruct->hAcc; + const uint32_t hAcc = ubxDataStruct->hAcc; std::cout << "Lat: " << latitude << " Lng: " << longitude @@ -157,45 +215,53 @@ void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { << " Horizontal Accuracy Estimate: " << hAcc << " mm" << std::endl; } -void SensorData::savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { +void SensorData::savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) +{ SensorData::printPVTdata(ubxDataStruct); SensorData::ubxDataStatic = ubxDataStruct; SensorData::ubxUpdateTimeStatic = millis(); } -void SensorData::setOutputStatusPrintPVTdata(bool status) { +void SensorData::setOutputStatusPrintPVTdata(bool status) +{ SensorData::outputStatusPrintPVTdata = status; } -void SensorData::run() { - if (this->realCompass) { +void SensorData::run() +{ + if (static_cast(this->realCompass)) + { this->realCompass->read(); this->realAzimuth = this->realCompass->getAzimuth(); } - if (this->gyroskop - && this->gyroskop->dmpGetCurrentFIFOPacket(this->gyroBuffer)) + if (static_cast(this->gyroskop) && this->gyroskop->dmpGetCurrentFIFOPacket(static_cast(this->gyroBuffer))) { - this->gyroskop->dmpGetQuaternion(&this->quaternion, this->gyroBuffer); + this->gyroskop->dmpGetQuaternion(&this->quaternion, static_cast(this->gyroBuffer)); this->gyroskop->dmpGetGravity(&this->gravity, &this->quaternion); - this->gyroskop->dmpGetYawPitchRoll(this->yawPitchRoll, &this->quaternion, &this->gravity); + this->gyroskop->dmpGetYawPitchRoll(static_cast(this->yawPitchRoll), &this->quaternion, &this->gravity); } } -void SensorData::runAsChild() { - if (this->gnss) { +void SensorData::runAsChild() +{ + if (static_cast(this->gnss)) + { this->gnss->checkUblox(); this->gnss->checkCallbacks(); if (SensorData::ubxUpdateTimeStatic != this->lastUbxUpdate) + { this->updateUbxData(); - } + } + } } -void SensorData::initGnss() { - uint8_t versionHigh = this->gnss->getProtocolVersionHigh(); - uint8_t versionLow = this->gnss->getProtocolVersionLow(); - std::cout << "u-blox protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl; +void SensorData::initGnss() +{ + const uint8_t versionHigh = this->gnss->getProtocolVersionHigh(); + const uint8_t versionLow = this->gnss->getProtocolVersionLow(); + std::cout << "u-blox protocol version: " << static_cast(versionHigh) << "." << static_cast(versionLow) << std::endl; this->gnss->setSPIOutput(COM_TYPE_UBX); this->gnss->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10); @@ -206,11 +272,12 @@ void SensorData::initGnss() { this->gnss->setAutoPVT(true); } -void SensorData::updateUbxData() { +void SensorData::updateUbxData() +{ this->gnssData = SensorData::ubxDataStatic; this->lastUbxUpdate = SensorData::ubxUpdateTimeStatic; - Point::Coordinates coords; + Point::Coordinates coords{0, 0}; coords.lat = this->gnssData->lat / 10000000.0; coords.lon = this->gnssData->lon / 10000000.0; diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index 29656e1..598e42c 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -1,12 +1,12 @@ /** * @file sensorData.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-02 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef SENSOR_DATA_H @@ -28,84 +28,86 @@ #include "point.h" class Sensors; -class SensorData : public Component { - public: - SensorData(); - ~SensorData(); - - void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); - void enableGnss(SPIClass* spiPort, uint8_t csPin); - void enableGnss(); - void enableRealCompass(); - void enableCalcCompass(); - void enableGyroskop(); +class SensorData : public Component +{ +public: + SensorData(); + ~SensorData(); - // Interface Const kram - int16_t getRealAzimuth() const { return this->realAzimuth; } - int16_t getCalcAzimuth() const { return this->calcAzimuth; } - CalcAzimuth::State getCalcAzimuthState() const; + void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); + void enableGnss(SPIClass *spiPort, uint8_t csPin); + void enableGnss(); + void enableRealCompass(); + void enableCalcCompass(); + void enableGyroskop(); - Point getCurrentPos() const { return this->currentPosition; } - const UBX_NAV_PVT_data_t* getGnssData() const { return this->gnssData; }; - NTRIPClientStates getNtripState() const; - const float* getGyroData() const { return this->yawPitchRoll; } + // Interface Const kram + int16_t getRealAzimuth() const { return this->realAzimuth; } + int16_t getCalcAzimuth() const { return this->calcAzimuth; } + CalcAzimuth::State getCalcAzimuthState() const; - CalcAzimuth* getCalcCompass() const { return this->calcCompass; } - QMC5883LCompass* getRealCompass() const { return this->realCompass; } - NTRIPClient* getNtripClient() const { return this->ntripClient; } - MPU6050* getGyroskop() const { return this->gyroskop; } + Point getCurrentPos() const { return this->currentPosition; } + const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; }; + NTRIPClientStates getNtripState() const; + const float *getGyroData() const { return this->yawPitchRoll; } - // 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); + CalcAzimuth *getCalcCompass() const { return this->calcCompass; } + QMC5883LCompass *getRealCompass() const { return this->realCompass; } + NTRIPClient *getNtripClient() const { return this->ntripClient; } + MPU6050 *getGyroskop() const { return this->gyroskop; } - private: - void run() override; - void runAsChild() override; - void initGnss(); - void updateUbxData(); + // 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; - CalcAzimuth* calcCompass = nullptr; - SFE_UBLOX_GNSS* gnss = nullptr; - NTRIPClient* ntripClient = nullptr; - MPU6050* gyroskop = nullptr; + QMC5883LCompass *realCompass = nullptr; + CalcAzimuth *calcCompass = nullptr; + SFE_UBLOX_GNSS *gnss = nullptr; + NTRIPClient *ntripClient = nullptr; + MPU6050 *gyroskop = nullptr; - UBX_NAV_PVT_data_t* gnssData; - Point currentPosition; - Quaternion quaternion; - VectorFloat gravity; + UBX_NAV_PVT_data_t *gnssData = nullptr; + Point currentPosition; + Quaternion quaternion; + VectorFloat gravity; - char* host; - char* mountPoint; - char* user; - char* password; - - bool isNtripInit = false; + char *host = nullptr; + char *mountPoint = nullptr; + char *user = nullptr; + char *password = nullptr; - uint8_t gyroBuffer[64]; - uint16_t port; - int16_t realAzimuth = INT16_MAX; - int16_t calcAzimuth = INT16_MAX; - uint32_t lastUbxUpdate = 0; + bool isNtripInit = false; - float yawPitchRoll[3] {0, 0, 0}; + uint8_t gyroBuffer[64]; + uint16_t port = 0; + int16_t realAzimuth = INT16_MAX; + int16_t calcAzimuth = 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); + float yawPitchRoll[3]{0, 0, 0}; - static UBX_NAV_PVT_data_t* ubxDataStatic; - static uint32_t ubxUpdateTimeStatic; - static bool outputStatusPrintPVTdata; + // 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 +#endif // SENSOR_DATA_H diff --git a/lib/Speedometer/speedometer.cpp b/lib/Speedometer/speedometer.cpp index 7132b56..703aa13 100644 --- a/lib/Speedometer/speedometer.cpp +++ b/lib/Speedometer/speedometer.cpp @@ -5,18 +5,16 @@ * @see speedometer.h * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "speedometer.h" -Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) { - this->diameter = diameter; - this->steps = steps; - - this->pulseCounter = new Counter(pin); - this->pulseCounter->setFilterValue(1023); // ignore pulses less than 1000 x 2.5ns +Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) + : pulseCounter{new Counter(pin)}, diameter{diameter}, steps{steps}, buf{} +{ + this->pulseCounter->setFilterValue(Speedometer::maxFilterValue); // ignore pulses less than 1000 x 2.5ns this->pulseCounter->clear(); this->pulseCounter->resume(); @@ -26,105 +24,131 @@ Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) { this->clearAvgBuf(); } -Speedometer::~Speedometer() { +Speedometer::~Speedometer() +{ delete this->pulseCounter; } -void Speedometer::run() { +void Speedometer::run() +{ + static constexpr float minimalSpeed = 0.1; + if (this->calibrationRunning) + { return; + } - uint32_t time = millis(); + const uint32_t time = millis(); - uint16_t elapsedTime = time - this->lastMillisCalc; + const uint16_t elapsedTime = time - this->lastMillisCalc; this->lastMillisCalc = time; - int16_t pulse = this->pulseCounter->getValue(); + const double pulse = this->pulseCounter->getValue(); this->pulseCounter->clear(); this->pulseCounter->resume(); - - double n = (double)pulse / this->steps; // Wheel revolutions in absolute time - double u = n / ((double)elapsedTime / 1000); // Wheel revolutions per second - double ms = u * (diameter * PI); // Speed in m/s - double rad = u * 2 * PI; + const double wheelRevolutionsAbsolute = pulse / this->steps; + const double wheelRevolutionsRelativ = wheelRevolutionsAbsolute / (elapsedTime / 1000.0); - if (speed < 0.1) { - speed = 0; - rad = 0; + double meterPerSecond = wheelRevolutionsRelativ * (diameter * PI); + double radPerSecond = wheelRevolutionsRelativ * 2 * PI; + + if (meterPerSecond < minimalSpeed) + { + meterPerSecond = 0; + radPerSecond = 0; } - switch (this->currentDirection) { - case Direction::Forward : - this->speed = ms; - this->rad = rad; - break; - - case Direction::Backward : - this->speed = -ms; - this->rad = -rad; - break; + switch (this->currentDirection) + { + case Direction::Forward: + this->speed = meterPerSecond; + this->rad = radPerSecond; + break; - case Direction::None : - this->speed = 0; - this->rad = 0; - break; + case Direction::Backward: + this->speed = -meterPerSecond; + this->rad = -radPerSecond; + break; + + case Direction::None: + this->speed = 0; + this->rad = 0; + break; } this->addValToBuf(static_cast(this->speed * Speedometer::conversionFactor)); } -void Speedometer::setDirection(Direction dir) { +void Speedometer::setDirection(Direction dir) +{ if (this->currentDirection == dir) + { return; + } this->currentDirection = dir; this->clearAvgBuf(); } -void Speedometer::setEncFilter(uint16_t val) { - if (val > 1023) - val = 1023; +void Speedometer::setEncFilter(uint16_t val) +{ + if (val > Speedometer::maxFilterValue) + { + val = Speedometer::maxFilterValue; + } this->pulseCounter->setFilterValue(val); } -double Speedometer::getAvgSpeed() const { - int16_t avg = this->calcAverage(); - return (float)avg / Speedometer::conversionFactor; +double Speedometer::getAvgSpeed() const +{ + const double avg = this->calcAverage(); + return avg / Speedometer::conversionFactor; } -void Speedometer::calibrationMeasurementStart() { +void Speedometer::calibrationMeasurementStart() +{ std::cout << "Start" << std::endl; this->calibrationRunning = true; this->pulseCounter->clear(); this->pulseCounter->resume(); } -uint16_t Speedometer::calibrationMeasurementStop() { +uint16_t Speedometer::calibrationMeasurementStop() +{ std::cout << "Ende" << std::endl; this->calibrationRunning = false; - uint16_t res = abs(this->pulseCounter->getValue()); + const uint16_t res = abs(this->pulseCounter->getValue()); this->pulseCounter->clear(); this->pulseCounter->resume(); std::cout << "Result: " << res << std::endl; return res; } -void Speedometer::clearAvgBuf() { - for (uint8_t i = 0; i < bufSize; i++) +void Speedometer::clearAvgBuf() +{ + for (uint8_t i = 0; i < bufSize; i++) + { this->buf[i] = 0; + } } -void Speedometer::addValToBuf(int16_t val) { +void Speedometer::addValToBuf(int16_t val) +{ this->buf[this->bufPos] = val; this->bufPos++; if (bufPos == bufSize) - bufPos = 0; + { + bufPos = 0; + } } -int16_t Speedometer::calcAverage() const { +int16_t Speedometer::calcAverage() const +{ int16_t sum = 0; - for (int i = 0; i < this->bufSize; i++) + for (int i = 0; i < Speedometer::bufSize; i++) + { sum += this->buf[i]; - return sum / this->bufSize; + } + return sum / Speedometer::bufSize; } diff --git a/lib/Speedometer/speedometer.h b/lib/Speedometer/speedometer.h index a1635fb..87ff979 100644 --- a/lib/Speedometer/speedometer.h +++ b/lib/Speedometer/speedometer.h @@ -4,9 +4,9 @@ * @brief A implementation to measure wheel speeds with an encoder. * @version 0.1 * @date 2021-12-09 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef SPEEDOMETER_H @@ -21,114 +21,115 @@ /** * @brief A class which use a encoder to calc the speed - * + * * This class use ESP32 pulse counter hardware peripheral. * The calculated speed is the average of an amount of last measurements. - * + * */ -class Speedometer : public Component { - public: - /** - * @brief Enum to control the direction. - * - * If the Direction is Forward, the internal counter counts up and a positiv speed will be returned. - * If the Direction is Backward, the internal counter counts down and a negativ speed will be returned. - * If the Direction is None, no measurement will be taken. - */ - enum Direction { - None, - Forward, - Backward - }; +class Speedometer : public Component +{ +public: + /** + * @brief Enum to control the direction. + * + * If the Direction is Forward, the internal counter counts up and a positiv speed will be returned. + * If the Direction is Backward, the internal counter counts down and a negativ speed will be returned. + * If the Direction is None, no measurement will be taken. + */ + enum Direction + { + None, + Forward, + Backward + }; - /** - * @brief Construct a new Speedometer object - * - * @param pin Pin on the Esp from the encoder. - * @param diameter Diameter of the wheel in meters. - * @param steps Encodersteps for a complete wheel rotation. - */ - Speedometer(uint8_t pin, double diameter, uint16_t steps); + /** + * @brief Construct a new Speedometer object + * + * @param pin Pin on the Esp from the encoder. + * @param diameter Diameter of the wheel in meters. + * @param steps Encodersteps for a complete wheel rotation. + */ + Speedometer(uint8_t pin, double diameter, uint16_t steps); - ~Speedometer(); + ~Speedometer(); - /** - * @brief Set the direction - * - * @param dir Direction - */ - void setDirection(Direction dir); + /** + * @brief Set the direction + * + * @param dir Direction + */ + void setDirection(Direction dir); - /** - * @brief Set the Enc Filter to prevent bouncing - * - * ignore pulses less than val x 2.5ns - * - * @param val default = 1000, max = 1023 - */ - void setEncFilter(uint16_t val); + /** + * @brief Set the Enc Filter to prevent bouncing + * + * ignore pulses less than val x 2.5ns + * + * @param val default = 1000, max = 1023 + */ + void setEncFilter(uint16_t val); - /** - * @brief Get the Direction - * - * @return Direction - */ - Direction getDirection() const { return this->currentDirection; } + /** + * @brief Get the Direction + * + * @return Direction + */ + Direction getDirection() const { return this->currentDirection; } - /** - * @brief Get the calculated speed of the Wheel - * - * @return double speed in m/s - */ - double getSpeed() const { return this->speed; } - double getSpeedRad() const { return this->rad; }; - double getAvgSpeed() const; + /** + * @brief Get the calculated speed of the Wheel + * + * @return double speed in m/s + */ + double getSpeed() const { return this->speed; } + double getSpeedRad() const { return this->rad; }; + double getAvgSpeed() const; - /** - * @brief Start calibration - * - * This functions stops the loop. So that steps of one manual wheel turn - * can measured. Call calibrationMeasurementStop to start the loop and get - * the result. - */ - void calibrationMeasurementStart(); + /** + * @brief Start calibration + * + * This functions stops the loop. So that steps of one manual wheel turn + * can measured. Call calibrationMeasurementStop to start the loop and get + * the result. + */ + void calibrationMeasurementStart(); - /** - * @brief Stop calibration - * - * Start the loop function and read the past steps. - * - * @return uint16_t steps since calibrationMeasurementStart was called - */ - uint16_t calibrationMeasurementStop(); + /** + * @brief Stop calibration + * + * Start the loop function and read the past steps. + * + * @return uint16_t steps since calibrationMeasurementStart was called + */ + uint16_t calibrationMeasurementStop(); +private: + void run() override; + void clearAvgBuf(); + void addValToBuf(int16_t val); + int16_t calcAverage() const; - private: - void run() override; - void clearAvgBuf(); - void addValToBuf(int16_t val); - int16_t calcAverage() const; + static constexpr uint8_t loopDelay = 30; + static constexpr uint8_t bufSize = 5; + static constexpr uint8_t conversionFactor = 100; - static constexpr uint8_t loopDelay = 30; - static constexpr uint8_t bufSize = 5; - static constexpr uint8_t conversionFactor = 100; + Counter *pulseCounter; + Direction currentDirection = Direction::None; - Counter* pulseCounter; - Direction currentDirection = Direction::None; + bool calibrationRunning = false; - bool calibrationRunning = false; + double speed = 0; + double rad = 0; + double diameter; - double speed = 0; - double rad = 0; - double diameter; + uint8_t printCounter = 0; + uint8_t bufPos = 0; + uint16_t steps; + int16_t buf[Speedometer::bufSize]; + uint32_t lastMillisCalc = 0; - uint8_t printCounter = 0; - uint8_t bufPos = 0; - uint16_t steps; - - int16_t buf[Speedometer::bufSize]; - - uint32_t lastMillisCalc = 0; + static constexpr uint16_t maxFilterValue = 1023; }; #endif // SPEEDOMETER_H diff --git a/lib/Times/debugTimes.cpp b/lib/Times/debugTimes.cpp index 7490f5d..d94e856 100644 --- a/lib/Times/debugTimes.cpp +++ b/lib/Times/debugTimes.cpp @@ -4,42 +4,53 @@ * @brief Implemention of the class debugTimes.h. * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "debugTimes.h" bool DebugTimes::print = false; bool DebugTimes::printWarning = true; -DebugTimes::DebugTimes() { - this->startTime = millis(); - - if (DebugTimes::printWarning) { - std::cout << std::endl << "Warning: DebugTimes is muuted, no times are be shown." << std::endl << std::endl; +DebugTimes::DebugTimes() + : startTime{millis()} +{ + if (DebugTimes::printWarning) + { + std::cout << std::endl + << "Warning: DebugTimes is muuted, no times are be shown." << std::endl + << std::endl; DebugTimes::printWarning = false; } } -void DebugTimes::restart() { +void DebugTimes::restart() +{ this->startTime = millis(); } -uint16_t DebugTimes::stop() { +const uint16_t DebugTimes::stop() +{ return millis() - this->startTime; } -uint16_t DebugTimes::stopConsol(const char* name, uint16_t minTime) { - uint64_t time = millis() - this->startTime; +const uint16_t DebugTimes::stopConsol(const char *name, uint16_t minTime) +{ + const uint64_t time = millis() - this->startTime; if (time > minTime && DebugTimes::print) + { std::cout << name << " needs " << time << " ms" << std::endl; + } return time; } -void DebugTimes::setConsolOutput(bool enable) { +void DebugTimes::setConsolOutput(bool enable) +{ if (enable == DebugTimes::print) + { return; + } DebugTimes::print = enable; DebugTimes::printWarning = !enable; diff --git a/lib/Times/debugTimes.h b/lib/Times/debugTimes.h index 9155429..5327a94 100644 --- a/lib/Times/debugTimes.h +++ b/lib/Times/debugTimes.h @@ -4,9 +4,9 @@ * @brief Inherits a class to measure times of functions. * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef DEBUG_TIMES_H @@ -20,57 +20,58 @@ /** * @brief A class to measure times of functions. - * + * * This simple class only save the value of the millis() * function when you call the constructor or restart(). * To get the elapsed time call stop() or stopConsol(). - * + * * @warning This class is not very accurate * It only give you the time in milliseconds. */ -class DebugTimes { - public: - /** - * @brief Construct a new Debug Times object - * Starts to count milliseconds - */ +class DebugTimes +{ +public: + /** + * @brief Construct a new Debug Times object + * Starts to count milliseconds + */ - DebugTimes(); - /** - * @brief Set the counter to 0 - */ + DebugTimes(); + /** + * @brief Set the counter to 0 + */ - void restart(); + void restart(); - /** - * @brief Give the elapsed time - * - * @return uint16_t elapsed milliseconds - */ - uint16_t stop(); + /** + * @brief Give the elapsed time + * + * @return uint16_t elapsed milliseconds + */ + const uint16_t stop(); - /** - * @brief Print the elapsed time to consol - * - * @param name Functionname to print - * @param minTime A minimum time before printing - * - * @return uint16_t elapsed milliseconds - */ - uint16_t stopConsol(const char* name, uint16_t minTime = 0); + /** + * @brief Print the elapsed time to consol + * + * @param name Functionname to print + * @param minTime A minimum time before printing + * + * @return uint16_t elapsed milliseconds + */ + const uint16_t stopConsol(const char *name, uint16_t minTime = 0); - /** - * @brief Sets if the result should be printed. - * - * @param enable - */ - static void setConsolOutput(bool enable); + /** + * @brief Sets if the result should be printed. + * + * @param enable + */ + static void setConsolOutput(bool enable); - private: - uint64_t startTime; +private: + uint64_t startTime; - static bool print; - static bool printWarning; + static bool print; + static bool printWarning; }; -#endif //DEBUG_TIMES_H +#endif // DEBUG_TIMES_H diff --git a/lib/calibrateCompass/calibrateCompass.cpp b/lib/calibrateCompass/calibrateCompass.cpp index 43e3326..d618f38 100644 --- a/lib/calibrateCompass/calibrateCompass.cpp +++ b/lib/calibrateCompass/calibrateCompass.cpp @@ -12,8 +12,8 @@ #include "calibrateCompass.h" CalibrateCompass::CalibrateCompass(QMC5883LCompass *compass) + : compass{compass} { - this->compass = compass; this->state = State::Ready; this->clearData(); this->activateOnlyChilds(); @@ -29,9 +29,9 @@ void CalibrateCompass::runAsChild() bool changed = false; this->compass->read(); - int xAxis = this->compass->getX(); - int yAxis = this->compass->getY(); - int zAxis = this->compass->getZ(); + const int xAxis = this->compass->getX(); + const int yAxis = this->compass->getY(); + const int zAxis = this->compass->getZ(); if (xAxis < this->data.data[0][0]) { @@ -70,7 +70,9 @@ void CalibrateCompass::runAsChild() } if (changed) + { this->lastChange = millis(); + } if (millis() - this->lastChange > this->maxTimeWithoutChange) { @@ -182,23 +184,23 @@ void CalibrateCompass::checkDataValidity() sum += this->data.data[i][0]; sum += this->data.data[i][1]; } - this->dataValid = sum; + this->dataValid = static_cast(sum); } -std::ostream &operator<<(std::ostream &os, const CalibrateCompass &caliComp) +std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp) { - os << "("; - os << caliComp.data.data[0][0]; - os << ", "; - os << caliComp.data.data[0][1]; - os << ", "; - os << caliComp.data.data[1][0]; - os << ", "; - os << caliComp.data.data[1][1]; - os << ", "; - os << caliComp.data.data[2][0]; - os << ", "; - os << caliComp.data.data[2][1]; - os << ")"; - return os; + stream << "("; + stream << caliComp.data.data[0][0]; + stream << ", "; + stream << caliComp.data.data[0][1]; + stream << ", "; + stream << caliComp.data.data[1][0]; + stream << ", "; + stream << caliComp.data.data[1][1]; + stream << ", "; + stream << caliComp.data.data[2][0]; + stream << ", "; + stream << caliComp.data.data[2][1]; + stream << ")"; + return stream; } diff --git a/lib/calibrateCompass/calibrateCompass.h b/lib/calibrateCompass/calibrateCompass.h index 72bffb0..9fc953c 100644 --- a/lib/calibrateCompass/calibrateCompass.h +++ b/lib/calibrateCompass/calibrateCompass.h @@ -1,12 +1,12 @@ /** * @file calibrateCompass.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-05-23 - * + * * @copyright Copyright (c) 2023 - * + * */ #pragma once @@ -17,44 +17,47 @@ #include "component.h" -class CalibrateCompass : public Component { - public: - enum State { - Ready, - Calibrating, - Finished - }; +class CalibrateCompass : public Component +{ +public: + enum State + { + Ready, + Calibrating, + Finished + }; - struct CallibrationData { - int data[3][2]; - }; + struct CallibrationData + { + int data[3][2]; + }; - CalibrateCompass(QMC5883LCompass* compass); + CalibrateCompass(QMC5883LCompass *compass); - void start(); - void useData(); - void removeCalibration(); - void reset(); - void saveData(); - void loadData(); + void start(); + void useData(); + void removeCalibration(); + void reset(); + void saveData(); + void loadData(); - State getState() const { return this->state; } - CallibrationData getCallibrationData() const { return this->data; } + State getState() const { return this->state; } + CallibrationData getCallibrationData() const { return this->data; } - friend std::ostream& operator<<(std::ostream& os, const CalibrateCompass& caliComp); + friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp); - private: - void runAsChild() override; - void run() override; - void checkDataValidity(); +private: + void runAsChild() override; + void run() override; + void checkDataValidity(); - QMC5883LCompass* compass; - State state; - CallibrationData data; + QMC5883LCompass *compass; + State state = State::Ready; + CallibrationData data{}; - void clearData(); + void clearData(); - bool dataValid = false; - const uint16_t maxTimeWithoutChange = 10000; - uint32_t lastChange = 0; + bool dataValid = false; + const uint16_t maxTimeWithoutChange = 10000; + uint32_t lastChange = 0; }; diff --git a/src/OutputBuf/outputBuf.cpp b/src/OutputBuf/outputBuf.cpp index 1e761d0..c33c288 100644 --- a/src/OutputBuf/outputBuf.cpp +++ b/src/OutputBuf/outputBuf.cpp @@ -4,56 +4,73 @@ * @brief Contains the implementation of the class OutputBufMqtt * @version 0.1 * @date 2022-02-14 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "OutputBuf/outputBuf.h" -OutputBuf::OutputBuf(DebugMqtt* debugMqtt, BluetoothSerial* serialBT) - : std::streambuf() { - this->debugMqtt = debugMqtt; - this->serialBT = serialBT; - - if (debugMqtt) +OutputBuf::OutputBuf(DebugMqtt *debugMqtt, BluetoothSerial *serialBT) + : debugMqtt{debugMqtt}, serialBT{serialBT} +{ + if (static_cast(debugMqtt)) + { this->isMqttActive = true; + } - if (serialBT) + if (static_cast(serialBT)) + { this->isMqttActive = true; + } } -void OutputBuf::activateMqtt(bool status) { - if (debugMqtt) +void OutputBuf::activateMqtt(bool status) +{ + if (static_cast(debugMqtt)) + { this->isMqttActive = status; + } } -void OutputBuf::activateSerialBT(bool status) { - if (serialBT) +void OutputBuf::activateSerialBT(bool status) +{ + if (static_cast(serialBT)) + { this->isSerialBTActive = status; + } } -void OutputBuf::setDebugMqtt(DebugMqtt* debugMqtt) { +void OutputBuf::setDebugMqtt(DebugMqtt *debugMqtt) +{ this->debugMqtt = debugMqtt; this->isMqttActive = true; } -void OutputBuf::setSerialBT(BluetoothSerial* serialBT) { +void OutputBuf::setSerialBT(BluetoothSerial *serialBT) +{ this->serialBT = serialBT; - this->isSerialBTActive = true;; + this->isSerialBTActive = true; + ; } -std::streambuf::int_type OutputBuf::overflow(std::streambuf::int_type c) { - if (c != EOF) { +std::streambuf::int_type OutputBuf::overflow(std::streambuf::int_type character) +{ + if (character != EOF) + { // c = std::toupper(static_cast(c), getloc()); if (this->debugMqtt && this->isMqttActive) - this->debugMqtt->addCharacter((char) c); + { + this->debugMqtt->addCharacter(static_cast(character)); + } if (this->serialBT && this->isSerialBTActive && this->serialBT->connected()) - this->serialBT->print((char) c); + { + this->serialBT->print(static_cast(character)); + } - Serial.print((char) c); + Serial.print(static_cast(character)); } - return c; + return character; } diff --git a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp index b9ded0a..ca8b0ff 100644 --- a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp +++ b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp @@ -1,59 +1,70 @@ /** * @file menuCalibrateBattery.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-26 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "menuCalibrateBattery.h" -MenuCalibrateBattery::MenuCalibrateBattery(Battery* battery) { - this->setUpdateDelay(400); - this->battery = battery; +MenuCalibrateBattery::MenuCalibrateBattery(Battery *battery) + : battery{battery} +{ + this->setUpdateDelay(MenuCalibrateBattery::updateDelay); } -void MenuCalibrateBattery::printMenu() { +void MenuCalibrateBattery::printMenu() +{ if (this->battery->getCalibrationState() == Battery::CalibrationState::None) + { this->battery->startCalibration(); + } String lineOne = ""; String lineTwo = ""; - switch (this->battery->getCalibrationState()) { - case Battery::CalibrationState::Waiting: - lineOne = "Target Voltage:"; - lineTwo = "7 + "; - lineTwo.concat(this->battery->getCurrentCalibrationVoltage()); - lineTwo.concat(" / 10"); - break; + switch (this->battery->getCalibrationState()) + { + case Battery::CalibrationState::Waiting: + lineOne = "Target Voltage:"; + lineTwo = "7 + "; + lineTwo.concat(this->battery->getCurrentCalibrationVoltage()); + lineTwo.concat(" / 10"); + break; - case Battery::CalibrationState::Reading: - lineOne = "Reading..."; - break; + case Battery::CalibrationState::Reading: + lineOne = "Reading..."; + break; - case Battery::CalibrationState::Finished: - lineOne = "Finished!"; - break; - - default: - break; + case Battery::CalibrationState::Finished: + lineOne = "Finished!"; + break; + + default: + break; } this->print(lineOne, lineTwo); } -void MenuCalibrateBattery::left() { +void MenuCalibrateBattery::left() +{ this->battery->finishCalibration(); - if (parentMenu) + if (static_cast(parentMenu)) + { this->parentMenu->printMenu(); + } } -void MenuCalibrateBattery::right() { +void MenuCalibrateBattery::right() +{ if (this->battery->getCalibrationState() == Battery::CalibrationState::Waiting) + { this->battery->nextVoltageIsReady(); + } } diff --git a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h index 89758eb..28ca45d 100644 --- a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h +++ b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h @@ -1,12 +1,12 @@ /** * @file menuCalibrateBattery.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-26 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef MENU_CALIBRATE_BATTERY_H @@ -15,19 +15,22 @@ #include "menuControl.h" #include "battery.h" -class MenuCalibrateBattery : public MenuControl { - public: - MenuCalibrateBattery(Battery* battery); +class MenuCalibrateBattery : public MenuControl +{ +public: + MenuCalibrateBattery(Battery *battery); - void printMenu() override; + void printMenu() override; - void left() override; - void no() override { this->left(); } - void right() override; - void yes() override { this->right(); } + void left() override; + void no() override { this->left(); } + void right() override; + void yes() override { this->right(); } - private: - Battery* battery; +private: + Battery *battery; + + static constexpr uint16_t updateDelay = 400; }; -#endif //MENU_CALIBRATE_BATTERY_H +#endif // MENU_CALIBRATE_BATTERY_H diff --git a/src/SpecialMenus/PID/menuPidSettings.cpp b/src/SpecialMenus/PID/menuPidSettings.cpp index f5f5c00..d85c9ac 100644 --- a/src/SpecialMenus/PID/menuPidSettings.cpp +++ b/src/SpecialMenus/PID/menuPidSettings.cpp @@ -4,19 +4,20 @@ * @brief Contains an implementation of the class MenuPidSettings * @version 0.1 * @date 2022-01-19 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuPidSettings.h" -MenuPidSettings::MenuPidSettings(PID* pid) { - this->pid = pid; -} +MenuPidSettings::MenuPidSettings(PID *pid) : pid{pid} {} -void MenuPidSettings::action(int16_t* values, uint8_t length) { - if (length != 3) +void MenuPidSettings::action(int16_t *values, uint8_t length) +{ + if (length != 3) + { return; + } this->pid->SetTunings(values[0], values[1], values[2]); } diff --git a/src/SpecialMenus/Route/menuRoute.cpp b/src/SpecialMenus/Route/menuRoute.cpp index 875d505..183e17f 100644 --- a/src/SpecialMenus/Route/menuRoute.cpp +++ b/src/SpecialMenus/Route/menuRoute.cpp @@ -12,9 +12,8 @@ #include "menuRoute.h" MenuActionRoute::MenuActionRoute(MenuRoute *menuRoute, DataFunction dataFunction) + : menuRoute{menuRoute}, dataFunction{dataFunction} { - this->menuRoute = menuRoute; - this->dataFunction = dataFunction; } void MenuActionRoute::action() @@ -23,8 +22,8 @@ void MenuActionRoute::action() } MenuRoute::MenuRoute(Route *route) + : route{route} { - this->route = route; } MenuRoute::~MenuRoute() @@ -185,12 +184,12 @@ void MenuRoute::importRoute(uint8_t routeNumber) String host = "http://rover.kleiax.de/api/"; host.concat(routeNumber); http.begin(client, host); - int httpResponseCode = http.GET(); + const int httpResponseCode = http.GET(); lineOne = "Import complete"; lineTwo = "Code: "; - if (httpResponseCode == 202) + if (httpResponseCode == MenuRoute::httpValidImport) { deserializeJson(doc, http.getStream()); } @@ -231,7 +230,7 @@ void MenuRoute::exportRoute(uint8_t routeNumber) String lineOne = ""; String lineTwo = ""; - if (WiFi.status() != WL_CONNECTED) + if (WiFiSTAClass::status() != WL_CONNECTED) { lineOne = "Not connected to"; lineTwo = "the WiFi."; @@ -270,9 +269,9 @@ void MenuRoute::exportRoute(uint8_t routeNumber) http.begin(client, "http://rover.kleiax.de/api/"); http.addHeader("Content-Type", "application/json"); - int httpResponseCode = http.POST(jsonData); + const int httpResponseCode = http.POST(jsonData); - if (httpResponseCode == 201) + if (httpResponseCode == MenuRoute::httpValidExport) { lineOne = "Export complete"; } @@ -295,7 +294,7 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) String lineOne = ""; String lineTwo = ""; - if (WiFi.status() != WL_CONNECTED) + if (WiFiSTAClass::status() != WL_CONNECTED) { lineOne = "Not connected to"; lineTwo = "the WiFi."; @@ -320,12 +319,12 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) String host = "http://rover.kleiax.de/api/"; host.concat(routeNumber); http.begin(client, host); - int httpResponseCode = http.sendRequest("DELETE"); + const int httpResponseCode = http.sendRequest("DELETE"); lineOne = "Delete complete"; lineTwo = "Code: "; - if (httpResponseCode == 202) + if (httpResponseCode == MenuRoute::httpValidDelete) { deserializeJson(doc, http.getStream()); } @@ -343,16 +342,15 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) void MenuRoute::clearRoute(uint8_t none) { - //The parameter exist only for compability + // The parameter exist only for compability none; this->route->clear(); this->print("Currente route", "deleted..."); } MenuRouteWrapper::MenuRouteWrapper(MenuRoute *menuRoute, DataFunction dataFunction) - : menuRoute {menuRoute}, dataFunction {dataFunction} + : menuRoute{menuRoute}, dataFunction{dataFunction} { - } void MenuRouteWrapper::action(int16_t *values, uint8_t length) diff --git a/src/SpecialMenus/Route/menuRoute.h b/src/SpecialMenus/Route/menuRoute.h index b53437b..7d6072f 100644 --- a/src/SpecialMenus/Route/menuRoute.h +++ b/src/SpecialMenus/Route/menuRoute.h @@ -4,9 +4,9 @@ * @brief Contains a classes to handles routes with the user input. * @version 0.1 * @date 2022-12-28 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_ROUTE_H @@ -30,135 +30,137 @@ typedef void (MenuRoute::*DataFunction)(uint8_t); /** * @brief MenuActionWrapper to call DataFunctions - * + * * This class should be used to call importRoute, * exportRoute and clearRoute over the Menu. */ -class MenuActionRoute : public MenuActionWrapper { - public: - /** - * @brief Construct a new Menu Action Route object - * - * @param menuRoute - * @param dataFunction like exportRoute - */ - MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction); +class MenuActionRoute : public MenuActionWrapper +{ +public: + /** + * @brief Construct a new Menu Action Route object + * + * @param menuRoute + * @param dataFunction like exportRoute + */ + MenuActionRoute(MenuRoute *menuRoute, DataFunction dataFunction); - /** - * @brief Runs the given DataFunction - */ - void action() override; + /** + * @brief Runs the given DataFunction + */ + void action() override; - private: - MenuRoute* menuRoute; - DataFunction dataFunction; +private: + MenuRoute *menuRoute; + DataFunction dataFunction; }; /** * @brief Handles routes - * - * With this menu the user can import, export and delete routes. + * + * With this menu the user can import, export and delete routes. */ -class MenuRoute : public MenuControl { - public: - /** - * @brief Construct a new Menu Route object - * - * @param route - */ - MenuRoute(Route* route); - ~MenuRoute(); +class MenuRoute : public MenuControl +{ +public: + /** + * @brief Construct a new Menu Route object + * + * @param route + */ + MenuRoute(Route *route); + ~MenuRoute(); - /** - * @brief Prints the last informations - * - * On first call this function calls the init function. - * On every call this functions call the printMenu function from - * the mainMenu of this class. - */ - void printMenu() override; + /** + * @brief Prints the last informations + * + * On first call this function calls the init function. + * On every call this functions call the printMenu function from + * the mainMenu of this class. + */ + void printMenu() override; - /** - * @name User Inputs - * @brief Inputs given by the parentMenu - */ - ///@{ - void down() override; - void up() override; - void right() override; - void left() override; - void yes() override; - void no() override; - ///@} + /** + * @name User Inputs + * @brief Inputs given by the parentMenu + */ + ///@{ + void down() override; + void up() override; + void right() override; + void left() override; + void yes() override; + void no() override; + ///@} - /** - * @brief Import a Route. - * - * The functions tries to pull the given route id from the RoverApi. - * - * @param routeNumber id - */ - void importRoute(uint8_t routeNumber); + /** + * @brief Import a Route. + * + * The functions tries to pull the given route id from the RoverApi. + * + * @param routeNumber id + */ + void importRoute(uint8_t routeNumber); - /** - * @brief Export a Route. - * - * The functions tries to push the current route to the RoverApi. - * - * @param routeNumber id - */ - void exportRoute(uint8_t routeNumber); + /** + * @brief Export a Route. + * + * The functions tries to push the current route to the RoverApi. + * + * @param routeNumber id + */ + void exportRoute(uint8_t routeNumber); - void deleteRoute(uint8_t routeNumber); + void deleteRoute(uint8_t routeNumber); - /** - * @brief Delete the current Route. - * - * @param none this param is not be used. - */ - void clearRoute(uint8_t none); - - private: - void init(); + /** + * @brief Delete the current Route. + * + * @param none this param is not be used. + */ + void clearRoute(uint8_t none); - Route* route; - Menu* mainMenu; +private: + void init(); - bool isInit = false; - bool blockInput = false; + Route *route; + Menu *mainMenu = nullptr; - static constexpr uint8_t maxRouteNumber = 100; - static constexpr uint16_t httpValidExport = 201; - static constexpr uint16_t httpValidImport = 202; - static constexpr uint16_t httpValidDelete = 202; + bool isInit = false; + bool blockInput = false; + static constexpr uint8_t maxRouteNumber = 100; + static constexpr uint16_t httpValidExport = 201; + static constexpr uint16_t httpValidImport = 202; + static constexpr uint16_t httpValidDelete = 202; }; /** * @brief MenuRouteWrapper to call DataFunctions with numeric user input - * + * */ -class MenuRouteWrapper : public MenuIntInputWrapper { - public: - /** - * @brief Construct a new Menu Route Wrapper object. - * - * @param menuRoute - * @param dataFunction - */ - MenuRouteWrapper(MenuRoute* menuRoute, DataFunction dataFunction); +class MenuRouteWrapper : public MenuIntInputWrapper +{ +public: + /** + * @brief Construct a new Menu Route Wrapper object. + * + * @param menuRoute + * @param dataFunction + */ + MenuRouteWrapper(MenuRoute *menuRoute, DataFunction dataFunction); - /** - * @brief Calls the given DataFunction. - * - * @param values The value to be given to the DataFunction. - * @param length Number of values, should be 1. - */ - void action(int16_t* values, uint8_t length) override; + /** + * @brief Calls the given DataFunction. + * + * @param values The value to be given to the DataFunction. + * @param length Number of values, should be 1. + */ + void action(int16_t *values, uint8_t length) override; - private: - MenuRoute* menuRoute; - DataFunction dataFunction = nullptr; +private: + MenuRoute *menuRoute; + DataFunction dataFunction = nullptr; }; #endif // MENU_ROUTE_H diff --git a/src/SpecialMenus/Route/menuRoutePoints.cpp b/src/SpecialMenus/Route/menuRoutePoints.cpp index 3fd14f4..f5241ce 100644 --- a/src/SpecialMenus/Route/menuRoutePoints.cpp +++ b/src/SpecialMenus/Route/menuRoutePoints.cpp @@ -4,34 +4,48 @@ * @brief Contains the implementation of the class MenuRoutePoints. * @version 0.1 * @date 2022-12-28 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuRoutePoints.h" -MenuRoutePoints::MenuRoutePoints(Route *route) : MenuInformationSites() { - this->route = route; +MenuRoutePoints::MenuRoutePoints(Route *route) + : route{route} +{ } -void MenuRoutePoints::init() { - uint16_t amountPoints = this->route->getRouteInfo().totalPoints; +void MenuRoutePoints::init() +{ + const uint16_t amountPoints = this->route->getRouteInfo().totalPoints; if (amountPoints > UINT8_MAX) + { this->error = true; + } else + { this->setCountPages(amountPoints); + } } -void MenuRoutePoints::printPage() const { - uint8_t currentPage = this->getCurrentPage(); +void MenuRoutePoints::printPage() const +{ + static constexpr int8_t width = 9; + static constexpr int8_t prec = 7; + static constexpr int8_t bufSize = 20; + + const uint8_t currentPage = this->getCurrentPage(); if (this->lastPageNumber == currentPage) + { return; + } String lineOne = "N "; String lineTwo = "E "; - if (this->error) { + if (this->error) + { lineOne = "Error: To much"; lineTwo = "points are given"; this->print(lineOne, lineTwo); @@ -39,35 +53,46 @@ void MenuRoutePoints::printPage() const { } RouteInfo info = this->route->getRouteInfo(); - if (info.totalPoints == 0) { + if (info.totalPoints == 0) + { lineOne = "No Points are"; lineTwo = "available"; this->print(lineOne, lineTwo); return; } - Point p; + Point point; if (currentPage == 0) - p = this->route->startRoute(); + { + point = this->route->startRoute(); + } else if (this->lastPageNumber - 1 == currentPage) - p = this->route->getPreviousPoint(); + { + point = this->route->getPreviousPoint(); + } else if (this->lastPageNumber + 1 == currentPage) - p = this->route->getNextPoint(); + { + point = this->route->getNextPoint(); + } else if (currentPage == this->getCountPages() - 1) - p = this->route->endRoute(); + { + point = this->route->endRoute(); + } else + { std::cout << "Error in: MenuRoutePoints::printPage()" << std::endl; + } - char buf[20]; - char* string; + char buf[bufSize]; + char *string; info = this->route->getRouteInfo(); - string = dtostrf(p.getLatitude(), 9, 7, buf); + string = dtostrf(point.getLatitude(), width, prec, static_cast(buf)); lineOne.concat(string); lineOne.concat(" "); lineOne.concat(info.currentPoint); // lineOne.concat(currentPage); - string = dtostrf(p.getLongitude(), 9, 7, buf); + string = dtostrf(point.getLongitude(), width, prec, static_cast(buf)); lineTwo.concat(string); lineTwo.concat(" "); lineTwo.concat(info.totalPoints); diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp index 2a6f86e..19ec032 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.cpp +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -1,119 +1,151 @@ /** * @file menuSensorData.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-04 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "menuSensorData.h" -MenuSensorData::MenuSensorData(SensorData* sensorData) : - MenuInformationSites(7) { - this->sensorData = sensorData; - this->noEqualLeft = true; +MenuSensorData::MenuSensorData(SensorData *sensorData) : MenuInformationSites(7), sensorData{sensorData} +{ + this->noEqualLeft = true; } -void MenuSensorData::printPage() const { - const UBX_NAV_PVT_data_t* gpsData = this->sensorData->getGnssData(); +void MenuSensorData::printPage() const +{ + const UBX_NAV_PVT_data_t *gpsData = this->sensorData->getGnssData(); uint8_t fixType = 0; - if (gpsData) + if (static_cast(gpsData)) + { fixType = gpsData->fixType; + } String lineOne = ""; String lineTwo = ""; - switch (this->getCurrentPage()) { - case 0: - lineOne = " Y P R :"; - lineTwo.concat(this->sensorData->getGyroData()[0]); - lineTwo.concat(" "); - lineTwo.concat(this->sensorData->getGyroData()[1]); - lineTwo.concat(" "); - lineTwo.concat(this->sensorData->getGyroData()[2]); - break; + switch (this->getCurrentPage()) + { + case 0: + lineOne = " Y P R :"; + lineTwo.concat(this->sensorData->getGyroData()[0]); + lineTwo.concat(" "); + lineTwo.concat(this->sensorData->getGyroData()[1]); + lineTwo.concat(" "); + lineTwo.concat(this->sensorData->getGyroData()[2]); + break; - case 1: - lineOne = "Real Azimuth:"; - lineTwo.concat(this->sensorData->getRealAzimuth()); - break; + case 1: + lineOne = "Real Azimuth:"; + lineTwo.concat(this->sensorData->getRealAzimuth()); + break; - case 2: - lineOne = "Calc Azimuth:"; - lineTwo.concat(this->sensorData->getCalcAzimuth()); - lineTwo.concat(" "); - lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState())); - break; + case 2: + lineOne = "Calc Azimuth:"; + lineTwo.concat(this->sensorData->getCalcAzimuth()); + lineTwo.concat(" "); + lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState())); + break; - case 3: { - lineOne = "Lat:"; - lineTwo = "Lon:"; - Point pos = this->sensorData->getCurrentPos(); - lineOne.concat(pos.getLatitude()); - lineTwo.concat(pos.getLongitude()); + case 3: + { + lineOne = "Lat:"; + lineTwo = "Lon:"; + const Point pos = this->sensorData->getCurrentPos(); + lineOne.concat(pos.getLatitude()); + lineTwo.concat(pos.getLongitude()); + } + break; + + case 4: + lineOne = "Time: "; + lineTwo = ""; + if (static_cast(fixType)) + { + if (gpsData->hour < 10) + { + lineTwo.concat("0"); } - break; - - case 4: - lineOne = "Time: "; - lineTwo = ""; - if (fixType) { - if (gpsData->hour < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->hour); - lineTwo.concat(":"); - if (gpsData->min < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->min); - lineTwo.concat(":"); - if (gpsData->sec < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->sec); - } else - lineTwo = "00:00:00"; - - break; - - case 5: { - lineOne = "CarSol: "; - lineTwo = "Ntrip: "; - uint8_t carrSoln = gpsData->flags.bits.carrSoln; - if (carrSoln == 0) - lineOne.concat("None"); - else if (carrSoln == 1) - lineOne.concat("Floating"); - else if (carrSoln == 2) - lineOne.concat("Fixed"); - else - lineOne = "UNKNOWN"; - NTRIPClientStates status = this->sensorData->getNtripState(); - if (status == NTRIPClientStates::pushData) - lineTwo.concat("enabled"); - else if (status == NTRIPClientStates::notAvailable) - lineTwo.concat(" N/A"); - else - lineTwo.concat("disabled"); + lineTwo.concat(gpsData->hour); + lineTwo.concat(":"); + if (gpsData->min < 10) + { + lineTwo.concat("0"); } - break; - - case 6: - lineOne = "HAcc: "; - lineTwo = "Sats: "; - if (fixType) { - lineOne.concat(gpsData->hAcc); - lineTwo.concat(gpsData->numSV); - } else { - lineOne.concat("-/-"); - lineTwo.concat("-/-"); + lineTwo.concat(gpsData->min); + lineTwo.concat(":"); + if (gpsData->sec < 10) + { + lineTwo.concat("0"); } - break; + lineTwo.concat(gpsData->sec); + } + else + { + lineTwo = "00:00:00"; + } - default: - this->printDefault(); - return; + break; + + case 5: + { + lineOne = "CarSol: "; + lineTwo = "Ntrip: "; + const uint8_t carrSoln = gpsData->flags.bits.carrSoln; + if (carrSoln == 0) + { + lineOne.concat("None"); + } + else if (carrSoln == 1) + { + lineOne.concat("Floating"); + } + else if (carrSoln == 2) + { + lineOne.concat("Fixed"); + } + else + { + lineOne = "UNKNOWN"; + } + const NTRIPClientStates status = this->sensorData->getNtripState(); + if (status == NTRIPClientStates::pushData) + { + lineTwo.concat("enabled"); + } + else if (status == NTRIPClientStates::notAvailable) + { + lineTwo.concat(" N/A"); + } + else + { + lineTwo.concat("disabled"); + } + } + break; + + case 6: + lineOne = "HAcc: "; + lineTwo = "Sats: "; + if (static_cast(fixType)) + { + lineOne.concat(gpsData->hAcc); + lineTwo.concat(gpsData->numSV); + } + else + { + lineOne.concat("-/-"); + lineTwo.concat("-/-"); + } + break; + + default: + this->printDefault(); + return; } this->print(lineOne, lineTwo); diff --git a/src/SpecialMenus/Speed/menuSpeed.cpp b/src/SpecialMenus/Speed/menuSpeed.cpp index 1cb1736..dcb26d6 100644 --- a/src/SpecialMenus/Speed/menuSpeed.cpp +++ b/src/SpecialMenus/Speed/menuSpeed.cpp @@ -12,8 +12,9 @@ #include "menuSpeed.h" void MenuSpeed::action(int16_t* values, uint8_t length) { - if (length != 2) + if (length != 2) { return; - this->speeds.x = (double) values[0] / 10.0; - this->speeds.rot = (double) values[1] / 10.0; + } + this->speeds.x = values[0] / 10.0; + this->speeds.rot = values[1] / 10.0; } diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp index 6706ae7..bbad40c 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp +++ b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp @@ -12,8 +12,7 @@ #include "menuSysteminformation.h" MenuSysteminformation::MenuSysteminformation(Battery* mainBattery) - : MenuInformationSites(8) { - this->mainBattery = mainBattery; + : MenuInformationSites(8), mainBattery {mainBattery} { this->noEqualLeft = true; } diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index 8447325..eb97490 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -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(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(correction.distance); distanceString.concat(distance); distanceString.concat("m"); - } else { - distance = (uint16_t) (correction.distance / 1000); + } + else + { + distance = static_cast(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(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(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(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(); diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp index f709559..9715f31 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp @@ -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() { diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h index 010bbaf..91d54bc 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h @@ -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 diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp index f90f3a5..f5a46ed 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp @@ -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(); diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h index 9c3ba8a..d4505ce 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h @@ -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 diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index 7f3cb5c..8a5d1b9 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -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(); } diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h index 9f2f6d8..ee5eb0f 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h @@ -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 diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 89d224f..7f88b5b 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -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; From 61a95e460168feeb614b43ad4e71c633233a2f0f Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 08:43:33 +0200 Subject: [PATCH 23/26] update comments 1 --- .vscode/settings.json | 2 + doc/TODO allgemein.txt | 1 - include/config.h | 39 ++++++++++----- include/moveControl.h | 88 ++++++++++++++++++--------------- src/moveControl.cpp | 108 ++++++++++++++++++++--------------------- 5 files changed, 133 insertions(+), 105 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3370206..51c1d3c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -128,6 +128,7 @@ "carr", "CIPO", "COPI", + "Dutycycle", "gast", "GNSS", "GPGGA", @@ -148,6 +149,7 @@ "Soln", "TPMOBIL", "UBLOX", + "wheelspeed", "ZLPJ" ], "cmake.configureOnOpen": false diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index d89abe9..771fbb1 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -33,7 +33,6 @@ Do later: Do now: Code: Doxygen Kommentare aktualisieren - magic numbers etc Fernbedienung! Latex: diff --git a/include/config.h b/include/config.h index d3828d3..5ea15ec 100644 --- a/include/config.h +++ b/include/config.h @@ -1,17 +1,22 @@ /** * @file config.h * @author Alexander Klein (alex@kleiax.de) - * @brief Some defines to configere the project. + * @brief Some defines to configure the project. * @version 0.1 * @date 2022-02-15 - * + * * @copyright Copyright (c) 2022 - * + * */ #pragma once -namespace PinNumbers { +/** + * @brief The numbers of pins to be used + * + */ +namespace PinNumbers +{ constexpr uint8_t spiCopi = 16; constexpr uint8_t spiCipo = 4; constexpr uint8_t spiSck = 5; @@ -20,24 +25,31 @@ namespace PinNumbers { constexpr uint8_t scl = 19; constexpr uint8_t battery = 35; - namespace LeftMotor { + namespace LeftMotor + { constexpr uint8_t dir1 = 27; constexpr uint8_t dir2 = 12; - constexpr uint8_t pwm = 13; + constexpr uint8_t pwm = 13; constexpr uint8_t encoder = 32; constexpr uint8_t pmwChannel = 0; } - namespace RightMotor { + namespace RightMotor + { constexpr uint8_t dir1 = 14; constexpr uint8_t dir2 = 23; - constexpr uint8_t pwm = 22; + constexpr uint8_t pwm = 22; constexpr uint8_t encoder = 33; constexpr uint8_t pmwChannel = 1; } } -namespace Settings { +/** + * @brief Default values for different components + * + */ +namespace Settings +{ constexpr uint32_t baudRate = 115200; constexpr uint32_t i2cSpeed = 400000; @@ -45,14 +57,17 @@ namespace Settings { constexpr float wheelDistance = 0.255; constexpr uint16_t encoderSteps = 384; - namespace Pid { - namespace Left { + namespace Pid + { + namespace Left + { constexpr uint8_t P = 5; constexpr uint8_t I = 0; constexpr uint8_t D = 0; } - namespace Right { + namespace Right + { constexpr uint8_t P = 5; constexpr uint8_t I = 0; constexpr uint8_t D = 0; diff --git a/include/moveControl.h b/include/moveControl.h index e274e9b..f2a1f08 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -22,6 +22,11 @@ #include "debugTimes.h" #include "component.h" + +/** + * @brief A struct to easy set the speed + * + */ struct DrivingSpeeds { double x; double rot; @@ -41,6 +46,11 @@ class MoveControl : public Component { * @brief used to set driving status * * When set to stop all motors are set to halt + * When set to Raw the PIDs are not used. The target + * values must be given withe @see setRawPowerLeft and + * @see setRawPowerRight. + * + * Drive is the normal working mode. * */ enum Status {Stop, @@ -52,7 +62,7 @@ class MoveControl : public Component { * @brief Construct a new Move Control object * * Initialize the motors, encoders and PIDs with given - * values in moveControlConfig.h + * values in config.h */ MoveControl(); @@ -66,6 +76,9 @@ class MoveControl : public Component { /** * @brief Set the Status * + * Control if this component should work normally or with + * raw values for the motors. + * * @see Status * @param status */ @@ -87,29 +100,39 @@ class MoveControl : public Component { void setSpeed(double speed); /** - * @brief Set the rotationspeed + * @brief Set the rotationSpeed * - * If the given rotationspeed is close to zero, then the - * target rotationspeed is set to zero. + * If the given rotationSpeed is close to zero, then the + * target rotationSpeed is set to zero. * @param speed rad/s */ void setRotationSpeed(double speed); + /** + * @brief Set the speeds + * + * This function is a combination of @see setSpeed and + * @see setRotationSpeed. The struct @see DrivingSpeeds + * is used for this. + * + * @param drivingSpeeds + */ void setSpeeds(DrivingSpeeds drivingSpeeds); /** - * @brief Set Raw Power Left + * @brief Set raw power left * - * This value has only an effect if Status is raw. + * This value has only an effect if the status is raw. + * @see setDrivingStatus * * @param power between -100 and 100 */ void setRawPowerLeft(int16_t power); /** - * @brief Set the Raw Power Right + * @brief Set the raw power right * - * This value has only an effect if Status is raw. + * This value has only an effect if status is raw. * * @param power between -100 and 100 */ @@ -119,9 +142,9 @@ class MoveControl : public Component { * @brief Set the pid tunings * * @param side 0 -> left, 1 -> right - * @param p - * @param i - * @param d + * @param pPart + * @param iPart + * @param dPart */ void setPidTunings(uint8_t side, double pPart, double iPart, double dPart); @@ -133,22 +156,11 @@ class MoveControl : public Component { */ PID* getPID(uint8_t side) const; - /** - * @brief Get the Speedometer Left object - * - * @return Speedometer* - */ - Speedometer* getSpeedometerLeft() const { return this->left_speedometer; } + Speedometer* getSpeedometerLeft() const { return this->leftSpeedometer; } + Speedometer* getSpeedometerRight() const { return this->rightSpeedometer; } - /** - * @brief Get the Speedometer Right object - * - * @return Speedometer* - */ - Speedometer* getSpeedometerRight() const { return this->right_speedometer; } - - uint16_t getDutycycleLeft() const { return this->left_motor->getDutycycle(); } - uint16_t getDutycycleRight() const { return this->right_motor->getDutycycle(); } + uint16_t getDutycycleLeft() const { return this->leftMotor->getDutycycle(); } + uint16_t getDutycycleRight() const { return this->rightMotor->getDutycycle(); } private: void run() override; @@ -157,22 +169,22 @@ class MoveControl : public Component { void regulateMotors(); void updateCurrentWheelSpeed(); - MotorControl *left_motor; - MotorControl *right_motor; - Speedometer *left_speedometer; - Speedometer *right_speedometer; - PID *left_pid; - PID *right_pid; + MotorControl *leftMotor; + MotorControl *rightMotor; + Speedometer *leftSpeedometer; + Speedometer *rightSpeedometer; + PID *leftPid; + PID *rightPid; Status driving_status = Status::Stop; DrivingSpeeds drivingSpeeds = {0, 0}; - double wheelspeed_left_target = 0; - double wheelspeed_right_target = 0; - double wheelspeed_left = 0; - double wheelspeed_right = 0; - double left_pid_out = 0; - double right_pid_out = 0; + double wheelspeedLeftTarget = 0; + double wheelspeedRightTarget = 0; + double wheelspeedLeft = 0; + double wheelspeedRight = 0; + double leftPidOut = 0; + double rightPidOut = 0; uint8_t overTimeCounter = 0; uint8_t overTimeMax = 100; diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 3f9fce5..145a786 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -12,53 +12,53 @@ MoveControl::MoveControl() : Component(MoveControl::loopDelay), - left_motor{new MotorControl()}, - right_motor{new MotorControl()}, - left_speedometer{new Speedometer(PinNumbers::LeftMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, - right_speedometer{new Speedometer(PinNumbers::RightMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, - left_pid{new PID(&this->wheelspeed_left, - &this->left_pid_out, - &this->wheelspeed_left_target, + leftMotor{new MotorControl()}, + rightMotor{new MotorControl()}, + leftSpeedometer{new Speedometer(PinNumbers::LeftMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, + rightSpeedometer{new Speedometer(PinNumbers::RightMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, + leftPid{new PID(&this->wheelspeedLeft, + &this->leftPidOut, + &this->wheelspeedLeftTarget, Settings::Pid::Left::P, Settings::Pid::Left::I, Settings::Pid::Left::D, DIRECT)}, - right_pid{new PID(&this->wheelspeed_right, - &this->right_pid_out, - &this->wheelspeed_right_target, + rightPid{new PID(&this->wheelspeedRight, + &this->rightPidOut, + &this->wheelspeedRightTarget, Settings::Pid::Right::P, Settings::Pid::Right::I, Settings::Pid::Right::D, DIRECT)} { - this->left_pid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax); - this->left_pid->SetSampleTime(Settings::Pid::sampleTime); - this->left_pid->SetMode(AUTOMATIC); + this->leftPid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax); + this->leftPid->SetSampleTime(Settings::Pid::sampleTime); + this->leftPid->SetMode(AUTOMATIC); - this->right_pid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax); - this->right_pid->SetSampleTime(Settings::Pid::sampleTime); - this->right_pid->SetMode(AUTOMATIC); + this->rightPid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax); + this->rightPid->SetSampleTime(Settings::Pid::sampleTime); + this->rightPid->SetMode(AUTOMATIC); - this->left_motor->init(PinNumbers::LeftMotor::pwm, PinNumbers::LeftMotor::pmwChannel, PinNumbers::LeftMotor::dir1, PinNumbers::LeftMotor::dir2); - this->right_motor->init(PinNumbers::RightMotor::pwm, PinNumbers::RightMotor::pmwChannel, PinNumbers::RightMotor::dir1, PinNumbers::RightMotor::dir2); + this->leftMotor->init(PinNumbers::LeftMotor::pwm, PinNumbers::LeftMotor::pmwChannel, PinNumbers::LeftMotor::dir1, PinNumbers::LeftMotor::dir2); + this->rightMotor->init(PinNumbers::RightMotor::pwm, PinNumbers::RightMotor::pmwChannel, PinNumbers::RightMotor::dir1, PinNumbers::RightMotor::dir2); - this->addChildComponent(this->left_motor); - this->addChildComponent(this->right_motor); - this->addChildComponent(this->left_speedometer); - this->addChildComponent(this->right_speedometer); + this->addChildComponent(this->leftMotor); + this->addChildComponent(this->rightMotor); + this->addChildComponent(this->leftSpeedometer); + this->addChildComponent(this->rightSpeedometer); } MoveControl::~MoveControl() { - this->left_motor->emergencyStop(); - this->right_motor->emergencyStop(); + this->leftMotor->emergencyStop(); + this->rightMotor->emergencyStop(); - delete this->left_motor; - delete this->right_motor; - delete this->left_speedometer; - delete this->right_speedometer; - delete this->left_pid; - delete this->right_pid; + delete this->leftMotor; + delete this->rightMotor; + delete this->leftSpeedometer; + delete this->rightSpeedometer; + delete this->leftPid; + delete this->rightPid; } void MoveControl::run() @@ -66,8 +66,8 @@ void MoveControl::run() this->updateCurrentWheelSpeed(); this->calcTargetWheelSpeed(); - this->right_pid->Compute(); - this->left_pid->Compute(); + this->rightPid->Compute(); + this->leftPid->Compute(); this->regulateMotors(); } @@ -100,8 +100,8 @@ void MoveControl::setDrivingStatus(Status status) void MoveControl::emergencyStop() { - this->left_motor->emergencyStop(); - this->right_motor->emergencyStop(); + this->leftMotor->emergencyStop(); + this->rightMotor->emergencyStop(); this->setSpeed(0); this->setRotationSpeed(0); this->setRawPowerLeft(0); @@ -158,11 +158,11 @@ void MoveControl::setPidTunings(uint8_t side, double pPart, double iPart, double PID *selectedPID = nullptr; if (side == 0) { - selectedPID = this->left_pid; + selectedPID = this->leftPid; } else if (side == 1) { - selectedPID = this->right_pid; + selectedPID = this->rightPid; } selectedPID->SetTunings(pPart, iPart, dPart); @@ -172,11 +172,11 @@ PID *MoveControl::getPID(uint8_t side) const { if (side == 0) { - return this->left_pid; + return this->leftPid; } if (side == 1) { - return this->right_pid; + return this->rightPid; } return nullptr; } @@ -208,8 +208,8 @@ void MoveControl::calcTargetWheelSpeed() // (1 / r) * b constexpr double B1rb = (1.0 / (Settings::wheelDiameter / 2)) * (Settings::wheelDistance / 2); - this->wheelspeed_right_target = (A1r1 * this->drivingSpeeds.x + B1rb * this->drivingSpeeds.rot); - this->wheelspeed_left_target = (A1r1 * this->drivingSpeeds.x + (-B1rb) * this->drivingSpeeds.rot); + this->wheelspeedRightTarget = (A1r1 * this->drivingSpeeds.x + B1rb * this->drivingSpeeds.rot); + this->wheelspeedLeftTarget = (A1r1 * this->drivingSpeeds.x + (-B1rb) * this->drivingSpeeds.rot); } void MoveControl::regulateMotors() @@ -217,24 +217,24 @@ void MoveControl::regulateMotors() switch (this->driving_status) { case Status::Stop: - this->left_motor->setTargetPower(0); - this->right_motor->setTargetPower(0); - this->setSpeedometerDirection(this->left_speedometer, 0); - this->setSpeedometerDirection(this->right_speedometer, 0); + this->leftMotor->setTargetPower(0); + this->rightMotor->setTargetPower(0); + this->setSpeedometerDirection(this->leftSpeedometer, 0); + this->setSpeedometerDirection(this->rightSpeedometer, 0); break; case Status::Drive: - this->left_motor->setTargetPower(static_cast(this->left_pid_out)); - this->right_motor->setTargetPower(static_cast(this->right_pid_out)); - this->setSpeedometerDirection(this->left_speedometer, this->left_motor->getPower()); - this->setSpeedometerDirection(this->right_speedometer, this->right_motor->getPower()); + this->leftMotor->setTargetPower(static_cast(this->leftPidOut)); + this->rightMotor->setTargetPower(static_cast(this->rightPidOut)); + this->setSpeedometerDirection(this->leftSpeedometer, this->leftMotor->getPower()); + this->setSpeedometerDirection(this->rightSpeedometer, this->rightMotor->getPower()); break; case Status::Raw: - this->left_motor->setTargetPower(this->rawPowerLeft); - this->right_motor->setTargetPower(this->rawPowerRight); - this->setSpeedometerDirection(this->left_speedometer, this->rawPowerLeft); - this->setSpeedometerDirection(this->right_speedometer, this->rawPowerRight); + this->leftMotor->setTargetPower(this->rawPowerLeft); + this->rightMotor->setTargetPower(this->rawPowerRight); + this->setSpeedometerDirection(this->leftSpeedometer, this->rawPowerLeft); + this->setSpeedometerDirection(this->rightSpeedometer, this->rawPowerRight); break; default: @@ -245,6 +245,6 @@ void MoveControl::regulateMotors() void MoveControl::updateCurrentWheelSpeed() { - this->wheelspeed_left = this->left_speedometer->getSpeedRad(); - this->wheelspeed_right = this->right_speedometer->getSpeedRad(); + this->wheelspeedLeft = this->leftSpeedometer->getSpeedRad(); + this->wheelspeedRight = this->rightSpeedometer->getSpeedRad(); } From db74898b7213bbf11cbc0d29d0367f8523c635d9 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 18:45:12 +0200 Subject: [PATCH 24/26] documentation checked and edit for all files in lib folder --- .vscode/settings.json | 5 + doc/Doxygen/Doxyfile | 10 +- doc/TODO allgemein.txt | 2 + doc/latexSnippet.cpp | 9 - include/Version.h | 15 +- include/moveControl.h | 290 +++++++++--------- include/networkConfig.h | 31 +- lib/Battery/battery.cpp | 10 +- lib/Battery/battery.h | 77 ++++- lib/CalcAzimuth/calcAzimuth.h | 38 ++- .../calibrateCompass.cpp | 0 lib/CalibrateCompass/calibrateCompass.h | 110 +++++++ lib/Component/component.cpp | 2 +- lib/Component/component.h | 94 +++++- lib/ControllPad/controlPad.cpp | 2 +- lib/ControllPad/controlPad.h | 33 +- lib/Counter/counter.h | 46 ++- lib/LcdWrapper/LcdWrapper.cpp | 2 +- lib/LcdWrapper/LcdWrapper.h | 3 +- lib/MQTT/debugMqtt.cpp | 83 ++--- lib/MQTT/debugMqtt.h | 237 +++++++------- lib/Navigation/navigation.h | 13 +- lib/Network/network.cpp | 26 +- lib/Network/network.h | 67 +++- lib/Point/point.h | 13 +- lib/Route/route.h | 132 ++++---- lib/Sensors/sensorData.cpp | 40 +-- lib/Sensors/sensorData.h | 79 ++++- lib/Speedometer/speedometer.h | 16 +- lib/Times/debugTimes.cpp | 4 +- lib/Times/debugTimes.h | 2 +- lib/calibrateCompass/calibrateCompass.h | 63 ---- src/OutputBuf/outputBuf.cpp | 2 +- src/OutputBuf/outputBuf.h | 3 +- .../Systeminformation/menuSysteminformation.h | 3 +- .../CalibrateCompass/menuCalibrateCompass.cpp | 12 +- .../driveModi/TestMode/menuTestMode.cpp | 2 +- .../driveModi/TestMode/speedometerTest.cpp | 2 +- .../driveModi/TestMode/speedometerTest.h | 2 +- src/driveModi/driveManager.h | 11 +- src/main.cpp | 8 +- 41 files changed, 1030 insertions(+), 569 deletions(-) delete mode 100644 doc/latexSnippet.cpp rename lib/{calibrateCompass => CalibrateCompass}/calibrateCompass.cpp (100%) create mode 100644 lib/CalibrateCompass/calibrateCompass.h delete mode 100644 lib/calibrateCompass/calibrateCompass.h diff --git a/.vscode/settings.json b/.vscode/settings.json index 51c1d3c..fa5cb03 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -123,11 +123,13 @@ "Ahnung", "akku", "ardui", + "Baseclass", "blox", "bluedroid", "carr", "CIPO", "COPI", + "Doxygen", "Dutycycle", "gast", "GNSS", @@ -137,9 +139,12 @@ "Keine", "kleiax", "Lebennig", + "microcontroller", + "MQTT", "NMEA", "NMEAGPGGA", "NTRIP", + "pcnt", "pidl", "pidr", "Punica", diff --git a/doc/Doxygen/Doxyfile b/doc/Doxygen/Doxyfile index 3ad1597..b80b40a 100644 --- a/doc/Doxygen/Doxyfile +++ b/doc/Doxygen/Doxyfile @@ -51,7 +51,7 @@ PROJECT_BRIEF = "A small verhicle which should be drive a route with GP # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = C:/Users/alex1/git/projektarbeit/doc/Doxygen/logo.png +PROJECT_LOGO = logo.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is @@ -606,7 +606,7 @@ HIDE_COMPOUND_REFERENCE= NO # will show which file needs to be included to use the class. # The default value is: YES. -SHOW_HEADERFILE = YES +# SHOW_HEADERFILE = YES # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. @@ -824,7 +824,7 @@ WARN_IF_DOC_ERROR = YES # parameters have no documentation without warning. # The default value is: YES. -WARN_IF_INCOMPLETE_DOC = YES +# WARN_IF_INCOMPLETE_DOC = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return @@ -1608,7 +1608,7 @@ GENERATE_TREEVIEW = YES # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -FULL_SIDEBAR = NO +# FULL_SIDEBAR = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. @@ -1691,7 +1691,7 @@ USE_MATHJAX = NO # The default value is: MathJax_2. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_VERSION = MathJax_2 +# MATHJAX_VERSION = MathJax_2 # When MathJax is enabled you can set the default output format to be used for # the MathJax output. For more details about the output format see MathJax diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 771fbb1..6d6bbdb 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -28,6 +28,8 @@ Do later: -> update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung -> Rover Objekt mit Error zustand freeze, damit das wenn möglich auch auf dem Display angezeigt wird. -> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz + -> Doxygen comments + - navigation Do now: diff --git a/doc/latexSnippet.cpp b/doc/latexSnippet.cpp deleted file mode 100644 index ac4c65b..0000000 --- a/doc/latexSnippet.cpp +++ /dev/null @@ -1,9 +0,0 @@ -void KomponenteA::loop() { - this->komponenteB->loop(); - this->komponenteC->loop(); - - if (millis() - this->lastMillis < this->delayMillis) - return; - - this->doSomething(); -} diff --git a/include/Version.h b/include/Version.h index 109f133..99c9ad6 100644 --- a/include/Version.h +++ b/include/Version.h @@ -1,9 +1,8 @@ - // AUTO GENERATED FILE, DO NOT EDIT - #ifndef VERSION - #define VERSION "0.8.36" - #endif - #ifndef BUILD_TIMESTAMP - #define BUILD_TIMESTAMP "2023-08-13 15:13:34.491991" - #endif - \ No newline at end of file +// AUTO GENERATED FILE, DO NOT EDIT +#ifndef VERSION +#define VERSION "1.8.36" +#endif +#ifndef BUILD_TIMESTAMP +#define BUILD_TIMESTAMP "2023-10-13 15:13:34.491991" +#endif diff --git a/include/moveControl.h b/include/moveControl.h index f2a1f08..a10c8a2 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -4,9 +4,9 @@ * @brief Contains the MoveControl class * @version 0.1 * @date 2021-12-14 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef MOVE_CONTROL_H #define MOVE_CONTROL_H @@ -22,178 +22,182 @@ #include "debugTimes.h" #include "component.h" - /** * @brief A struct to easy set the speed - * + * */ -struct DrivingSpeeds { +struct DrivingSpeeds +{ double x; double rot; }; /** * @brief This class manages the motors and the encoders - * + * * The class uses two PIDs to control the motors. The PIDs * use the Speedometer class to get the current speed and the * given target speed to calculate a new duty cycle for the motors. - * + * */ -class MoveControl : public Component { - public: - /** - * @brief used to set driving status - * - * When set to stop all motors are set to halt - * When set to Raw the PIDs are not used. The target - * values must be given withe @see setRawPowerLeft and - * @see setRawPowerRight. - * - * Drive is the normal working mode. - * - */ - enum Status {Stop, - Drive, - Raw}; +class MoveControl : public Component +{ +public: + /** + * @brief Used to set driving status + * + * When set to stop all motors are set to halt + * + * When set to Raw the PIDs are not used. The target + * values must be given withe setRawPowerLeft() and + * setRawPowerRight(). + * + * Drive is the normal working mode. + * + */ + enum Status + { + Stop, + Drive, + Raw + }; + /** + * @brief Construct a new Move Control object + * + * Initialize the motors, encoders and PIDs with given + * values in config.h + */ + MoveControl(); - /** - * @brief Construct a new Move Control object - * - * Initialize the motors, encoders and PIDs with given - * values in config.h - */ - MoveControl(); + /** + * @brief Destroy the Move Control object + * + * Stops the motors with emergencyStop() + */ + ~MoveControl(); - /** - * @brief Destroy the Move Control object - * - * Stops the motors with emergencyStop() - */ - ~MoveControl(); + /** + * @brief Set the Status + * + * Control if this component should work normally or with + * raw values for the motors. + * + * @see Status + * @param status + */ + void setDrivingStatus(Status status); - /** - * @brief Set the Status - * - * Control if this component should work normally or with - * raw values for the motors. - * - * @see Status - * @param status - */ - void setDrivingStatus(Status status); + /** + * @brief Stops the engine immediately + * + */ + void emergencyStop(); - /** - * @brief Stops the engine immediately - * - */ - void emergencyStop(); + /** + * @brief Set the target speed + * + * If the given speed is close to zero, then the + * target speed is set to zero. + * @param speed in m/s + */ + void setSpeed(double speed); - /** - * @brief Set the target speed - * - * If the given speed is close to zero, then the - * target speed is set to zero. - * @param speed in m/s - */ - void setSpeed(double speed); + /** + * @brief Set the rotationSpeed + * + * If the given rotationSpeed is close to zero, then the + * target rotationSpeed is set to zero. + * @param speed rad/s + */ + void setRotationSpeed(double speed); - /** - * @brief Set the rotationSpeed - * - * If the given rotationSpeed is close to zero, then the - * target rotationSpeed is set to zero. - * @param speed rad/s - */ - void setRotationSpeed(double speed); + /** + * @brief Set the speeds + * + * This function is a combination of the functions setSpeed() and + * setRotationSpeed(). The struct DrivingSpeeds + * is used for this. + * + * + * @param drivingSpeeds + */ + void setSpeeds(DrivingSpeeds drivingSpeeds); - /** - * @brief Set the speeds - * - * This function is a combination of @see setSpeed and - * @see setRotationSpeed. The struct @see DrivingSpeeds - * is used for this. - * - * @param drivingSpeeds - */ - void setSpeeds(DrivingSpeeds drivingSpeeds); + /** + * @brief Set raw power left + * + * This value has only an effect if the status is raw. + * @see setDrivingStatus + * + * @param power between -100 and 100 + */ + void setRawPowerLeft(int16_t power); - /** - * @brief Set raw power left - * - * This value has only an effect if the status is raw. - * @see setDrivingStatus - * - * @param power between -100 and 100 - */ - void setRawPowerLeft(int16_t power); + /** + * @brief Set the raw power right + * + * This value has only an effect if status is raw. + * + * @param power between -100 and 100 + */ + void setRawPowerRight(int16_t power); - /** - * @brief Set the raw power right - * - * This value has only an effect if status is raw. - * - * @param power between -100 and 100 - */ - void setRawPowerRight(int16_t power); + /** + * @brief Set the pid tunings + * + * @param side 0 -> left, 1 -> right + * @param pPart + * @param iPart + * @param dPart + */ + void setPidTunings(uint8_t side, double pPart, double iPart, double dPart); - /** - * @brief Set the pid tunings - * - * @param side 0 -> left, 1 -> right - * @param pPart - * @param iPart - * @param dPart - */ - void setPidTunings(uint8_t side, double pPart, double iPart, double dPart); + /** + * @brief Returns the PID object of the choosen side. + * + * @param side 0 -> left, 1 -> right + * @return PID* + */ + PID *getPID(uint8_t side) const; - /** - * @brief Returns the PID object of the choosen side. - * - * @param side 0 -> left, 1 -> right - * @return PID* - */ - PID* getPID(uint8_t side) const; + Speedometer *getSpeedometerLeft() const { return this->leftSpeedometer; } + Speedometer *getSpeedometerRight() const { return this->rightSpeedometer; } - Speedometer* getSpeedometerLeft() const { return this->leftSpeedometer; } - Speedometer* getSpeedometerRight() const { return this->rightSpeedometer; } + uint16_t getDutycycleLeft() const { return this->leftMotor->getDutycycle(); } + uint16_t getDutycycleRight() const { return this->rightMotor->getDutycycle(); } - uint16_t getDutycycleLeft() const { return this->leftMotor->getDutycycle(); } - uint16_t getDutycycleRight() const { return this->rightMotor->getDutycycle(); } +private: + void run() override; + static void setSpeedometerDirection(Speedometer *speedometer, double value); + void calcTargetWheelSpeed(); + void regulateMotors(); + void updateCurrentWheelSpeed(); - private: - void run() override; - static void setSpeedometerDirection(Speedometer *speedometer, double value); - void calcTargetWheelSpeed(); - void regulateMotors(); - void updateCurrentWheelSpeed(); + MotorControl *leftMotor; + MotorControl *rightMotor; + Speedometer *leftSpeedometer; + Speedometer *rightSpeedometer; + PID *leftPid; + PID *rightPid; - MotorControl *leftMotor; - MotorControl *rightMotor; - Speedometer *leftSpeedometer; - Speedometer *rightSpeedometer; - PID *leftPid; - PID *rightPid; + Status driving_status = Status::Stop; + DrivingSpeeds drivingSpeeds = {0, 0}; - Status driving_status = Status::Stop; - DrivingSpeeds drivingSpeeds = {0, 0}; + double wheelspeedLeftTarget = 0; + double wheelspeedRightTarget = 0; + double wheelspeedLeft = 0; + double wheelspeedRight = 0; + double leftPidOut = 0; + double rightPidOut = 0; - double wheelspeedLeftTarget = 0; - double wheelspeedRightTarget = 0; - double wheelspeedLeft = 0; - double wheelspeedRight = 0; - double leftPidOut = 0; - double rightPidOut = 0; - - uint8_t overTimeCounter = 0; - uint8_t overTimeMax = 100; - int8_t rawPowerLeft = 0; - int8_t rawPowerRight = 0; - - static constexpr int8_t maxPercentage = 100; - static constexpr float minSpeed = 0.2; - static constexpr uint8_t loopDelay = 20; + uint8_t overTimeCounter = 0; + uint8_t overTimeMax = 100; + int8_t rawPowerLeft = 0; + int8_t rawPowerRight = 0; + static constexpr int8_t maxPercentage = 100; + static constexpr float minSpeed = 0.2; + static constexpr uint8_t loopDelay = 20; }; #endif // MOVE_CONTROL_H diff --git a/include/networkConfig.h b/include/networkConfig.h index 8e28c90..13aac37 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -2,14 +2,14 @@ * @file networkConfig.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains the settings for the Network class - * + * * With different defines the location can be choosen. - * + * * @version 0.1 * @date 2022-02-15 - * + * * @copyright Copyright (c) 2022 - * + * */ #include @@ -17,7 +17,8 @@ #define HW1 #ifdef HOTSPOT -namespace NetworkConfig { +namespace NetworkConfig +{ const char ssid[] = "Kleiax Handy"; const char password[] = "12345677"; const char ip[] = "192.168.43.4"; @@ -26,10 +27,11 @@ namespace NetworkConfig { const char dns[] = "8.8.8.8"; const bool mqtt = false; } -#endif //HOTSPOT +#endif // HOTSPOT #ifdef HW1 -namespace NetworkConfig { +namespace NetworkConfig +{ const char ssid[] = "hw1_gast"; const char password[] = "KeineAhnung"; const char ip[] = "192.168.0.4"; @@ -38,11 +40,12 @@ namespace NetworkConfig { const char dns[] = "8.8.8.8"; const bool mqtt = false; } -#endif //HW1 +#endif // HW1 -//Network config Rhede +// Network config Rhede #ifdef RHEDE -namespace NetworkConfig { +namespace NetworkConfig +{ const char ssid[] = "LebennigHuus"; const char password[] = "Punica-699"; const char ip[] = "192.168.11.4"; @@ -51,16 +54,18 @@ namespace NetworkConfig { const char dns[] = "8.8.8.8"; const bool mqtt = true; } -#endif //RHEDE +#endif // RHEDE -namespace MqttConfig { +namespace MqttConfig +{ const char server[] = "192.168.1.7"; const uint16_t port = 1883; const char user[] = "kleiax"; const char password[] = "p?{$_~5%hBM7wrcFkr55KWr#"; } -namespace NtripConfig { +namespace NtripConfig +{ const char host[] = "rtk2go.com"; const uint16_t port = 2101; // const char mountPoint[] = "GER-Dortmund"; diff --git a/lib/Battery/battery.cpp b/lib/Battery/battery.cpp index 8aedcb2..73b77de 100644 --- a/lib/Battery/battery.cpp +++ b/lib/Battery/battery.cpp @@ -37,12 +37,12 @@ void Battery::run() this->readAdcToBuf(); this->loopCounter++; - if (this->loopCounter >= this->calulationDelayMultiplier) + if (this->loopCounter >= this->calculateDelayMultiplier) { this->calculateBatteryVoltage(); this->calculateBatteryPercent(); this->loopCounter = 0; - this->calculatetNewValues = true; + this->calculatedNewValues = true; } } @@ -89,12 +89,12 @@ bool Battery::isBatteryLow(double voltage) const bool Battery::isNewValue() { - if (!this->calculatetNewValues) + if (!this->calculatedNewValues) { return false; } - this->calculatetNewValues = false; + this->calculatedNewValues = false; return true; } @@ -136,7 +136,7 @@ double Battery::calculateInputVoltage() return 0; } - return -this->adcCurveCoeficient[0] * pow(reading, 4) + this->adcCurveCoeficient[1] * pow(reading, 3) - this->adcCurveCoeficient[2] * pow(reading, 2) + this->adcCurveCoeficient[3] * reading + this->adcCurveCoeficient[4]; + return -this->adcCurveCoefficient[0] * pow(reading, 4) + this->adcCurveCoefficient[1] * pow(reading, 3) - this->adcCurveCoefficient[2] * pow(reading, 2) + this->adcCurveCoefficient[3] * reading + this->adcCurveCoefficient[4]; } void Battery::calculateBatteryVoltage() diff --git a/lib/Battery/battery.h b/lib/Battery/battery.h index 2afc17d..c2787a3 100644 --- a/lib/Battery/battery.h +++ b/lib/Battery/battery.h @@ -24,12 +24,20 @@ * * This class reads the voltage from an analog pin to calculate the * charge level of a 3 Cell Li-Poly battery pack. The battery pack have - * to be after a voltage diveder, so that maximum voltage for the + * to be after a voltage divider, so that maximum voltage for the * microcontroller is 3.3 Volt. */ class Battery : public Component { public: + /** + * @brief States when the calibration modes is active + * + * - None means that no calibration is running + * - Reading means that the adc takes multiple values to calculate an average + * - Waiting means that the user has to set the new wanted voltage + * - Finished means that all measurements was taken + */ enum CalibrationState { None, @@ -41,15 +49,25 @@ public: /** * @brief Construct a new Battery object * - * The voltage devider have to be calculated, so that the input + * The voltage divider have to be calculated, so that the input * voltage from 3.3 Volt is never exceeded. It is assumed that * the microcontroller is connected to the second resistor. * * @param pin The analog to read from. - * @param firstResistor First resistor of the voltage devider. - * @param secondResistor Second resistor of the voltage devider. + * @param firstResistor First resistor of the voltage divider. + * @param secondResistor Second resistor of the voltage divider. */ Battery(uint8_t pin, uint32_t firstResistor, uint32_t secondResistor); + + /** + * @brief Construct a new Battery object + * + * With this constructor the real voltage is not calculated with the + * voltage divider but with a table which contains the raw reading from + * the adc mapped to a specific voltage + * + * @param pin + */ Battery(uint8_t pin); /** @@ -79,13 +97,50 @@ public: */ bool isBatteryLow(double voltage) const; + /** + * @brief Check if a new voltage was been calculated + * + * @return true + * @return false + */ bool isNewValue(); // Calibration CalibrationState getCalibrationState() const { return this->calibrationState; } + + /** + * @brief Get the current calibration voltage target + * + * The returned value stand for the index of the table for this reason + * the real value have to be calculated. After the returned voltage has been set + * you have to call nextVoltageIsReady(). + * + * @return uint8_t voltage multiply with 0,1 and add 7 + */ uint8_t getCurrentCalibrationVoltage() const { return this->currentCalibrationVoltage; } + + /** + * @brief Read next wanted voltage + * + * If this function is called, the calibration mode reads the new voltage + * and save the value in the table. + */ void nextVoltageIsReady(); + + /** + * @brief Calibrate the battery readings + * + * This calibration has only an effect if the Component + * uses the table with the raw adc values. The calibration gives + * the user different voltages that have to be set with a + * laboratory power supply. The power supply have to be connected + * instead of the battery. + */ void startCalibration(); + + /** + * @brief abort the calibration + */ void finishCalibration(); private: @@ -109,14 +164,14 @@ private: uint8_t batteryPercent = 0; uint8_t batteryLowPercent = 10; uint8_t bufferPos = 0; - uint8_t calulationDelayMultiplier = 5; + uint8_t calculateDelayMultiplier = 5; uint8_t loopCounter = 0; uint8_t currentCalibrationVoltage = 0; // *0.1 + 7 uint16_t adcBuffer[bufferSize]; uint16_t *newRawAdcVoltages = nullptr; uint32_t firstResistor = 0; uint32_t secondResistor = 0; - bool calculatetNewValues = false; + bool calculatedNewValues = false; double batteryVoltage = 0; double batteryVoltageFactor; @@ -137,11 +192,11 @@ private: 2920, 2956, 2983, 3019, 3054, 3088, 3121, 3158, 3189, 3226, 3264, 3300, 3339, 3379, 3414, 3453, 3500, 3544, 3598, 3636, 3682, 3730, 3781, 3837, 3887, 3943, 3997, 4054, 4093, 4095}; - const double adcCurveCoeficient[5] = {0.000000000000016, - 0.000000000118171, - 0.000000301211691, - 0.001109019271794, - 0.034143524634089}; + const double adcCurveCoefficient[5] = {0.000000000000016, + 0.000000000118171, + 0.000000301211691, + 0.001109019271794, + 0.034143524634089}; }; #endif // BATTERY_H diff --git a/lib/CalcAzimuth/calcAzimuth.h b/lib/CalcAzimuth/calcAzimuth.h index c3aa08d..4b18315 100644 --- a/lib/CalcAzimuth/calcAzimuth.h +++ b/lib/CalcAzimuth/calcAzimuth.h @@ -1,7 +1,7 @@ /** * @file calcAzimuth.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a class that calculates the azimuth from a last and a current position * @version 0.1 * @date 2023-09-03 * @@ -15,9 +15,18 @@ #include "component.h" #include "point.h" +/** + * @brief A class to calculate an azimuth + * + * This class calculates the current Azimuth with the last position + * where the rover has been rotated and the current position + */ class CalcAzimuth : public Component { public: + /** + * @brief States which represent the quality of the current calculated azimuth + */ enum State { Invalid, @@ -27,13 +36,40 @@ public: Super }; + /** + * @brief Construct a new Calc Azimuth object + * + * @param point current position + */ CalcAzimuth(Point point); + /** + * @brief Have to be called if the rover rotates + * + * @param point current position + */ void drivingDirectionChange(Point point); + + /** + * @brief update the current position + * + * This function should be called if the rover has moved in + * a straight direction, to calculated the current Azimuth. + * More distance to the point given to drivingDirectionChange() + * increase the accuracy of the calculation. + * + * @param point current position + */ void updateCurrentPosition(Point point); void disableCalcAzimuth() { this->directionChangeMode = false; } int16_t getAzimuth() const { return this->calcAzimuth; } + + /** + * @brief Get the State struct + * + * @return State current quality of the calculation + */ State getState() const { return this->state; } static String stateToString(State state); diff --git a/lib/calibrateCompass/calibrateCompass.cpp b/lib/CalibrateCompass/calibrateCompass.cpp similarity index 100% rename from lib/calibrateCompass/calibrateCompass.cpp rename to lib/CalibrateCompass/calibrateCompass.cpp diff --git a/lib/CalibrateCompass/calibrateCompass.h b/lib/CalibrateCompass/calibrateCompass.h new file mode 100644 index 0000000..f5ce2da --- /dev/null +++ b/lib/CalibrateCompass/calibrateCompass.h @@ -0,0 +1,110 @@ +/** + * @file calibrateCompass.h + * @author Alexander Klein (alex@kleiax.de) + * @brief Contains a class to calibrate the compass module + * @version 0.1 + * @date 2023-05-23 + * + * @copyright Copyright (c) 2023 + * + */ + +#pragma once + +#include +#include +#include + +#include "component.h" + +/** + * @brief A Class to calibrate the compass + * + * This class reads the raw values of the compass while + * the rove have to be moved. The lowest and highest values + * are used to calibrate the compass to the current location. + */ +class CalibrateCompass : public Component +{ +public: + /** + * @brief State of the calibration process + */ + enum State + { + Ready, + Calibrating, + Finished + }; + + /** + * @brief Type for calibration data + * + * The data consist of 6 values. For each for the 3 axis + * are to integer needed. + */ + struct CalibrationData + { + int data[3][2]; + }; + + CalibrateCompass(QMC5883LCompass *compass); + + /** + * @brief Starts the calibration + */ + void start(); + + /** + * @brief Use the measured calibration data + */ + void useData(); + + /** + * @brief Remove the measured calibration data + */ + void removeCalibration(); + + /** + * @brief Reset the calibration process to start again + */ + void reset(); + + /** + * @brief Save the measured calibration data to the flash + */ + void saveData(); + + /** + * @brief Load the measured calibration data from the flash + * + */ + void loadData(); + + State getState() const { return this->state; } + CalibrationData getCalibrationData() const { return this->data; } + + /** + * @brief Makes the calibration data printable with std::cout() + * + * @param stream + * @param caliComp + * @return std::ostream& + */ + friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp); + +private: + void runAsChild() override; + void run() override; + void checkDataValidity(); + + QMC5883LCompass *compass; + State state = State::Ready; + CalibrationData data{}; + + void clearData(); + + bool dataValid = false; + const uint16_t maxTimeWithoutChange = 10000; + uint32_t lastChange = 0; +}; diff --git a/lib/Component/component.cpp b/lib/Component/component.cpp index 8bf2ab5..0595c77 100644 --- a/lib/Component/component.cpp +++ b/lib/Component/component.cpp @@ -19,7 +19,7 @@ void Component::loop() (*it)->loop(); } } - this->runAsChild(); + this->runAsChild();F if (this->onlyChilds) { diff --git a/lib/Component/component.h b/lib/Component/component.h index 7e4b93a..bf37591 100644 --- a/lib/Component/component.h +++ b/lib/Component/component.h @@ -1,7 +1,7 @@ /** * @file component.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains an interface to make non blocking components with delay. * @version 0.1 * @date 2023-08-16 * @@ -15,31 +15,123 @@ #include +/** + * @brief An Interface to make components + * + * A component is a task that be called in a loop which not + * runs every loop, so every component has a non blocking delay. + * + * A component can manage other components which called children components. + */ class Component { public: + /** + * @brief Construct a new Component object + * + * With the default constructor the created component is + * by default inactive. This does not affect the execution of + * the children components. + */ Component() {} + + /** + * @brief Construct a new Component object + * + * If the given parameter is zero, there are no differences to the + * default constructor. + * + * @param loopDelay the minimum time in milliseconds before the task runs + */ Component(uint16_t loopDelay); + /** + * @brief Runs the children components and the task + * + * The loop() function of the children is called every time this + * loop is called. + * + * The run() function which presents the task of this component is + * only called if the delay is reached. + */ void loop(); + /** + * @brief Deactivate this component + * + * If the component is deactivated the call of loop() ha no effect + */ void deactivate() { this->active = false; } void activate() { this->active = false; } protected: + /** + * @brief Override this function to avoid the delay + */ virtual void runAsChild() {} + + /** + * @brief Runs befor the run() function + * + * This function is only called, if the delay + * is reached. + * The function do nothing, except the function is overwritten + * by the class which inherits this class. + */ virtual void beforeRun() {} + + /** + * @brief The actual task + * + * This function have to be overwritten by the inheriting class. + */ virtual void run() = 0; + + /** + * @brief Runs after the run() function + * + * This function is only called, if the delay + * is reached. + * The function do nothing, except the function is overwritten + * by the class which inherits this class. + */ virtual void afterRun() {} + /** + * @brief Adds a child component + * + * The child component will be called every time the loop() function + * is called. + * + * @param child + */ void addChildComponent(Component *child); void removeChildComponent(Component *child); void activateOnlyChilds() { this->onlyChilds = true; } + + /** + * @brief Skip the actual task + * + * Same as set the loopDelay to zero. + */ void deactivateOnlyChilds() { this->onlyChilds = false; } + /** + * @brief Set the timer after task + * + * If this function is called once the measurement of the delay + * starts after task has finished. The default is, that the + * measurement begins at the start of the task. + */ void setTimerAfterTask() { this->timeUpdateAfter = true; } + /** + * @brief the minimum time in milliseconds before the task runs + * + * If this value is zero, the functions beforeRun(), run() and + * afterRun() would not be called + */ uint16_t loopDelay = 0; private: diff --git a/lib/ControllPad/controlPad.cpp b/lib/ControllPad/controlPad.cpp index 737ae6c..9fcf9ae 100644 --- a/lib/ControllPad/controlPad.cpp +++ b/lib/ControllPad/controlPad.cpp @@ -11,7 +11,7 @@ #include "controlPad.h" -ControlPad::ControlPad() : Component(5), controlInput{0, 0, 0, 0} {} +ControlPad::ControlPad() : Component(10), controlInput{0, 0, 0, 0} {} void ControlPad::run() { diff --git a/lib/ControllPad/controlPad.h b/lib/ControllPad/controlPad.h index 1df2ba2..c0f0904 100644 --- a/lib/ControllPad/controlPad.h +++ b/lib/ControllPad/controlPad.h @@ -1,7 +1,7 @@ /** * @file controlPad.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a class that gets the input data * @version 0.1 * @date 2023-03-30 * @@ -16,15 +16,46 @@ #include #include +/** + * @brief A class to manage inputs + * + * This class converts the incoming data to the buttons and + * the axis from the joystick. The converted data will be send + * to the menu. + */ class ControlPad : public Component { public: ControlPad(); + /** + * @brief Insert the incoming data to convert + * + * The data is converted to the ControlPadInput struct. + * + * @param data have to be 4 byte long + */ void insertData(const uint8_t *data); + /** + * @brief Set the MenuControl object + * + * The MenuControl object is used to control the Menu. + * + * @see Menu + * @see ControlPadInput + * + * @param menuControl + */ void setMenuControl(MenuControl *menuControl) { this->menuControl = menuControl; } + /** + * @brief Get the Control Pad Data + * + * The pointer holds the lates data from the ControlPad + * + * @return const ControlPadInput* + */ const ControlPadInput *getControlPadDataPtr() const { return &this->controlInput; } bool isControlPadConnected() const { return this->connected; } diff --git a/lib/Counter/counter.h b/lib/Counter/counter.h index 34579e6..74c96b6 100644 --- a/lib/Counter/counter.h +++ b/lib/Counter/counter.h @@ -1,21 +1,65 @@ +/** + * @file counter.h + * @author Alexander Klein (alex@kleiax.de) + * @brief Contains a class that abstract the hardware counter from the esp32 + * @version 0.1 + * @date 2023-10-12 + * + * @copyright Copyright (c) 2023 + * + */ #pragma once #include #include #include +/** + * @brief A class that abstract the hardware counter from the esp32 + */ class Counter { public: + /** + * @brief Construct a new Counter object + * + * @param pin with incoming pulses + */ Counter(uint8_t pin); + /** + * @brief Pause the pulse counting + */ void pause(); + + /** + * @brief Resume the pulse counting + */ void resume(); + + /** + * @brief Start counting by zero again + */ void clear(); + /** + * @brief Get the counted pulses + * + * @return int16_t + */ int16_t getValue() const; + /** + * @brief Set the filter value + * + * The filter skip all pulses after a pulse for the filter time. + * The filter time depends on the frequency of the processor. The time + * for a whole tact multiplied with the filter value results the filter time. + * + * @param value max 1023 + */ void setFilterValue(uint16_t value); + void filterEnable(); void filterDisable(); @@ -26,7 +70,7 @@ private: static uint8_t amountOfCounter; - bool initalised = false; + bool initalized = false; uint8_t pulsePin; pcnt_unit_t unit; diff --git a/lib/LcdWrapper/LcdWrapper.cpp b/lib/LcdWrapper/LcdWrapper.cpp index 4d48230..80d66db 100644 --- a/lib/LcdWrapper/LcdWrapper.cpp +++ b/lib/LcdWrapper/LcdWrapper.cpp @@ -1,5 +1,5 @@ /** - * @file displayWrapper.cpp + * @file LcdWrapper.cpp * @author Alexander Klein (alex@kleiax.de) * @brief Contains the implementation of the class LcdWrapper * @version 0.1 diff --git a/lib/LcdWrapper/LcdWrapper.h b/lib/LcdWrapper/LcdWrapper.h index dd19cc5..e000fef 100644 --- a/lib/LcdWrapper/LcdWrapper.h +++ b/lib/LcdWrapper/LcdWrapper.h @@ -1,5 +1,5 @@ /** - * @file displayWrapper.h + * @file LcdWrapper.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains the LcdWrapper class * @version 0.1 @@ -37,7 +37,6 @@ public: /** * @brief Empty the buffer - * */ void clear() override; diff --git a/lib/MQTT/debugMqtt.cpp b/lib/MQTT/debugMqtt.cpp index 3de8e95..e042414 100644 --- a/lib/MQTT/debugMqtt.cpp +++ b/lib/MQTT/debugMqtt.cpp @@ -5,101 +5,115 @@ * @see debugMqtt.h * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "debugMqtt.h" -PubSubClient* DebugMqtt::client; +PubSubClient *DebugMqtt::client; Loglevel DebugMqtt::loglevel; bool DebugMqtt::isInit = false; char DebugMqtt::msg[MQTT_BUFFER_SIZE]; char DebugMqtt::topic[MQTT_BUFFER_SIZE]; - -DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) - : name {name} +DebugMqtt::DebugMqtt(const char *name, uint8_t bufSize) + : name{name} { - if (bufSize != 0) { + if (bufSize != 0) + { this->bufSize = bufSize; } this->buf = new char[this->bufSize]; } -DebugMqtt::~DebugMqtt() { +DebugMqtt::~DebugMqtt() +{ delete this->buf; } -void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg) { - snprintf (static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s: %s"),this->name ,msg.c_str()); - this->sendData(loglevel, topic, static_cast(DebugMqtt::msg)); +void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg) +{ + snprintf(static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s: %s"), this->name, msg.c_str()); + this->sendData(loglevel, topic, static_cast(DebugMqtt::msg)); } -void DebugMqtt::sendMsg(Loglevel loglevel, String msg) { +void DebugMqtt::sendMsg(Loglevel loglevel, String msg) +{ this->sendMsg(loglevel, "", msg); } -void DebugMqtt::sendData(Loglevel loglevel, String topic, String data) { - if (!DebugMqtt::isInit) { +void DebugMqtt::sendData(Loglevel loglevel, String topic, String data) +{ + if (!DebugMqtt::isInit) + { return; } - if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none) { - snprintf (static_cast(DebugMqtt::topic), MQTT_BUFFER_SIZE, static_cast("%s%s"), DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str()); - snprintf (static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s"), data.c_str()); - client->publish(DebugMqtt::topic, static_cast(DebugMqtt::msg)); + if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none) + { + snprintf(static_cast(DebugMqtt::topic), MQTT_BUFFER_SIZE, static_cast("%s%s"), DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str()); + snprintf(static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s"), data.c_str()); + client->publish(DebugMqtt::topic, static_cast(DebugMqtt::msg)); } } -void DebugMqtt::sendData(Loglevel loglevel, String data){ +void DebugMqtt::sendData(Loglevel loglevel, String data) +{ DebugMqtt::sendData(loglevel, "", data); } -void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos) { +void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos) +{ // Example String: "weather temperature=82 1465839830100400200"; - snprintf(static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s %s=%f %llu"), measurement_name.c_str(), field_set.c_str(), measurement, nanos); - this->sendData(Loglevel::influx, static_cast(DebugMqtt::msg)); + snprintf(static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s %s=%f %llu"), measurement_name.c_str(), field_set.c_str(), measurement, nanos); + this->sendData(Loglevel::influx, static_cast(DebugMqtt::msg)); } -void DebugMqtt::addCharacter(char character) { +void DebugMqtt::addCharacter(char character) +{ this->buf[this->bufPos] = character; this->bufPos++; - if (character == '\n' || this->bufPos >= this->bufSize - 1) { + if (character == '\n' || this->bufPos >= this->bufSize - 1) + { this->buf[this->bufPos - 1] = '\0'; this->sendMsg(Loglevel::info, buf); this->bufPos = 0; } } -void DebugMqtt::init(PubSubClient *client, Loglevel max_loglevel) { +void DebugMqtt::init(PubSubClient *client, Loglevel max_loglevel) +{ DebugMqtt::client = client; DebugMqtt::loglevel = max_loglevel; DebugMqtt::isInit = true; } -void DebugMqtt::changeLoglevel(Loglevel loglevel) { +void DebugMqtt::changeLoglevel(Loglevel loglevel) +{ DebugMqtt::loglevel = loglevel; } -String DebugMqtt::enum_to_string(Loglevel loglevel) { +String DebugMqtt::enum_to_string(Loglevel loglevel) +{ String topic = ""; topic += MQTT_DEBUG_TOPIC; - switch(loglevel){ - case Loglevel::error : + switch (loglevel) + { + case Loglevel::error: topic += "/Error"; break; - case Loglevel::warn : + case Loglevel::warn: topic += "/Warn"; break; - case Loglevel::info : + case Loglevel::info: topic += "/Info"; break; - case Loglevel::debug : + case Loglevel::debug: topic += "/Debug"; break; - case Loglevel::influx : + case Loglevel::influx: topic += "/Influx"; break; default: @@ -107,5 +121,4 @@ String DebugMqtt::enum_to_string(Loglevel loglevel) { break; } return topic; - } - +} diff --git a/lib/MQTT/debugMqtt.h b/lib/MQTT/debugMqtt.h index 194fd14..bb17640 100644 --- a/lib/MQTT/debugMqtt.h +++ b/lib/MQTT/debugMqtt.h @@ -4,9 +4,9 @@ * @brief Inherits a class to send debug messages over MQTT * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef DEBUG_MQTT_H #define DEBUG_MQTT_H @@ -14,10 +14,9 @@ #include #include - /** - * @brief - * + * @brief + * * If you want to change the default topic * to an other value, than you have to define this define * in your code befor you include this File. @@ -28,151 +27,155 @@ /** * @brief Defualt for max message size - * + * * If you want to change the default size of 128 Byte * to an other value, than you have to define this define * in your code befor you include this File. */ #ifndef MQTT_BUFFER_SIZE #define MQTT_BUFFER_SIZE 128 -#endif //MQTT_BUFFER_SIZE +#endif // MQTT_BUFFER_SIZE /** * @brief An enum to set the log level - * + * * The log level is the last part of the MQTT topic. * Unless you give sendMsg() or sendData() a additional * topic as String. - * + * * @see sendMsg() * @see sendData() - * + * */ -enum Loglevel { none, - error, - warn, - info, - debug, - influx}; +enum Loglevel +{ + none, + error, + warn, + info, + debug, + influx +}; /** * @brief A class to send debug messages over MQTT - * + * * This class send debug messages over MQTT with different topics * by the enum Loglevel. Besides that this class supports to send * data via Telegraf into Grafana. - * + * * @see Loglevel */ -class DebugMqtt { - public: - /** - * @brief Construct a new Debug Mqtt object. - * - * @param name A String with send with every Message. - * @param bufSize for the addCharacter function. - */ - DebugMqtt(const char* name, uint8_t bufSize = 0); +class DebugMqtt +{ +public: + /** + * @brief Construct a new Debug Mqtt object. + * + * @param name A String with send with every Message. + * @param bufSize for the addCharacter function. + */ + DebugMqtt(const char *name, uint8_t bufSize = 0); - ~DebugMqtt(); + ~DebugMqtt(); - /** - * @brief Send a Message via MQTT - * - * This function uses sendData to send the given string and - * add the name to the message given by the constructer. - * - * @see sendData() - * @see Loglevel - * - * @param loglevel Loglevel given by the enum Loglevel - * @param topic Additional topic behind loglevel - * @param msg The message to send as String - */ - void sendMsg(Loglevel loglevel, String topic, String msg); - void sendMsg(Loglevel loglevel, String msg); + /** + * @brief Send a Message via MQTT + * + * This function uses sendData to send the given string and + * add the name to the message given by the constructer. + * + * @see sendData() + * @see Loglevel + * + * @param loglevel Loglevel given by the enum Loglevel + * @param topic Additional topic behind loglevel + * @param msg The message to send as String + */ + void sendMsg(Loglevel loglevel, String topic, String msg); + void sendMsg(Loglevel loglevel, String msg); - /** - * @brief Send a Message via MQTT - * - * This function sends the Data via MQTT with the given topic - * from Loglevel or followed by given String topic. - * Normally this function is called by sendMsg() or by - * writeToInflux() - * - * @see sendData() - * @see writeToInflux() - * @see Loglevel - * - * @param loglevel Loglevel given by the enum Loglevel - * @param topic Additional topic behind loglevel - * @param data The message to send as String - */ - static void sendData(Loglevel loglevel, String topic, String data); - static void sendData(Loglevel loglevel, String data); + /** + * @brief Send a Message via MQTT + * + * This function sends the Data via MQTT with the given topic + * from Loglevel or followed by given String topic. + * Normally this function is called by sendMsg() or by + * writeToInflux() + * + * @see sendData() + * @see writeToInflux() + * @see Loglevel + * + * @param loglevel Loglevel given by the enum Loglevel + * @param topic Additional topic behind loglevel + * @param data The message to send as String + */ + static void sendData(Loglevel loglevel, String topic, String data); + static void sendData(Loglevel loglevel, String data); - /** - * @brief Send a Message via MQTT for InfluxDB - * - * This function sends a MQTT message which is intended for - * Telegraf. Telegraf can listen on MQTT messages and put - * them in an Influx Database. - * - * @param measurement_name like a category - * @param field_set the name of the value e.g temperature - * @param measurement the real value - * @param nanos Current time in nanoseconds - */ - void writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos); + /** + * @brief Send a Message via MQTT for InfluxDB + * + * This function sends a MQTT message which is intended for + * Telegraf. Telegraf can listen on MQTT messages and put + * them in an Influx Database. + * + * @param measurement_name like a category + * @param field_set the name of the value e.g temperature + * @param measurement the real value + * @param nanos Current time in nanoseconds + */ + void writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos); - /** - * @brief Adds a single character to the buf - * - * The buf will be flushed out: - * 1. when the buffer is full - * 2. when the character is '\n' - * - * @param character - */ - void addCharacter(char character); + /** + * @brief Adds a single character to the buf + * + * The buf will be flushed out: + * 1. when the buffer is full + * 2. when the character is '\n' + * + * @param character + */ + void addCharacter(char character); - /** - * @brief Initialize debugMQTT for all instances - * - * You only have to call this function once for your project. - * If you call this function again you overwrite the client and - * the loglevel. If you only want du overwrite the max_loglevel - * use changeLoglevel() - * - * @see changeLoglevel() - * - * @param client PubSubClient - * @param max_loglevel Max loglevel to send. - */ - static void init(PubSubClient* client, Loglevel max_loglevel); + /** + * @brief Initialize debugMQTT for all instances + * + * You only have to call this function once for your project. + * If you call this function again you overwrite the client and + * the loglevel. If you only want du overwrite the max_loglevel + * use changeLoglevel() + * + * @see changeLoglevel() + * + * @param client PubSubClient + * @param max_loglevel Max loglevel to send. + */ + static void init(PubSubClient *client, Loglevel max_loglevel); - /** - * @brief Change loglevel - * - * This function changes the maximum loglevel which be send. - * - * @param loglevel - */ - static void changeLoglevel(Loglevel loglevel); + /** + * @brief Change loglevel + * + * This function changes the maximum loglevel which be send. + * + * @param loglevel + */ + static void changeLoglevel(Loglevel loglevel); - private: - const char* name; - char* buf; - uint8_t bufPos = 0; - uint8_t bufSize = 100; +private: + const char *name; + char *buf; + uint8_t bufPos = 0; + uint8_t bufSize = 100; - static String enum_to_string(Loglevel loglevel); + static String enum_to_string(Loglevel loglevel); - static PubSubClient* client; - static Loglevel loglevel; - static bool isInit; - static char msg[MQTT_BUFFER_SIZE]; - static char topic[MQTT_BUFFER_SIZE]; + static PubSubClient *client; + static Loglevel loglevel; + static bool isInit; + static char msg[MQTT_BUFFER_SIZE]; + static char topic[MQTT_BUFFER_SIZE]; }; #endif // DEBUG_MQTT_H diff --git a/lib/Navigation/navigation.h b/lib/Navigation/navigation.h index cfe7ed6..65d5689 100644 --- a/lib/Navigation/navigation.h +++ b/lib/Navigation/navigation.h @@ -52,9 +52,10 @@ public: }; /** - * @brief Construct a new Navigation object and using I2C + * @brief Construct a new Navigation object * - * @param route with which to navigate + * @param sensorData + * @param route */ Navigation(const SensorData *sensorData, Route *route = nullptr); @@ -89,11 +90,9 @@ public: /** * @brief Get the Course Correction object * - * This should be called by the driver to get new instructions. - * - * @param correction passed as refernce to get the data - * @return true if new correction data provided - * @return false if route is finished + * @param correction + * @param forceUpdate + * @return Status */ Status getCourseCorrection(CourseCorrection &correction, bool forceUpdate = false); diff --git a/lib/Network/network.cpp b/lib/Network/network.cpp index 3479e3e..93ae142 100644 --- a/lib/Network/network.cpp +++ b/lib/Network/network.cpp @@ -21,18 +21,18 @@ Network::Network(const char *ssid, const char *passphrase) this->init(ssid, passphrase); } -Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) - : adresses{adresses} +Network::Network(const char *ssid, const char *passphrase, NetworkAddresses adresses) + : addresses{adresses} { if (!WiFiGenericClass::mode(WIFI_AP_STA)) { std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; } - if (!WiFi.config(this->adresses.localIP, - this->adresses.gateway, - this->adresses.subnet, - this->adresses.dnsServer)) + if (!WiFi.config(this->addresses.localIP, + this->addresses.gateway, + this->addresses.subnet, + this->addresses.dnsServer)) { std::cout << "STA Failed to configure" << std::endl; } @@ -45,7 +45,7 @@ Network::~Network() delete mqttClient; } -bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) +bool Network::activateEspNow(receiveCallbackPtr reci, sendCallbackPtr send) { if (esp_now_init() != ESP_OK) { @@ -76,7 +76,7 @@ bool Network::activateMqtt(const char *user, const char *passphrase) this->mqttPassphrase = passphrase; this->mqttClient = new PubSubClient(this->wifiClient); - this->mqttClient->setServer(this->adresses.mqttServer, this->adresses.mqttPort); + this->mqttClient->setServer(this->addresses.mqttServer, this->addresses.mqttPort); this->mqttClient->setSocketTimeout(1); if (this->wifiConnected) @@ -116,7 +116,7 @@ uint8_t Network::getCurrentChannel() void Network::runAsChild() { - if (!this->initSucessful) + if (!this->initSuccessful) { return; } @@ -154,21 +154,21 @@ void Network::init(const char *ssid, const char *passphrase) void Network::checkWifi() { - if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay)) + if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiReconnectAttempt >= Network::wifiReconnectDelay)) { std::cout << "Reconnecting to WiFi..." << std::endl; WiFi.disconnect(); this->wifiConnected = WiFi.reconnect(); - this->lastWifiRecoonectAttemp = millis(); + this->lastWifiReconnectAttempt = millis(); } } void Network::checkMqtt() { - if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay) + if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttempt > Network::mqttReconnectDelay) { this->mqttConnected = this->connectMqtt(); - this->lastMqttReconnectAttemp = millis(); + this->lastMqttReconnectAttempt = millis(); } if (this->mqttConnected) diff --git a/lib/Network/network.h b/lib/Network/network.h index acd7841..b35d255 100644 --- a/lib/Network/network.h +++ b/lib/Network/network.h @@ -20,10 +20,20 @@ #include #include -typedef void (*recieveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len); +/** + * @brief Typedef to easy handle the receive Callback + */ +typedef void (*receiveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len); + +/** + * @brief Typedef to easy handle the send Callback + */ typedef void (*sendCallbackPtr)(const uint8_t *mac_addr, esp_now_send_status_t status); -struct NetworkAdresses +/** + * @brief A Struct to hold all network addresses + */ +struct NetworkAddresses { IPAddress localIP; IPAddress gateway; @@ -33,17 +43,58 @@ struct NetworkAdresses uint16_t mqttPort = 1883; }; +/** + * @brief A class to manage the wireless connections + */ class Network : public Component { public: + /** + * @brief Construct a new Network object + * + * With this constructor the esp gets its ip from a Dhcp server + * + * @param ssid + * @param passphrase + */ Network(const char *ssid, const char *passphrase); - Network(const char *ssid, const char *passphrase, NetworkAdresses adresses); + + /** + * @brief Construct a new Network object + * + * This constructor is used for a static ip setup + * + * @param ssid + * @param passphrase + * @param addresses + */ + Network(const char *ssid, const char *passphrase, NetworkAddresses addresses); ~Network(); - bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send); + /** + * @brief Activate ESP-NOW to communicate with the remote Control + * + * @param receive + * @param send + * @return true + * @return false + */ + bool activateEspNow(receiveCallbackPtr receive, sendCallbackPtr send); + + /** + * @brief Activate MQTT to send debug messages + * + * @param user + * @param passphrase + * @return true + * @return false + */ bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr); + /** + * @brief Print the current used IPs + */ const void printIPs(); bool isWifiConnected() const { return this->wifiConnected; } @@ -61,11 +112,11 @@ private: void checkMqtt(); bool connectMqtt(); - NetworkAdresses adresses; + NetworkAddresses addresses; WiFiClient wifiClient; PubSubClient *mqttClient = nullptr; - bool initSucessful = false; + bool initSuccessful = false; bool wifiConnected = false; bool mqttConnected = false; @@ -73,8 +124,8 @@ private: const char *mqttPassphrase = nullptr; uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10}; - uint32_t lastWifiRecoonectAttemp = 0; - uint32_t lastMqttReconnectAttemp = 0; + uint32_t lastWifiReconnectAttempt = 0; + uint32_t lastMqttReconnectAttempt = 0; static constexpr uint8_t wifiConnectTimeout = 20; static constexpr uint16_t wifiConnectLoopTime = 500; diff --git a/lib/Point/point.h b/lib/Point/point.h index 3cc4862..b229054 100644 --- a/lib/Point/point.h +++ b/lib/Point/point.h @@ -18,9 +18,9 @@ #define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300 /** - * @brief A to handle points on the earth + * @brief A class to handle points on the earth * - * The points inherits latidue and longitude as doubles + * The points inherits latitude and longitude as doubles * */ class Point @@ -58,11 +58,10 @@ public: /** * @brief Construct a new Point object * - * @param lat latitude - * @param lon longitude - * @param horizontalAccuracy mm - * @param coords Coordinates - * @param imported if true than highest accuracy + * @param lat + * @param lon + * @param horizontalAccuracy + * @param creationTime */ Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); diff --git a/lib/Route/route.h b/lib/Route/route.h index 7b38315..0b86be5 100644 --- a/lib/Route/route.h +++ b/lib/Route/route.h @@ -1,27 +1,28 @@ /** * @file route.h * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the class Point and Route + * @brief Contains the class Route * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef ROUTE_H #define ROUTE_H #include -#include +#include #include "point.h" /** * @brief Holds some route information - * + * */ -struct RouteInfo{ +struct RouteInfo +{ /** * @brief Selected number of Points */ @@ -35,77 +36,76 @@ struct RouteInfo{ /** * @brief A class to manage multiple points - * + * * The list of point presents a route which can be driven */ -class Route { - public: - /** - * @brief Adds a point to the list. - * - * @param point - */ - void addPointToRoute(Point point); +class Route +{ +public: + /** + * @brief Adds a point to the list. + * + * @param point + */ + void addPointToRoute(Point point); - /** - * @brief Delete all points. - * - */ - void clear(); + /** + * @brief Delete all points + */ + void clear(); - /** - * @brief Select the first point as target. - * - * @return Point - */ - Point startRoute(); + /** + * @brief Select the first point as target. + * + * @return Point + */ + Point startRoute(); - /** - * @brief Select the last point as target. - * - * @return Point - */ - Point endRoute(); + /** + * @brief Select the last point as target. + * + * @return Point + */ + Point endRoute(); - /** - * @brief Get the next point and set it as target. - * - * @return Point is zero if there are no more Points. - */ - Point getNextPoint(); + /** + * @brief Get the next point and set it as target. + * + * @return Point is zero if there are no more Points. + */ + Point getNextPoint(); - /** - * @brief Get the previous point and set it as target. - * - * @return Point - */ - Point getPreviousPoint(); + /** + * @brief Get the previous point and set it as target. + * + * @return Point + */ + Point getPreviousPoint(); - /** - * @brief Get the Route Info object - * - * @return RouteInfo - */ - RouteInfo getRouteInfo(); + /** + * @brief Get the Route Info object + * + * @return RouteInfo + */ + RouteInfo getRouteInfo(); - /** - * @brief Get the Started object - * - * The Route will be marked as started when startRoute or - * endRoute has been called. - * - * @return true - * @return false - */ - bool getStarted() const { return this->started; } + /** + * @brief Get the Started object + * + * The Route will be marked as started when startRoute or + * endRoute has been called. + * + * @return true + * @return false + */ + bool getStarted() const { return this->started; } - private: - uint16_t currentPoint = 0; - bool started = false; - - std::list points; - std::list::iterator it; +private: + uint16_t currentPoint = 0; + bool started = false; + std::list points; + std::list::iterator it; }; #endif // ROUTE_H diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index b80c8ac..f5246e8 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -1,5 +1,5 @@ /** - * @file senors.cpp + * @file sensorData.cpp * @author Alexander Klein (alex@kleiax.de) * @brief * @version 0.1 @@ -83,32 +83,32 @@ void SensorData::enableCalcCompass() // TODO: !!! implementieren } -void SensorData::enableGyroskop() +void SensorData::enableGyroscope() { - this->gyroskop = new MPU6050(); - this->gyroskop->initialize(); - if (!this->gyroskop->testConnection()) + this->gyroscope = new MPU6050(); + this->gyroscope->initialize(); + if (!this->gyroscope->testConnection()) { - std::cout << "SensorData::enableGyroskop: Gyroskop is not conntected. Freeze!" << std::endl; + std::cout << "SensorData::enableGyroscope: Gyroskop is not conntected. Freeze!" << std::endl; while (true) { } } - const uint8_t deviceStatus = this->gyroskop->dmpInitialize(); + const uint8_t deviceStatus = this->gyroscope->dmpInitialize(); // TODO: !!! MagicNumer 6x - this->gyroskop->setXGyroOffset(220); - this->gyroskop->setYGyroOffset(76); - this->gyroskop->setZGyroOffset(-85); - this->gyroskop->setZAccelOffset(1788); + this->gyroscope->setXGyroOffset(220); + this->gyroscope->setYGyroOffset(76); + this->gyroscope->setZGyroOffset(-85); + this->gyroscope->setZAccelOffset(1788); if (deviceStatus == 0) { - this->gyroskop->CalibrateAccel(6); - this->gyroskop->CalibrateGyro(6); - this->gyroskop->PrintActiveOffsets(); - this->gyroskop->setDMPEnabled(true); + this->gyroscope->CalibrateAccel(6); + this->gyroscope->CalibrateGyro(6); + this->gyroscope->PrintActiveOffsets(); + this->gyroscope->setDMPEnabled(true); } else { @@ -116,7 +116,7 @@ void SensorData::enableGyroskop() // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) - std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << static_cast(deviceStatus) << "). Freeze!" << std::endl; + std::cout << "SensorData::enableGyroscope: DMP Initialization failed (code" << static_cast(deviceStatus) << "). Freeze!" << std::endl; while (true) { } @@ -236,11 +236,11 @@ void SensorData::run() this->realAzimuth = this->realCompass->getAzimuth(); } - if (static_cast(this->gyroskop) && this->gyroskop->dmpGetCurrentFIFOPacket(static_cast(this->gyroBuffer))) + if (static_cast(this->gyroscope) && this->gyroscope->dmpGetCurrentFIFOPacket(static_cast(this->gyroBuffer))) { - this->gyroskop->dmpGetQuaternion(&this->quaternion, static_cast(this->gyroBuffer)); - this->gyroskop->dmpGetGravity(&this->gravity, &this->quaternion); - this->gyroskop->dmpGetYawPitchRoll(static_cast(this->yawPitchRoll), &this->quaternion, &this->gravity); + this->gyroscope->dmpGetQuaternion(&this->quaternion, static_cast(this->gyroBuffer)); + this->gyroscope->dmpGetGravity(&this->gravity, &this->quaternion); + this->gyroscope->dmpGetYawPitchRoll(static_cast(this->yawPitchRoll), &this->quaternion, &this->gravity); } } diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index 598e42c..7eb69cf 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -1,7 +1,7 @@ /** * @file sensorData.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains the SensorData class * @version 0.1 * @date 2023-09-02 * @@ -26,8 +26,12 @@ #include "ntripClient.h" #include "point.h" -class Sensors; +/** + * @brief A class to manage all sensors + * + * Each sensor have separately to be enabled + */ class SensorData : public Component { public: @@ -35,26 +39,89 @@ public: ~SensorData(); void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); + + /** + * @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(); - void enableGyroskop(); + void enableGyroscope(); - // Interface Const kram + // Interface Const + /** + * @brief Get the azimuth measured by the compass module + * + * @return int16_t + */ int16_t getRealAzimuth() const { return this->realAzimuth; } + + /** + * @brief Get the azimuth calculated by CalcAzimuth + * + * Consider to call getCalcAzimuthState() to check, if the data is valid. + * + * @return int16_t + */ int16_t getCalcAzimuth() const { return this->calcAzimuth; } + + /** + * @brief Get the CalcAzimuth::State object + * + * Needed to check the quality of calculated azimuth + * + * @return CalcAzimuth::State + */ CalcAzimuth::State getCalcAzimuthState() const; Point getCurrentPos() const { return this->currentPosition; } const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; }; NTRIPClientStates getNtripState() const; + + /** + * @brief Get the data from the gyroscope + * + * The returned float pointer is an array of 3 floats + * - Yaw + * - Pitch + * - Roll + * + * @return const float* + */ const float *getGyroData() const { return this->yawPitchRoll; } + /** + * @brief Get the CalcCompass object + * @return CalcAzimuth* + */ CalcAzimuth *getCalcCompass() const { return this->calcCompass; } + + /** + * @brief Get the RealCompass object + * @return QMC5883LCompass* + */ QMC5883LCompass *getRealCompass() const { return this->realCompass; } + + /** + * @brief Get the NTRIPClient object + * @return NTRIPClient* + */ NTRIPClient *getNtripClient() const { return this->ntripClient; } - MPU6050 *getGyroskop() const { return this->gyroskop; } + + /** + * @brief Get the Gyroscope object + * @return MPU6050* + */ + MPU6050 *getGyroscope() const { return this->gyroscope; } // static /** @@ -77,7 +144,7 @@ private: CalcAzimuth *calcCompass = nullptr; SFE_UBLOX_GNSS *gnss = nullptr; NTRIPClient *ntripClient = nullptr; - MPU6050 *gyroskop = nullptr; + MPU6050 *gyroscope = nullptr; UBX_NAV_PVT_data_t *gnssData = nullptr; Point currentPosition; diff --git a/lib/Speedometer/speedometer.h b/lib/Speedometer/speedometer.h index 87ff979..a47f1ff 100644 --- a/lib/Speedometer/speedometer.h +++ b/lib/Speedometer/speedometer.h @@ -48,7 +48,7 @@ public: * * @param pin Pin on the Esp from the encoder. * @param diameter Diameter of the wheel in meters. - * @param steps Encodersteps for a complete wheel rotation. + * @param steps EncoderSteps for a complete wheel rotation. */ Speedometer(uint8_t pin, double diameter, uint16_t steps); @@ -78,12 +78,24 @@ public: Direction getDirection() const { return this->currentDirection; } /** - * @brief Get the calculated speed of the Wheel + * @brief Get the calculated speed of the wheel * * @return double speed in m/s */ double getSpeed() const { return this->speed; } + + /** + * @brief Get the calculated speed of the wheel + * + * @return double speed in rad/s + */ double getSpeedRad() const { return this->rad; }; + + /** + * @brief Get the calculated average speed of the wheel + * + * @return double speed in m/s + */ double getAvgSpeed() const; /** diff --git a/lib/Times/debugTimes.cpp b/lib/Times/debugTimes.cpp index d94e856..82b5d73 100644 --- a/lib/Times/debugTimes.cpp +++ b/lib/Times/debugTimes.cpp @@ -1,7 +1,7 @@ /** * @file debugTimes.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief Implemention of the class debugTimes.h. + * @brief Implementation of the class debugTimes.h. * @version 0.1 * @date 2021-12-13 * @@ -19,7 +19,7 @@ DebugTimes::DebugTimes() if (DebugTimes::printWarning) { std::cout << std::endl - << "Warning: DebugTimes is muuted, no times are be shown." << std::endl + << "Warning: DebugTimes is muted, no times are be shown." << std::endl << std::endl; DebugTimes::printWarning = false; } diff --git a/lib/Times/debugTimes.h b/lib/Times/debugTimes.h index 5327a94..da82965 100644 --- a/lib/Times/debugTimes.h +++ b/lib/Times/debugTimes.h @@ -53,7 +53,7 @@ public: /** * @brief Print the elapsed time to consol * - * @param name Functionname to print + * @param name FunctionName to print * @param minTime A minimum time before printing * * @return uint16_t elapsed milliseconds diff --git a/lib/calibrateCompass/calibrateCompass.h b/lib/calibrateCompass/calibrateCompass.h deleted file mode 100644 index 9fc953c..0000000 --- a/lib/calibrateCompass/calibrateCompass.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file calibrateCompass.h - * @author Alexander Klein (alex@kleiax.de) - * @brief - * @version 0.1 - * @date 2023-05-23 - * - * @copyright Copyright (c) 2023 - * - */ - -#pragma once - -#include -#include -#include - -#include "component.h" - -class CalibrateCompass : public Component -{ -public: - enum State - { - Ready, - Calibrating, - Finished - }; - - struct CallibrationData - { - int data[3][2]; - }; - - CalibrateCompass(QMC5883LCompass *compass); - - void start(); - void useData(); - void removeCalibration(); - void reset(); - void saveData(); - void loadData(); - - State getState() const { return this->state; } - CallibrationData getCallibrationData() const { return this->data; } - - friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp); - -private: - void runAsChild() override; - void run() override; - void checkDataValidity(); - - QMC5883LCompass *compass; - State state = State::Ready; - CallibrationData data{}; - - void clearData(); - - bool dataValid = false; - const uint16_t maxTimeWithoutChange = 10000; - uint32_t lastChange = 0; -}; diff --git a/src/OutputBuf/outputBuf.cpp b/src/OutputBuf/outputBuf.cpp index c33c288..7d4cd83 100644 --- a/src/OutputBuf/outputBuf.cpp +++ b/src/OutputBuf/outputBuf.cpp @@ -1,5 +1,5 @@ /** - * @file outputBufMqtt.cpp + * @file outputBuf.cpp * @author Alexander Klein (alex@kleiax.de) * @brief Contains the implementation of the class OutputBufMqtt * @version 0.1 diff --git a/src/OutputBuf/outputBuf.h b/src/OutputBuf/outputBuf.h index 6b785b4..fa6abb3 100644 --- a/src/OutputBuf/outputBuf.h +++ b/src/OutputBuf/outputBuf.h @@ -1,5 +1,5 @@ /** - * @file outputBufMqtt.h + * @file outputBuf.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains a small class that provide a streambuf * @@ -38,6 +38,7 @@ class OutputBuf : public std::streambuf { * @brief Construct a new Output Buf Mqtt object * * @param debugMqtt + * @param serialBT */ OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr); diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformation.h b/src/SpecialMenus/Systeminformation/menuSysteminformation.h index d0d885a..8b35dc6 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformation.h +++ b/src/SpecialMenus/Systeminformation/menuSysteminformation.h @@ -31,8 +31,7 @@ class MenuSysteminformation : public MenuInformationSites { /** * @brief Construct a new Menu Systeminformation object * - * @param mainBattery - * @param gamepad + * @param mainBattery */ MenuSysteminformation(Battery* mainBattery); diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp index 9715f31..c479fc7 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp @@ -81,23 +81,23 @@ void MenuCalibrateCompass::printPage() const { case 8: lineOne = "X min: "; - lineOne.concat(this->caliCompass->getCallibrationData().data[0][0]); + lineOne.concat(this->caliCompass->getCalibrationData().data[0][0]); lineTwo = "X max: "; - lineTwo.concat(this->caliCompass->getCallibrationData().data[0][1]); + lineTwo.concat(this->caliCompass->getCalibrationData().data[0][1]); break; case 9: lineOne = "Y min: "; - lineOne.concat(this->caliCompass->getCallibrationData().data[1][0]); + lineOne.concat(this->caliCompass->getCalibrationData().data[1][0]); lineTwo = "Y max: "; - lineTwo.concat(this->caliCompass->getCallibrationData().data[1][1]); + lineTwo.concat(this->caliCompass->getCalibrationData().data[1][1]); break; case 10: lineOne = "Z min: "; - lineOne.concat(this->caliCompass->getCallibrationData().data[2][0]); + lineOne.concat(this->caliCompass->getCalibrationData().data[2][0]); lineTwo = "Z max: "; - lineTwo.concat(this->caliCompass->getCallibrationData().data[2][1]); + lineTwo.concat(this->caliCompass->getCalibrationData().data[2][1]); break; default: diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 7f88b5b..72dc8b8 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -164,7 +164,7 @@ void MenuTestMode::init() { auto *lightBlueAction = new MenuAction("Blue", dummy); auto *lightOffAction = new MenuAction("Off", dummy); - // Add entrys to the menus + // Add entries to the menus this->mainMenu->addEntry(engineAction); this->mainMenu->addEntry(drivingAction); this->mainMenu->addEntry(encoderAction); diff --git a/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp b/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp index 8d88049..4481e53 100644 --- a/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp +++ b/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp @@ -1,5 +1,5 @@ /** - * @file menuTest.cpp + * @file speedometerTest.cpp * @author Alexander Klein (alex@kleiax.de) * @brief Contains the implementation of the class SpeedometerTest. * @version 0.1 diff --git a/src/SpecialMenus/driveModi/TestMode/speedometerTest.h b/src/SpecialMenus/driveModi/TestMode/speedometerTest.h index 609e474..3990403 100644 --- a/src/SpecialMenus/driveModi/TestMode/speedometerTest.h +++ b/src/SpecialMenus/driveModi/TestMode/speedometerTest.h @@ -1,5 +1,5 @@ /** - * @file menuTest.h + * @file speedometerTest.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains a class to test the wheel encoder. * @version 0.1 diff --git a/src/driveModi/driveManager.h b/src/driveModi/driveManager.h index 8c7f5f9..1050a34 100644 --- a/src/driveModi/driveManager.h +++ b/src/driveModi/driveManager.h @@ -22,14 +22,21 @@ class DriveManager : public Component { public: + /** * @brief Construct a new Drive Manager object * - * Creates a Navigation object - * * @param moveControl + * @param sensorData + * @param input */ DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input); + + /** + * @brief Construct a new Drive Manager object + * + * @param params + */ DriveManager(DriveModiParams params); /** diff --git a/src/main.cpp b/src/main.cpp index 3431a27..9c3134f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,7 +70,7 @@ void restart(); void receiveCallback(const uint8_t *mac, const uint8_t *incomingData, int len); void sendCallback(const uint8_t *mac_addr, esp_now_send_status_t status); void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows); -NetworkAdresses setIPs(); +NetworkAddresses setIPs(); void setup() { @@ -130,7 +130,7 @@ void setup() static_cast(NtripConfig::mountPoint), static_cast(NtripConfig::user), static_cast(NtripConfig::password)); - // sensorData->enableGyroskop(); + // sensorData->enableGyroscope(); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); char wifiIndicator = 'X'; @@ -355,9 +355,9 @@ void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, } } -NetworkAdresses setIPs() +NetworkAddresses setIPs() { - NetworkAdresses adresses; + NetworkAddresses adresses; adresses.localIP.fromString(static_cast(NetworkConfig::ip)); adresses.subnet.fromString(static_cast(NetworkConfig::subnet)); adresses.gateway.fromString(static_cast(NetworkConfig::gateway)); From 5eaeb2749bd49fabb639e6e09f9b01d20edb7c80 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 19:50:10 +0200 Subject: [PATCH 25/26] doxygen finished --- .vscode/settings.json | 1 + doc/TODO allgemein.txt | 2 + .../controlPad.cpp | 0 lib/{ControllPad => ControlPad}/controlPad.h | 0 .../controlPadInput.h | 0 src/OutputBuf/outputBuf.h | 100 ++++---- .../CalibrateBattery/menuCalibrateBattery.h | 16 +- src/SpecialMenus/PID/menuPidSettings.h | 30 +-- src/SpecialMenus/Route/menuRoute.h | 7 + src/SpecialMenus/Route/menuRoutePoints.h | 50 ++-- src/SpecialMenus/SensorData/menuSensorData.h | 29 ++- src/SpecialMenus/Speed/menuSpeed.cpp | 12 +- src/SpecialMenus/Speed/menuSpeed.h | 29 ++- .../menuSysteminformatio.cpp | 94 +++---- .../Systeminformation/menuSysteminformation.h | 29 ++- .../driveModi/Autopilot/menuAutopilot.h | 68 ++--- .../CalibrateCompass/menuCalibrateCompass.cpp | 240 +++++++++--------- .../CalibrateCompass/menuCalibrateCompass.h | 56 ++-- .../driveModi/CaptureRoute/menuCaptureRoute.h | 62 ++--- .../driveModi/ManualDrive/menuManualDrive.cpp | 91 ++++--- .../driveModi/ManualDrive/menuManualDrive.h | 54 ++-- .../driveModi/TestMode/menuTestMode.cpp | 155 ++++++----- .../driveModi/TestMode/menuTestMode.h | 126 ++++----- .../driveModi/TestMode/speedometerTest.cpp | 98 +++---- .../driveModi/TestMode/speedometerTest.h | 80 +++--- src/SpecialMenus/driveModi/menuDriveMode.cpp | 110 +++++--- src/SpecialMenus/driveModi/menuDriveMode.h | 107 +++++--- src/driveModi/Modi/Autopilot/autopilot.h | 178 ++++++------- .../CalibrateCompass/calibrateCompassM.cpp | 17 +- .../Modi/CalibrateCompass/calibrateCompassM.h | 27 +- .../Modi/CaptureRoute/captureRoute.h | 90 ++++--- .../Modi/ManualControl/manualControl.h | 73 ++++-- src/driveModi/Modi/TestMode/testMode.cpp | 36 ++- src/driveModi/Modi/TestMode/testMode.h | 10 +- src/driveModi/driveManager.h | 99 ++++---- src/driveModi/driveModi.cpp | 12 +- src/driveModi/driveModi.h | 72 ++++-- src/main.cpp | 18 +- src/moveControl.cpp | 24 +- 39 files changed, 1283 insertions(+), 1019 deletions(-) rename lib/{ControllPad => ControlPad}/controlPad.cpp (100%) rename lib/{ControllPad => ControlPad}/controlPad.h (100%) rename lib/{ControllPad => ControlPad}/controlPadInput.h (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json index fa5cb03..d055b55 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -152,6 +152,7 @@ "Rtcm", "Schalke", "Soln", + "Systeminformation", "TPMOBIL", "UBLOX", "wheelspeed", diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 6d6bbdb..98bf03d 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -30,12 +30,14 @@ Do later: -> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz -> Doxygen comments - navigation + - autopilot Do now: Code: Doxygen Kommentare aktualisieren Fernbedienung! + Compass calibration überprüfen Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung diff --git a/lib/ControllPad/controlPad.cpp b/lib/ControlPad/controlPad.cpp similarity index 100% rename from lib/ControllPad/controlPad.cpp rename to lib/ControlPad/controlPad.cpp diff --git a/lib/ControllPad/controlPad.h b/lib/ControlPad/controlPad.h similarity index 100% rename from lib/ControllPad/controlPad.h rename to lib/ControlPad/controlPad.h diff --git a/lib/ControllPad/controlPadInput.h b/lib/ControlPad/controlPadInput.h similarity index 100% rename from lib/ControllPad/controlPadInput.h rename to lib/ControlPad/controlPadInput.h diff --git a/src/OutputBuf/outputBuf.h b/src/OutputBuf/outputBuf.h index fa6abb3..f75cfe2 100644 --- a/src/OutputBuf/outputBuf.h +++ b/src/OutputBuf/outputBuf.h @@ -2,15 +2,15 @@ * @file outputBuf.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains a small class that provide a streambuf - * + * * The streambuf is used to double the std::cout to consol * and MQTT. - * + * * @version 0.1 * @date 2022-02-14 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef OUTPUT_STREAM_MQTT_H @@ -26,61 +26,61 @@ #include /** - * @brief A alternativ streambuf for std::cout - * + * @brief A alternative streambuf for std::cout + * * The streambuf is used to double the std::cout to consol * and MQTT. - * + * */ -class OutputBuf : public std::streambuf { - public: - /** - * @brief Construct a new Output Buf Mqtt object - * - * @param debugMqtt - * @param serialBT - */ - OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr); +class OutputBuf : public std::streambuf +{ +public: + /** + * @brief Construct a new Output Buf Mqtt object + * + * @param debugMqtt + * @param serialBT + */ + OutputBuf(DebugMqtt *debugMqtt = nullptr, BluetoothSerial *serialBT = nullptr); - /** - * @brief Activate the mqtt output - * - * This only works if the DebugMqtt is set by - * setDebugMqtt. - * - * @param status - */ - void activateMqtt(bool status); + /** + * @brief Activate the mqtt output + * + * This only works if the DebugMqtt is set by + * setDebugMqtt(). + * + * @param status + */ + void activateMqtt(bool status); - /** - * @brief Active the output over the bluetooth serial consol - * - * This only works if BluetoothSerial is set by - * setSerialBT. - * - * @param status - */ - void activateSerialBT(bool status); + /** + * @brief Active the output over the bluetooth serial consol + * + * This only works if BluetoothSerial is set by + * setSerialBT(). + * + * @param status + */ + void activateSerialBT(bool status); - void setDebugMqtt(DebugMqtt* debugMqtt); - void setSerialBT(BluetoothSerial* serialBT); + void setDebugMqtt(DebugMqtt *debugMqtt); + void setSerialBT(BluetoothSerial *serialBT); +protected: + /** + * @brief + * + * @param c + * @return std::streambuf::int_type + */ + virtual std::streambuf::int_type overflow(std::streambuf::int_type c); - protected: - /** - * @brief - * - * @param c - * @return std::streambuf::int_type - */ - virtual std::streambuf::int_type overflow(std::streambuf::int_type c); +private: + bool isMqttActive = false; + bool isSerialBTActive = false; - private: - bool isMqttActive = false; - bool isSerialBTActive = false; - - DebugMqtt* debugMqtt; - BluetoothSerial* serialBT; + DebugMqtt *debugMqtt; + BluetoothSerial *serialBT; }; #endif // OUTPUT_STREAM_MQTT_H diff --git a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h index 28ca45d..50b45eb 100644 --- a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h +++ b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h @@ -1,7 +1,7 @@ /** * @file menuCalibrateBattery.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a Menu class to calibrate the Battery class * @version 0.1 * @date 2023-09-26 * @@ -15,13 +15,27 @@ #include "menuControl.h" #include "battery.h" +/** + * @brief A Menu class to calibrate the Battery class + */ class MenuCalibrateBattery : public MenuControl { public: + /** + * @brief Construct a new MenuCalibrateBattery object + * + * Prepare the calibration. + * + * @param battery + */ MenuCalibrateBattery(Battery *battery); + /** + * @brief Prints the instructions for the calibration + */ void printMenu() override; + // User Inputs void left() override; void no() override { this->left(); } void right() override; diff --git a/src/SpecialMenus/PID/menuPidSettings.h b/src/SpecialMenus/PID/menuPidSettings.h index b8fbb44..cc9f877 100644 --- a/src/SpecialMenus/PID/menuPidSettings.h +++ b/src/SpecialMenus/PID/menuPidSettings.h @@ -4,9 +4,9 @@ * @brief Contains a class to tune the PID settings * @version 0.1 * @date 2022-01-19 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef PID_SETTINGS_H @@ -18,22 +18,22 @@ /** * @brief A class to tune the PID settings - * + * */ -class MenuPidSettings : public MenuIntInputWrapper { - public: - /** - * @brief Construct a new Menu Pid Settings object - * - * @param pid - */ - MenuPidSettings(PID* pid); +class MenuPidSettings : public MenuIntInputWrapper +{ +public: + /** + * @brief Construct a new Menu Pid Settings object + * + * @param pid + */ + MenuPidSettings(PID *pid); - void action(int16_t* values, uint8_t length) override; - - private: - PID* pid; + void action(int16_t *values, uint8_t length) override; +private: + PID *pid; }; #endif // PID_SETTINGS_H diff --git a/src/SpecialMenus/Route/menuRoute.h b/src/SpecialMenus/Route/menuRoute.h index 7d6072f..b65ee37 100644 --- a/src/SpecialMenus/Route/menuRoute.h +++ b/src/SpecialMenus/Route/menuRoute.h @@ -111,6 +111,13 @@ public: */ void exportRoute(uint8_t routeNumber); + /** + * @brief Delete a Route + * + * The functions tries to delete the current route from the RoverApi. + * + * @param routeNumber + */ void deleteRoute(uint8_t routeNumber); /** diff --git a/src/SpecialMenus/Route/menuRoutePoints.h b/src/SpecialMenus/Route/menuRoutePoints.h index 58b60c7..382dbce 100644 --- a/src/SpecialMenus/Route/menuRoutePoints.h +++ b/src/SpecialMenus/Route/menuRoutePoints.h @@ -4,9 +4,9 @@ * @brief Contains a class to print the coordinates of a Route. * @version 0.1 * @date 2022-12-28 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_ROUTE_POINTS_H @@ -18,33 +18,33 @@ /** * @brief Prints coordinates of Route side by side. - * + * */ -class MenuRoutePoints : public MenuInformationSites { - public: - /** - * @brief Construct a new Menu Route Points object - * - * @param route - */ - MenuRoutePoints(Route *route); +class MenuRoutePoints : public MenuInformationSites +{ +public: + /** + * @brief Construct a new Menu Route Points object + * + * @param route + */ + MenuRoutePoints(Route *route); - /** - * @brief Configure the base class MenuInformationSites - * - * Set the amount of pages. - */ - void init () override; + /** + * @brief Configure the base class MenuInformationSites + * + * Set the amount of pages. + */ + void init() override; - /** - * @brief Prints the the coordinates of the current Point. - */ - void printPage() const override; - - private: - Route* route; - bool error = false; + /** + * @brief Prints the the coordinates of the current Point. + */ + void printPage() const override; +private: + Route *route; + bool error = false; }; #endif // MENU_ROUTE_POINTS_H diff --git a/src/SpecialMenus/SensorData/menuSensorData.h b/src/SpecialMenus/SensorData/menuSensorData.h index 9f0883b..83d820b 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.h +++ b/src/SpecialMenus/SensorData/menuSensorData.h @@ -1,12 +1,12 @@ /** * @file menuSensorData.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a MenuInformationClass to print the SensorData * @version 0.1 * @date 2023-09-04 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef MENU_SENSOR_DATA_H @@ -15,14 +15,23 @@ #include "menuInformationSites.h" #include "sensorData.h" -class MenuSensorData : public MenuInformationSites { - public: - MenuSensorData(SensorData* SensorData); +/** + * @brief A MenuInformationClass to print the SensorData + */ +class MenuSensorData : public MenuInformationSites +{ +public: + /** + * @brief Construct a new MenuSensorData object + * + * @param SensorData + */ + MenuSensorData(SensorData *SensorData); - private: - void printPage() const override; +private: + void printPage() const override; - SensorData* sensorData; + SensorData *sensorData; }; -#endif //MENU_SENSOR_DATA_H +#endif // MENU_SENSOR_DATA_H diff --git a/src/SpecialMenus/Speed/menuSpeed.cpp b/src/SpecialMenus/Speed/menuSpeed.cpp index dcb26d6..6f4b170 100644 --- a/src/SpecialMenus/Speed/menuSpeed.cpp +++ b/src/SpecialMenus/Speed/menuSpeed.cpp @@ -1,18 +1,20 @@ /** * @file menuSpeed.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-26 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "menuSpeed.h" -void MenuSpeed::action(int16_t* values, uint8_t length) { - if (length != 2) { +void MenuSpeed::action(int16_t *values, uint8_t length) +{ + if (length != 2) + { return; } this->speeds.x = values[0] / 10.0; diff --git a/src/SpecialMenus/Speed/menuSpeed.h b/src/SpecialMenus/Speed/menuSpeed.h index 2bdf127..419cf91 100644 --- a/src/SpecialMenus/Speed/menuSpeed.h +++ b/src/SpecialMenus/Speed/menuSpeed.h @@ -1,12 +1,12 @@ /** * @file menuSpeed.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a MenuIntInputWrapper to change speeds * @version 0.1 * @date 2023-09-26 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef MENU_SPEED_H @@ -15,15 +15,24 @@ #include #include "moveControl.h" -class MenuSpeed : public MenuIntInputWrapper { - public: - MenuSpeed(DrivingSpeeds& speeds) : speeds(speeds){}; +/** + * @brief A MenuIntInputWrapper class to change speeds + */ +class MenuSpeed : public MenuIntInputWrapper +{ +public: + MenuSpeed(DrivingSpeeds &speeds) : speeds(speeds){}; - void action(int16_t* values, uint8_t length) override; - - private: - DrivingSpeeds& speeds; + /** + * @brief Changes the speeds + * + * @param values + * @param length + */ + void action(int16_t *values, uint8_t length) override; +private: + DrivingSpeeds &speeds; }; #endif // MENU_SPEED_H diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp index bbad40c..a145123 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp +++ b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp @@ -4,71 +4,73 @@ * @brief Contains an implementation of the class MenuSysteminformation * @version 0.1 * @date 2022-12-27 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuSysteminformation.h" -MenuSysteminformation::MenuSysteminformation(Battery* mainBattery) - : MenuInformationSites(8), mainBattery {mainBattery} { +MenuSysteminformation::MenuSysteminformation(Battery *mainBattery) + : MenuInformationSites(8), mainBattery{mainBattery} +{ this->noEqualLeft = true; } -void MenuSysteminformation::printPage() const { +void MenuSysteminformation::printPage() const +{ String lineOne = ""; String lineTwo = ""; - switch (this->getCurrentPage()) { - case 0: - lineOne = "Free Heap:"; - lineTwo.concat(ESP.getFreeHeap()); - break; + switch (this->getCurrentPage()) + { + case 0: + lineOne = "Free Heap:"; + lineTwo.concat(ESP.getFreeHeap()); + break; - case 1: - lineOne = "Max alloc Heap:"; - lineTwo.concat(ESP.getMaxAllocHeap()); - break; + case 1: + lineOne = "Max alloc Heap:"; + lineTwo.concat(ESP.getMaxAllocHeap()); + break; - case 2: - lineOne = "Uptime in secs:"; - lineTwo.concat((millis() / 1000)); - break; + case 2: + lineOne = "Uptime in secs:"; + lineTwo.concat((millis() / 1000)); + break; - case 3: - lineOne = "Main battery:"; - lineTwo = ""; - lineTwo.concat(this->mainBattery->getBatteryPercent()); - lineTwo.concat("% - V="); - lineTwo.concat(this->mainBattery->getBatteryVoltage()); - break; + case 3: + lineOne = "Main battery:"; + lineTwo = ""; + lineTwo.concat(this->mainBattery->getBatteryPercent()); + lineTwo.concat("% - V="); + lineTwo.concat(this->mainBattery->getBatteryVoltage()); + break; - case 4: - lineOne = "Current WiFi"; - lineTwo = "channel: "; - lineTwo.concat(Network::getCurrentChannel()); - break; + case 4: + lineOne = "Current WiFi"; + lineTwo = "channel: "; + lineTwo.concat(Network::getCurrentChannel()); + break; - case 5: - lineOne = "Software verion:"; - lineTwo = VERSION; - break; + case 5: + lineOne = "Software verion:"; + lineTwo = VERSION; + break; - case 6: - lineOne = "Build timestamp:"; - lineTwo = String(BUILD_TIMESTAMP).substring(0, 16); - break; + case 6: + lineOne = "Build timestamp:"; + lineTwo = String(BUILD_TIMESTAMP).substring(0, 16); + break; - case 7: - lineOne = "Kleiax Rover by"; - lineTwo = "Alexander Klein"; - break; + case 7: + lineOne = "Kleiax Rover by"; + lineTwo = "Alexander Klein"; + break; - default: - this->printDefault(); - return; + default: + this->printDefault(); + return; } this->print(lineOne, lineTwo); } - diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformation.h b/src/SpecialMenus/Systeminformation/menuSysteminformation.h index 8b35dc6..754596f 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformation.h +++ b/src/SpecialMenus/Systeminformation/menuSysteminformation.h @@ -4,9 +4,9 @@ * @brief Contains a class to print informations about the system * @version 0.1 * @date 2022-12-27 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_SYSTEMINFORMATION_H @@ -23,22 +23,23 @@ /** * @brief Prints information about the current system status. - * + * * The informations are about the batteries, memory and uptime. */ -class MenuSysteminformation : public MenuInformationSites { - public: - /** - * @brief Construct a new Menu Systeminformation object - * - * @param mainBattery - */ - MenuSysteminformation(Battery* mainBattery); +class MenuSysteminformation : public MenuInformationSites +{ +public: + /** + * @brief Construct a new Menu Systeminformation object + * + * @param mainBattery + */ + MenuSysteminformation(Battery *mainBattery); - private: - void printPage() const override; +private: + void printPage() const override; - Battery* mainBattery; + Battery *mainBattery; }; #endif // MENU_SYSTEMINFORMATION_H diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h index 206ffab..48c94c9 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h @@ -4,9 +4,9 @@ * @brief Contains a class to print informations about the Autopilot * @version 0.1 * @date 2022-02-03 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_AUTOPILOT_DRIVE_H @@ -17,44 +17,44 @@ /** * @brief A class to print informations about the Autopilot - * + * */ -class MenuAutopilot : public MenuDriveMode { - public: - /** - * @brief Construct a new Menu Autopilot object - * - * @param driveManager for MenuDriveMode - */ - MenuAutopilot(DriveManager* driveManager) : MenuDriveMode(driveManager) {} +class MenuAutopilot : public MenuDriveMode +{ +public: + /** + * @brief Construct a new Menu Autopilot object + * + * @param driveManager for MenuDriveMode + */ + MenuAutopilot(DriveManager *driveManager) : MenuDriveMode(driveManager) {} - /** - * @brief Prints the Information to display and console - * - * The informations are only printed to the display if it - * set. - * - * Changes the DriveModi to Autopilot if it is the first time called - * and save the Autopilot object. - */ - void printPage() const override; - + /** + * @brief Prints the Information to display and console + * + * The informations are only printed to the display if it + * set. + * + * Changes the DriveModi to Autopilot if it is the first time called + * and save the Autopilot object. + */ + void printPage() const override; - /** - * @brief can be called to update shown data - */ - void update() override; + /** + * @brief can be called to update shown data + */ + void update() override; - private: - void init() override; - void runCommand() override; - void runCommandNo() override; +private: + void init() override; + void runCommand() override; + void runCommandNo() override; - bool mutable targetFreezed = false; - double mutable minDistance; + bool mutable targetFreezed = false; + double mutable minDistance; - Autopilot* autopilot; - RouteInfo routeInfo; + Autopilot *autopilot; + RouteInfo routeInfo; }; #endif // MENU_AUTOPILOT_DRIVE_H diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp index c479fc7..83950a6 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp @@ -4,159 +4,167 @@ * @brief Contains an implementation of the class MenuManualDrive * @version 0.1 * @date 2022-01-20 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuCalibrateCompass.h" -MenuCalibrateCompass::MenuCalibrateCompass(DriveManager* driveManager) : MenuDriveMode(driveManager) {} +MenuCalibrateCompass::MenuCalibrateCompass(DriveManager *driveManager) : MenuDriveMode(driveManager) {} -MenuCalibrateCompass::~MenuCalibrateCompass() { +MenuCalibrateCompass::~MenuCalibrateCompass() +{ delete this->caliCompass; this->caliCompassMode->setCalibrateCompass(); } -void MenuCalibrateCompass::printPage() const { +void MenuCalibrateCompass::printPage() const +{ String lineOne = ""; String lineTwo = ""; - switch (this->getCurrentPage()) { - case 0: - lineOne = "-Ready to drive-"; - lineTwo = "Compass Mode"; + switch (this->getCurrentPage()) + { + case 0: + lineOne = "-Ready to drive-"; + lineTwo = "Compass Mode"; + break; + + case 1: + lineOne = "Azimuth:"; + lineTwo.concat(this->caliCompassMode->getSensorData()->getRealAzimuth()); + break; + + case 2: + switch (this->caliCompass->getState()) + { + case CalibrateCompass::State::Ready: + lineOne = "Start compass"; + lineTwo = "calibration"; break; - case 1: - lineOne = "Azimuth:"; - lineTwo.concat(this->caliCompassMode->getSensorData()->getRealAzimuth()); - break; - - case 2: - switch (this->caliCompass->getState()) { - case CalibrateCompass::State::Ready : - lineOne = "Start compass"; - lineTwo = "calibration"; - break; - - case CalibrateCompass::State::Calibrating : - lineOne = "Calibrating..."; - lineTwo = "Move around"; - break; - - case CalibrateCompass::State::Finished: - lineOne = "Calibration"; - lineTwo = "finished"; - break; - - default: - break; - } + case CalibrateCompass::State::Calibrating: + lineOne = "Calibrating..."; + lineTwo = "Move around"; break; - case 3: - lineOne = "Save compass"; - lineTwo = "data in flash"; - break; - - case 4: - lineOne = "Load data"; - lineTwo = "from flash"; - break; - - case 5: - lineOne = "Remove"; - lineTwo = "calibration data"; - break; - - case 6: - lineOne = "Use current"; - lineTwo = "calibration data"; - break; - - case 7: - lineOne = "Reset for new"; - lineTwo = "calibration run"; - break; - - case 8: - lineOne = "X min: "; - lineOne.concat(this->caliCompass->getCalibrationData().data[0][0]); - lineTwo = "X max: "; - lineTwo.concat(this->caliCompass->getCalibrationData().data[0][1]); - break; - - case 9: - lineOne = "Y min: "; - lineOne.concat(this->caliCompass->getCalibrationData().data[1][0]); - lineTwo = "Y max: "; - lineTwo.concat(this->caliCompass->getCalibrationData().data[1][1]); - break; - - case 10: - lineOne = "Z min: "; - lineOne.concat(this->caliCompass->getCalibrationData().data[2][0]); - lineTwo = "Z max: "; - lineTwo.concat(this->caliCompass->getCalibrationData().data[2][1]); + case CalibrateCompass::State::Finished: + lineOne = "Calibration"; + lineTwo = "finished"; break; default: - this->printDefault(); + break; + } + break; + + case 3: + lineOne = "Save compass"; + lineTwo = "data in flash"; + break; + + case 4: + lineOne = "Load data"; + lineTwo = "from flash"; + break; + + case 5: + lineOne = "Remove"; + lineTwo = "calibration data"; + break; + + case 6: + lineOne = "Use current"; + lineTwo = "calibration data"; + break; + + case 7: + lineOne = "Reset for new"; + lineTwo = "calibration run"; + break; + + case 8: + lineOne = "X min: "; + lineOne.concat(this->caliCompass->getCalibrationData().data[0][0]); + lineTwo = "X max: "; + lineTwo.concat(this->caliCompass->getCalibrationData().data[0][1]); + break; + + case 9: + lineOne = "Y min: "; + lineOne.concat(this->caliCompass->getCalibrationData().data[1][0]); + lineTwo = "Y max: "; + lineTwo.concat(this->caliCompass->getCalibrationData().data[1][1]); + break; + + case 10: + lineOne = "Z min: "; + lineOne.concat(this->caliCompass->getCalibrationData().data[2][0]); + lineTwo = "Z max: "; + lineTwo.concat(this->caliCompass->getCalibrationData().data[2][1]); + break; + + default: + this->printDefault(); return; } this->print(lineOne, lineTwo); } -void MenuCalibrateCompass::init() { +void MenuCalibrateCompass::init() +{ this->firstPrint = false; this->caliCompassMode = new CalibrateCompassM(); this->driveManager->changeModus(this->caliCompassMode); this->caliCompass = new CalibrateCompass(this->caliCompassMode->getSensorData()->getRealCompass()); this->setCountPages(11); - MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay; + MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay; } -void MenuCalibrateCompass::runCommand() { - switch (this->getCurrentPage()) { - case 2: - switch (this->caliCompass->getState()) { - case CalibrateCompass::State::Ready : - this->caliCompassMode->setCalibrateCompass(this->caliCompass); - this->caliCompass->start(); - break; - - case CalibrateCompass::State::Finished: - this->caliCompassMode->setCalibrateCompass(); - this->caliCompass->useData(); - break; - - default: - break; - } +void MenuCalibrateCompass::runCommand() +{ + switch (this->getCurrentPage()) + { + case 2: + switch (this->caliCompass->getState()) + { + case CalibrateCompass::State::Ready: + this->caliCompassMode->setCalibrateCompass(this->caliCompass); + this->caliCompass->start(); break; - case 3: - this->caliCompass->saveData(); - break; - - case 4: - this->caliCompass->loadData(); - break; - - case 5: - this->caliCompass->removeCalibration(); - break; - - case 6: + case CalibrateCompass::State::Finished: + this->caliCompassMode->setCalibrateCompass(); this->caliCompass->useData(); - break; + break; - case 7: - this->caliCompass->reset(); - break; - default: break; + } + break; + + case 3: + this->caliCompass->saveData(); + break; + + case 4: + this->caliCompass->loadData(); + break; + + case 5: + this->caliCompass->removeCalibration(); + break; + + case 6: + this->caliCompass->useData(); + break; + + case 7: + this->caliCompass->reset(); + break; + + default: + break; } } diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h index 91d54bc..fd57f64 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h @@ -4,9 +4,9 @@ * @brief Contains a class to print information about the class ManualControl * @version 0.1 * @date 2022-01-20 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_CALIBRATE_COMPASS_H @@ -18,37 +18,37 @@ /** * @brief A class to print informations about the class ManualControl - * + * */ -class MenuCalibrateCompass : public MenuDriveMode { - public: - /** - * @brief Construct a new Menu Manual Control object - * - * @param driveManager - */ - MenuCalibrateCompass(DriveManager* driveManager); - ~MenuCalibrateCompass(); +class MenuCalibrateCompass : public MenuDriveMode +{ +public: + /** + * @brief Construct a new Menu Manual Control object + * + * @param driveManager + */ + MenuCalibrateCompass(DriveManager *driveManager); + ~MenuCalibrateCompass(); - /** - * @brief Prints the Information to display and console - * - * The informations are only printed to the display if it - * set. - * - * Changes the DriveModi to Autopilot if it is the first time called. - */ - void printPage() const override; + /** + * @brief Prints the Information to display and console + * + * The informations are only printed to the display if it + * set. + * + * Changes the DriveModi to Autopilot if it is the first time called. + */ + void printPage() const override; - protected: - void init() override; - void runCommand() override; +private: + void init() override; + void runCommand() override; - private: - CalibrateCompassM* caliCompassMode = nullptr; - CalibrateCompass* caliCompass = nullptr; + CalibrateCompassM *caliCompassMode = nullptr; + CalibrateCompass *caliCompass = nullptr; - static constexpr uint16_t updateDelay = 500; + static constexpr uint16_t updateDelay = 500; }; #endif // MENU_CALIBRATE_COMPASS_H diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h index d4505ce..679844f 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h @@ -4,9 +4,9 @@ * @brief Contains a class to print informations about CaptureRoute * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_CAPTURE_ROUTE_H #define MENU_MANUAL_DRIVE_H @@ -16,41 +16,41 @@ /** * @brief A class to print informations about the Autopilot - * + * */ -class MenuCaptureRoute : public MenuDriveMode { - public: - /** - * @brief Construct a new Menu Capture Route object - * - * @param driveManager - */ - MenuCaptureRoute(DriveManager* driveManager) : MenuDriveMode(driveManager) {} +class MenuCaptureRoute : public MenuDriveMode +{ +public: + /** + * @brief Construct a new Menu Capture Route object + * + * @param driveManager + */ + MenuCaptureRoute(DriveManager *driveManager) : MenuDriveMode(driveManager) {} - /** - * @brief Prints the Information to display and console - * - * The informations are only printed to the display if it - * set. - * - * Changes the DriveModi to CaptureRoute if it is the first time called - * and save the CaptureRoute object. - */ - void printPage() const override; + /** + * @brief Prints the Information to display and console + * + * The informations are only printed to the display if it + * set. + * + * Changes the DriveModi to CaptureRoute if it is the first time called + * and save the CaptureRoute object. + */ + void printPage() const override; - /** - * @brief can be called to update shown data - */ - void update() override; + /** + * @brief can be called to update shown data + */ + void update() override; - void runCommand() override; +private: + void runCommand() override; + void init() override; - private: - void init() override; + CaptureRoute *captureRoute = nullptr; - CaptureRoute* captureRoute = nullptr; - - static constexpr uint16_t updateDelay = 500; + static constexpr uint16_t updateDelay = 500; }; #endif // MENU_MANUAL_DRIVE_H diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index 8a5d1b9..9ef590e 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -4,77 +4,84 @@ * @brief Contains an implementation of the class MenuManualDrive * @version 0.1 * @date 2022-01-20 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuManualDrive.h" -MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) { +MenuManualControl::MenuManualControl(DriveManager *driveManager) : MenuDriveMode(driveManager) +{ this->noEqualLeft = true; } - -void MenuManualControl::printPage() const { +void MenuManualControl::printPage() const +{ String lineOne = ""; String lineTwo = ""; - switch (this->getCurrentPage()) { - case 0: - lineOne = "-Ready to drive-"; - break; + switch (this->getCurrentPage()) + { + case 0: + lineOne = "-Ready to drive-"; + break; - case 1: - lineOne = "Input mode:"; - if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) { - lineTwo = "Analog"; - } - else { - lineTwo = "Digital"; - } - break; + case 1: + lineOne = "Input mode:"; + if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) + { + lineTwo = "Analog"; + } + else + { + lineTwo = "Digital"; + } + break; - case 2: - lineOne = "Speed Menu"; - break; + case 2: + lineOne = "Speed Menu"; + break; - case 3: - lineOne = "Sensor Menu"; - break; + case 3: + lineOne = "Sensor Menu"; + break; - default: - this->printDefault(); + default: + this->printDefault(); return; } this->print(lineOne, lineTwo); } -void MenuManualControl::init() { +void MenuManualControl::init() +{ this->firstPrint = false; this->manualControl = new ManualControl(); this->driveManager->changeModus(this->manualControl); this->setCountPages(4); - MenuDriveMode::updateDelay = MenuManualControl::updateDelay; + MenuDriveMode::updateDelay = MenuManualControl::updateDelay; this->activateSpeedMenu(); MenuDriveMode::init(); } -void MenuManualControl::runCommand() { - switch (this->getCurrentPage()) { - case 1: - this->manualControl->switchInputMode(); - break; +void MenuManualControl::runCommand() +{ + switch (this->getCurrentPage()) + { + case 1: + this->manualControl->switchInputMode(); + break; - case 2: - this->enterSpeedMenu(); - break; + case 2: + this->enterSpeedMenu(); + break; - case 3: - this->enterSensorMenu(); - break; - - default: - break; + case 3: + this->enterSensorMenu(); + break; + + default: + break; } } diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h index ee5eb0f..f405a00 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h @@ -4,9 +4,9 @@ * @brief Contains a class to print information about the class ManualControl * @version 0.1 * @date 2022-01-20 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_MANUAL_DRIVE_H @@ -17,36 +17,36 @@ /** * @brief A class to print informations about the class ManualControl - * + * */ -class MenuManualControl : public MenuDriveMode { - public: - /** - * @brief Construct a new Menu Manual Control object - * - * @param driveManager - */ - MenuManualControl(DriveManager* driveManager); +class MenuManualControl : public MenuDriveMode +{ +public: + /** + * @brief Construct a new Menu Manual Control object + * + * @param driveManager + */ + MenuManualControl(DriveManager *driveManager); - /** - * @brief Prints the Information to display and console - * - * The informations are only printed to the display if it - * set. - * - * Changes the DriveModi to Autopilot if it is the first time called. - */ - void printPage() const override; + /** + * @brief Prints the Information to display and console + * + * The informations are only printed to the display if it + * set. + * + * Changes the DriveModi to Autopilot if it is the first time called. + */ + void printPage() const override; - protected: - void init() override; - void runCommand() override; +private: + void init() override; + void runCommand() override; - private: - ManualControl* manualControl = nullptr; - CalibrateCompass* caliCompass = nullptr; + ManualControl *manualControl = nullptr; + CalibrateCompass *caliCompass = nullptr; - static constexpr uint16_t updateDelay = 500; + static constexpr uint16_t updateDelay = 500; }; #endif // MENU_MANUAL_DRIVE_H diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 72dc8b8..aafcca5 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -4,25 +4,29 @@ * @brief Contains the implementation of the class MenuTestMode. * @version 0.1 * @date 2022-09-08 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuTestMode.h" -MenuTestMode::MenuTestMode(DriveManager* driveManager) - : driveManager {driveManager} -{ +MenuTestMode::MenuTestMode(DriveManager *driveManager) + : driveManager{driveManager} +{ } -MenuTestMode::~MenuTestMode() { - if (isInit) { +MenuTestMode::~MenuTestMode() +{ + if (isInit) + { delete this->mainMenu; } } -void MenuTestMode::printMenu() { - if (!this->isInit) { +void MenuTestMode::printMenu() +{ + if (!this->isInit) + { this->isInit = true; this->init(); } @@ -30,62 +34,82 @@ void MenuTestMode::printMenu() { this->mainMenu->printMenu(); } -void MenuTestMode::down() { - if (this->checkInput()) { +void MenuTestMode::down() +{ + if (this->checkInput()) + { this->mainMenu->down(); } } -void MenuTestMode::up() { - if (this->checkInput()) { +void MenuTestMode::up() +{ + if (this->checkInput()) + { this->mainMenu->up(); } } -void MenuTestMode::right() { - if (this->checkInput()) { +void MenuTestMode::right() +{ + if (this->checkInput()) + { this->mainMenu->right(); } } -void MenuTestMode::left() { +void MenuTestMode::left() +{ if (this->mainMenu->isInSubmenu()) - if (this->checkInput()) { + if (this->checkInput()) + { this->mainMenu->left(); } - else { + else + { this->testMode->abortManeuver(); this->mainMenu->left(); } - else { + else + { this->parentMenu->printMenu(); } } -void MenuTestMode::yes() { - if (this->checkInput()) { +void MenuTestMode::yes() +{ + if (this->checkInput()) + { this->mainMenu->yes(); } } -void MenuTestMode::no() { - if (this->mainMenu->isInSubmenu()) { +void MenuTestMode::no() +{ + if (this->mainMenu->isInSubmenu()) + { if (this->checkInput()) this->mainMenu->no(); - else { + else + { this->testMode->abortManeuver(); this->mainMenu->no(); - }} - else{ - this->left();} + } + } + else + { + this->left(); + } } -void MenuTestMode::init() { +void MenuTestMode::init() +{ this->testMode = new TestMode(); this->driveManager->changeModus(this->testMode); - auto dummy = []() { - std::cout << "Dummy in Action" <testMode->getSpeedometerLeft()); auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight()); - // Set menus on LCD this->mainMenu->setLcd(this->lcd); engineMenu->setLcd(this->lcd); @@ -143,7 +166,6 @@ void MenuTestMode::init() { engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1); engineBothMenu->setPrintParentMenu(false); - // Entrys for the menus auto *engineAction = new MenuAction("Engine", engineMenu); auto *engineLeftAction = new MenuAction("Left", engineLeftMenu); @@ -162,7 +184,7 @@ void MenuTestMode::init() { auto *lightRedAction = new MenuAction("Red", dummy); auto *lightGreenAction = new MenuAction("Green", dummy); auto *lightBlueAction = new MenuAction("Blue", dummy); - auto *lightOffAction = new MenuAction("Off", dummy); + auto *lightOffAction = new MenuAction("Off", dummy); // Add entries to the menus this->mainMenu->addEntry(engineAction); @@ -182,74 +204,89 @@ void MenuTestMode::init() { lightMenu->addEntry(lightRedAction); lightMenu->addEntry(lightGreenAction); lightMenu->addEntry(lightBlueAction); - lightMenu->addEntry(lightOffAction); + lightMenu->addEntry(lightOffAction); } -void MenuTestMode::update() { - if (this->maneuverInAction) { - if (millis() - this->lastUpdateTime > updateDelay) { +void MenuTestMode::update() +{ + if (this->maneuverInAction) + { + if (millis() - this->lastUpdateTime > updateDelay) + { this->printManeuverTime(); this->lastUpdateTime = millis(); - }} + } + } } -bool MenuTestMode::checkInput() { - if (this->testMode->getBusy()) { +bool MenuTestMode::checkInput() +{ + if (this->testMode->getBusy()) + { this->printManeuverTime(); this->maneuverInAction = true; return false; } - if (this->maneuverInAction) { + if (this->maneuverInAction) + { this->maneuverInAction = false; } - - return true; + + return true; } -void MenuTestMode::printManeuverTime() { +void MenuTestMode::printManeuverTime() +{ uint8_t maneuverTime = this->testMode->getRemainingManeuverTime(); - if (maneuverTime) { + if (maneuverTime) + { String lineTwo = ""; lineTwo.concat(maneuverTime); lineTwo.concat(" secs"); this->print("Maneuver time:", lineTwo); - } else { + } + else + { this->maneuverInAction = false; this->printMenu(); } } -MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction) - : menu {menu}, - testModeFunctionSingle {testModeFunction}, - testMode {menu->getTestMode()} +MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction) + : menu{menu}, + testModeFunctionSingle{testModeFunction}, + testMode{menu->getTestMode()} { } -MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction) - : menu {menu}, - testModeFunctionDouble {testModeFunction}, - testMode {menu->getTestMode()} +MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction) + : menu{menu}, + testModeFunctionDouble{testModeFunction}, + testMode{menu->getTestMode()} { } -void MenuTestModeWrapper::action(int16_t* values, uint8_t length) { +void MenuTestModeWrapper::action(int16_t *values, uint8_t length) +{ // This function calls a member function with a pointer // Very helpful site: // https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types bool res = false; - if (length == 2 && static_cast(this->testModeFunctionDouble)) { + if (length == 2 && static_cast(this->testModeFunctionDouble)) + { res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]); } - else if (length == 1 && static_cast(this->testModeFunctionSingle)) { + else if (length == 1 && static_cast(this->testModeFunctionSingle)) + { res = (this->testMode->*this->testModeFunctionSingle)(values[0]); } - if (res) { + if (res) + { this->menu->printManeuverTime(); this->menu->maneuverStarted(); } -} +} diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.h b/src/SpecialMenus/driveModi/TestMode/menuTestMode.h index 4022dbc..6d22523 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.h +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.h @@ -4,9 +4,9 @@ * @brief Contains a class to use and print information about the TestMode. * @version 0.1 * @date 2022-09-08 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_TEST_MODE_H #define MENU_TEST_MODE_H @@ -20,80 +20,82 @@ /** * @brief Interact with the TestMode - * + * */ -class MenuTestMode : public MenuControl { - public: - /** - * @brief Construct a new Menu Test Mode object - * - * @param driveManager - */ - MenuTestMode(DriveManager *driveManager); - ~MenuTestMode(); +class MenuTestMode : public MenuControl +{ +public: + /** + * @brief Construct a new Menu Test Mode object + * + * @param driveManager + */ + MenuTestMode(DriveManager *driveManager); + ~MenuTestMode(); - /** - * @brief Prints the last informations - * - * On first call this function calls the init function. - * On every call this functions call the printMenu function from - * the mainMenu of this class. - */ - void printMenu() override; + /** + * @brief Prints the last informations + * + * On first call this function calls the init function. + * On every call this functions call the printMenu function from + * the mainMenu of this class. + */ + void printMenu() override; - /** - * @brief Prints maneuver Timer - * - * Aside from that the function looks if the maneuver is done and - * give the user input free. - */ - void printManeuverTime(); + /** + * @brief Prints maneuver Timer + * + * Aside from that the function looks if the maneuver is done and + * give the user input free. + */ + void printManeuverTime(); - void down() override; - void up() override; - void right() override; - void left() override; - void yes() override; - void no() override; + void down() override; + void up() override; + void right() override; + void left() override; + void yes() override; + void no() override; - /** - * @brief Calls the printManeuverTime function if a maneuver is in process. - * - */ - void update() override; + /** + * @brief Calls the printManeuverTime function if a maneuver is in process. + * + */ + void update() override; - TestMode* getTestMode() const { return this->testMode; } - void maneuverStarted() { this->maneuverInAction = true; } + TestMode *getTestMode() const { return this->testMode; } + void maneuverStarted() { this->maneuverInAction = true; } - private: - void init(); - bool checkInput(); +private: + void init(); + bool checkInput(); - DriveManager* driveManager; - TestMode* testMode = nullptr; - Menu* mainMenu = nullptr; + DriveManager *driveManager; + TestMode *testMode = nullptr; + Menu *mainMenu = nullptr; - bool isInit = false; - bool maneuverInAction = false; + bool isInit = false; + bool maneuverInAction = false; - uint32_t lastUpdateTime = 0; - uint16_t updateDelay = 1000; + uint32_t lastUpdateTime = 0; + uint16_t updateDelay = 1000; }; -typedef bool (TestMode::*TestModeFunctionSingle)(int16_t); -typedef bool (TestMode::*TestModeFunctionDouble)(int16_t, int16_t); -class MenuTestModeWrapper : public MenuIntInputWrapper { - public: - MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction); - MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction); +typedef bool (TestMode::*TestModeFunctionSingle)(int16_t); +typedef bool (TestMode::*TestModeFunctionDouble)(int16_t, int16_t); +class MenuTestModeWrapper : public MenuIntInputWrapper +{ +public: + MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction); + MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction); - void action(int16_t* values, uint8_t length) override; + void action(int16_t *values, uint8_t length) override; - private: - MenuTestMode* menu; - TestMode* testMode; - TestModeFunctionSingle testModeFunctionSingle = nullptr; - TestModeFunctionDouble testModeFunctionDouble = nullptr; +private: + MenuTestMode *menu; + TestMode *testMode; + TestModeFunctionSingle testModeFunctionSingle = nullptr; + TestModeFunctionDouble testModeFunctionDouble = nullptr; }; #endif // MENU_TEST_MODE_H diff --git a/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp b/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp index 4481e53..4f3735c 100644 --- a/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp +++ b/src/SpecialMenus/driveModi/TestMode/speedometerTest.cpp @@ -4,50 +4,54 @@ * @brief Contains the implementation of the class SpeedometerTest. * @version 0.1 * @date 2023-01-24 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "speedometerTest.h" -SpeedometerTest::SpeedometerTest(Speedometer* speedometer) - : speedometer {speedometer} +SpeedometerTest::SpeedometerTest(Speedometer *speedometer) + : speedometer{speedometer} { this->speedometer->setDirection(Speedometer::Forward); } +void SpeedometerTest::printMenu() +{ + switch (this->state) + { + case State::Off: + this->print("Press Yes (O)", "to start"); + break; -void SpeedometerTest::printMenu() { - switch (this->state) { - case State::Off : - this->print("Press Yes (O)", "to start"); - break; + case State::Running: + this->print("Running, Yes (O)", "to stop"); + break; - case State::Running : - this->print("Running, Yes (O)", "to stop"); - break; + case State::Finished: + { + String res = ""; + res.concat(this->result); + this->print("Result: ", res); + } + break; - case State::Finished : { - String res = ""; - res.concat(this->result); - this->print("Result: ", res); - } - break; - - default: - this->print("Error in", "MenuTest.cpp"); - break; + default: + this->print("Error in", "MenuTest.cpp"); + break; } } - -void SpeedometerTest::left() { +void SpeedometerTest::left() +{ this->no(); } -void SpeedometerTest::no() { - if (this->state == State::Running){ +void SpeedometerTest::no() +{ + if (this->state == State::Running) + { speedometer->calibrationMeasurementStop(); } @@ -55,27 +59,29 @@ void SpeedometerTest::no() { this->parentMenu->printMenu(); } -void SpeedometerTest::yes() { - switch (this->state) { - case State::Off : - this->state = State::Running; - this->speedometer->calibrationMeasurementStart(); - this->printMenu(); - break; +void SpeedometerTest::yes() +{ + switch (this->state) + { + case State::Off: + this->state = State::Running; + this->speedometer->calibrationMeasurementStart(); + this->printMenu(); + break; - case State::Running : - this->state = State::Finished; - this->result = this->speedometer->calibrationMeasurementStop(); - this->printMenu(); - break; - - case State::Finished : - this->state = State::Running; - this->speedometer->calibrationMeasurementStart(); - this->printMenu(); - break; + case State::Running: + this->state = State::Finished; + this->result = this->speedometer->calibrationMeasurementStop(); + this->printMenu(); + break; - default: - break; + case State::Finished: + this->state = State::Running; + this->speedometer->calibrationMeasurementStart(); + this->printMenu(); + break; + + default: + break; } } diff --git a/src/SpecialMenus/driveModi/TestMode/speedometerTest.h b/src/SpecialMenus/driveModi/TestMode/speedometerTest.h index 3990403..ad8173a 100644 --- a/src/SpecialMenus/driveModi/TestMode/speedometerTest.h +++ b/src/SpecialMenus/driveModi/TestMode/speedometerTest.h @@ -4,9 +4,9 @@ * @brief Contains a class to test the wheel encoder. * @version 0.1 * @date 2023-01-24 - * + * * @copyright Copyright (c) 2023 - * + * */ #pragma once @@ -16,49 +16,51 @@ /** * @brief Tests the wheel encoder. - * + * */ -class SpeedometerTest : public MenuControl { - public: - /** - * @brief The states of the test. - */ - enum State { - Off, - Running, - Finished - }; +class SpeedometerTest : public MenuControl +{ +public: + /** + * @brief The states of the test. + */ + enum State + { + Off, + Running, + Finished + }; - /** - * @brief Construct a new Speedometer Test object - * - * @param speedometer - */ - SpeedometerTest(Speedometer* speedometer); + /** + * @brief Construct a new Speedometer Test object + * + * @param speedometer + */ + SpeedometerTest(Speedometer *speedometer); - /** - * @brief Prints the actual state of the test. - */ - void printMenu() override; + /** + * @brief Prints the actual state of the test. + */ + void printMenu() override; - /** - * @brief Calls no. - */ - void left() override; + /** + * @brief Calls no. + */ + void left() override; - /** - * @brief Exit the menu or end the test. - */ - void no() override; + /** + * @brief Exit the menu or end the test. + */ + void no() override; - /** - * @brief Starts or restarts the test. - */ - void yes() override; + /** + * @brief Starts or restarts the test. + */ + void yes() override; - private: - Speedometer* speedometer; - State state = State::Off; +private: + Speedometer *speedometer; + State state = State::Off; - uint16_t result = 0; + uint16_t result = 0; }; diff --git a/src/SpecialMenus/driveModi/menuDriveMode.cpp b/src/SpecialMenus/driveModi/menuDriveMode.cpp index 2245eee..527aeca 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.cpp +++ b/src/SpecialMenus/driveModi/menuDriveMode.cpp @@ -4,79 +4,114 @@ * @brief Contains an implementation of the class MenuDriveMode * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuDriveMode.h" -MenuDriveMode::MenuDriveMode(DriveManager* driveManager) - : driveManager {driveManager} +MenuDriveMode::MenuDriveMode(DriveManager *driveManager) + : driveManager{driveManager} { } -void MenuDriveMode::left() { - if (static_cast(this->activeMenu)) { - if (static_cast(this->activeMenu)) { - this->activeMenu->left(); +MenuDriveMode::~MenuDriveMode() +{ + if (this->selfCreatedMenuSpeed) + { + delete this->menuSpeed; + } +} + +void MenuDriveMode::addSpeedMenu(MenuIntInput *menuSpeed) +{ + if (this->selfCreatedMenuSpeed) + { + delete this->menuSpeed; + this->selfCreatedMenuSpeed = false; + } + + this->menuSpeed = menuSpeed; +} + +void MenuDriveMode::left() +{ + if (static_cast(this->activeMenu)) + { + if (static_cast(this->activeMenu)) + { + this->activeMenu->left(); } return; } this->firstPrint = true; this->configureOnLeave(); - delete this->menuSpeed; + delete this->menuSpeed; this->driveManager->changeModus(); MenuInformationSites::left(); } -void MenuDriveMode::right() { - if (static_cast(this->activeMenu)) { +void MenuDriveMode::right() +{ + if (static_cast(this->activeMenu)) + { this->activeMenu->right(); return; } MenuInformationSites::right(); } -void MenuDriveMode::up() { - if (static_cast(this->activeMenu)) { +void MenuDriveMode::up() +{ + if (static_cast(this->activeMenu)) + { this->activeMenu->up(); return; } MenuInformationSites::up(); } -void MenuDriveMode::down() { - if (static_cast(this->activeMenu)) { +void MenuDriveMode::down() +{ + if (static_cast(this->activeMenu)) + { this->activeMenu->down(); return; } MenuInformationSites::down(); } -void MenuDriveMode::yes() { - if (static_cast(this->activeMenu)) { +void MenuDriveMode::yes() +{ + if (static_cast(this->activeMenu)) + { this->activeMenu->yes(); return; } MenuInformationSites::yes(); } -void MenuDriveMode::no() { - if (static_cast(this->activeMenu)) { +void MenuDriveMode::no() +{ + if (static_cast(this->activeMenu)) + { this->activeMenu->no(); return; } MenuInformationSites::no(); } -void MenuDriveMode::prepareReenterMenu() { +void MenuDriveMode::prepareReenterMenu() +{ this->activeMenu = nullptr; } -void MenuDriveMode::printMenu() { - if (static_cast(this->activeMenu)) { +void MenuDriveMode::printMenu() +{ + if (static_cast(this->activeMenu)) + { this->activeMenu->printMenu(); return; } @@ -84,40 +119,53 @@ void MenuDriveMode::printMenu() { MenuInformationSites::printMenu(); } -void MenuDriveMode::init() { +void MenuDriveMode::init() +{ this->activeMenu = nullptr; } -void MenuDriveMode::activateSpeedMenu() { - if (!this->driveManager->isActive()) { +void MenuDriveMode::activateSpeedMenu() +{ + if (!this->driveManager->isActive()) + { return; } - DrivingSpeeds& speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef(); + if (this->selfCreatedMenuSpeed) + { + delete this->menuSpeed; + } + + DrivingSpeeds &speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef(); auto *menu = new MenuIntInput(2, new MenuSpeed(speeds)); menu->setMinMax(5, UINT8_MAX); menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10); menu->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10); + this->selfCreatedMenuSpeed = true; this->addSpeedMenu(menu); } -void MenuDriveMode::enterSpeedMenu() { +void MenuDriveMode::enterSpeedMenu() +{ this->activeMenu = this->menuSpeed; this->enterMenu(); } -void MenuDriveMode::enterSensorMenu() { +void MenuDriveMode::enterSensorMenu() +{ this->activeMenu = this->menuSensor; this->enterMenu(); } -void MenuDriveMode::enterMenu() { - if (!static_cast(this->activeMenu)) { +void MenuDriveMode::enterMenu() +{ + if (!static_cast(this->activeMenu)) + { return; } - + this->activeMenu->printMenu(); this->activeMenu->setParentMenu(this); } diff --git a/src/SpecialMenus/driveModi/menuDriveMode.h b/src/SpecialMenus/driveModi/menuDriveMode.h index c74861e..ce9bcbf 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.h +++ b/src/SpecialMenus/driveModi/menuDriveMode.h @@ -4,9 +4,9 @@ * @brief Contains a base class for Menus about DriveModi * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_DRIVE_MODI_H #define MENU_DRIVE_MODI_H @@ -18,49 +18,80 @@ /** * @brief A base class for Menus about DriveModi - * + * */ -class MenuDriveMode : public MenuInformationSites { - public: - /** - * @brief Construct a new Menu Drive Mode object - * - * @param driveManager - */ - MenuDriveMode(DriveManager* driveManager); +class MenuDriveMode : public MenuInformationSites +{ +public: + /** + * @brief Construct a new Menu Drive Mode object + * + * @param driveManager + */ + MenuDriveMode(DriveManager *driveManager); - void addSensorMenu(MenuSensorData* menuSensor) { this->menuSensor = menuSensor; } - void addSpeedMenu(MenuIntInput* menuSpeed) { this->menuSpeed = menuSpeed; } + ~MenuDriveMode(); - /** - * @brief Goes back to the parentMenu. - */ - void left() override; - void right() override; - void up() override; - void down() override; - void yes() override; - void no() override; + void addSensorMenu(MenuSensorData *menuSensor) { this->menuSensor = menuSensor; } + void addSpeedMenu(MenuIntInput *menuSpeed); - void prepareReenterMenu() override; - void printMenu() override; + /** + * @brief Goes back to the parentMenu. + */ + void left() override; + void right() override; + void up() override; + void down() override; + void yes() override; + void no() override; - protected: - void init() override; - virtual void configureOnLeave() {} - void activateSpeedMenu(); - void enterSpeedMenu(); - void enterSensorMenu(); + void prepareReenterMenu() override; + void printMenu() override; - DriveManager* driveManager; - - bool firstPrint = true; +protected: + void init() override; - private: - void enterMenu(); + /** + * @brief Prepare leaving the menu + * + * Can be overwritten to add extra functionality to safely + * exit the menu. This function is called before the parentMenu + * is printed. + */ + virtual void configureOnLeave() {} - MenuControl* activeMenu = nullptr; - MenuSensorData* menuSensor = nullptr; - MenuIntInput* menuSpeed = nullptr; + /** + * @brief Creates an own SpeedMenu + * + * This function uses addSpeedMenu() at the end to that the new menu + */ + void activateSpeedMenu(); + + /** + * @brief Enter a Menu to edit the speeds + * + * To enter this menu it has to be set by addSpeedMenu() or activateSpeedMenu() + */ + void enterSpeedMenu(); + + /** + * @brief Enter a Menu with the SensorData + * + * To enter this menu it has to be set by addSensorMenu() + */ + void enterSensorMenu(); + + DriveManager *driveManager; + + bool firstPrint = true; + +private: + void enterMenu(); + + MenuControl *activeMenu = nullptr; + MenuSensorData *menuSensor = nullptr; + MenuIntInput *menuSpeed = nullptr; + + bool selfCreatedMenuSpeed = false; }; #endif // MENU_DRIVE_MODI_H diff --git a/src/driveModi/Modi/Autopilot/autopilot.h b/src/driveModi/Modi/Autopilot/autopilot.h index 6a5efc3..510ecda 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.h +++ b/src/driveModi/Modi/Autopilot/autopilot.h @@ -4,15 +4,14 @@ * @brief Contains a class which use the navigate class to drive automaticaly * @version 0.1 * @date 2022-02-02 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef AUTOPILOT_H #define AUTOPILOT_H - #include "navigation.h" #include "driveModi/Modi/ManualControl/manualControl.h" @@ -20,110 +19,113 @@ class DirectionChangeSignal; /** * @brief This class use the navigate class to drive automaticaly - * + * * This class get the information from the navigate class. When an * object of this class is constructed the rover can be driven manually. * When the Rover is near to the first position of the Route, you can * switch to automatic drive. - * + * */ -class Autopilot : public ManualControl { - public: - enum State { - InsufficientAccuracy = -2, - NoRoute = -1, - None = 0, - NavigationStarted, - GetToStartPoint, - SelfDrivingAvailable, - SelfDriving, - SelfDrivingRotate, - TargetReached - }; +class Autopilot : public ManualControl +{ +public: + enum State + { + InsufficientAccuracy = -2, + NoRoute = -1, + None = 0, + NavigationStarted, + GetToStartPoint, + SelfDrivingAvailable, + SelfDriving, + SelfDrivingRotate, + TargetReached + }; - /** - * @brief Destroy the Autopilot object - * - * Disconnect the NTRIP-Client - */ - ~Autopilot(); + /** + * @brief Destroy the Autopilot object + * + * Disconnect the NTRIP-Client + */ + ~Autopilot(); - void restart(); + void restart(); - /** - * @brief Get the Route Info object - * - * @return RouteInfo - */ - RouteInfo getRouteInfo() const { return this->routeInfo; } + /** + * @brief Get the Route Info object + * + * @return RouteInfo + */ + RouteInfo getRouteInfo() const { return this->routeInfo; } - /** - * @brief Get the Course Correction object - * - * @return CourseCorrection - */ - CourseCorrection getCourseCorrection() const { return this->courseCorrection; } + /** + * @brief Get the Course Correction object + * + * @return CourseCorrection + */ + CourseCorrection getCourseCorrection() const { return this->courseCorrection; } - /** - * @brief Get the State object - * - * @return State - */ - State getState() const { return this->state; } - Navigation* getNavigation() const { return this->navigation; } - - /** - * @brief Tells if there are new informations to display - * - * @return true - * @return false - */ - bool shouldUpdate(); - void testRotate(int16_t degree); - void endRotate(); - void switchLoopMode() { this->loopMode = !this->loopMode; } - bool getLoopMode() const { return this->loopMode; } + /** + * @brief Get the State object + * + * @return State + */ + State getState() const { return this->state; } + Navigation *getNavigation() const { return this->navigation; } - private: - void init(); - void drive(); - void beginRotate(); - void rotate(); - void run() override; - void checkButtonInput(); - void askNavigationForOrder(); - void selfDriving(); - void restartLoop(); - void afterActivate() override; + /** + * @brief Tells if there are new informations to display + * + * @return true + * @return false + */ + bool shouldUpdate(); + void testRotate(int16_t degree); + void endRotate(); + void switchLoopMode() { this->loopMode = !this->loopMode; } + bool getLoopMode() const { return this->loopMode; } - Navigation* navigation = nullptr; - CourseCorrection courseCorrection{0, 0}; - RouteInfo routeInfo{0, 0}; - State state = State::None; - State lastState = State::None; - Navigation::Status lastOrderStatus; - DirectionChangeSignal* directionChangeSignal = nullptr; +private: + void init(); + void drive(); + void beginRotate(); + void rotate(); + void run() override; + void checkButtonInput(); + void askNavigationForOrder(); + void selfDriving(); + void restartLoop(); + void afterActivate() override; - bool updateDisplay = false; - bool loopMode = false; + Navigation *navigation = nullptr; + CourseCorrection courseCorrection{0, 0}; + RouteInfo routeInfo{0, 0}; + State state = State::None; + State lastState = State::None; + Navigation::Status lastOrderStatus; + DirectionChangeSignal *directionChangeSignal = nullptr; - uint8_t maxCourseDeviationBeforeAct = 5; - uint16_t autopilotChangeDelayMillis = 500; - uint32_t lastAutopilotChangeMillis = 0; + bool updateDisplay = false; + bool loopMode = false; - int16_t rotationAimAzimuth = 0; + uint8_t maxCourseDeviationBeforeAct = 5; + uint16_t autopilotChangeDelayMillis = 500; + uint32_t lastAutopilotChangeMillis = 0; - double minRemainingDistance = 0.25; + int16_t rotationAimAzimuth = 0; + + double minRemainingDistance = 0.25; }; -class DirectionChangeSignal : public DirectionChangeWrapper { - public: - DirectionChangeSignal(Autopilot* pilot); - ~DirectionChangeSignal(); - void action() override; +class DirectionChangeSignal : public DirectionChangeWrapper +{ +public: + DirectionChangeSignal(Autopilot *pilot); + ~DirectionChangeSignal(); + void action() override; - private: - Autopilot* pilot; +private: + Autopilot *pilot; }; #endif // AUTOPILOT_H diff --git a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp index 81a970e..f4a2bd4 100644 --- a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp +++ b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.cpp @@ -1,22 +1,25 @@ /** * @file calibrateCompassM.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "calibrateCompassM.h" - -void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) { - if (static_cast(caliCompass)) { +void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) +{ + if (static_cast(caliCompass)) + { this->caliCompass = caliCompass; this->addChildComponent(this->caliCompass); - } else if (static_cast(this->caliCompass)) { + } + else if (static_cast(this->caliCompass)) + { this->removeChildComponent(this->caliCompass); this->caliCompass = caliCompass; } diff --git a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h index 753bbc1..50ef4f7 100644 --- a/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h +++ b/src/driveModi/Modi/CalibrateCompass/calibrateCompassM.h @@ -1,12 +1,12 @@ /** * @file calibrateCompassM.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a Menu class to calibrate the compass * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef CALIBRATE_COMPASS_M_H @@ -16,12 +16,21 @@ #include "driveModi/Modi/ManualControl/manualControl.h" -class CalibrateCompassM : public ManualControl { - public: - void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr); +/** + * @brief A Menu class to interact with CalibrateCompass class + */ +class CalibrateCompassM : public ManualControl +{ +public: + /** + * @brief Set the CalibrateCompass object + * + * @param caliCompass + */ + void setCalibrateCompass(CalibrateCompass *caliCompass = nullptr); - private: - CalibrateCompass* caliCompass = nullptr; +private: + CalibrateCompass *caliCompass = nullptr; }; -#endif //CALIBRATE_COMPASS_M_H +#endif // CALIBRATE_COMPASS_M_H diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.h b/src/driveModi/Modi/CaptureRoute/captureRoute.h index 48caa1a..d60dd03 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.h +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.h @@ -4,9 +4,9 @@ * @brief Contains a class to capture a driven route * @version 0.1 * @date 2022-02-15 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef CAPTURE_ROUTE_H @@ -19,61 +19,57 @@ /** * @brief A class to capture a driven class - * + * * This class inherits ManualControl so you can drive * normally as in ManualControl. If GPS signal is valid * you can add a Point everytime you want. - * + * */ -class CaptureRoute : public ManualControl { - public: - /** - * @brief Destroy the Capture Route object - * - * Disconnect the NTRIP-Client - */ - ~CaptureRoute(); +class CaptureRoute : public ManualControl +{ +public: + /** + * @brief Destroy the Capture Route object + * + * Disconnect the NTRIP-Client + */ + ~CaptureRoute(); - // /** - // * @brief Get the Navigation object - // * - // * @return Navigation* - // */ - // Navigation* getNavigation() const { return this->navigation; } + /** + * @brief Get the Route Info object + * + * @return RouteInfo + */ + RouteInfo getRouteInfo() const { return this->routeInfo; } - /** - * @brief Get the Route Info object - * - * @return RouteInfo - */ - RouteInfo getRouteInfo() const { return this->routeInfo; } - Navigation::Status getLastStatus() const { return this->status; } - Navigation* getNavigation() const { return this->navigation; } + Navigation::Status getLastStatus() const { return this->status; } + Navigation *getNavigation() const { return this->navigation; } - /** - * @brief Get the distance to the last saved oint - * - * @return double in meters - */ - double getDistanceToLastPoint() const; + /** + * @brief Get the distance to the last saved oint + * + * @return double in meters + */ + double getDistanceToLastPoint() const; - /** - * @brief Tells if there are new informations to display - * - * @return true - * @return false - */ - bool shouldUpdate(); - private: - void run() override; - void afterActivate() override; + /** + * @brief Tells if there are new informations to display + * + * @return true + * @return false + */ + bool shouldUpdate(); - Navigation* navigation = nullptr; - RouteInfo routeInfo; - Point lastSavedPoint; - Navigation::Status status = Navigation::Status::Complete; +private: + void run() override; + void afterActivate() override; - bool updateDisplay = false; + Navigation *navigation = nullptr; + RouteInfo routeInfo; + Point lastSavedPoint; + Navigation::Status status = Navigation::Status::Complete; + + bool updateDisplay = false; }; #endif // CAPTURE_ROUTE_H diff --git a/src/driveModi/Modi/ManualControl/manualControl.h b/src/driveModi/Modi/ManualControl/manualControl.h index bcda7df..319f1d3 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.h +++ b/src/driveModi/Modi/ManualControl/manualControl.h @@ -4,53 +4,70 @@ * @brief A small class to drive the Rover by the controller joystick. * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef MANUAL_CONTROL_H #define MANUAL_CONTROL_H #include "driveModi/driveModi.h" -class DirectionChangeWrapper { - public: - virtual void action() = 0; +class DirectionChangeWrapper +{ +public: + virtual void action() = 0; }; /** * @brief Drive the Rover with a Joystick - * - * This class gets the x and y value from the PS3 controller + * + * This class gets the x and y value from the ControlPad * and map the values to moveControl - * + * * @see MoveControl */ -class ManualControl : public DriveModi { - public: - enum class InputMode : uint8_t { - Analog, - Digital - }; +class ManualControl : public DriveModi +{ +public: + /** + * @brief The enum is used to change the interpretation of the joystick data + */ + enum class InputMode : uint8_t + { + Analog, + Digital + }; - void switchInputMode(); - void setInputMode(InputMode mode) { this->inputMode = mode; } - InputMode getInputMode() const { return this->inputMode; } - void setDirectionChangeCallback(DirectionChangeWrapper* callback) { this->directionChangeWrapper = callback; } + /** + * @brief Change the InputMode to the opposite + */ + void switchInputMode(); + void setInputMode(InputMode mode) { this->inputMode = mode; } + InputMode getInputMode() const { return this->inputMode; } - uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); } - uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); } + /** + * @brief Set the DirectionChangeWrapper object + * + * This callback is used to inform the CalcAzimuth Component about a direction change + * + * @param callback + */ + void setDirectionChangeCallback(DirectionChangeWrapper *callback) { this->directionChangeWrapper = callback; } - protected: - void run() override; + uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); } + uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); } - private: - void analogControl(); - void digitalControl(); +protected: + void run() override; - bool lastLoopTurned = false; - DirectionChangeWrapper* directionChangeWrapper = nullptr; - InputMode inputMode = InputMode::Analog; +private: + void analogControl(); + void digitalControl(); + + bool lastLoopTurned = false; + DirectionChangeWrapper *directionChangeWrapper = nullptr; + InputMode inputMode = InputMode::Analog; }; #endif // MANUAL_CONTROL_H diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index 9e26897..afda3dd 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -15,7 +15,8 @@ void TestMode::run() if (this->maneuver == Maneuver::Turn) { uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth()); - if (delta > this->degree) { + if (delta > this->degree) + { this->abort = true; } } @@ -31,7 +32,8 @@ void TestMode::run() bool TestMode::drive(int16_t cmDistance, int16_t degree) { - if (this->busy){ + if (this->busy) + { return false; } @@ -43,10 +45,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree) // Only left or right this->moveControl->setSpeed(0); - if (degree < 0){ + if (degree < 0) + { this->moveControl->setRotationSpeed(-this->maxSpeeds.rot); } - else if (degree > 0){ + else if (degree > 0) + { this->moveControl->setRotationSpeed(this->maxSpeeds.rot); } @@ -62,10 +66,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree) // Only forward or backward this->moveControl->setRotationSpeed(0); - if (cmDistance < 0){ + if (cmDistance < 0) + { this->moveControl->setSpeed(-this->maxSpeeds.x); } - else if (cmDistance > 0){ + else if (cmDistance > 0) + { this->moveControl->setSpeed(this->maxSpeeds.x); } @@ -78,10 +84,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree) { // forward or backward and left or right // TODO: Calculate roationspeed - if (cmDistance < 0){ + if (cmDistance < 0) + { this->moveControl->setSpeed(-this->maxSpeeds.x); } - else if (cmDistance > 0){ + else if (cmDistance > 0) + { this->moveControl->setSpeed(this->maxSpeeds.x); } @@ -137,7 +145,8 @@ void TestMode::abortManeuver() uint8_t TestMode::getRemainingManeuverTime() const { - if (this->busy){ + if (this->busy) + { return static_cast((this->maneuverTime - (millis() - this->actionStart)) / 1000); } return 0; @@ -145,13 +154,16 @@ uint8_t TestMode::getRemainingManeuverTime() const bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds) { - if (this->busy){ + if (this->busy) + { return false; } - if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage){ + if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage) + { return false; } - if (seconds < 0){ + if (seconds < 0) + { return false; } diff --git a/src/driveModi/Modi/TestMode/testMode.h b/src/driveModi/Modi/TestMode/testMode.h index bb49794..f82a493 100644 --- a/src/driveModi/Modi/TestMode/testMode.h +++ b/src/driveModi/Modi/TestMode/testMode.h @@ -26,7 +26,6 @@ class TestMode : public DriveModi public: /** * @brief Different states to test the engine - * */ enum Maneuver { @@ -38,6 +37,14 @@ public: Drive }; + /** + * @brief Let the rover drive + * + * @param cmDistance to drive + * @param degree degree to rotate over the hole distance + * @return true + * @return false + */ bool drive(int16_t cmDistance = 0, int16_t degree = 0); /** @@ -89,6 +96,7 @@ public: * @return false */ bool getBusy() const { return this->busy; } + Maneuver getManeuver() const { return this->maneuver; } Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); } Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); } diff --git a/src/driveModi/driveManager.h b/src/driveModi/driveManager.h index 1050a34..f3f014a 100644 --- a/src/driveModi/driveManager.h +++ b/src/driveModi/driveManager.h @@ -4,9 +4,9 @@ * @brief Contains a class to switch the DriveModi * @version 0.1 * @date 2021-12-14 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef DRIVE_MANAGER_H @@ -20,58 +20,61 @@ #include "component.h" #include "sensorData.h" -class DriveManager : public Component { - public: +/** + * @brief A class to manage and hold the different DriveModi + * + */ +class DriveManager : public Component +{ +public: + /** + * @brief Construct a new Drive Manager object + * + * @param moveControl + * @param sensorData + * @param input + */ + DriveManager(MoveControl *moveControl, const SensorData *sensorData, const ControlPadInput *input); - /** - * @brief Construct a new Drive Manager object - * - * @param moveControl - * @param sensorData - * @param input - */ - DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input); + /** + * @brief Construct a new Drive Manager object + * + * @param params + */ + DriveManager(DriveModiParams params); - /** - * @brief Construct a new Drive Manager object - * - * @param params - */ - DriveManager(DriveModiParams params); + /** + * @brief Change the DriveModi to a specific value + * + * Sets MoveControl to a safe state, delete the last + * DriveModi and than set the new DriveModi + * + * @param modus + */ + void changeModus(DriveModi *modus = nullptr); - /** - * @brief Change the DriveModi to a specific value - * - * Sets MoveControl to a safe state, delete the last - * DriveModi and than set the new DriveModi - * - * @param modus - */ - void changeModus(DriveModi* modus = nullptr); + /** + * @brief Get the DriveModi Ptr object + * + * This is a pointer to the Object of the current DriveMode. + * If you know which DriveMode is active, you can cast this + * pointer to it. + * + * @see getDriveModi + * @return DriveModi* + */ + DriveModi *getDriveModiPtr() const { return this->currentModusPtr; } + DrivingSpeeds &getDrivingSpeedsRef() { return this->drivingSpeeds; } - /** - * @brief Get the DriveModi Ptr object - * - * This is a pointer to the Object of the current DriveMode. - * If you know which DriveMode is active, you can cast this - * pointer to it. - * - * @see getDriveModi - * @return DriveModi* - */ - DriveModi* getDriveModiPtr() const { return this->currentModusPtr; } - DrivingSpeeds& getDrivingSpeedsRef() { return this->drivingSpeeds; } + bool isActive() const { return this->currentModusPtr; } - bool isActive() const { return this->currentModusPtr; } +private: + void run() override{}; + void init(); - private: - void run() override {}; - void init(); - - DriveModi *currentModusPtr = nullptr; - DriveModiParams driveModiParams; - DrivingSpeeds drivingSpeeds = {1, 7}; + DriveModi *currentModusPtr = nullptr; + DriveModiParams driveModiParams; + DrivingSpeeds drivingSpeeds = {1, 7}; }; - #endif // DRIVE_MANAGER_H diff --git a/src/driveModi/driveModi.cpp b/src/driveModi/driveModi.cpp index ef573d3..37a75c5 100644 --- a/src/driveModi/driveModi.cpp +++ b/src/driveModi/driveModi.cpp @@ -1,26 +1,30 @@ #include "driveModi.h" -DriveModi::~DriveModi() { +DriveModi::~DriveModi() +{ this->moveControl->setSpeed(0); this->moveControl->setRotationSpeed(0); this->moveControl->setDrivingStatus(MoveControl::Status::Stop); } -void DriveModi::activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData) { +void DriveModi::activate(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData) +{ this->moveControl = moveControl; this->input = input; this->sensorData = sensorData; this->init(); } -void DriveModi::activate(DriveModiParams params){ +void DriveModi::activate(DriveModiParams params) +{ this->moveControl = params.moveControl; this->input = params.input; this->sensorData = params.sensorData; this->init(); } -void DriveModi::init() { +void DriveModi::init() +{ this->moveControl->setDrivingStatus(MoveControl::Status::Drive); this->loopDelay = DriveModi::defaultDelay; this->afterActivate(); diff --git a/src/driveModi/driveModi.h b/src/driveModi/driveModi.h index daa6749..ba40324 100644 --- a/src/driveModi/driveModi.h +++ b/src/driveModi/driveModi.h @@ -4,9 +4,9 @@ * @brief Contains a virtual class for all Modi * @version 0.1 * @date 2021-12-14 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef DRIVEMODI_H @@ -17,42 +17,64 @@ #include "controlPadInput.h" #include "sensorData.h" -struct DriveModiParams { - MoveControl* moveControl; - const ControlPadInput* input; - const SensorData* sensorData; +/** + * @brief The struct contains all objects needed by a DriveMode + */ +struct DriveModiParams +{ + MoveControl *moveControl; + const ControlPadInput *input; + const SensorData *sensorData; }; /** * @brief Baseclass to build DriveModi - * + * * This class must be inherited by other classes which want to be * act as a DriveModi, because the DriveModi structure uses polymorphism. */ -class DriveModi : public Component { - public: - virtual ~DriveModi(); +class DriveModi : public Component +{ +public: + virtual ~DriveModi(); - const SensorData* getSensorData() const { return this->sensorData; } + const SensorData *getSensorData() const { return this->sensorData; } - void activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData); - void activate(DriveModiParams params); + /** + * @brief This activates a DriveMode + * + * This function have to be called to provide the DriveMode + * with this objects + * + * @param moveControl + * @param input + * @param sensorData + */ + void activate(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData); + void activate(DriveModiParams params); - void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; } - DrivingSpeeds getSpeeds() const { return this->maxSpeeds; } - DrivingSpeeds& getSpeedsRef() { return this->maxSpeeds; } + void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; } + DrivingSpeeds getSpeeds() const { return this->maxSpeeds; } + DrivingSpeeds &getSpeedsRef() { return this->maxSpeeds; } - protected: - virtual void afterActivate() {} +protected: + /** + * @brief Prepare other things + * + * This function can be overwritten to prepare things + * for the specific DriveModi. This function will be + * called after activate(). + */ + virtual void afterActivate() {} - MoveControl *moveControl = nullptr; - DrivingSpeeds maxSpeeds = {1, 7}; - const ControlPadInput* input = nullptr; - const SensorData* sensorData = nullptr; + MoveControl *moveControl = nullptr; + DrivingSpeeds maxSpeeds = {1, 7}; + const ControlPadInput *input = nullptr; + const SensorData *sensorData = nullptr; - private: - void init(); +private: + void init(); - static constexpr uint8_t defaultDelay = 40; + static constexpr uint8_t defaultDelay = 40; }; #endif // DRIVEMODI_H diff --git a/src/main.cpp b/src/main.cpp index 9c3134f..8fc49a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,14 +92,14 @@ void setup() lcd->clear(); lcd->noBacklight(); - network = new Network(static_cast(NetworkConfig::ssid), - static_cast(NetworkConfig::password), + network = new Network(static_cast(NetworkConfig::ssid), + static_cast(NetworkConfig::password), setIPs()); network->activateEspNow(receiveCallback, sendCallback); if (NetworkConfig::mqtt) { - if (network->activateMqtt(static_cast(MqttConfig::user), - static_cast(MqttConfig::password))) + if (network->activateMqtt(static_cast(MqttConfig::user), + static_cast(MqttConfig::password))) { DebugMqtt::init(network->getMqttClient(), Loglevel::debug); debugMqtt = new DebugMqtt("Console"); @@ -125,11 +125,11 @@ void setup() sensorData = new SensorData(); sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs); sensorData->enableRealCompass(); - sensorData->enableNtrip(static_cast(NtripConfig::host), - NtripConfig::port, - static_cast(NtripConfig::mountPoint), - static_cast(NtripConfig::user), - static_cast(NtripConfig::password)); + sensorData->enableNtrip(static_cast(NtripConfig::host), + NtripConfig::port, + static_cast(NtripConfig::mountPoint), + static_cast(NtripConfig::user), + static_cast(NtripConfig::password)); // sensorData->enableGyroscope(); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 145a786..6ad879d 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -17,19 +17,19 @@ MoveControl::MoveControl() leftSpeedometer{new Speedometer(PinNumbers::LeftMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, rightSpeedometer{new Speedometer(PinNumbers::RightMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)}, leftPid{new PID(&this->wheelspeedLeft, - &this->leftPidOut, - &this->wheelspeedLeftTarget, - Settings::Pid::Left::P, - Settings::Pid::Left::I, - Settings::Pid::Left::D, - DIRECT)}, + &this->leftPidOut, + &this->wheelspeedLeftTarget, + Settings::Pid::Left::P, + Settings::Pid::Left::I, + Settings::Pid::Left::D, + DIRECT)}, rightPid{new PID(&this->wheelspeedRight, - &this->rightPidOut, - &this->wheelspeedRightTarget, - Settings::Pid::Right::P, - Settings::Pid::Right::I, - Settings::Pid::Right::D, - DIRECT)} + &this->rightPidOut, + &this->wheelspeedRightTarget, + Settings::Pid::Right::P, + Settings::Pid::Right::I, + Settings::Pid::Right::D, + DIRECT)} { this->leftPid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax); this->leftPid->SetSampleTime(Settings::Pid::sampleTime); From 451517e7cdddc6e9ee60470083dc0ddb3af3f075 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 20:11:15 +0200 Subject: [PATCH 26/26] cleaning --- clangtidy.txt | 52 ------------------------------------------ doc/TODO allgemein.txt | 2 -- rover.cppcheck | 16 ------------- 3 files changed, 70 deletions(-) delete mode 100644 clangtidy.txt delete mode 100644 rover.cppcheck diff --git a/clangtidy.txt b/clangtidy.txt deleted file mode 100644 index d6d4dfe..0000000 --- a/clangtidy.txt +++ /dev/null @@ -1,52 +0,0 @@ - -========================= [PASSED] Took 541.63 seconds ========================= - -Component HIGH MEDIUM LOW -------------------------------------------- ------ -------- ----- -include 0 4 0 -lib/Battery 0 85 0 -lib/CalcAzimuth 0 9 0 -lib/Component 0 10 0 -lib/ControllPad 0 27 0 -lib/Counter 0 9 0 -lib/LcdWrapper 0 23 0 -lib/MQTT 0 42 0 -lib/Menu/include 0 13 0 -lib/Menu/src 0 188 0 -lib/MotorControl 0 38 0 -lib/Navigation 0 41 0 -lib/Network 0 36 0 -lib/NtripClient 0 98 0 -lib/Point 0 42 0 -lib/Route 0 20 0 -lib/Sensors 0 108 0 -lib/Speedometer 0 44 0 -lib/Times 0 11 0 -lib/calibrateCompass 0 28 0 -src 0 129 0 -src/OutputBuf 0 22 0 -src/SpecialMenus/CalibrateBattery 0 8 0 -src/SpecialMenus/PID 0 7 0 -src/SpecialMenus/Route 0 62 0 -src/SpecialMenus/SensorData 0 32 0 -src/SpecialMenus/Speed 0 9 0 -src/SpecialMenus/Systeminformation 0 9 0 -src/SpecialMenus/driveModi 0 26 0 -src/SpecialMenus/driveModi/Autopilot 0 37 0 -src/SpecialMenus/driveModi/CalibrateCompass 0 16 0 -src/SpecialMenus/driveModi/CaptureRoute 0 27 0 -src/SpecialMenus/driveModi/ManualDrive 0 8 0 -src/SpecialMenus/driveModi/TestMode 0 108 0 -src/driveModi 0 6 0 -src/driveModi/Modi/Autopilot 0 20 0 -src/driveModi/Modi/CalibrateCompass 0 2 0 -src/driveModi/Modi/CaptureRoute 0 7 0 -src/driveModi/Modi/ManualControl 0 9 0 -src/driveModi/Modi/TestMode 0 31 0 - -Total 0 1451 0 - -Environment Tool Status Duration -------------- --------- -------- ------------ -embedded clangtidy PASSED 00:09:01.626 -========================= 1 succeeded in 00:09:01.626 ========================= diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index 98bf03d..a3fc74a 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -35,9 +35,7 @@ Do later: Do now: Code: - Doxygen Kommentare aktualisieren Fernbedienung! - Compass calibration überprüfen Latex: Anhang: Liste mit allen Komponenten und Kurzbeschreibung diff --git a/rover.cppcheck b/rover.cppcheck deleted file mode 100644 index d853181..0000000 --- a/rover.cppcheck +++ /dev/null @@ -1,16 +0,0 @@ - - - rover-cppcheck-build-dir - false - true - true - 2 - 100 - - - - - - - rover -