doxygen finished

This commit is contained in:
2023-10-12 19:50:10 +02:00
parent db74898b72
commit 5eaeb2749b
39 changed files with 1283 additions and 1019 deletions
@@ -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;
+15 -15
View File
@@ -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
+7
View File
@@ -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);
/**
+25 -25
View File
@@ -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
+19 -10
View File
@@ -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
+7 -5
View File
@@ -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;
+19 -10
View File
@@ -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 <menuIntInput.h>
#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
@@ -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);
}
@@ -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
@@ -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
@@ -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;
}
}
@@ -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
@@ -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
@@ -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;
}
}
@@ -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
@@ -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" <<std::endl;
auto dummy = []()
{
std::cout << "Dummy in Action" << std::endl;
};
// Create menu
@@ -103,7 +127,6 @@ void MenuTestMode::init() {
auto *encoderLeftMenu = new SpeedometerTest(this->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<bool>(this->testModeFunctionDouble)) {
if (length == 2 && static_cast<bool>(this->testModeFunctionDouble))
{
res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]);
}
else if (length == 1 && static_cast<bool>(this->testModeFunctionSingle)) {
else if (length == 1 && static_cast<bool>(this->testModeFunctionSingle))
{
res = (this->testMode->*this->testModeFunctionSingle)(values[0]);
}
if (res) {
if (res)
{
this->menu->printManeuverTime();
this->menu->maneuverStarted();
}
}
}
@@ -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
@@ -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;
}
}
@@ -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;
};
+79 -31
View File
@@ -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<bool>(this->activeMenu)) {
if (static_cast<bool>(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<bool>(this->activeMenu))
{
if (static_cast<bool>(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<bool>(this->activeMenu)) {
void MenuDriveMode::right()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->right();
return;
}
MenuInformationSites::right();
}
void MenuDriveMode::up() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::up()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->up();
return;
}
MenuInformationSites::up();
}
void MenuDriveMode::down() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::down()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->down();
return;
}
MenuInformationSites::down();
}
void MenuDriveMode::yes() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::yes()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->yes();
return;
}
MenuInformationSites::yes();
}
void MenuDriveMode::no() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::no()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->no();
return;
}
MenuInformationSites::no();
}
void MenuDriveMode::prepareReenterMenu() {
void MenuDriveMode::prepareReenterMenu()
{
this->activeMenu = nullptr;
}
void MenuDriveMode::printMenu() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::printMenu()
{
if (static_cast<bool>(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<bool>(this->activeMenu)) {
void MenuDriveMode::enterMenu()
{
if (!static_cast<bool>(this->activeMenu))
{
return;
}
this->activeMenu->printMenu();
this->activeMenu->setParentMenu(this);
}
+69 -38
View File
@@ -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