Update doxygen comments

This commit is contained in:
2023-02-13 20:36:04 +01:00
parent 1604cb0026
commit deecf7724c
23 changed files with 497 additions and 70 deletions
+6
View File
@@ -23,7 +23,13 @@
*/ */
#define NO_GLOBAL_INSTANCES #define NO_GLOBAL_INSTANCES
/**
* @name SPI-Pins
* @brief Pins for SPI communication with the gnss module
*/
///@{
#define UBLOX_GNSS_SPI_CS 17 #define UBLOX_GNSS_SPI_CS 17
#define UBLOX_GNSS_SPI_COPI 16 #define UBLOX_GNSS_SPI_COPI 16
#define UBLOX_GNSS_SPI_CIPO 4 #define UBLOX_GNSS_SPI_CIPO 4
#define UBLOX_GNSS_SPI_SCK 5 #define UBLOX_GNSS_SPI_SCK 5
///@}
+27
View File
@@ -98,7 +98,22 @@ class MoveControl {
*/ */
void setRotationSpeed(double speed); void setRotationSpeed(double speed);
/**
* @brief Set Raw Power Left
*
* This value has only an effect if DrivingStatus is raw.
*
* @param power between -100 and 100
*/
void setRawPowerLeft(int16_t power); void setRawPowerLeft(int16_t power);
/**
* @brief Set the Raw Power Right
*
* This value has only an effect if DrivingStatus is raw.
*
* @param power between -100 and 100
*/
void setRawPowerRight(int16_t power); void setRawPowerRight(int16_t power);
/** /**
@@ -118,7 +133,19 @@ class MoveControl {
* @return PID* * @return PID*
*/ */
PID* getPID(uint8_t side); PID* getPID(uint8_t side);
/**
* @brief Get the Speedometer Left object
*
* @return Speedometer*
*/
Speedometer* getSpeedometerLeft() const { return this->left_speedometer; } Speedometer* getSpeedometerLeft() const { return this->left_speedometer; }
/**
* @brief Get the Speedometer Right object
*
* @return Speedometer*
*/
Speedometer* getSpeedometerRight() const { return this->right_speedometer; } Speedometer* getSpeedometerRight() const { return this->right_speedometer; }
/** /**
+8 -9
View File
@@ -57,7 +57,6 @@ void Navigation::init(Route* route) {
else else
this->route = new Route(); this->route = new Route();
this->ntripClient = new NTRIPClient();
this->compass = new QMC5883LCompass(); this->compass = new QMC5883LCompass();
// Init Compass // Init Compass
@@ -77,7 +76,7 @@ Navigation::~Navigation() {
} }
void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) { void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) {
this->ntripClient->init(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str()); this->ntripClient = new NTRIPClient(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str());
this->ntripClient->gpsConfiguration(); this->ntripClient->gpsConfiguration();
this->ntripClient->loop(); this->ntripClient->loop();
this->ntripClient->setActivated(false); this->ntripClient->setActivated(false);
@@ -93,7 +92,7 @@ void Navigation::loop() {
Navigation::newData = false; Navigation::newData = false;
} }
if (this->isNtripInit) if (this->ntripClient)
this->ntripClient->loop(); this->ntripClient->loop();
if (millis() - this->lastMillis > AZIMUTH_UPDATE_DELAY) { if (millis() - this->lastMillis > AZIMUTH_UPDATE_DELAY) {
@@ -169,12 +168,12 @@ bool Navigation::addCurrentPosToRoute() {
return false; return false;
} }
bool Navigation::setPointBeforeTurn() { // bool Navigation::setPointBeforeTurn() {
if (millis() - this->currentPosition.getCreationTime() > 1000) // if (millis() - this->currentPosition.getCreationTime() > 1000)
return false; // return false;
this->beforeTurnPoint = this->currentPosition; // this->beforeTurnPoint = this->currentPosition;
return true; // return true;
} // }
void Navigation::updateCurrentLocation() { void Navigation::updateCurrentLocation() {
if (Navigation::ubxUpdateTimeStatic == this->ubxUpdateTime) if (Navigation::ubxUpdateTimeStatic == this->ubxUpdateTime)
+19 -8
View File
@@ -128,14 +128,8 @@ class Navigation {
*/ */
bool addCurrentPosToRoute(); bool addCurrentPosToRoute();
bool setPointBeforeTurn(); // TODO: can be deleted?
// bool setPointBeforeTurn();
// /**
// * @brief Returns the GPS object
// *
// * @return SFE_UBLOX_GNSS*
// */
// SFE_UBLOX_GNSS* getGPS() { return this->gps; }
/** /**
* @brief Get the Ubx Data object * @brief Get the Ubx Data object
@@ -163,8 +157,25 @@ class Navigation {
*/ */
RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); } RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); }
Route* getRoute() const { return this->route; } Route* getRoute() const { return this->route; }
/**
* @brief Get azimuth
*
* This value represents the angle between north and
* the line of sight. Clockwise.
*
* @return uint16_t degree
*/
uint16_t getAzimuth() const { return this->azimuth; } uint16_t getAzimuth() const { return this->azimuth; }
/**
* @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); static void setOutputStatusPrintPVTdata(bool status);
private: private:
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file route.cpp * @file route.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Implements the class Route * @brief Implements the class Route and Point
* @version 0.1 * @version 0.1
* @date 2022-01-31 * @date 2022-01-31
* *
+76 -8
View File
@@ -1,7 +1,7 @@
/** /**
* @file route.h * @file route.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains a class which hold multiple Points * @brief Contains the class Point and Route
* @version 0.1 * @version 0.1
* @date 2022-01-31 * @date 2022-01-31
* *
@@ -30,6 +30,10 @@
*/ */
class Point{ class Point{
public: public:
/**
* @brief Hold the data longitude and latitude
*
*/
struct Coordinates { struct Coordinates {
double lon; double lon;
double lat; double lat;
@@ -39,6 +43,10 @@ class Point{
} }
}; };
/**
* @brief The Accuracy is set by the constructor
*
*/
enum PointAccuracy { enum PointAccuracy {
none, none,
fourDigOfCM, fourDigOfCM,
@@ -54,6 +62,9 @@ class Point{
* *
* @param lat latitude * @param lat latitude
* @param lon longitude * @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); Point(double lat, double lon, uint32_t horizontalAccuracy = 0);
Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0); Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0);
@@ -62,7 +73,7 @@ class Point{
Point(); Point();
/** /**
* @brief checks if to points are equal * @brief Checks if to points are equal.
* *
* @param rhs * @param rhs
* @return true * @return true
@@ -71,16 +82,38 @@ class Point{
bool operator==(const Point& rhs) const; bool operator==(const Point& rhs) const;
/** /**
* @brief Checks if the Point is initalized. * @brief Checks if the point is initalized.
* *
* @return true * @return true
* @return false * @return false
*/ */
bool isInit() const { return this->coordinates.lat + this->coordinates.lon; } 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; } 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 Coordinates& point) const;
double distanceTo(const Point& 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 Coordinates& point) const;
int16_t courseTo(const Point& point) const; int16_t courseTo(const Point& point) const;
@@ -89,6 +122,14 @@ class Point{
double getLatitude() const { return this->coordinates.lat; } double getLatitude() const { return this->coordinates.lat; }
Coordinates getCoordinates() const { return this->coordinates; } Coordinates getCoordinates() const { return this->coordinates; }
/**
* @brief Get the Accuracy object
*
* The higher the value, the greater the accuracy.
* You can check it by PointAccuracy.
*
* @return PointAccuracy
*/
PointAccuracy getAccuracy() { return this->accuracy; } PointAccuracy getAccuracy() { return this->accuracy; }
private: private:
@@ -124,32 +165,49 @@ struct RouteInfo{
class Route { class Route {
public: public:
/** /**
* @brief Construct a new Route object * @brief Construct a new Route object.
*/ */
Route(); Route();
/** /**
* @brief Adds a point to the list * @brief Adds a point to the list.
* *
* @param point * @param point
*/ */
void addPointToRoute(Point point); void addPointToRoute(Point point);
/**
* @brief Delete all points.
*
*/
void clear(); void clear();
/** /**
* @brief Select the first point as target * @brief Select the first point as target.
* *
* @return Point * @return Point
*/ */
Point startRoute(); Point startRoute();
/**
* @brief Select the last point as target.
*
* @return Point
*/
Point endRoute(); Point endRoute();
/** /**
* @brief Get the next point and set it as target * @brief Get the next point and set it as target.
* *
* @return Point is zero if there are no more Points * @return Point is zero if there are no more Points.
*/ */
Point getNextPoint(); Point getNextPoint();
/**
* @brief Get the previous point and set it as target.
*
* @return Point
*/
Point getPreviousPoint(); Point getPreviousPoint();
/** /**
@@ -158,6 +216,16 @@ class Route {
* @return RouteInfo * @return RouteInfo
*/ */
RouteInfo getRouteInfo(); 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; } bool getStarted() const { return this->started; }
private: private:
+6 -9
View File
@@ -1,7 +1,7 @@
/** /**
* @file NTRIPClient.cpp * @file NTRIPClient.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains the implementation of the class NTRIPClient.
* @version 0.1 * @version 0.1
* @date 2022-09-18 * @date 2022-09-18
* *
@@ -11,15 +11,8 @@
#include "ntripClient.h" #include "ntripClient.h"
NTRIPClient::NTRIPClient() {
} NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) {
NTRIPClient::~NTRIPClient() {
delete this->ntripClient;
}
void NTRIPClient::init(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) {
this->gps = gps; this->gps = gps;
strcpy(this->host, host); strcpy(this->host, host);
this->port = port; this->port = port;
@@ -31,6 +24,10 @@ void NTRIPClient::init(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, con
this->state = NTRIPClientStates::closeConnection; this->state = NTRIPClientStates::closeConnection;
} }
NTRIPClient::~NTRIPClient() {
delete this->ntripClient;
}
void NTRIPClient::loop() { void NTRIPClient::loop() {
if (millis() - this->lastLoopTime < this->delayTime) if (millis() - this->lastLoopTime < this->delayTime)
return; return;
+68 -4
View File
@@ -1,3 +1,14 @@
/**
* @file ntripClient.h
* @author Alexander Klein (alex@kleiax.de)
* @brief Contains the class NTRIPClient
* @version 0.1
* @date 2023-02-13
*
* @copyright Copyright (c) 2023
*
*/
#ifndef NTRIP_CLIENT #ifndef NTRIP_CLIENT
#define NTRIP_CLIENT #define NTRIP_CLIENT
@@ -9,6 +20,10 @@
#include "debugTimes.h" #include "debugTimes.h"
/**
* @brief States for the state machine.
*
*/
enum NTRIPClientStates { enum NTRIPClientStates {
openConnection, openConnection,
pushData, pushData,
@@ -16,24 +31,73 @@ enum NTRIPClientStates {
wait, wait,
notAvailable 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 { class NTRIPClient {
public: public:
NTRIPClient(); /**
* @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(); ~NTRIPClient();
void init(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password); /**
* @brief Runs the state machine.
*
* See NTRIPClientStates for more information.
* Should be called ever main loop.
*/
void loop(); void loop();
/**
* @brief Configure the Gnss module to accept correction data
*
*/
void gpsConfiguration(); 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; } void setTransmitLocation(bool b) { this->transmitLocation = b; }
/**
* @brief Activate or deactivate the connection to the server.
*
* @param b
* @return true success
* @return false failure
*/
bool setActivated(bool b); bool setActivated(bool b);
bool isConnected(); bool isConnected();
/**
* @brief Get the Client State object
*
* Returns the state of the State machine
*
* @return NTRIPClientStates
*/
NTRIPClientStates getClientState() { return this->state; } NTRIPClientStates getClientState() { return this->state; }
private: private:
void pushGPGGA(NMEA_GGA_data_t *nmeaData); void pushGPGGA(NMEA_GGA_data_t *nmeaData);
bool beginClient(); bool beginClient();
+15
View File
@@ -100,7 +100,22 @@ class Speedometer {
*/ */
double getSpeed(); double getSpeed();
/**
* @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(); 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(); uint16_t calibrationMeasurementStop();
+5
View File
@@ -59,6 +59,11 @@ class DebugTimes {
*/ */
uint16_t stopConsol(const char* name, uint16_t minTime = 0); 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); static void setConsolOutput(bool enable);
private: private:
+1
View File
@@ -27,6 +27,7 @@ lib_deps =
marian-craciunescu/ESP32Ping@^1.7 marian-craciunescu/ESP32Ping@^1.7
bblanchon/ArduinoJson@^6.20.0 bblanchon/ArduinoJson@^6.20.0
mprograms/QMC5883LCompass@^1.1.1 mprograms/QMC5883LCompass@^1.1.1
https://git.kleiax.de/PlatformIO-Libs/Menu.git
upload_port = COM3 upload_port = COM3
[env:release] [env:release]
+18
View File
@@ -40,7 +40,25 @@ class OutputBuf : public std::streambuf {
* @param debugMqtt * @param debugMqtt
*/ */
OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr); 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); 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); void activateSerialBT(bool status);
void setDebugMqtt(DebugMqtt* debugMqtt); void setDebugMqtt(DebugMqtt* debugMqtt);
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file menuRoute.cpp * @file menuRoute.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains the implementation of the classes MenuActionRoute, MenuRoute and MenuRouteWrapper.
* @version 0.1 * @version 0.1
* @date 2022-12-28 * @date 2022-12-28
* *
+78 -2
View File
@@ -1,7 +1,7 @@
/** /**
* @file menuRoute.h * @file menuRoute.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a classes to handles routes with the user input.
* @version 0.1 * @version 0.1
* @date 2022-12-28 * @date 2022-12-28
* *
@@ -28,9 +28,25 @@
class MenuRoute; class MenuRoute;
typedef void (MenuRoute::*DataFunction)(uint8_t); 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 { class MenuActionRoute : public MenuActionWrapper {
public: public:
/**
* @brief Construct a new Menu Action Route object
*
* @param menuRoute
* @param dataFunction like exportRoute
*/
MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction); MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction);
/**
* @brief Runs the given DataFunction
*/
void action() override; void action() override;
private: private:
@@ -38,21 +54,66 @@ class MenuActionRoute : public MenuActionWrapper {
DataFunction dataFunction; DataFunction dataFunction;
}; };
/**
* @brief Handles routes
*
* With this menu the user can import, export and delete routes.
*/
class MenuRoute : public MenuControl { class MenuRoute : public MenuControl {
public: public:
/**
* @brief Construct a new Menu Route object
*
* @param route
*/
MenuRoute(Route* route); MenuRoute(Route* route);
~MenuRoute(); ~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; void printMenu() override;
/**
* @name User Inputs
* @brief Inputs given by the parentMenu
*/
///@{
void down() override; void down() override;
void up() override; void up() override;
void right() override; void right() override;
void left() override; void left() override;
void yes() override; void yes() override;
void no() 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); 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); void exportRoute(uint8_t routeNumber);
/**
* @brief Delete the current Route.
*
* @param none this param is not be used.
*/
void clearRoute(uint8_t none); void clearRoute(uint8_t none);
private: private:
@@ -65,11 +126,26 @@ class MenuRoute : public MenuControl {
bool blockInput = false; bool blockInput = false;
}; };
/**
* @brief MenuRouteWrapper to call DataFunctions with numeric user input
*
*/
class MenuRouteWrapper : public MenuIntInputWrapper { class MenuRouteWrapper : public MenuIntInputWrapper {
public: public:
/**
* @brief Construct a new Menu Route Wrapper object.
*
* @param menuRoute
* @param dataFunction
*/
MenuRouteWrapper(MenuRoute* menuRoute, DataFunction 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; void action(int16_t* values, uint8_t length) override;
private: private:
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file menuRoutePoints.cpp * @file menuRoutePoints.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains the implementation of the class MenuRoutePoints.
* @version 0.1 * @version 0.1
* @date 2022-12-28 * @date 2022-12-28
* *
+19 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file menuRoutePoints.h * @file menuRoutePoints.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a class to print the coordinates of a Route.
* @version 0.1 * @version 0.1
* @date 2022-12-28 * @date 2022-12-28
* *
@@ -16,11 +16,29 @@
#include "route.h" #include "route.h"
#include "menuInformationSites.h" #include "menuInformationSites.h"
/**
* @brief Prints coordinates of Route side by side.
*
*/
class MenuRoutePoints : public MenuInformationSites { class MenuRoutePoints : public MenuInformationSites {
public: public:
/**
* @brief Construct a new Menu Route Points object
*
* @param route
*/
MenuRoutePoints(Route *route); MenuRoutePoints(Route *route);
/**
* @brief Configure the base class MenuInformationSites
*
* Set the amount of pages.
*/
void init () override; void init () override;
/**
* @brief Prints the the coordinates of the current Point.
*/
void printPage() const override; void printPage() const override;
private: private:
@@ -18,8 +18,19 @@
#include "menuInformationSites.h" #include "menuInformationSites.h"
#include "battery.h" #include "battery.h"
/**
* @brief Prints information about the current system status.
*
* The informations are about the batteries, memory and uptime.
*/
class MenuSysteminformation : public MenuInformationSites { class MenuSysteminformation : public MenuInformationSites {
public: public:
/**
* @brief Construct a new Menu Systeminformation object
*
* @param mainBattery
* @param gamepad
*/
MenuSysteminformation(Battery* mainBattery, Ps3Controller* gamepad); MenuSysteminformation(Battery* mainBattery, Ps3Controller* gamepad);
private: private:
@@ -1,7 +1,7 @@
/** /**
* @file menuTestMode.cpp * @file menuTestMode.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains the implementation of the class MenuTestMode.
* @version 0.1 * @version 0.1
* @date 2022-09-08 * @date 2022-09-08
* *
@@ -1,7 +1,7 @@
/** /**
* @file menuTestMode.h * @file menuTestMode.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a class to use and print information about the TestMode.
* @version 0.1 * @version 0.1
* @date 2022-09-08 * @date 2022-09-08
* *
@@ -17,11 +17,35 @@
#include "menuAction.h" #include "menuAction.h"
#include "menuIntInput.h" #include "menuIntInput.h"
/**
* @brief Interact with the TestMode
*
*/
class MenuTestMode : public MenuDriveMode { class MenuTestMode : public MenuDriveMode {
public: public:
/**
* @brief Construct a new Menu Test Mode object
*
* @param driveManager
*/
MenuTestMode(DriveManager *driveManager); MenuTestMode(DriveManager *driveManager);
~MenuTestMode(); ~MenuTestMode();
void printMenu();
/**
* @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(); void printManeuverTime();
void down() override; void down() override;
@@ -31,6 +55,10 @@ class MenuTestMode : public MenuDriveMode {
void yes() override; void yes() override;
void no() override; void no() override;
/**
* @brief Calls the printManeuverTime function if a maneuver is in process.
*
*/
void update() override; void update() override;
TestMode* getTestMode() const { return this->testMode; } TestMode* getTestMode() const { return this->testMode; }
@@ -30,8 +30,17 @@ class MenuDriveMode : public MenuControl {
void down() override {} void down() override {}
void up() override {} void up() override {}
void right() override {} void right() override {}
/**
* @brief Goes back to the parentMenu.
*/
void left() override; void left() override;
/**
* @brief Calls left.
*/
void no() override; void no() override;
void yes() override {} void yes() override {}
virtual void printMenu() = 0; virtual void printMenu() = 0;
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file testMode.cpp * @file testMode.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains the implementation of the class TestMode.
* @version 0.1 * @version 0.1
* @date 2022-09-08 * @date 2022-09-08
* *
+75 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file testMode.h * @file testMode.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a class to test different functions from the rover.
* @version 0.1 * @version 0.1
* @date 2022-09-08 * @date 2022-09-08
* *
@@ -17,8 +17,18 @@
#include "navigation.h" #include "navigation.h"
#include "driveModi/driveModi.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 { class TestMode : public DriveModi {
public: public:
/**
* @brief Different states to test the engine
*
*/
enum Maneuver { enum Maneuver {
None, None,
LeftEngine, LeftEngine,
@@ -28,23 +38,87 @@ class TestMode : public DriveModi {
Drive Drive
}; };
/**
* @brief Construct a new Test Mode object
*
* @param moveControl
* @param navigation
*/
TestMode(MoveControl *moveControl, Navigation* navigation); TestMode(MoveControl *moveControl, Navigation* navigation);
~TestMode(); ~TestMode();
/**
* @brief Controls the maneuver.
*
* Needed for actions which take a longer time.
* Should be called ever main loop.
*/
void loop() override; void loop() override;
/**
* @brief Set the speed for the Maneuver Drive
*
* @param speed m/s / 100
*/
void setSpeed(int16_t speed); void setSpeed(int16_t speed);
/**
* @brief Set the rotation speed for the Maneuver Drive
*
* @param speed rad/s / 100
*/
void setRotationSpeed(int16_t speed); void setRotationSpeed(int16_t speed);
bool drive(int16_t cm = 0, int16_t degree = 0); bool drive(int16_t cm = 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); 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); 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); 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(); void abortManeuver();
uint8_t getRemainingManeuverTime(); uint8_t getRemainingManeuverTime();
/**
* @brief Returns true if a maneuver is running
*
* @return true
* @return false
*/
bool getBusy() const { return this->busy; } bool getBusy() const { return this->busy; }
Maneuver getManeuver() const { return this->maneuver; } Maneuver getManeuver() const { return this->maneuver; }
+21 -21
View File
@@ -50,7 +50,7 @@ MoveControl moveController;
DriveManager* driveManager; DriveManager* driveManager;
Menu* main_m; Menu* main_m;
LiquidCrystal_I2C* lcd; LiquidCrystal_I2C* lcd;
DisplayWrapper* lcdWrapper; LcdWrapper* lcdWrapper;
OutputBuf* outputBuf; OutputBuf* outputBuf;
DebugMqtt* debugMqtt = nullptr; DebugMqtt* debugMqtt = nullptr;
Battery* mainBattery; Battery* mainBattery;
@@ -125,7 +125,7 @@ void setup() {
lcd->printf("%c Kleiax-Rover %c", wifiIndicator, wifiIndicator); lcd->printf("%c Kleiax-Rover %c", wifiIndicator, wifiIndicator);
lcd->setCursor(0, 1); lcd->setCursor(0, 1);
lcd->print("Press PS-Button"); lcd->print("Press PS-Button");
lcdWrapper = new DisplayWrapper(lcd); lcdWrapper = new LcdWrapper(lcd);
makeMenu(); makeMenu();
@@ -280,17 +280,17 @@ void makeMenu() {
// Set Menus on LCD // Set Menus on LCD
main_m->setLcd(lcdWrapper); main_m->setLcd(lcdWrapper);
mode_m->setLcd(lcdWrapper); mode_m->setLcd(lcdWrapper);
pid_m->setLcd(lcdWrapper); pid_m->setLcd(LcdWrapper);
pidl_m->setLcd(lcdWrapper); pidl_m->setLcd(LcdWrapper);
pidr_m->setLcd(lcdWrapper); pidr_m->setLcd(LcdWrapper);
man_m->setLcd(lcdWrapper); man_m->setLcd(LcdWrapper);
cap_m->setLcd(lcdWrapper); cap_m->setLcd(LcdWrapper);
auto_m->setLcd(lcdWrapper); auto_m->setLcd(LcdWrapper);
testM_m->setLcd(lcdWrapper); testM_m->setLcd(LcdWrapper);
gps_m->setLcd(lcdWrapper); gps_m->setLcd(LcdWrapper);
sys_m->setLcd(lcdWrapper); sys_m->setLcd(LcdWrapper);
rout_m->setLcd(lcdWrapper); rout_m->setLcd(LcdWrapper);
test_m->setLcd(lcdWrapper); test_m->setLcd(LcdWrapper);
// Entry for the main menu // Entry for the main menu
@@ -342,17 +342,17 @@ void makeMenu() {
} }
void restart(void) { void restart(void) {
lcdWrapper->clear(); LcdWrapper->clear();
lcdWrapper->setCursor(0, 0); LcdWrapper->setCursor(0, 0);
lcdWrapper->print("Rebooting ..."); LcdWrapper->print("Rebooting ...");
ESP.restart(); ESP.restart();
} }
void disconnectController(void) { void disconnectController(void) {
disconnectPs3 = true; disconnectPs3 = true;
lcdWrapper->clear(); LcdWrapper->clear();
lcdWrapper->setCursor(0, 0); LcdWrapper->setCursor(0, 0);
lcdWrapper->print("Controller is"); LcdWrapper->print("Controller is");
lcdWrapper->setCursor(0, 1); LcdWrapper->setCursor(0, 1);
lcdWrapper->print("disconnected."); LcdWrapper->print("disconnected.");
} }