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
|
||||
Reference in New Issue
Block a user