added Route Menu
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @file menuRoute.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-12-28
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuRoute.h"
|
||||
|
||||
MenuRoute::MenuRoute(Route* route) {
|
||||
this->route = route;
|
||||
}
|
||||
|
||||
MenuRoute::~MenuRoute() {
|
||||
if (isInit)
|
||||
delete this->mainMenu;
|
||||
}
|
||||
|
||||
void MenuRoute::printMenu() {
|
||||
if (!this->isInit) {
|
||||
this->isInit = true;
|
||||
this->init();
|
||||
}
|
||||
|
||||
this->mainMenu->printMenu();
|
||||
}
|
||||
|
||||
|
||||
void MenuRoute::down() {
|
||||
this->mainMenu->down();
|
||||
}
|
||||
|
||||
void MenuRoute::up() {
|
||||
this->mainMenu->up();
|
||||
}
|
||||
|
||||
void MenuRoute::right() {
|
||||
this->mainMenu->right();
|
||||
}
|
||||
|
||||
void MenuRoute::left() {
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
this->mainMenu->left();
|
||||
else
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuRoute::yes() {
|
||||
this->mainMenu->yes();
|
||||
}
|
||||
|
||||
void MenuRoute::no() {
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
this->mainMenu->no();
|
||||
else
|
||||
this->left();
|
||||
}
|
||||
|
||||
|
||||
void MenuRoute::init() {
|
||||
auto dummy = []() {
|
||||
std::cout << "Dummy in Action" <<std::endl;
|
||||
};
|
||||
|
||||
this->mainMenu = new Menu;
|
||||
MenuRoutePoints* pointsMenu = new MenuRoutePoints(this->route);
|
||||
Menu* importMenu = new Menu;
|
||||
Menu* exportMenu = new Menu;
|
||||
|
||||
this->mainMenu->setLcd(this->lcd);
|
||||
pointsMenu->setLcd(this->lcd);
|
||||
importMenu->setLcd(this->lcd);
|
||||
exportMenu->setLcd(this->lcd);
|
||||
|
||||
MenuAction* pointsAction = new MenuAction("Points", pointsMenu);
|
||||
MenuAction* importAction = new MenuAction("Import", dummy);
|
||||
MenuAction* exportAction = new MenuAction("Export", dummy);
|
||||
|
||||
this->mainMenu->addEntry(pointsAction);
|
||||
this->mainMenu->addEntry(importAction);
|
||||
this->mainMenu->addEntry(exportAction);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file menuRoute.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-12-28
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MENU_ROUTE_H
|
||||
#define MENU_ROUTE_H
|
||||
|
||||
#include "route.h"
|
||||
#include "menu.h"
|
||||
#include "menuControl.h"
|
||||
#include "menuRoutePoints.h"
|
||||
|
||||
class MenuRoute : public MenuControl {
|
||||
public:
|
||||
MenuRoute(Route* route);
|
||||
~MenuRoute();
|
||||
void printMenu();
|
||||
|
||||
void down() override;
|
||||
void up() override;
|
||||
void right() override;
|
||||
void left() override;
|
||||
void yes() override;
|
||||
void no() override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
Route* route;
|
||||
Menu* mainMenu;
|
||||
|
||||
bool isInit = false;
|
||||
};
|
||||
|
||||
#endif // MENU_ROUTE_H
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @file menuRoutePoints.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-12-28
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuRoutePoints.h"
|
||||
|
||||
MenuRoutePoints::MenuRoutePoints(Route *route) : MenuInformationSites() {
|
||||
this->route = route;
|
||||
uint16_t amountPoints = this->route->getRouteInfo().totalPoints;
|
||||
if (amountPoints > UINT8_MAX)
|
||||
this->error = true;
|
||||
else
|
||||
this->setCountPages(amountPoints);
|
||||
}
|
||||
|
||||
void MenuRoutePoints::printPage() const {
|
||||
String lineOne = "N";
|
||||
String lineTwo = "E";
|
||||
|
||||
if (this->error) {
|
||||
lineOne = "Error: To much";
|
||||
lineTwo = "points are given";
|
||||
this->print(lineOne, lineTwo);
|
||||
return;
|
||||
}
|
||||
|
||||
RouteInfo info = this->route->getRouteInfo();
|
||||
if (info.totalPoints == 0) {
|
||||
lineOne = "No Points are";
|
||||
lineTwo = "available";
|
||||
this->print(lineOne, lineTwo);
|
||||
return;
|
||||
}
|
||||
|
||||
Point p;
|
||||
uint8_t currentPage = this->getCurrentPage();
|
||||
if (currentPage == 0)
|
||||
p = this->route->startRoute();
|
||||
else if (currentPage == this->getCountPages())
|
||||
p = this->route->endRoute();
|
||||
else if (this->lastPageNumber - 1 == currentPage)
|
||||
p = this->route->getPreviousPoint();
|
||||
else if (this->lastPageNumber + 1 == currentPage)
|
||||
p = this->route->getNextPoint();
|
||||
else
|
||||
std::cout << "Error in: MenuRoutePoints::printPage()" << std::endl;
|
||||
|
||||
lineOne.concat(p.getLatitude());
|
||||
lineOne.concat(" ");
|
||||
lineOne.concat(info.currentPoint);
|
||||
lineTwo.concat(p.getLongitude());
|
||||
lineTwo.concat(" ");
|
||||
lineTwo.concat(info.totalPoints);
|
||||
|
||||
this->print(lineOne, lineTwo);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @file menuRoutePoints.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-12-28
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MENU_ROUTE_POINTS_H
|
||||
#define MENU_ROUTE_POINTS_H
|
||||
|
||||
#include "navigation.h"
|
||||
#include "route.h"
|
||||
#include "menuInformationSites.h"
|
||||
|
||||
class MenuRoutePoints : public MenuInformationSites {
|
||||
public:
|
||||
MenuRoutePoints(Route *route);
|
||||
|
||||
void printPage() const override;
|
||||
|
||||
private:
|
||||
Route* route;
|
||||
uint8_t lastPageNumber = 0;
|
||||
bool error = false;
|
||||
|
||||
};
|
||||
|
||||
#endif // MENU_ROUTE_POINTS_H
|
||||
+8
-3
@@ -39,9 +39,10 @@
|
||||
#include "SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h"
|
||||
#include "SpecialMenus/driveModi/Autopilot/menuAutopilot.h"
|
||||
#include "SpecialMenus/driveModi/TestMode/menuTestMode.h"
|
||||
#include "SpecialMenus/PID/menuPidSettings.h"
|
||||
#include "SpecialMenus/GPS/menuGPS.h"
|
||||
#include "SpecialMenus/Systeminformation/menuSysteminformation.h"
|
||||
#include "SpecialMenus/PID/menuPidSettings.h"
|
||||
#include "SpecialMenus/Route/menuRoute.h"
|
||||
#include "SpecialMenus/GPS/menuGPS.h"
|
||||
|
||||
MoveControl moveController;
|
||||
DriveManager* driveManager;
|
||||
@@ -280,7 +281,8 @@ void makeMenu() {
|
||||
MenuAutopilot* auto_m = new MenuAutopilot(driveManager);
|
||||
MenuTestMode* test_m = new MenuTestMode(driveManager);
|
||||
MenuGPS* gps_m = new MenuGPS(driveManager);
|
||||
MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery, gamepad);
|
||||
MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery, gamepad);
|
||||
MenuRoute* rout_m = new MenuRoute(driveManager->getNavigation()->getRoute());
|
||||
|
||||
// Set Menus on LCD
|
||||
main_m->setLcd(lcd);
|
||||
@@ -294,6 +296,7 @@ void makeMenu() {
|
||||
test_m->setLcd(lcd);
|
||||
gps_m->setLcd(lcd);
|
||||
sys_m->setLcd(lcd);
|
||||
rout_m->setLcd(lcd);
|
||||
|
||||
|
||||
// Entry for the main menu
|
||||
@@ -303,8 +306,10 @@ void makeMenu() {
|
||||
MenuAction* restart_e = new MenuAction("Restart", restart);
|
||||
MenuAction* contr_e = new MenuAction("Remove PS3", disconnectController);
|
||||
MenuAction* sys_e = new MenuAction("Systeminfo", sys_m);
|
||||
MenuAction* rout_e = new MenuAction("Route", rout_m);
|
||||
main_m->addEntry(mode_e);
|
||||
main_m->addEntry(gps_e);
|
||||
main_m->addEntry(rout_e);
|
||||
main_m->addEntry(pid_e);
|
||||
main_m->addEntry(sys_e);
|
||||
main_m->addEntry(contr_e);
|
||||
|
||||
Reference in New Issue
Block a user