158 lines
4.9 KiB
C++
158 lines
4.9 KiB
C++
/**
|
|
* @file menuTestMode.cpp
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2022-09-08
|
|
*
|
|
* @copyright Copyright (c) 2022
|
|
*
|
|
*/
|
|
#include "menuTestMode.h"
|
|
|
|
MenuTestMode::MenuTestMode(DriveManager* driveManager)
|
|
: MenuDriveMode(driveManager) {
|
|
// this->testMode = testMode;
|
|
this->values[0] = 1;
|
|
this->values[1] = 2;
|
|
this->values[2] = 3;
|
|
|
|
strcpy(this->names[0], "Alpha");
|
|
strcpy(this->names[1], "Beta");
|
|
strcpy(this->names[2], "Gamma");
|
|
}
|
|
|
|
MenuTestMode::~MenuTestMode() {
|
|
if (isInit) {
|
|
delete this->mainMenu;
|
|
}
|
|
}
|
|
|
|
void MenuTestMode::printMenu() {
|
|
if (!this->isInit) {
|
|
this->isInit = true;
|
|
this->init();
|
|
}
|
|
|
|
this->mainMenu->printMenu();
|
|
}
|
|
|
|
void MenuTestMode::down() {
|
|
this->mainMenu->down();
|
|
}
|
|
|
|
void MenuTestMode::up() {
|
|
this->mainMenu->up();
|
|
}
|
|
|
|
void MenuTestMode::right() {
|
|
this->mainMenu->right();
|
|
}
|
|
|
|
void MenuTestMode::left() {
|
|
if (this->mainMenu->isInSubmenu())
|
|
this->mainMenu->left();
|
|
else
|
|
this->parentMenu->printMenu();
|
|
}
|
|
|
|
void MenuTestMode::yes() {
|
|
this->mainMenu->yes();
|
|
}
|
|
|
|
void MenuTestMode::no() {
|
|
if (this->mainMenu->isInSubmenu())
|
|
this->mainMenu->no();
|
|
else
|
|
this->left();
|
|
}
|
|
|
|
void MenuTestMode::init() {
|
|
this->testMode = (TestMode*) this->driveManager->getDriveModiPtr();
|
|
|
|
auto dummy = []() {
|
|
std::cout << "Dummy in Action" <<std::endl;
|
|
};
|
|
|
|
// Create menu
|
|
this->mainMenu = new Menu;
|
|
Menu* engineMenu = new Menu;
|
|
Menu* engineLeftMenu = new Menu;
|
|
Menu* engineRightMenu = new Menu;
|
|
Menu* drivingMenu = new Menu;
|
|
Menu* drivingForwardMenu = new Menu;
|
|
Menu* drivingBackwardMenu = new Menu;
|
|
Menu* lightMenu = new Menu;
|
|
|
|
MenuIntInput* testInputMenu = new MenuIntInput(values, (char *)names, length, new MenuTestModeWrapper(this->testMode));
|
|
|
|
// Set menus on LCD
|
|
this->mainMenu->setLcd(this->lcd);
|
|
engineMenu->setLcd(this->lcd);
|
|
engineLeftMenu->setLcd(this->lcd);
|
|
engineRightMenu->setLcd(this->lcd);
|
|
drivingMenu->setLcd(this->lcd);
|
|
drivingForwardMenu->setLcd(this->lcd);
|
|
drivingBackwardMenu->setLcd(this->lcd);
|
|
lightMenu->setLcd(this->lcd);
|
|
testInputMenu->setLcd(this->lcd);
|
|
|
|
// Entrys for the menus
|
|
MenuAction* engineAction = new MenuAction("Engine", engineMenu);
|
|
MenuAction* engineLeftAction = new MenuAction("Left", engineLeftMenu);
|
|
MenuAction* engineRightAction = new MenuAction("Right", engineRightMenu);
|
|
|
|
MenuAction* drivingAction = new MenuAction("Driving", drivingMenu);
|
|
MenuAction* drivingForwardAction = new MenuAction("Forward", drivingForwardMenu);
|
|
MenuAction* drivingForwardLeftAction = new MenuAction("Left", testInputMenu);
|
|
MenuAction* drivingForwardStraightAction = new MenuAction("Straight", dummy);
|
|
MenuAction* drivingForwardRightAction = new MenuAction("Right", dummy);
|
|
MenuAction* drivingBackwardAction = new MenuAction("Backward", drivingBackwardMenu);
|
|
MenuAction* drivingBackwardLeftAction = new MenuAction("Left", dummy);
|
|
MenuAction* drivingBackwardStraightAction = new MenuAction("Straight", dummy);
|
|
MenuAction* drivingBackwardRightAction = new MenuAction("Right", dummy);
|
|
|
|
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);
|
|
|
|
// Add entrys to the menus
|
|
this->mainMenu->addEntry(engineAction);
|
|
this->mainMenu->addEntry(drivingAction);
|
|
this->mainMenu->addEntry(lightAction);
|
|
|
|
engineMenu->addEntry(engineLeftAction);
|
|
engineMenu->addEntry(engineRightAction);
|
|
|
|
drivingMenu->addEntry(drivingForwardAction);
|
|
drivingMenu->addEntry(drivingBackwardAction);
|
|
drivingForwardMenu->addEntry(drivingForwardLeftAction);
|
|
drivingForwardMenu->addEntry(drivingForwardStraightAction);
|
|
drivingForwardMenu->addEntry(drivingForwardRightAction);
|
|
drivingBackwardMenu->addEntry(drivingBackwardLeftAction);
|
|
drivingBackwardMenu->addEntry(drivingBackwardStraightAction);
|
|
drivingBackwardMenu->addEntry(drivingBackwardRightAction);
|
|
|
|
lightMenu->addEntry(lightFlashAction);
|
|
lightMenu->addEntry(lightFadeAction);
|
|
lightMenu->addEntry(lightRedAction);
|
|
lightMenu->addEntry(lightGreenAction);
|
|
lightMenu->addEntry(lightBlueAction);
|
|
lightMenu->addEntry(lightOffAction);
|
|
}
|
|
|
|
MenuTestModeWrapper::MenuTestModeWrapper(TestMode* testMode) {
|
|
this->testMode = testMode;
|
|
}
|
|
|
|
void MenuTestModeWrapper::action(int16_t* values, uint8_t length) {
|
|
if (length > 2)
|
|
std::cout << "Dummy in Action" << values[0] << values[1] << values[2] << std::endl;
|
|
else
|
|
std::cout << "Dummy in Action kene dre values" << std::endl;
|
|
}
|