refactor, comment and move speedometerTest
This commit is contained in:
@@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* @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;
|
|
||||||
};
|
|
||||||
@@ -90,6 +90,7 @@ void MenuTestMode::init() {
|
|||||||
this->mainMenu = new Menu;
|
this->mainMenu = new Menu;
|
||||||
Menu* engineMenu = new Menu;
|
Menu* engineMenu = new Menu;
|
||||||
Menu* lightMenu = new Menu;
|
Menu* lightMenu = new Menu;
|
||||||
|
Menu* encoderMenu = new Menu;
|
||||||
// Sound
|
// Sound
|
||||||
// Ping google
|
// Ping google
|
||||||
// WheelEncoder
|
// WheelEncoder
|
||||||
@@ -98,6 +99,8 @@ void MenuTestMode::init() {
|
|||||||
MenuIntInput* engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine));
|
MenuIntInput* engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::leftEngine));
|
||||||
MenuIntInput* engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine));
|
MenuIntInput* engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::rightEngine));
|
||||||
MenuIntInput* engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine));
|
MenuIntInput* engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this, &TestMode::bothEngine));
|
||||||
|
SpeedometerTest* encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft());
|
||||||
|
SpeedometerTest* encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight());
|
||||||
|
|
||||||
|
|
||||||
// Set menus on LCD
|
// Set menus on LCD
|
||||||
@@ -108,6 +111,9 @@ void MenuTestMode::init() {
|
|||||||
engineBothMenu->setLcd(this->lcd);
|
engineBothMenu->setLcd(this->lcd);
|
||||||
drivingMenu->setLcd(this->lcd);
|
drivingMenu->setLcd(this->lcd);
|
||||||
lightMenu->setLcd(this->lcd);
|
lightMenu->setLcd(this->lcd);
|
||||||
|
encoderMenu->setLcd(this->lcd);
|
||||||
|
encoderLeftMenu->setLcd(this->lcd);
|
||||||
|
encoderRightMenu->setLcd(this->lcd);
|
||||||
|
|
||||||
// Other menu config
|
// Other menu config
|
||||||
drivingMenu->setEntry(0, "Centimeter", 100);
|
drivingMenu->setEntry(0, "Centimeter", 100);
|
||||||
@@ -140,6 +146,10 @@ void MenuTestMode::init() {
|
|||||||
|
|
||||||
MenuAction* drivingAction = new MenuAction("Driving", drivingMenu);
|
MenuAction* drivingAction = new MenuAction("Driving", drivingMenu);
|
||||||
|
|
||||||
|
MenuAction* encoderAction = new MenuAction("Encoder", encoderMenu);
|
||||||
|
MenuAction* encoderLeftAction = new MenuAction("Left", encoderLeftMenu);
|
||||||
|
MenuAction* encoderRightAction = new MenuAction("Right", encoderRightMenu);
|
||||||
|
|
||||||
MenuAction* lightAction = new MenuAction("Light", lightMenu);
|
MenuAction* lightAction = new MenuAction("Light", lightMenu);
|
||||||
MenuAction* lightFlashAction = new MenuAction("Flash", dummy);
|
MenuAction* lightFlashAction = new MenuAction("Flash", dummy);
|
||||||
MenuAction* lightFadeAction = new MenuAction("Fade", dummy);
|
MenuAction* lightFadeAction = new MenuAction("Fade", dummy);
|
||||||
@@ -151,12 +161,16 @@ void MenuTestMode::init() {
|
|||||||
// Add entrys to the menus
|
// Add entrys to the menus
|
||||||
this->mainMenu->addEntry(engineAction);
|
this->mainMenu->addEntry(engineAction);
|
||||||
this->mainMenu->addEntry(drivingAction);
|
this->mainMenu->addEntry(drivingAction);
|
||||||
|
this->mainMenu->addEntry(encoderAction);
|
||||||
this->mainMenu->addEntry(lightAction);
|
this->mainMenu->addEntry(lightAction);
|
||||||
|
|
||||||
engineMenu->addEntry(engineLeftAction);
|
engineMenu->addEntry(engineLeftAction);
|
||||||
engineMenu->addEntry(engineRightAction);
|
engineMenu->addEntry(engineRightAction);
|
||||||
engineMenu->addEntry(engineBothAction);
|
engineMenu->addEntry(engineBothAction);
|
||||||
|
|
||||||
|
encoderMenu->addEntry(encoderLeftAction);
|
||||||
|
encoderMenu->addEntry(encoderRightAction);
|
||||||
|
|
||||||
lightMenu->addEntry(lightFlashAction);
|
lightMenu->addEntry(lightFlashAction);
|
||||||
lightMenu->addEntry(lightFadeAction);
|
lightMenu->addEntry(lightFadeAction);
|
||||||
lightMenu->addEntry(lightRedAction);
|
lightMenu->addEntry(lightRedAction);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "menuAction.h"
|
#include "menuAction.h"
|
||||||
#include "menuIntInput.h"
|
#include "menuIntInput.h"
|
||||||
|
#include "speedometerTest.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Interact with the TestMode
|
* @brief Interact with the TestMode
|
||||||
|
|||||||
+7
-7
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file menuTest.cpp
|
* @file menuTest.cpp
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief Contains the implementation of the class SpeedometerTest.
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-01-24
|
* @date 2023-01-24
|
||||||
*
|
*
|
||||||
@@ -9,14 +9,14 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "menuTest.h"
|
#include "speedometerTest.h"
|
||||||
|
|
||||||
MenuTest::MenuTest(Speedometer* speedometer) {
|
SpeedometerTest::SpeedometerTest(Speedometer* speedometer) {
|
||||||
this->speedometer = speedometer;
|
this->speedometer = speedometer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MenuTest::printMenu() {
|
void SpeedometerTest::printMenu() {
|
||||||
switch (this->state) {
|
switch (this->state) {
|
||||||
case State::Off :
|
case State::Off :
|
||||||
this->print("Press Yes (O)", "to start");
|
this->print("Press Yes (O)", "to start");
|
||||||
@@ -40,11 +40,11 @@ void MenuTest::printMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MenuTest::left() {
|
void SpeedometerTest::left() {
|
||||||
this->no();
|
this->no();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTest::no() {
|
void SpeedometerTest::no() {
|
||||||
if (this->state == State::Running)
|
if (this->state == State::Running)
|
||||||
speedometer->calibrationMeasurementStop();
|
speedometer->calibrationMeasurementStop();
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ void MenuTest::no() {
|
|||||||
this->parentMenu->printMenu();
|
this->parentMenu->printMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTest::yes() {
|
void SpeedometerTest::yes() {
|
||||||
switch (this->state) {
|
switch (this->state) {
|
||||||
case State::Off :
|
case State::Off :
|
||||||
this->state = State::Running;
|
this->state = State::Running;
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/**
|
||||||
|
* @file menuTest.h
|
||||||
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
|
* @brief Contains a class to test the wheel encoder.
|
||||||
|
* @version 0.1
|
||||||
|
* @date 2023-01-24
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "menuControl.h"
|
||||||
|
#include "speedometer.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Tests the wheel encoder.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SpeedometerTest : public MenuControl {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief The states of the test.
|
||||||
|
*/
|
||||||
|
enum State {
|
||||||
|
Off,
|
||||||
|
Running,
|
||||||
|
Finished
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Speedometer Test object
|
||||||
|
*
|
||||||
|
* @param speedometer
|
||||||
|
*/
|
||||||
|
SpeedometerTest(Speedometer* speedometer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints the actual state of the test.
|
||||||
|
*/
|
||||||
|
void printMenu() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calls no.
|
||||||
|
*/
|
||||||
|
void left() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Exit the menu or end the test.
|
||||||
|
*/
|
||||||
|
void no() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starts or restarts the test.
|
||||||
|
*/
|
||||||
|
void yes() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Speedometer* speedometer;
|
||||||
|
State state = State::Off;
|
||||||
|
|
||||||
|
uint16_t result = 0;
|
||||||
|
};
|
||||||
@@ -121,6 +121,8 @@ class TestMode : public DriveModi {
|
|||||||
*/
|
*/
|
||||||
bool getBusy() const { return this->busy; }
|
bool getBusy() const { return this->busy; }
|
||||||
Maneuver getManeuver() const { return this->maneuver; }
|
Maneuver getManeuver() const { return this->maneuver; }
|
||||||
|
Speedometer* getSpeedometerLeft() { this->moveControl->getSpeedometerLeft(); }
|
||||||
|
Speedometer* getSpeedometerRight() { this->moveControl->getSpeedometerRight(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool engineInit(int16_t powerPercentage, int16_t seconds);
|
bool engineInit(int16_t powerPercentage, int16_t seconds);
|
||||||
|
|||||||
@@ -275,7 +275,6 @@ void makeMenu() {
|
|||||||
MenuGPS* gps_m = new MenuGPS(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());
|
MenuRoute* rout_m = new MenuRoute(driveManager->getNavigation()->getRoute());
|
||||||
MenuTest* test_m = new MenuTest(moveController.getSpeedometerLeft());
|
|
||||||
|
|
||||||
// Set Menus on LCD
|
// Set Menus on LCD
|
||||||
main_m->setLcd(lcdWrapper);
|
main_m->setLcd(lcdWrapper);
|
||||||
@@ -290,7 +289,6 @@ void makeMenu() {
|
|||||||
gps_m->setLcd(LcdWrapper);
|
gps_m->setLcd(LcdWrapper);
|
||||||
sys_m->setLcd(LcdWrapper);
|
sys_m->setLcd(LcdWrapper);
|
||||||
rout_m->setLcd(LcdWrapper);
|
rout_m->setLcd(LcdWrapper);
|
||||||
test_m->setLcd(LcdWrapper);
|
|
||||||
|
|
||||||
|
|
||||||
// Entry for the main menu
|
// Entry for the main menu
|
||||||
@@ -301,13 +299,11 @@ void makeMenu() {
|
|||||||
MenuAction* contr_e = new MenuAction("Remove PS3", disconnectController);
|
MenuAction* contr_e = new MenuAction("Remove PS3", disconnectController);
|
||||||
MenuAction* sys_e = new MenuAction("Systeminfo", sys_m);
|
MenuAction* sys_e = new MenuAction("Systeminfo", sys_m);
|
||||||
MenuAction* rout_e = new MenuAction("Route", rout_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(mode_e);
|
||||||
main_m->addEntry(gps_e);
|
main_m->addEntry(gps_e);
|
||||||
main_m->addEntry(rout_e);
|
main_m->addEntry(rout_e);
|
||||||
main_m->addEntry(pid_e);
|
main_m->addEntry(pid_e);
|
||||||
main_m->addEntry(sys_e);
|
main_m->addEntry(sys_e);
|
||||||
main_m->addEntry(test_e);
|
|
||||||
main_m->addEntry(contr_e);
|
main_m->addEntry(contr_e);
|
||||||
main_m->addEntry(restart_e);
|
main_m->addEntry(restart_e);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user