add menuTest

This commit is contained in:
2023-01-31 08:21:04 +01:00
parent c63428412f
commit d96f382702
7 changed files with 177 additions and 32 deletions
+78
View File
@@ -0,0 +1,78 @@
/**
* @file menuTest.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @version 0.1
* @date 2023-01-24
*
* @copyright Copyright (c) 2023
*
*/
#include "menuTest.h"
MenuTest::MenuTest(Speedometer* speedometer) {
this->speedometer = speedometer;
}
void MenuTest::printMenu() {
switch (this->state) {
case State::Off :
this->print("Press Yes (O)", "to start");
break;
case State::Running :
this->print("Running, Yes (O)", "to stop");
break;
case State::Finished : {
String res = "";
res.concat(this->result);
this->print("Result: ", res);
}
break;
default:
this->print("Error in", "MenuTest.cpp");
break;
}
}
void MenuTest::left() {
this->no();
}
void MenuTest::no() {
if (this->state == State::Running)
speedometer->calibrationMeasurementStop();
this->state = State::Off;
this->parentMenu->printMenu();
}
void MenuTest::yes() {
switch (this->state) {
case State::Off :
this->state = State::Running;
this->speedometer->calibrationMeasurementStart();
this->printMenu();
break;
case State::Running :
this->state = State::Finished;
this->result = this->speedometer->calibrationMeasurementStop();
this->printMenu();
break;
case State::Finished :
this->state = State::Running;
this->speedometer->calibrationMeasurementStart();
this->printMenu();
break;
default:
break;
}
}
+37
View File
@@ -0,0 +1,37 @@
/**
* @file menuTest.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @version 0.1
* @date 2023-01-24
*
* @copyright Copyright (c) 2023
*
*/
#pragma once
#include "menuControl.h"
#include "speedometer.h"
class MenuTest : public MenuControl {
public:
enum State {
Off,
Running,
Finished
};
MenuTest(Speedometer* speedometer);
void printMenu() override;
void left() override;
void no() override;
void yes() override;
private:
Speedometer* speedometer;
State state = State::Off;
uint16_t result = 0;
};
+8 -3
View File
@@ -44,6 +44,7 @@
#include "SpecialMenus/PID/menuPidSettings.h"
#include "SpecialMenus/Route/menuRoute.h"
#include "SpecialMenus/GPS/menuGPS.h"
#include "SpecialMenus/Test/menuTest.h"
MoveControl moveController;
DriveManager* driveManager;
@@ -270,10 +271,11 @@ void makeMenu() {
MenuManualControl* man_m = new MenuManualControl(driveManager);
MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager);
MenuAutopilot* auto_m = new MenuAutopilot(driveManager);
MenuTestMode* test_m = new MenuTestMode(driveManager);
MenuTestMode* testM_m = new MenuTestMode(driveManager);
MenuGPS* gps_m = new MenuGPS(driveManager);
MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery, gamepad);
MenuRoute* rout_m = new MenuRoute(driveManager->getNavigation()->getRoute());
MenuTest* test_m = new MenuTest(moveController.getSpeedometerLeft());
// Set Menus on LCD
main_m->setLcd(lcdWrapper);
@@ -284,10 +286,11 @@ void makeMenu() {
man_m->setLcd(lcdWrapper);
cap_m->setLcd(lcdWrapper);
auto_m->setLcd(lcdWrapper);
test_m->setLcd(lcdWrapper);
testM_m->setLcd(lcdWrapper);
gps_m->setLcd(lcdWrapper);
sys_m->setLcd(lcdWrapper);
rout_m->setLcd(lcdWrapper);
test_m->setLcd(lcdWrapper);
// Entry for the main menu
@@ -298,11 +301,13 @@ void makeMenu() {
MenuAction* contr_e = new MenuAction("Remove PS3", disconnectController);
MenuAction* sys_e = new MenuAction("Systeminfo", sys_m);
MenuAction* rout_e = new MenuAction("Route", rout_m);
MenuAction* test_e = new MenuAction("Test", test_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(test_e);
main_m->addEntry(contr_e);
main_m->addEntry(restart_e);
@@ -311,7 +316,7 @@ void makeMenu() {
MenuAction* captureRoute_e = new MenuAction("Capture Route", cap_m);
MenuAction* consolControl_e = new MenuAction("Consol Control", dummy);
MenuAction* manualControl_e = new MenuAction("Manual Control", man_m);
MenuAction* testMode_e = new MenuAction("Test Mode", test_m);
MenuAction* testMode_e = new MenuAction("Test Mode", testM_m);
mode_m->addEntry(autopilot_e);
mode_m->addEntry(captureRoute_e);
mode_m->addEntry(manualControl_e);