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