clangtidy corrections part 1
This commit is contained in:
@@ -1,36 +1,44 @@
|
||||
/**
|
||||
* @file menuRoute.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the implementation of the classes MenuActionRoute, MenuRoute and MenuRouteWrapper.
|
||||
* @brief Contains the implementation of the classes MenuActionRoute, MenuRoute and MenuRouteWrapper.
|
||||
* @version 0.1
|
||||
* @date 2022-12-28
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuRoute.h"
|
||||
|
||||
MenuActionRoute::MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction) {
|
||||
MenuActionRoute::MenuActionRoute(MenuRoute *menuRoute, DataFunction dataFunction)
|
||||
{
|
||||
this->menuRoute = menuRoute;
|
||||
this->dataFunction = dataFunction;
|
||||
}
|
||||
|
||||
void MenuActionRoute::action() {
|
||||
void MenuActionRoute::action()
|
||||
{
|
||||
(this->menuRoute->*this->dataFunction)(0);
|
||||
}
|
||||
|
||||
MenuRoute::MenuRoute(Route* route) {
|
||||
MenuRoute::MenuRoute(Route *route)
|
||||
{
|
||||
this->route = route;
|
||||
}
|
||||
|
||||
MenuRoute::~MenuRoute() {
|
||||
MenuRoute::~MenuRoute()
|
||||
{
|
||||
if (isInit)
|
||||
{
|
||||
delete this->mainMenu;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuRoute::printMenu() {
|
||||
if (!this->isInit) {
|
||||
void MenuRoute::printMenu()
|
||||
{
|
||||
if (!this->isInit)
|
||||
{
|
||||
this->isInit = true;
|
||||
this->init();
|
||||
}
|
||||
@@ -38,72 +46,103 @@ void MenuRoute::printMenu() {
|
||||
this->mainMenu->printMenu();
|
||||
}
|
||||
|
||||
|
||||
void MenuRoute::down() {
|
||||
if (blockInput) return;
|
||||
void MenuRoute::down()
|
||||
{
|
||||
if (blockInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->mainMenu->down();
|
||||
}
|
||||
|
||||
void MenuRoute::up() {
|
||||
if (blockInput) return;
|
||||
void MenuRoute::up()
|
||||
{
|
||||
if (blockInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->mainMenu->up();
|
||||
}
|
||||
|
||||
void MenuRoute::right() {
|
||||
if (blockInput) return;
|
||||
void MenuRoute::right()
|
||||
{
|
||||
if (blockInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->mainMenu->right();
|
||||
}
|
||||
|
||||
void MenuRoute::left() {
|
||||
if (blockInput) return;
|
||||
void MenuRoute::left()
|
||||
{
|
||||
if (blockInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
{
|
||||
this->mainMenu->left();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuRoute::yes() {
|
||||
if (blockInput) return;
|
||||
void MenuRoute::yes()
|
||||
{
|
||||
if (blockInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->mainMenu->yes();
|
||||
}
|
||||
|
||||
void MenuRoute::no() {
|
||||
if (blockInput) return;
|
||||
void MenuRoute::no()
|
||||
{
|
||||
if (blockInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
{
|
||||
this->mainMenu->no();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->left();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MenuRoute::init() {
|
||||
void MenuRoute::init()
|
||||
{
|
||||
// auto dummy = []() {
|
||||
// std::cout << "Dummy in Action" <<std::endl;
|
||||
// };
|
||||
|
||||
this->mainMenu = new Menu;
|
||||
MenuRoutePoints* pointsMenu = new MenuRoutePoints(this->route);
|
||||
auto *pointsMenu = new MenuRoutePoints(this->route);
|
||||
|
||||
this->mainMenu->setLcd(this->lcd);
|
||||
pointsMenu->setLcd(this->lcd);
|
||||
|
||||
auto importWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::importRoute));
|
||||
auto exportWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::exportRoute));
|
||||
auto deleteWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::deleteRoute));
|
||||
auto clearWrapper = new MenuActionRoute(this, &MenuRoute::clearRoute);
|
||||
auto *importWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::importRoute));
|
||||
auto *exportWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::exportRoute));
|
||||
auto *deleteWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::deleteRoute));
|
||||
auto *clearWrapper = new MenuActionRoute(this, &MenuRoute::clearRoute);
|
||||
|
||||
importWrapper->setLcd(this->lcd);
|
||||
importWrapper->setMinMax(0, 100);
|
||||
importWrapper->setMinMax(0, MenuRoute::maxRouteNumber);
|
||||
importWrapper->setPrintParentMenu(false);
|
||||
importWrapper->setEntry(0, "Import Route");
|
||||
|
||||
exportWrapper->setLcd(this->lcd);
|
||||
exportWrapper->setMinMax(0, 100);
|
||||
exportWrapper->setMinMax(0, MenuRoute::maxRouteNumber);
|
||||
exportWrapper->setPrintParentMenu(false);
|
||||
exportWrapper->setEntry(0, "Export Route");
|
||||
|
||||
deleteWrapper->setLcd(this->lcd);
|
||||
deleteWrapper->setMinMax(0, 100);
|
||||
deleteWrapper->setMinMax(0, MenuRoute::maxRouteNumber);
|
||||
deleteWrapper->setPrintParentMenu(false);
|
||||
deleteWrapper->setEntry(0, "Delete Route");
|
||||
|
||||
@@ -114,13 +153,15 @@ void MenuRoute::init() {
|
||||
this->mainMenu->addEntry(new MenuAction("Delete", deleteWrapper));
|
||||
}
|
||||
|
||||
void MenuRoute::importRoute(uint8_t routeNumber) {
|
||||
void MenuRoute::importRoute(uint8_t routeNumber)
|
||||
{
|
||||
this->blockInput = true;
|
||||
|
||||
String lineOne = "";
|
||||
String lineTwo = "";
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
lineOne = "Not connected to";
|
||||
lineTwo = "the WiFi.";
|
||||
this->print(lineOne, lineTwo);
|
||||
@@ -128,7 +169,8 @@ void MenuRoute::importRoute(uint8_t routeNumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) {
|
||||
if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE)
|
||||
{
|
||||
lineOne = "Not enough mem";
|
||||
lineTwo = "for Json obj";
|
||||
this->print(lineOne, lineTwo);
|
||||
@@ -139,7 +181,7 @@ void MenuRoute::importRoute(uint8_t routeNumber) {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
DynamicJsonDocument doc(JSON_DOCUMENT_SIZE_ROUTE);
|
||||
|
||||
|
||||
String host = "http://rover.kleiax.de/api/";
|
||||
host.concat(routeNumber);
|
||||
http.begin(client, host);
|
||||
@@ -149,14 +191,19 @@ void MenuRoute::importRoute(uint8_t routeNumber) {
|
||||
lineTwo = "Code: ";
|
||||
|
||||
if (httpResponseCode == 202)
|
||||
{
|
||||
deserializeJson(doc, http.getStream());
|
||||
}
|
||||
else
|
||||
{
|
||||
lineOne = "HTTP Error";
|
||||
}
|
||||
|
||||
lineTwo.concat(httpResponseCode);
|
||||
this->print(lineOne, lineTwo);
|
||||
|
||||
if (httpResponseCode <= 0) {
|
||||
if (httpResponseCode <= 0)
|
||||
{
|
||||
this->blockInput = false;
|
||||
return;
|
||||
}
|
||||
@@ -164,7 +211,8 @@ void MenuRoute::importRoute(uint8_t routeNumber) {
|
||||
uint16_t totalPoints = doc["amountPoints"];
|
||||
|
||||
this->route->clear();
|
||||
for (uint16_t i = 0; i < totalPoints; i++) {
|
||||
for (uint16_t i = 0; i < totalPoints; i++)
|
||||
{
|
||||
Point::Coordinates coords;
|
||||
coords.lat = doc["points"][i][0].as<double>();
|
||||
coords.lon = doc["points"][i][1].as<double>();
|
||||
@@ -175,14 +223,16 @@ void MenuRoute::importRoute(uint8_t routeNumber) {
|
||||
http.end();
|
||||
}
|
||||
|
||||
void MenuRoute::exportRoute(uint8_t routeNumber) {
|
||||
void MenuRoute::exportRoute(uint8_t routeNumber)
|
||||
{
|
||||
this->blockInput = true;
|
||||
uint16_t totalPoints = this->route->getRouteInfo().totalPoints;
|
||||
|
||||
String lineOne = "";
|
||||
String lineTwo = "";
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
lineOne = "Not connected to";
|
||||
lineTwo = "the WiFi.";
|
||||
this->print(lineOne, lineTwo);
|
||||
@@ -190,7 +240,8 @@ void MenuRoute::exportRoute(uint8_t routeNumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) {
|
||||
if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE)
|
||||
{
|
||||
lineOne = "Not enough mem";
|
||||
lineTwo = "for Json obj";
|
||||
this->print(lineOne, lineTwo);
|
||||
@@ -205,7 +256,8 @@ void MenuRoute::exportRoute(uint8_t routeNumber) {
|
||||
Point::Coordinates coords = this->route->startRoute().getCoordinates();
|
||||
doc["points"][0][0] = coords.lat;
|
||||
doc["points"][0][1] = coords.lon;
|
||||
for (uint16_t i = 1; i < totalPoints; i++) {
|
||||
for (uint16_t i = 1; i < totalPoints; i++)
|
||||
{
|
||||
coords = this->route->getNextPoint().getCoordinates();
|
||||
doc["points"][i][0] = coords.lat;
|
||||
doc["points"][i][1] = coords.lon;
|
||||
@@ -215,30 +267,36 @@ void MenuRoute::exportRoute(uint8_t routeNumber) {
|
||||
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
|
||||
|
||||
http.begin(client, "http://rover.kleiax.de/api/");
|
||||
http.addHeader("Content-Type", "application/json");
|
||||
int httpResponseCode = http.POST(jsonData);
|
||||
|
||||
if (httpResponseCode == 201)
|
||||
{
|
||||
lineOne = "Export complete";
|
||||
}
|
||||
else
|
||||
{
|
||||
lineOne = "HTTP Error";
|
||||
}
|
||||
lineTwo = "Code: ";
|
||||
lineTwo.concat(httpResponseCode);
|
||||
this->print(lineOne, lineTwo);
|
||||
this->blockInput = false;
|
||||
|
||||
|
||||
http.end();
|
||||
}
|
||||
|
||||
void MenuRoute::deleteRoute(uint8_t routeNumber) {
|
||||
void MenuRoute::deleteRoute(uint8_t routeNumber)
|
||||
{
|
||||
this->blockInput = true;
|
||||
|
||||
String lineOne = "";
|
||||
String lineTwo = "";
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
lineOne = "Not connected to";
|
||||
lineTwo = "the WiFi.";
|
||||
this->print(lineOne, lineTwo);
|
||||
@@ -246,7 +304,8 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) {
|
||||
if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE)
|
||||
{
|
||||
lineOne = "Not enough mem";
|
||||
lineTwo = "for Json obj";
|
||||
this->print(lineOne, lineTwo);
|
||||
@@ -257,7 +316,7 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
DynamicJsonDocument doc(JSON_DOCUMENT_SIZE_ROUTE);
|
||||
|
||||
|
||||
String host = "http://rover.kleiax.de/api/";
|
||||
host.concat(routeNumber);
|
||||
http.begin(client, host);
|
||||
@@ -267,9 +326,13 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) {
|
||||
lineTwo = "Code: ";
|
||||
|
||||
if (httpResponseCode == 202)
|
||||
{
|
||||
deserializeJson(doc, http.getStream());
|
||||
}
|
||||
else
|
||||
{
|
||||
lineOne = "HTTP Error";
|
||||
}
|
||||
|
||||
lineTwo.concat(httpResponseCode);
|
||||
this->print(lineOne, lineTwo);
|
||||
@@ -278,29 +341,37 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) {
|
||||
http.end();
|
||||
}
|
||||
|
||||
void MenuRoute::clearRoute(uint8_t none) {
|
||||
void MenuRoute::clearRoute(uint8_t none)
|
||||
{
|
||||
//The parameter exist only for compability
|
||||
none;
|
||||
this->route->clear();
|
||||
this->print("Currente route", "deleted...");
|
||||
}
|
||||
|
||||
MenuRouteWrapper::MenuRouteWrapper(MenuRoute* menuRoute, DataFunction dataFunction) {
|
||||
this->menuRoute = menuRoute;
|
||||
this->dataFunction = dataFunction;
|
||||
MenuRouteWrapper::MenuRouteWrapper(MenuRoute *menuRoute, DataFunction dataFunction)
|
||||
: menuRoute {menuRoute}, dataFunction {dataFunction}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MenuRouteWrapper::action(int16_t* values, uint8_t length) {
|
||||
if (length < 1) {
|
||||
void MenuRouteWrapper::action(int16_t *values, uint8_t length)
|
||||
{
|
||||
if (length < 1)
|
||||
{
|
||||
std::cout << "Error in MenuRouteWrapper::action" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (values[0] < 0)
|
||||
{
|
||||
values[0] = 0;
|
||||
}
|
||||
|
||||
if (values[0] > UINT8_MAX)
|
||||
{
|
||||
values[0] = UINT8_MAX;
|
||||
}
|
||||
|
||||
(this->menuRoute->*this->dataFunction)(values[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -126,6 +126,12 @@ class MenuRoute : public MenuControl {
|
||||
|
||||
bool isInit = false;
|
||||
bool blockInput = false;
|
||||
|
||||
static constexpr uint8_t maxRouteNumber = 100;
|
||||
static constexpr uint16_t httpValidExport = 201;
|
||||
static constexpr uint16_t httpValidImport = 202;
|
||||
static constexpr uint16_t httpValidDelete = 202;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
*/
|
||||
#include "menuTestMode.h"
|
||||
|
||||
MenuTestMode::MenuTestMode(DriveManager* driveManager) {
|
||||
this->driveManager = driveManager;
|
||||
MenuTestMode::MenuTestMode(DriveManager* driveManager)
|
||||
: driveManager {driveManager}
|
||||
{
|
||||
}
|
||||
|
||||
MenuTestMode::~MenuTestMode() {
|
||||
@@ -30,73 +31,77 @@ void MenuTestMode::printMenu() {
|
||||
}
|
||||
|
||||
void MenuTestMode::down() {
|
||||
if (this->checkInput())
|
||||
if (this->checkInput()) {
|
||||
this->mainMenu->down();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuTestMode::up() {
|
||||
if (this->checkInput())
|
||||
if (this->checkInput()) {
|
||||
this->mainMenu->up();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuTestMode::right() {
|
||||
if (this->checkInput())
|
||||
if (this->checkInput()) {
|
||||
this->mainMenu->right();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuTestMode::left() {
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
if (this->checkInput())
|
||||
if (this->checkInput()) {
|
||||
this->mainMenu->left();
|
||||
}
|
||||
else {
|
||||
this->testMode->abortManeuver();
|
||||
this->mainMenu->left();
|
||||
}
|
||||
else
|
||||
else {
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuTestMode::yes() {
|
||||
if (this->checkInput())
|
||||
if (this->checkInput()) {
|
||||
this->mainMenu->yes();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuTestMode::no() {
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
if (this->mainMenu->isInSubmenu()) {
|
||||
if (this->checkInput())
|
||||
this->mainMenu->no();
|
||||
else {
|
||||
this->testMode->abortManeuver();
|
||||
this->mainMenu->no();
|
||||
}
|
||||
else
|
||||
this->left();
|
||||
}}
|
||||
else{
|
||||
this->left();}
|
||||
}
|
||||
|
||||
void MenuTestMode::init() {
|
||||
this->testMode = new TestMode();
|
||||
this->driveManager->changeModus(this->testMode);
|
||||
|
||||
this->testMode->setSpeeds(DrivingSpeeds{1, 8});
|
||||
|
||||
auto dummy = []() {
|
||||
std::cout << "Dummy in Action" <<std::endl;
|
||||
};
|
||||
|
||||
// Create menu
|
||||
this->mainMenu = new Menu;
|
||||
auto engineMenu = new Menu;
|
||||
auto lightMenu = new Menu;
|
||||
auto encoderMenu = new Menu;
|
||||
auto *engineMenu = new Menu;
|
||||
auto *lightMenu = new Menu;
|
||||
auto *encoderMenu = new Menu;
|
||||
// Sound
|
||||
// Ping google
|
||||
|
||||
auto drivingMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::drive));
|
||||
auto engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine));
|
||||
auto engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine));
|
||||
auto engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine));
|
||||
auto encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft());
|
||||
auto encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight());
|
||||
auto *drivingMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::drive));
|
||||
auto *engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine));
|
||||
auto *engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine));
|
||||
auto *engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine));
|
||||
auto *encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft());
|
||||
auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight());
|
||||
|
||||
|
||||
// Set menus on LCD
|
||||
@@ -112,47 +117,52 @@ void MenuTestMode::init() {
|
||||
encoderRightMenu->setLcd(this->lcd);
|
||||
|
||||
// Other menu config
|
||||
static constexpr uint8_t percentMax = 100;
|
||||
static constexpr uint8_t degreeMax = 360;
|
||||
static constexpr uint8_t secondsMax = 120;
|
||||
static constexpr uint8_t steps = 5;
|
||||
|
||||
drivingMenu->setEntry(0, "Centimeter", 100);
|
||||
drivingMenu->setMinMaxSteps(0, -1000, 1000, 25);
|
||||
drivingMenu->setMinMaxSteps(0, -1000, 1000, steps * 5);
|
||||
drivingMenu->setEntry(1, "Degree");
|
||||
drivingMenu->setMinMaxSteps(1, -360, 360, 15);
|
||||
drivingMenu->setMinMaxSteps(1, -degreeMax, degreeMax, steps * 3);
|
||||
drivingMenu->setPrintParentMenu(false);
|
||||
engineLeftMenu->setEntry(0, "Percentage");
|
||||
engineLeftMenu->setMinMaxSteps(0, -100, 100, 5);
|
||||
engineLeftMenu->setEntry(1, "Seconds", 5);
|
||||
engineLeftMenu->setMinMaxSteps(1, 0, 120, 1);
|
||||
engineLeftMenu->setMinMaxSteps(0, -percentMax, percentMax, steps);
|
||||
engineLeftMenu->setEntry(1, "Seconds", steps);
|
||||
engineLeftMenu->setMinMaxSteps(1, 0, secondsMax, 1);
|
||||
engineLeftMenu->setPrintParentMenu(false);
|
||||
engineRightMenu->setEntry(0, "Percentage");
|
||||
engineRightMenu->setMinMaxSteps(0, -100, 100, 5);
|
||||
engineRightMenu->setEntry(1, "Seconds", 5);
|
||||
engineRightMenu->setMinMaxSteps(1, 0, 120, 1);
|
||||
engineRightMenu->setMinMaxSteps(0, -percentMax, percentMax, steps);
|
||||
engineRightMenu->setEntry(1, "Seconds", steps);
|
||||
engineRightMenu->setMinMaxSteps(1, 0, secondsMax, 1);
|
||||
engineRightMenu->setPrintParentMenu(false);
|
||||
engineBothMenu->setEntry(0, "Percentage");
|
||||
engineBothMenu->setMinMaxSteps(0, -100, 100, 5);
|
||||
engineBothMenu->setEntry(1, "Seconds", 5);
|
||||
engineBothMenu->setMinMaxSteps(1, 0, 120, 1);
|
||||
engineBothMenu->setMinMaxSteps(0, -percentMax, percentMax, steps);
|
||||
engineBothMenu->setEntry(1, "Seconds", steps);
|
||||
engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1);
|
||||
engineBothMenu->setPrintParentMenu(false);
|
||||
|
||||
|
||||
// Entrys for the menus
|
||||
MenuAction* engineAction = new MenuAction("Engine", engineMenu);
|
||||
MenuAction* engineLeftAction = new MenuAction("Left", engineLeftMenu);
|
||||
MenuAction* engineRightAction = new MenuAction("Right", engineRightMenu);
|
||||
MenuAction* engineBothAction = new MenuAction("Both", engineBothMenu);
|
||||
auto *engineAction = new MenuAction("Engine", engineMenu);
|
||||
auto *engineLeftAction = new MenuAction("Left", engineLeftMenu);
|
||||
auto *engineRightAction = new MenuAction("Right", engineRightMenu);
|
||||
auto *engineBothAction = new MenuAction("Both", engineBothMenu);
|
||||
|
||||
MenuAction* drivingAction = new MenuAction("Driving", drivingMenu);
|
||||
auto *drivingAction = new MenuAction("Driving", drivingMenu);
|
||||
|
||||
MenuAction* encoderAction = new MenuAction("Encoder", encoderMenu);
|
||||
MenuAction* encoderLeftAction = new MenuAction("Left", encoderLeftMenu);
|
||||
MenuAction* encoderRightAction = new MenuAction("Right", encoderRightMenu);
|
||||
auto *encoderAction = new MenuAction("Encoder", encoderMenu);
|
||||
auto *encoderLeftAction = new MenuAction("Left", encoderLeftMenu);
|
||||
auto *encoderRightAction = new MenuAction("Right", encoderRightMenu);
|
||||
|
||||
MenuAction* lightAction = new MenuAction("Light", lightMenu);
|
||||
MenuAction* lightFlashAction = new MenuAction("Flash", dummy);
|
||||
MenuAction* lightFadeAction = new MenuAction("Fade", dummy);
|
||||
MenuAction* lightRedAction = new MenuAction("Red", dummy);
|
||||
MenuAction* lightGreenAction = new MenuAction("Green", dummy);
|
||||
MenuAction* lightBlueAction = new MenuAction("Blue", dummy);
|
||||
MenuAction* lightOffAction = new MenuAction("Off", dummy);
|
||||
auto *lightAction = new MenuAction("Light", lightMenu);
|
||||
auto *lightFlashAction = new MenuAction("Flash", dummy);
|
||||
auto *lightFadeAction = new MenuAction("Fade", dummy);
|
||||
auto *lightRedAction = new MenuAction("Red", dummy);
|
||||
auto *lightGreenAction = new MenuAction("Green", dummy);
|
||||
auto *lightBlueAction = new MenuAction("Blue", dummy);
|
||||
auto *lightOffAction = new MenuAction("Off", dummy);
|
||||
|
||||
// Add entrys to the menus
|
||||
this->mainMenu->addEntry(engineAction);
|
||||
@@ -176,11 +186,11 @@ void MenuTestMode::init() {
|
||||
}
|
||||
|
||||
void MenuTestMode::update() {
|
||||
if (this->maneuverInAction)
|
||||
if (this->maneuverInAction) {
|
||||
if (millis() - this->lastUpdateTime > updateDelay) {
|
||||
this->printManeuverTime();
|
||||
this->lastUpdateTime = millis();
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
bool MenuTestMode::checkInput() {
|
||||
@@ -190,8 +200,9 @@ bool MenuTestMode::checkInput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->maneuverInAction)
|
||||
if (this->maneuverInAction) {
|
||||
this->maneuverInAction = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -209,16 +220,18 @@ void MenuTestMode::printManeuverTime() {
|
||||
}
|
||||
}
|
||||
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction) {
|
||||
this->menu = menu;
|
||||
this->testMode = this->menu->getTestMode();
|
||||
this->testModeFunctionSingle = testModeFunction;
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction)
|
||||
: menu {menu},
|
||||
testModeFunctionSingle {testModeFunction},
|
||||
testMode {menu->getTestMode()}
|
||||
{
|
||||
}
|
||||
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction) {
|
||||
this->menu = menu;
|
||||
this->testMode = this->menu->getTestMode();
|
||||
this->testModeFunctionDouble = testModeFunction;
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction)
|
||||
: menu {menu},
|
||||
testModeFunctionDouble {testModeFunction},
|
||||
testMode {menu->getTestMode()}
|
||||
{
|
||||
}
|
||||
|
||||
void MenuTestModeWrapper::action(int16_t* values, uint8_t length) {
|
||||
@@ -228,10 +241,12 @@ void MenuTestModeWrapper::action(int16_t* values, uint8_t length) {
|
||||
|
||||
bool res = false;
|
||||
|
||||
if (length == 2 && this->testModeFunctionDouble)
|
||||
if (length == 2 && static_cast<bool>(this->testModeFunctionDouble)) {
|
||||
res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]);
|
||||
else if (length == 1 && this->testModeFunctionSingle)
|
||||
}
|
||||
else if (length == 1 && static_cast<bool>(this->testModeFunctionSingle)) {
|
||||
res = (this->testMode->*this->testModeFunctionSingle)(values[0]);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
this->menu->printManeuverTime();
|
||||
|
||||
@@ -70,8 +70,8 @@ class MenuTestMode : public MenuControl {
|
||||
bool checkInput();
|
||||
|
||||
DriveManager* driveManager;
|
||||
TestMode* testMode;
|
||||
Menu* mainMenu;
|
||||
TestMode* testMode = nullptr;
|
||||
Menu* mainMenu = nullptr;
|
||||
|
||||
bool isInit = false;
|
||||
bool maneuverInAction = false;
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
|
||||
#include "speedometerTest.h"
|
||||
|
||||
SpeedometerTest::SpeedometerTest(Speedometer* speedometer) {
|
||||
this->speedometer = speedometer;
|
||||
SpeedometerTest::SpeedometerTest(Speedometer* speedometer)
|
||||
: speedometer {speedometer}
|
||||
{
|
||||
this->speedometer->setDirection(Speedometer::Forward);
|
||||
}
|
||||
|
||||
@@ -46,8 +47,9 @@ void SpeedometerTest::left() {
|
||||
}
|
||||
|
||||
void SpeedometerTest::no() {
|
||||
if (this->state == State::Running)
|
||||
if (this->state == State::Running){
|
||||
speedometer->calibrationMeasurementStop();
|
||||
}
|
||||
|
||||
this->state = State::Off;
|
||||
this->parentMenu->printMenu();
|
||||
|
||||
@@ -11,27 +11,28 @@
|
||||
|
||||
#include "menuDriveMode.h"
|
||||
|
||||
MenuDriveMode::MenuDriveMode(DriveManager* driveManager) {
|
||||
this->driveManager = driveManager;
|
||||
MenuDriveMode::MenuDriveMode(DriveManager* driveManager)
|
||||
: driveManager {driveManager}
|
||||
{
|
||||
}
|
||||
|
||||
void MenuDriveMode::left() {
|
||||
if (this->activeMenu) {
|
||||
if (this->activeMenu)
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
this->activeMenu->left();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this->firstPrint = true;
|
||||
this->configureOnLeave();
|
||||
if (this->menuSpeed)
|
||||
delete this->menuSpeed;
|
||||
this->driveManager->changeModus();
|
||||
MenuInformationSites::left();
|
||||
}
|
||||
|
||||
void MenuDriveMode::right() {
|
||||
if (this->activeMenu) {
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
this->activeMenu->right();
|
||||
return;
|
||||
}
|
||||
@@ -39,7 +40,7 @@ void MenuDriveMode::right() {
|
||||
}
|
||||
|
||||
void MenuDriveMode::up() {
|
||||
if (this->activeMenu) {
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
this->activeMenu->up();
|
||||
return;
|
||||
}
|
||||
@@ -47,7 +48,7 @@ void MenuDriveMode::up() {
|
||||
}
|
||||
|
||||
void MenuDriveMode::down() {
|
||||
if (this->activeMenu) {
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
this->activeMenu->down();
|
||||
return;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ void MenuDriveMode::down() {
|
||||
}
|
||||
|
||||
void MenuDriveMode::yes() {
|
||||
if (this->activeMenu) {
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
this->activeMenu->yes();
|
||||
return;
|
||||
}
|
||||
@@ -63,7 +64,7 @@ void MenuDriveMode::yes() {
|
||||
}
|
||||
|
||||
void MenuDriveMode::no() {
|
||||
if (this->activeMenu) {
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
this->activeMenu->no();
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +76,7 @@ void MenuDriveMode::prepareReenterMenu() {
|
||||
}
|
||||
|
||||
void MenuDriveMode::printMenu() {
|
||||
if (this->activeMenu) {
|
||||
if (static_cast<bool>(this->activeMenu)) {
|
||||
this->activeMenu->printMenu();
|
||||
return;
|
||||
}
|
||||
@@ -88,11 +89,12 @@ void MenuDriveMode::init() {
|
||||
}
|
||||
|
||||
void MenuDriveMode::activateSpeedMenu() {
|
||||
if (!this->driveManager->isActive())
|
||||
if (!this->driveManager->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DrivingSpeeds& speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef();
|
||||
MenuIntInput* menu = new MenuIntInput(2, new MenuSpeed(speeds));
|
||||
auto *menu = new MenuIntInput(2, new MenuSpeed(speeds));
|
||||
|
||||
menu->setMinMax(5, UINT8_MAX);
|
||||
menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10);
|
||||
@@ -112,8 +114,9 @@ void MenuDriveMode::enterSensorMenu() {
|
||||
}
|
||||
|
||||
void MenuDriveMode::enterMenu() {
|
||||
if (!this->activeMenu)
|
||||
if (!static_cast<bool>(this->activeMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->activeMenu->printMenu();
|
||||
this->activeMenu->setParentMenu(this);
|
||||
|
||||
Reference in New Issue
Block a user